Skip to content

Commit 46c67d8

Browse files
committed
Adding support for Apache Skywalking
1 parent a435231 commit 46c67d8

File tree

21 files changed

+1651
-0
lines changed

21 files changed

+1651
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,6 @@ dmypy.json
127127

128128
# Pyre type checker
129129
.pyre/
130+
131+
.DS_Store
132+
.DS_Store
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
configuration.apollo.apolloEnv DEV description
2+
services[1].duration 20000 description
3+
configuration.nacos.port 49317 description
4+
configuration.zookeeper.hostPort localhost:49315 description
5+
configuration.nacos.username nacos description
6+
configuration.nacos.port 49319 description
7+
storage.mysql.metadataQueryMaxSize 5000 description
8+
configuration.apollo.period -1000000000000 description
9+
configuration.nacos.period 2 description
10+
configuration.nacos.accessKey description
11+
configuration.consul.period 1 description
12+
configuration.etcd.period 1 description
13+
configuration.zookeeper.maxRetries 3 description
14+
configuration.apollo.apolloCluster default description
15+
configuration.zookeeper.hostPort localhost:49310 description
16+
core.default.enableDataKeeperExecutor TRUE description
17+
default.rate 10000 description
18+
receiver-zipkin.default.restPort 9411 description
19+
services[1].name name1 description
20+
services[0].rate 2000 description
21+
MO-1.MO-1-P1.prop2 value2-prop description
22+
MO-1.MO-1-P1.p1 value1 description
23+
configuration.consul.hostAndPorts localhost:49296 description
24+
configuration.zookeeper.namespace /default description
25+
configuration.nacos.secretKey description
26+
configuration.apollo.appId SampleApp description
27+
storage.mysql.properties.jdbcUrl jdbc:mysql://localhost:3306/swtest?rewriteBatchedStatements description
28+
configuration.nacos.serverAddr localhost description
29+
configuration.etcd.endpoints http://127.0.0.1:49305 description
30+
services[1].rate 1000 description
31+
configuration.nacos.group skywalking description
32+
configuration.apollo.apolloMeta http://localhost:49284 description
33+
configuration.etcd.endpoints http://127.0.0.1:49302 description
34+
services[0].name name2 description
35+
configuration.zookeeper.baseSleepTimeMs 1000 description
36+
storage.mysql.properties.dataSource.password !AI!3B description
37+
configuration.apollo.apolloMeta http://localhost:49287 description
38+
default.duration -1 description
39+
configuration.consul.hostAndPorts localhost:49290 description
40+
receiver-zipkin.default.restHost 0.0.0.0 description
41+
configuration.nacos.namespace description
42+
configuration.nacos.password nacos description
43+
MO-1.MO-1-P1.p2 value2 description
44+
services[0].duration 30000 description
45+
configuration.zookeeper.period 1 description
46+
configuration.etcd.namespace /skywalking/ description
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# ctest-runner
2+
3+
java -jar ../../ctest-runner/target/ctest-runner-1.0-SNAPSHOT-jar-with-dependencies.jar /home/sk117/final-project/copy/overrides application2.yml oap-server/server-configuration/configuration-zookeeper org.apache.skywalking.oap.server.configuration.zookeeper.it.ITZookeeperConfigurationTest#shouldReadUpdated
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>org.uiuc</groupId>
8+
<artifactId>ctest-runner</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
11+
<properties>
12+
<maven.compiler.source>8</maven.compiler.source>
13+
<maven.compiler.target>8</maven.compiler.target>
14+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15+
</properties>
16+
17+
<dependencies>
18+
<dependency>
19+
<groupId>org.apache.maven.shared</groupId>
20+
<artifactId>maven-invoker</artifactId>
21+
<version>3.2.0</version>
22+
</dependency>
23+
<dependency>
24+
<groupId>com.google.code.gson</groupId>
25+
<artifactId>gson</artifactId>
26+
<version>2.9.1</version>
27+
</dependency>
28+
<dependency>
29+
<groupId>com.anubhavshukla</groupId>
30+
<artifactId>properties-to-yaml-converter</artifactId>
31+
<version>1.0.1</version>
32+
</dependency>
33+
</dependencies>
34+
35+
<build>
36+
<plugins>
37+
<plugin>
38+
<artifactId>maven-assembly-plugin</artifactId>
39+
<configuration>
40+
<archive>
41+
<manifest>
42+
<mainClass>org.uiuc.Main</mainClass>
43+
</manifest>
44+
</archive>
45+
<descriptorRefs>
46+
<descriptorRef>jar-with-dependencies</descriptorRef>
47+
</descriptorRefs>
48+
</configuration>
49+
<executions>
50+
<execution>
51+
<id>make-assembly</id> <!-- this is used for inheritance merges -->
52+
<phase>package</phase> <!-- bind to the packaging phase -->
53+
<goals>
54+
<goal>single</goal>
55+
</goals>
56+
</execution>
57+
</executions>
58+
</plugin>
59+
</plugins>
60+
</build>
61+
62+
</project>
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package org.uiuc;
2+
3+
import java.util.Arrays;
4+
import java.util.HashMap;
5+
import java.util.List;
6+
import java.util.Map;
7+
8+
public interface AppConstants {
9+
10+
Map<String, String> moduleToDirMap = new HashMap<String, String>() {
11+
{
12+
put("oap-server/server-starter", "./oap-server/server-starter/src/main/resources/");
13+
put("oap-server/server-configuration/configuration-apollo", "./oap-server/server-configuration/configuration-apollo/src/test/resources/");
14+
put("oap-server/server-configuration/configuration-etcd", "./oap-server/server-configuration/configuration-etcd/src/test/resources/");
15+
put("oap-server/server-configuration/configuration-zookeeper", "./oap-server/server-configuration/configuration-zookeeper/src/test/resources/");
16+
put("oap-server/analyzer/agent-analyzer", "./oap-server/analyzer/agent-analyzer/src/main/resources/");
17+
put("oap-server/server-configuration/configuration-nacos", "./oap-server/server-configuration/configuration-nacos/src/test/resources/");
18+
put("oap-server/server-configuration/configuration-consul", "./oap-server/server-configuration/configuration-consul/src/test/resources/");
19+
}
20+
};
21+
22+
Map<String, String> moduleToFileNameMap = new HashMap<String, String>() {
23+
{
24+
put("oap-server/server-starter", "application2.yml");
25+
put("oap-server/server-configuration/configuration-apollo", "application2.yml");
26+
put("oap-server/server-configuration/configuration-etcd", "application2.yml");
27+
put("oap-server/server-configuration/configuration-zookeeper", "application2.yml");
28+
put("oap-server/analyzer/agent-analyzer", "trace-sampling-policy-settings2.yml");
29+
put("oap-server/server-configuration/configuration-nacos", "application2.yml");
30+
put("oap-server/server-configuration/configuration-consul", "application2.yml");
31+
}
32+
};
33+
34+
List<String> testCases = Arrays.asList(
35+
"oap-server/server-starter>org.apache.skywalking.oap.server.starter.config.ApplicationConfigLoaderTestCase#testLoadConfig",
36+
"oap-server/server-starter>org.apache.skywalking.oap.server.starter.config.ApplicationConfigLoaderTestCase#testLoadStringTypeConfig",
37+
"oap-server/server-starter>org.apache.skywalking.oap.server.starter.config.ApplicationConfigLoaderTestCase#testLoadIntegerTypeConfig",
38+
"oap-server/server-starter>org.apache.skywalking.oap.server.starter.config.ApplicationConfigLoaderTestCase#testLoadBooleanTypeConfig",
39+
"oap-server/server-starter>org.apache.skywalking.oap.server.starter.config.ApplicationConfigLoaderTestCase#testLoadSpecialStringTypeConfig",
40+
"oap-server/server-library/library-module>org.apache.skywalking.oap.server.library.module.ApplicationConfigurationTest#testBuildConfig",
41+
"oap-server/server-configuration/configuration-apollo>org.apache.skywalking.oap.server.configuration.apollo.ITApolloConfigurationTest#shouldReadUpdated",
42+
"oap-server/server-configuration/configuration-apollo>org.apache.skywalking.oap.server.configuration.apollo.ITApolloConfigurationTest#shouldReadUpdated4Group",
43+
"oap-server/server-configuration/configuration-consul>org.apache.skywalking.oap.server.configuration.consul.ITConsulConfigurationTest#shouldReadUpdated",
44+
"oap-server/server-configuration/configuration-consul>org.apache.skywalking.oap.server.configuration.consul.ITConsulConfigurationTest#shouldReadUpdated4Group",
45+
"oap-server/server-configuration/configuration-etcd>org.apache.skywalking.oap.server.configuration.etcd.ITEtcdConfigurationTest#shouldReadUpdated",
46+
"oap-server/server-configuration/configuration-etcd>org.apache.skywalking.oap.server.configuration.etcd.ITEtcdConfigurationTest#shouldReadUpdated4Group",
47+
"oap-server/server-configuration/configuration-zookeeper>org.apache.skywalking.oap.server.configuration.zookeeper.it.ITZookeeperConfigurationTest#shouldReadUpdated",
48+
"oap-server/server-configuration/configuration-zookeeper>org.apache.skywalking.oap.server.configuration.zookeeper.it.ITZookeeperConfigurationTest#shouldReadUpdated4GroupConfig",
49+
"oap-server/analyzer/agent-analyzer>org.apache.skywalking.oap.server.analyzer.provider.trace.TraceSamplingPolicyWatcherTest#testStaticConfigInit",
50+
"oap-server/analyzer/agent-analyzer>org.apache.skywalking.oap.server.analyzer.provider.trace.TraceSamplingPolicyWatcherTest#testTraceLatencyThresholdDynamicUpdate",
51+
"oap-server/analyzer/agent-analyzer>org.apache.skywalking.oap.server.analyzer.provider.trace.TraceSamplingPolicyWatcherTest#testTraceLatencyThresholdNotify",
52+
"oap-server/analyzer/agent-analyzer>org.apache.skywalking.oap.server.analyzer.provider.trace.TraceSamplingPolicyWatcherTest#testDefaultSampleRateDynamicUpdate",
53+
"oap-server/analyzer/agent-analyzer>org.apache.skywalking.oap.server.analyzer.provider.trace.TraceSamplingPolicyWatcherTest#testDefaultSampleRateNotify",
54+
"oap-server/analyzer/agent-analyzer>org.apache.skywalking.oap.server.analyzer.provider.trace.TraceSamplingPolicyWatcherTest#testServiceSampleRateDynamicUpdate",
55+
"oap-server/analyzer/agent-analyzer>org.apache.skywalking.oap.server.analyzer.provider.trace.TraceSamplingPolicyWatcherTest#testServiceSampleRateNotify",
56+
"oap-server/server-configuration/configuration-nacos>org.apache.skywalking.oap.server.configuration.nacos.ITNacosConfigurationTest#shouldReadUpdated",
57+
"oap-server/server-configuration/configuration-nacos>org.apache.skywalking.oap.server.configuration.nacos.ITNacosConfigurationTest#shouldReadUpdatedGroup",
58+
"oap-server/server-configuration/configuration-nacos>org.apache.skywalking.oap.server.configuration.nacos.NacosConfigWatcherRegisterTest#shouldReadConfigs"
59+
);
60+
61+
String ERROR_MSG = "Error on exec() method";
62+
}
Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
package org.uiuc;
2+
3+
import com.anubhavshukla.p2y.converter.PropertiesToYamlConverter;
4+
import com.google.gson.Gson;
5+
import org.apache.commons.io.FileUtils;
6+
7+
import java.io.*;
8+
import java.nio.charset.Charset;
9+
import java.nio.file.Files;
10+
import java.nio.file.Paths;
11+
import java.util.ArrayList;
12+
import java.util.LinkedHashMap;
13+
import java.util.List;
14+
import java.util.Map;
15+
import java.util.stream.Collectors;
16+
import java.util.stream.Stream;
17+
18+
import static org.uiuc.AppConstants.*;
19+
20+
public class Main {
21+
public static void main(String[] args) throws IOException {
22+
23+
String configDestDir = args[0];
24+
String testToConfigMapperInputFile = args[1];
25+
String generatedValueListFile = args[2];
26+
String resultDir = args[3];
27+
28+
List<String> arrList = new ArrayList<>();
29+
try (Stream<String> lines = Files.lines(Paths.get(generatedValueListFile), Charset.defaultCharset())) {
30+
lines.forEachOrdered(line -> {
31+
if (!line.isEmpty()) {
32+
String[] split = line.split("\t");
33+
if (!line.contains("SKIP")) {
34+
arrList.add(split[0] + "=" + split[1]);
35+
arrList.add(split[0] + "=" + split[2]);
36+
}
37+
}
38+
});
39+
}
40+
System.out.println(arrList);
41+
FileWriter writer = new FileWriter(configDestDir + "/output.txt");
42+
for (String str : arrList) {
43+
writer.write(str + System.lineSeparator());
44+
}
45+
writer.close();
46+
47+
List<String> overrideConfigFileList = new ArrayList<>();
48+
int i = 0;
49+
try (Stream<String> lines = Files.lines(Paths.get(configDestDir + "/output.txt"), Charset.defaultCharset())) {
50+
lines.forEachOrdered(line -> {
51+
try {
52+
File file = new File("config" + i + ".txt");
53+
FileUtils.writeStringToFile(file, line, Charset.forName("UTF-8"));
54+
PropertiesToYamlConverter p = new PropertiesToYamlConverter();
55+
String yaml = p.fileToYamlString(file);
56+
if (yaml.contains("[")) {
57+
yaml = yaml.replaceFirst("\\[[^\\]]+\\]", "").trim().replace("\n ", "\n" + " -");
58+
}
59+
System.out.println(yaml);
60+
FileUtils.writeStringToFile(new File(configDestDir + "/" + line), yaml, Charset.forName("UTF-8"));
61+
overrideConfigFileList.add(line);
62+
} catch (IOException e) {
63+
throw new RuntimeException(e);
64+
}
65+
});
66+
}
67+
68+
StringBuffer mapperInputStr = new StringBuffer();
69+
try (Stream<String> lines = Files.lines(Paths.get(testToConfigMapperInputFile), Charset.defaultCharset())) {
70+
lines.forEachOrdered(line ->
71+
mapperInputStr.append(line)
72+
);
73+
}
74+
System.out.println(mapperInputStr);
75+
76+
Gson gson = new Gson();
77+
Map<String, List<String>> testToConfigList = gson.fromJson(mapperInputStr.toString(), Map.class);
78+
System.out.println(testToConfigList);
79+
80+
Map<String, String> testCaseToModuleMap = testCases.stream()
81+
.collect(Collectors.toMap(x -> x.split(">")[1], y -> y.split(">")[0]));
82+
83+
List<String> finalReport = new ArrayList<>();
84+
Map<String, List<String>> finalParamToTestReport = new LinkedHashMap<>();
85+
testToConfigList.forEach((testCase, configList) -> {
86+
configList.forEach(config -> {
87+
List<String> allMatchingFiles = overrideConfigFileList.stream().filter(x -> x.split("=")[0].equals(config)).collect(Collectors.toList());
88+
allMatchingFiles.forEach(c -> {
89+
System.out.println("Module : " + testCaseToModuleMap.get(testCase) + " TestCase : " + testCase + " destFileName : " + c);
90+
try {
91+
runTest(configDestDir, c, testCaseToModuleMap.get(testCase), testCase, finalReport, finalParamToTestReport);
92+
} catch (Exception e) {
93+
throw new RuntimeException(e);
94+
}
95+
});
96+
});
97+
});
98+
99+
System.out.println(finalReport);
100+
FileWriter writer2 = new FileWriter(resultDir + "/test_result.tsv");
101+
for (String str : finalReport) {
102+
writer2.write(str + System.lineSeparator());
103+
}
104+
writer2.close();
105+
106+
String finalCtestJson = gson.toJson(finalParamToTestReport);
107+
System.out.println(finalCtestJson);
108+
FileWriter writer3 = new FileWriter(resultDir + "/ctests-skywalking.json");
109+
writer3.write(finalCtestJson);
110+
writer3.close();
111+
112+
}
113+
114+
private static void runTest(String sourceDir, String sourceFileName, String module, String testCase,
115+
List<String> finalReport, Map<String, List<String>> finalParamToTestReport) throws IOException, InterruptedException {
116+
117+
long startTime = System.nanoTime();
118+
119+
String destFileName = moduleToFileNameMap.get(module);
120+
121+
System.out.println("copying < " + sourceFileName + " > from < " + sourceDir + " > to < " + moduleToDirMap.get(module) + " >");
122+
123+
try {
124+
Runtime.getRuntime().exec("cp " + sourceDir + "/" + sourceFileName + " " + moduleToDirMap.get(module) + "/" + destFileName);
125+
} catch (IOException e) {
126+
System.err.println(ERROR_MSG);
127+
e.printStackTrace();
128+
}
129+
130+
Process p = null;
131+
try {
132+
p = Runtime.getRuntime().exec("mvn test -pl " + module + " -Dtest=" + testCase + " -DfailIfNoTests=false");
133+
} catch (IOException e) {
134+
System.err.println(ERROR_MSG);
135+
e.printStackTrace();
136+
}
137+
138+
OutputStream output = new OutputStream() {
139+
private final StringBuilder string = new StringBuilder();
140+
141+
@Override
142+
public void write(int b) {
143+
this.string.append((char) b);
144+
}
145+
146+
public String toString() {
147+
return this.string.toString();
148+
}
149+
};
150+
151+
copy(p.getInputStream(), output);
152+
BufferedReader bufReader = new BufferedReader(new StringReader(output.toString()));
153+
String next = bufReader.readLine();
154+
String parameter = sourceFileName.split("=")[0];
155+
long endTime = System.nanoTime();
156+
long execTime = (endTime - startTime);
157+
while (next != null) {
158+
System.out.println(next);
159+
if (next.contains("BUILD FAILURE")) {
160+
finalReport.add(parameter + "\t" + testCase + "\t" + sourceFileName.split("=")[1] + "\t" + "f" + "\t" + execTime);
161+
} else if (next.contains("BUILD SUCCESS")) {
162+
finalReport.add(parameter + "\t" + testCase + "\t" + sourceFileName.split("=")[1] + "\t" + "p" + "\t" + execTime);
163+
if (!finalParamToTestReport.containsKey(parameter)) {
164+
List<String> testList = new ArrayList<>();
165+
testList.add(testCase);
166+
finalParamToTestReport.put(parameter, testList);
167+
} else {
168+
finalParamToTestReport.get(parameter).add(testCase);
169+
}
170+
}
171+
next = bufReader.readLine();
172+
}
173+
174+
p.waitFor();
175+
}
176+
177+
178+
public static void copy(InputStream in, OutputStream out) throws IOException {
179+
while (true) {
180+
int c = in.read();
181+
if (c == -1)
182+
break;
183+
out.write((char) c);
184+
}
185+
}
186+
}

0 commit comments

Comments
 (0)