Skip to content

Commit

Permalink
[test/plugin] removes the dead codes (#3651)
Browse files Browse the repository at this point in the history
* removes the dead codes

* sync
  • Loading branch information
dmsolr authored and wu-sheng committed Oct 18, 2019
1 parent 6a7867e commit ef91bcf
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 656 deletions.
4 changes: 1 addition & 3 deletions test/plugin/containers/jvm-container/docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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=$?
Expand Down
15 changes: 7 additions & 8 deletions test/plugin/containers/tomcat-container/docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
30 changes: 0 additions & 30 deletions test/plugin/mock-collector/docker/Dockerfile

This file was deleted.

18 changes: 0 additions & 18 deletions test/plugin/mock-collector/docker/config.properties

This file was deleted.

25 changes: 0 additions & 25 deletions test/plugin/mock-collector/docker/docker-entrypoint.sh

This file was deleted.

20 changes: 0 additions & 20 deletions test/plugin/mock-collector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ services:
<#if service.healthcheck??>
healthcheck:
<#list service.healthcheck as item>
- ${item}
${item}
</#list>
</#if>
</#list>
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Original file line number Diff line number Diff line change
Expand Up @@ -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", "");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,64 +22,45 @@
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");

if (actualData.exists() && expectedData.exists()) {
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;
}

}

This file was deleted.

Loading

0 comments on commit ef91bcf

Please sign in to comment.