[test/plugin] removes the dead codes (#3651)
* removes the dead codes * sync
This commit is contained in:
parent
6a7867ef5f
commit
ef91bcf45f
|
|
@ -25,7 +25,6 @@ function exitOnError() {
|
|||
function exitAndClean() {
|
||||
[[ -f ${SCENARIO_HOME}/data/actualData.yaml ]] && rm -rf ${SCENARIO_HOME}/data/actualData.yaml
|
||||
[[ -d ${SCENARIO_HOME}/logs ]] && rm -rf ${SCENARIO_HOME}/logs
|
||||
[[ -d ${SCENARIO_HOME}/package ]] && rm -rf ${SCENARIO_HOME}/package
|
||||
exit $1
|
||||
}
|
||||
|
||||
|
|
@ -85,9 +84,8 @@ curl -s http://localhost:12800/receiveData > ${SCENARIO_HOME}/data/actualData.ya
|
|||
|
||||
echo "To validate"
|
||||
java -jar \
|
||||
-Dv2=true \
|
||||
-Xmx256m -Xms256m \
|
||||
-DtestDate="`date +%Y-%m-%d-%H-%M`" \
|
||||
-DcaseName="${SCENARIO_NAME}-${SCENARIO_VERSION}" \
|
||||
-DtestCasePath=${SCENARIO_HOME}/data/ \
|
||||
${TOOLS_HOME}/skywalking-validator-tools.jar 1>/dev/null
|
||||
status=$?
|
||||
|
|
|
|||
|
|
@ -72,17 +72,16 @@ curl -s http://localhost:12800/receiveData > ${SCENARIO_HOME}/data/actualData.ya
|
|||
|
||||
echo "To validate"
|
||||
java -jar \
|
||||
-Dv2=true \
|
||||
-Xmx256m -Xms256m \
|
||||
-DtestDate="`date +%Y-%m-%d-%H-%M`" \
|
||||
-DtestCasePath=${SCENARIO_HOME}/data/ \
|
||||
${TOOLS_HOME}/skywalking-validator-tools.jar 1>/dev/null
|
||||
-Xmx256m -Xms256m \
|
||||
-DcaseName="${SCENARIO_NAME}-${SCENARIO_VERSION}" \
|
||||
-DtestCasePath=${SCENARIO_HOME}/data/ \
|
||||
${TOOLS_HOME}/skywalking-validator-tools.jar 1>/dev/null
|
||||
status=$?
|
||||
|
||||
if [[ $status -eq 0 ]]; then
|
||||
echo "Scenario[${SCENARIO_NAME}-${SCENARIO_VERSION}] passed!" >&2
|
||||
echo "Scenario[${SCENARIO_NAME}-${SCENARIO_VERSION}] passed!" >&2
|
||||
else
|
||||
cat ${SCENARIO_HOME}/data/actualData.yaml >&2
|
||||
exitOnError "Scenario[${SCENARIO_NAME}-${SCENARIO_VERSION}] failed!"
|
||||
cat ${SCENARIO_HOME}/data/actualData.yaml >&2
|
||||
exitOnError "Scenario[${SCENARIO_NAME}-${SCENARIO_VERSION}] failed!"
|
||||
fi
|
||||
exitAndClean $status
|
||||
|
|
|
|||
|
|
@ -1,30 +0,0 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FROM openjdk:8-jdk
|
||||
|
||||
ENV GRPC_BIND_HOST=127.0.0.1 \
|
||||
GRPC_BIND_PORT=19876
|
||||
|
||||
ADD skywalking-mock-collector.tar.gz /usr/local
|
||||
ADD config.properties /usr/local/skywalking-mock-collector/config/config.properties
|
||||
EXPOSE 12800
|
||||
EXPOSE 5005
|
||||
|
||||
ADD docker-entrypoint.sh /
|
||||
RUN chmod +x /docker-entrypoint.sh
|
||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||
CMD ["/usr/local/skywalking-mock-collector/bin/collector-startup.sh"]
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
grpc_bind_host={GRPC_BIND_HOST}
|
||||
grpc_bind_port={GRPC_BIND_PORT}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
echo "replace GRPC_BIND_HOST with $GRPC_BIND_HOST"
|
||||
eval sed -i -e 's/\{GRPC_BIND_HOST\}/$GRPC_BIND_HOST/' /usr/local/skywalking-mock-collector/config/config.properties
|
||||
|
||||
echo "replace GRPC_BIND_PORT with $GRPC_BIND_PORT"
|
||||
eval sed -i -e 's/\{GRPC_BIND_PORT\}/$GRPC_BIND_PORT/' /usr/local/skywalking-mock-collector/config/config.properties
|
||||
|
||||
exec "$@"
|
||||
|
|
@ -165,26 +165,6 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>0.4.13</version>
|
||||
<configuration>
|
||||
<skipDocker>true</skipDocker>
|
||||
<imageName>${docker.image.name}</imageName>
|
||||
<imageTags>
|
||||
<imageTag>${docker.image.version}</imageTag>
|
||||
</imageTags>
|
||||
<dockerDirectory>${project.basedir}/docker</dockerDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<targetPath>/</targetPath>
|
||||
<directory>${project.basedir}/../dist</directory>
|
||||
<include>${build.finalName}.tar.gz</include>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ services:
|
|||
<#if service.healthcheck??>
|
||||
healthcheck:
|
||||
<#list service.healthcheck as item>
|
||||
- ${item}
|
||||
${item}
|
||||
</#list>
|
||||
</#if>
|
||||
</#list>
|
||||
|
|
@ -30,4 +30,9 @@ dependencies:
|
|||
- docker-entrypoint.sh
|
||||
- solr-precreate
|
||||
- mycore
|
||||
|
||||
healthcheck:
|
||||
- 'test: ["CMD", "curl", "-f", "http://localhost"]'
|
||||
- 'interval: 1m30s'
|
||||
- 'timeout: 10s'
|
||||
- 'retries: 3'
|
||||
- 'start_period: 40s'
|
||||
|
|
|
|||
|
|
@ -17,76 +17,16 @@
|
|||
|
||||
package org.apache.skywalking.plugin.test.agent.tool;
|
||||
|
||||
import java.io.File;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class ConfigHelper {
|
||||
private static Logger logger = LogManager.getLogger(ConfigHelper.class);
|
||||
|
||||
private ConfigHelper() {
|
||||
}
|
||||
|
||||
public static String testDate() {
|
||||
return System.getProperty("testDate");
|
||||
}
|
||||
|
||||
public static String testCases() {
|
||||
String testCasesInput = System.getProperty("testCases", "");
|
||||
if (testCasesInput.length() > 0) {
|
||||
return testCasesInput;
|
||||
}
|
||||
String testCasePath = System.getProperty("testCasePath", "");
|
||||
|
||||
if (testCasePath.length() == 0) {
|
||||
logger.warn("test case dir is empty");
|
||||
return "";
|
||||
}
|
||||
|
||||
File testCaseDir = new File(testCasePath);
|
||||
if (!testCaseDir.exists() || !testCaseDir.isDirectory()) {
|
||||
logger.warn("test case dir is not exists or is not directory");
|
||||
return "";
|
||||
}
|
||||
|
||||
StringBuilder testCases = new StringBuilder();
|
||||
File[] testCasesDir = testCaseDir.listFiles();
|
||||
for (File file : testCasesDir) {
|
||||
testCases.append(file.getName() + ",");
|
||||
}
|
||||
|
||||
return testCases.toString();
|
||||
public static String caseName() {
|
||||
return System.getProperty("caseName", "");
|
||||
}
|
||||
|
||||
public static String testCaseBaseDir() {
|
||||
return System.getProperty("testCasePath", "");
|
||||
}
|
||||
|
||||
public static boolean isV2() {
|
||||
return Boolean.getBoolean("v2");
|
||||
}
|
||||
|
||||
public static String reportFilePath() {
|
||||
return System.getProperty("reportFilePath");
|
||||
}
|
||||
|
||||
public static String agentBranch() {
|
||||
return System.getProperty("agentBranch");
|
||||
}
|
||||
|
||||
public static String agentCommit() {
|
||||
return System.getProperty("agentCommitId");
|
||||
}
|
||||
|
||||
public static String casesBranch() {
|
||||
return System.getProperty("casesBranch", "").replace("/", "-");
|
||||
}
|
||||
|
||||
public static String caseCommitId() {
|
||||
return System.getProperty("casesCommitId", "");
|
||||
}
|
||||
|
||||
public static String committer() {
|
||||
return System.getProperty("committer", "");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,45 +22,24 @@ import org.apache.logging.log4j.LogManager;
|
|||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.DataAssert;
|
||||
import org.apache.skywalking.plugin.test.agent.tool.validator.entity.Data;
|
||||
import org.apache.skywalking.plugin.test.agent.tool.report.entity.Report;
|
||||
import org.apache.skywalking.plugin.test.agent.tool.report.entity.TestCase;
|
||||
import org.apache.skywalking.plugin.test.agent.tool.report.entity.TestCaseDesc;
|
||||
import org.apache.skywalking.plugin.test.agent.tool.validator.exception.AssertFailedException;
|
||||
|
||||
public class Main {
|
||||
private static Logger logger = LogManager.getLogger(Main.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
Report report = new Report();
|
||||
String testCasePath = ConfigHelper.testCaseBaseDir();
|
||||
|
||||
boolean success = false;
|
||||
if (ConfigHelper.isV2()) {
|
||||
success |= verify(new File(testCasePath), TestCaseDesc.ParserV2.parse(), report).isSuccess();
|
||||
} else {
|
||||
String[] testCases = ConfigHelper.testCases().split(",");
|
||||
|
||||
for (String aCase : testCases) {
|
||||
File casePath = new File(testCasePath, aCase);
|
||||
File descFile = new File(casePath, "testcase.desc");
|
||||
success |= verify(casePath, TestCaseDesc.Parser.parse(descFile), report).isSuccess();
|
||||
}
|
||||
}
|
||||
|
||||
if (!ConfigHelper.isV2()) {
|
||||
try {
|
||||
report.generateReport(ConfigHelper.reportFilePath());
|
||||
} catch (Exception e) {
|
||||
logger.error("Failed to generate report file", e);
|
||||
}
|
||||
}
|
||||
System.exit(success ? 0 : 1);
|
||||
System.exit(verify() ? 0 : 1);
|
||||
}
|
||||
|
||||
static TestCase verify(File casePath, TestCaseDesc testCaseDesc, Report report) {
|
||||
TestCase testCase = new TestCase(testCaseDesc.getTestComponents());
|
||||
static boolean verify() {
|
||||
File casePath = new File(ConfigHelper.testCaseBaseDir());
|
||||
try {
|
||||
logger.info("start to assert data of test case[{}]", testCase.getCaseName());
|
||||
if (!casePath.exists()) {
|
||||
logger.error("test case dir is not exists or is not directory");
|
||||
return false;
|
||||
}
|
||||
|
||||
logger.info("start to assert data of test case[{}]", ConfigHelper.caseName());
|
||||
File actualData = new File(casePath, "actualData.yaml");
|
||||
File expectedData = new File(casePath, "expectedData.yaml");
|
||||
|
||||
|
|
@ -68,18 +47,20 @@ public class Main {
|
|||
try {
|
||||
DataAssert.assertEquals(Data.Loader.loadData("expectedData.yaml", expectedData),
|
||||
Data.Loader.loadData("actualData.yaml", actualData));
|
||||
testCase.testedSuccessfully();
|
||||
return true;
|
||||
} catch (AssertFailedException e) {
|
||||
logger.error("\nassert failed.\n{}\n", e.getCauseMessage());
|
||||
}
|
||||
} else {
|
||||
logger.error("assert failed. because actual data {} and expected data {}", actualData.exists() ? "founded" : "not founded", actualData.exists() ? "founded" : "not founded");
|
||||
logger.error("assert failed. because actual data {} and expected data {}",
|
||||
actualData.exists() ? "founded" : "not founded",
|
||||
expectedData.exists() ? "founded" : "not founded"
|
||||
);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("assert test case {} failed.", testCase.getCaseName(), e);
|
||||
logger.error("assert test case {} failed.", ConfigHelper.caseName(), e);
|
||||
}
|
||||
report.addTestCase(testCaseDesc.getProjectName(), testCaseDesc.getTestFramework(), testCase);
|
||||
return testCase;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.plugin.test.agent.tool.report.entity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CaseVersionCategory {
|
||||
private String name;
|
||||
private List<TestCase> testCases;
|
||||
|
||||
public CaseVersionCategory(String versionName) {
|
||||
this.name = versionName;
|
||||
testCases = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void addTestCases(TestCase testCase) {
|
||||
this.testCases.add(testCase);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public List<TestCase> getTestCases() {
|
||||
return testCases;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.plugin.test.agent.tool.report.entity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FrameworkCases {
|
||||
private String testFramework;
|
||||
private int successCaseCount;
|
||||
private int totalCaseCount;
|
||||
private List<CaseVersionCategory> caseByVersionCategories;
|
||||
|
||||
public FrameworkCases(String testFramework) {
|
||||
this.testFramework = testFramework;
|
||||
this.caseByVersionCategories = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void addTestCase(String versionCategory, TestCase aCase) {
|
||||
CaseVersionCategory caseVersionCategory = findCategoryForProject(versionCategory);
|
||||
if (caseVersionCategory == null) {
|
||||
caseVersionCategory = new CaseVersionCategory(versionCategory);
|
||||
this.caseByVersionCategories.add(caseVersionCategory);
|
||||
}
|
||||
|
||||
caseVersionCategory.addTestCases(aCase);
|
||||
|
||||
if (aCase.isSuccessfully()) {
|
||||
successCaseCount++;
|
||||
}
|
||||
totalCaseCount++;
|
||||
}
|
||||
|
||||
private CaseVersionCategory findCategoryForProject(String projectName) {
|
||||
for (CaseVersionCategory project : caseByVersionCategories) {
|
||||
if (project.getName().equals(projectName)) {
|
||||
return project;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getTestFramework() {
|
||||
return testFramework;
|
||||
}
|
||||
|
||||
public List<CaseVersionCategory> getCaseByVersionCategories() {
|
||||
return caseByVersionCategories;
|
||||
}
|
||||
|
||||
public int getSuccessCaseCount() {
|
||||
return successCaseCount;
|
||||
}
|
||||
|
||||
public int getTotalCaseCount() {
|
||||
return totalCaseCount;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,165 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.plugin.test.agent.tool.report.entity;
|
||||
|
||||
import freemarker.template.Configuration;
|
||||
import freemarker.template.Template;
|
||||
import freemarker.template.TemplateException;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.skywalking.plugin.test.agent.tool.ConfigHelper;
|
||||
|
||||
public class Report {
|
||||
private static Logger logger = LogManager.getLogger(Report.class);
|
||||
private final String testDate;
|
||||
private final String testBranch;
|
||||
private final String commitId;
|
||||
private final String caseBranch;
|
||||
private final String caseCommit;
|
||||
private final String committer;
|
||||
private int successCaseCount;
|
||||
private int totalCaseCount;
|
||||
private List<FrameworkCases> frameworkCases;
|
||||
|
||||
public Report() {
|
||||
this.testDate = formatTestDate(ConfigHelper.testDate());
|
||||
this.testBranch = ConfigHelper.agentBranch();
|
||||
this.commitId = ConfigHelper.agentCommit();
|
||||
this.caseBranch = ConfigHelper.casesBranch();
|
||||
this.caseCommit = ConfigHelper.caseCommitId();
|
||||
this.committer = ConfigHelper.committer();
|
||||
this.frameworkCases = new ArrayList<>();
|
||||
}
|
||||
|
||||
public String getTestDate() {
|
||||
return testDate;
|
||||
}
|
||||
|
||||
public String getTestBranch() {
|
||||
return testBranch;
|
||||
}
|
||||
|
||||
public String getCommitId() {
|
||||
return commitId;
|
||||
}
|
||||
|
||||
public List<FrameworkCases> getFrameworkCases() {
|
||||
return frameworkCases;
|
||||
}
|
||||
|
||||
private FrameworkCases findCasesByFrameworkName(String testFramework) {
|
||||
for (FrameworkCases ascenario : frameworkCases) {
|
||||
if (ascenario.getTestFramework().equalsIgnoreCase(testFramework)) {
|
||||
return ascenario;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private String formatTestDate(String date) {
|
||||
try {
|
||||
Date testDate = new SimpleDateFormat("yyyy-MM-dd-HH-mm").parse(date);
|
||||
return new SimpleDateFormat("yyyy-MM-dd HH:mm").format(testDate);
|
||||
} catch (ParseException e) {
|
||||
logger.error("Failed to format date[{}].", date, e);
|
||||
}
|
||||
return date;
|
||||
}
|
||||
|
||||
public void generateReport(String path) throws IOException, TemplateException, ParseException {
|
||||
File reportFile = generateReportFile(path);
|
||||
|
||||
Configuration cfg = new Configuration(Configuration.VERSION_2_3_23);
|
||||
cfg.setClassForTemplateLoading(this.getClass(), "/template");
|
||||
cfg.setDefaultEncoding("UTF-8");
|
||||
Template template = cfg.getTemplate("main-report.md.ftl");
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
Map<String, Report> resultMap = new HashMap<>();
|
||||
resultMap.put("testReport", this);
|
||||
template.process(resultMap, stringWriter);
|
||||
FileWriter fileOutputStream = new FileWriter(reportFile, false);
|
||||
fileOutputStream.write(stringWriter.getBuffer().toString());
|
||||
stringWriter.close();
|
||||
fileOutputStream.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* File Path Year - Month - apache - testReport-2019-10-10-10-11-11.md - testReport-2019-10-10-10-11-12.md -
|
||||
* ascrutae ...
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private File generateReportFile(String basePath) throws ParseException, IOException {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(testDate));
|
||||
File testReportDir = new File(new File(new File(basePath, calendar.get(Calendar.YEAR) + ""), (calendar.get(Calendar.MONTH) + 1) + ""), ConfigHelper.committer());
|
||||
if (!testReportDir.exists()) {
|
||||
testReportDir.mkdirs();
|
||||
}
|
||||
String fileName = "testReport-" + ConfigHelper.casesBranch() + "-" + ConfigHelper.testDate() + ".md";
|
||||
File testReportFile = new File(testReportDir, fileName);
|
||||
if (!testReportFile.exists()) {
|
||||
testReportFile.createNewFile();
|
||||
}
|
||||
return testReportFile;
|
||||
}
|
||||
|
||||
public void addTestCase(String projectName, String framework, TestCase aCase) {
|
||||
FrameworkCases frameworkCases = findCasesByFrameworkName(framework);
|
||||
if (frameworkCases == null) {
|
||||
frameworkCases = new FrameworkCases(framework);
|
||||
this.frameworkCases.add(frameworkCases);
|
||||
}
|
||||
|
||||
frameworkCases.addTestCase(projectName, aCase);
|
||||
|
||||
if (aCase.isSuccessfully()) {
|
||||
successCaseCount++;
|
||||
}
|
||||
totalCaseCount++;
|
||||
}
|
||||
|
||||
public int getSuccessCaseCount() {
|
||||
return successCaseCount;
|
||||
}
|
||||
|
||||
public int getTotalCaseCount() {
|
||||
return totalCaseCount;
|
||||
}
|
||||
|
||||
public String getCaseBranch() {
|
||||
return caseBranch;
|
||||
}
|
||||
|
||||
public String getCaseCommit() {
|
||||
return caseCommit;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.plugin.test.agent.tool.report.entity;
|
||||
|
||||
public class TestCase {
|
||||
private String caseName;
|
||||
private boolean success;
|
||||
|
||||
public TestCase(String testComponents) {
|
||||
this.caseName = testComponents;
|
||||
}
|
||||
|
||||
public String getCaseName() {
|
||||
return caseName;
|
||||
}
|
||||
|
||||
public void testedSuccessfully() {
|
||||
this.success = true;
|
||||
}
|
||||
|
||||
public boolean isSuccessfully() {
|
||||
return success;
|
||||
}
|
||||
|
||||
public boolean isSuccess() {
|
||||
return success;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.plugin.test.agent.tool.report.entity;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class TestCaseDesc {
|
||||
private static Logger logger = LogManager.getLogger(TestCaseDesc.class);
|
||||
private String testFramework;
|
||||
private String testComponents;
|
||||
private String projectName;
|
||||
|
||||
private TestCaseDesc() {
|
||||
}
|
||||
|
||||
public static class Parser {
|
||||
public static TestCaseDesc parse(File caseDescFile) {
|
||||
TestCaseDesc testCase = new TestCaseDesc();
|
||||
Properties properties = new Properties();
|
||||
if (caseDescFile.exists()) {
|
||||
try {
|
||||
properties.load(new FileInputStream(caseDescFile));
|
||||
} catch (IOException e) {
|
||||
logger.error("Failed to parse case desc file[{}]", caseDescFile.getAbsoluteFile());
|
||||
return testCase;
|
||||
}
|
||||
}
|
||||
|
||||
testCase.projectName = properties.getProperty("case.projectName", null);
|
||||
testCase.testFramework = properties.getProperty("case.testFramework", null);
|
||||
testCase.testComponents = properties.getProperty("case.testComponents", null);
|
||||
logger.info("load case desc: projectName[{}] testFramework[{}], testComponents[{}], cooperativeFrameworks[{}]",
|
||||
testCase.projectName,
|
||||
testCase.testFramework,
|
||||
testCase.testComponents);
|
||||
return testCase;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ParserV2 {
|
||||
public static TestCaseDesc parse() {
|
||||
TestCaseDesc testCase = new TestCaseDesc();
|
||||
testCase.projectName = System.getProperty("case.projectName", null);
|
||||
testCase.testFramework = System.getProperty("case.testFramework", null);
|
||||
testCase.testComponents = System.getProperty("case.testComponents", null);
|
||||
logger.info("load case desc: projectName[{}] testFramework[{}], testComponents[{}], cooperativeFrameworks[{}]",
|
||||
testCase.projectName,
|
||||
testCase.testFramework,
|
||||
testCase.testComponents);
|
||||
return testCase;
|
||||
}
|
||||
}
|
||||
|
||||
public String getTestFramework() {
|
||||
return testFramework;
|
||||
}
|
||||
|
||||
public String getTestComponents() {
|
||||
return testComponents;
|
||||
}
|
||||
|
||||
public String getProjectName() {
|
||||
return projectName;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Test Report - ${testReport.testDate}
|
||||
|
||||
- tests : **${testReport.successCaseCount} passed**. **${testReport.totalCaseCount - testReport.successCaseCount} failed**
|
||||
- branch name : **[${testReport.testBranch}](https://github.com/apache/incubator-skywalking/tree/${testReport.testBranch})**
|
||||
- commit id : **[${testReport.commitId}](https://github.com/apache/incubator-skywalking/commit/${testReport.commitId})**
|
||||
- cases branch: **[${testReport.caseBranch}](https://github.com/SkywalkingTest/skywalking-autotest-scenarios/tree/${testReport.caseBranch})**
|
||||
- cases commit id: **[${testReport.caseCommit}](https://github.com/SkywalkingTest/skywalking-autotest-scenarios/commit/${testReport.caseCommit})**
|
||||
|
||||
## Cases List
|
||||
|
||||
| Case description | Status | Cases|
|
||||
|:-----|:-----:|:-----:|
|
||||
<#list testReport.frameworkCases as frameworkCases>
|
||||
|${frameworkCases.testFramework}| **${frameworkCases.successCaseCount} passed. ${frameworkCases.totalCaseCount - frameworkCases.successCaseCount} failed**| [click me](#${frameworkCases.testFramework?lower_case}) |
|
||||
</#list>
|
||||
|
||||
<#list testReport.frameworkCases as frameworkCases>
|
||||
## ${frameworkCases.testFramework}
|
||||
|
||||
### <#list frameworkCases.caseByVersionCategories as versionCategory>
|
||||
| Version | Passed | Failed|
|
||||
|:------------- |:-------:|:-----:|
|
||||
<#list versionCategory.testCases as item>
|
||||
| ${item.caseName} | <#if item.success>:heavy_check_mark:</#if>|<#if !item.success>:heavy_check_mark:</#if>|
|
||||
</#list>
|
||||
</#list>
|
||||
|
||||
</#list>
|
||||
Loading…
Reference in New Issue