Skip to content

Commit 9de771b

Browse files
authored
Merge pull request #1036 from microsoft/trask/add-java-11-to-build-matrix
Add Java 11 to smoke test matrix
2 parents 3c65f76 + fbbe8a0 commit 9de771b

File tree

44 files changed

+750
-285
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+750
-285
lines changed

agent/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ shadowJar() {
7474
// javax.lang.model.element.Modifier which is no longer in the bootstrap class loader in Java 9, and this causes
7575
// spring class path scanning to fail when trying to read com.google.errorprone.annotations.ForOverride
7676
// (java.lang.NoClassDefFoundError: [Ljavax/lang/model/element/Modifier;)
77-
exclude shadowPrefix.replace('.', '/') + '/com/google/errorprone/**'
77+
exclude 'com/google/errorprone/**'
7878
}
7979

8080
task shadowJar2(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {

settings.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ include ':test:smoke:testApps:TraceLog4j2UsingAgent'
7474
include ':test:smoke:testApps:HeartBeat'
7575
include ':test:smoke:testApps:SpringBootTest'
7676
include ':test:smoke:testApps:FixedRateSampling'
77+
include ':test:smoke:testApps:Jdbc'
78+
include ':test:smoke:testApps:HttpClients'
79+
include ':test:smoke:testApps:CustomInstrumentation'
7780
include ':test:smoke:testApps:WebAuto'
7881
include ':test:smoke:testApps:SpringBoot1_3Auto'
7982
include ':test:smoke:testApps:SpringBootAuto'

test/smoke/appServers/global-resources/CustomInstrumentation_AI-Agent.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Instrumentation>
44
<BuiltIn enabled="true">
55
</BuiltIn>
6-
<Class name="com.springbootstartertest.controller.TargetObject">
6+
<Class name="com.microsoft.applicationinsights.smoketestapp.TargetObject">
77
<Method name="one"/>
88
<Method name="two" signature="(Ljava/lang/String;)Ljava/lang/String;"/>
99
<Method name="three"/>
@@ -14,7 +14,7 @@
1414
<Method name="eight" signature="(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"/>
1515
<Method name="nine"/>
1616
</Class>
17-
<Class name="com.springbootstartertest.controller.TargetObject$NestedObject">
17+
<Class name="com.microsoft.applicationinsights.smoketestapp.TargetObject$NestedObject">
1818
<Method name="four" signature="(Z[I[[Ljava/lang/String;)V"/>
1919
</Class>
2020
</Instrumentation>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
openjdk:7-jre
2-
openjdk:8-jre
2+
openjdk:8-jre
3+
azul/zulu-openjdk:11

test/smoke/framework/testCore/src/main/java/com/microsoft/applicationinsights/smoketest/AiSmokeTest.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import java.io.File;
4242
import java.io.FileReader;
4343
import java.io.IOException;
44+
import java.net.URL;
4445
import java.util.ArrayDeque;
4546
import java.util.ArrayList;
4647
import java.util.Arrays;
@@ -70,11 +71,18 @@ public static Collection<Object[]> parameterGenerator() throws IOException {
7071
List<String> appServers = Resources.readLines(Resources.getResource("appServers.txt"), Charsets.UTF_8);
7172
System.out.println("Target appservers="+Arrays.toString(appServers.toArray()));
7273
String os = System.getProperty("applicationinsights.smoketest.os", "linux");
74+
URL jreExcludesURL = Thread.currentThread().getContextClassLoader().getResource("jre.excludes.txt");
75+
List<String> jreExcludes;
76+
if (jreExcludesURL == null) {
77+
jreExcludes = new ArrayList<>();
78+
} else {
79+
jreExcludes = Resources.readLines(jreExcludesURL, Charsets.UTF_8);
80+
}
7381
Multimap<String, String> appServers2jres = HashMultimap.create();
7482
for (String appServer : appServers) {
7583
List<String> serverJres;
7684
try {
77-
serverJres = getAppServerJres(appServer);
85+
serverJres = getAppServerJres(appServer, jreExcludes);
7886
} catch (Exception e) {
7987
System.err.printf("SKIPPING '%s'. Could not configure jres: %s%n", appServer, e);
8088
continue;
@@ -93,14 +101,14 @@ public static Collection<Object[]> parameterGenerator() throws IOException {
93101
return rval;
94102
}
95103

96-
private static List<String> getAppServerJres(String appServer) throws IOException {
97-
List<String> rval = Resources.readLines(Resources.getResource(appServer+".jre.txt"), Charsets.UTF_8);
98-
return Lists.transform(rval, new Function<String, String>() {
99-
@Override
100-
public String apply(String input) {
101-
return input.replaceAll("[:/]", "_");
104+
private static List<String> getAppServerJres(String appServer, List<String> jreExcludes) throws IOException {
105+
List<String> jres = new ArrayList<>();
106+
for (String jre : Resources.readLines(Resources.getResource(appServer+".jre.txt"), Charsets.UTF_8)) {
107+
if (!jreExcludes.contains(jre)) {
108+
jres.add(jre.replaceAll("[:/]", "_"));
102109
}
103-
});
110+
}
111+
return jres;
104112
}
105113

106114
@Parameter(0) public String appServer;

test/smoke/testApps/CachingCalculator/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ dependencies {
1111
smokeTestCompile 'com.google.guava:guava:23.0'
1212
}
1313

14-
sourceCompatibility = 1.8
15-
targetCompatibility = 1.8
14+
sourceCompatibility = 1.7
15+
targetCompatibility = 1.7
1616
compileSmokeTestJava.sourceCompatibility = 1.8
1717
compileSmokeTestJava.targetCompatibility = 1.8
1818

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apply plugin: 'war'
2+
3+
dependencies {
4+
compile aiCoreJar
5+
compile aiWebJar
6+
7+
providedCompile 'javax.servlet:javax.servlet-api:3.0.1'
8+
}
9+
10+
sourceCompatibility = 1.7
11+
targetCompatibility = 1.7
12+
compileSmokeTestJava.sourceCompatibility = 1.8
13+
compileSmokeTestJava.targetCompatibility = 1.8
14+
15+
ext.testAppArtifactDir = war.destinationDirectory
16+
ext.testAppArtifactFilename = war.archiveFileName.get()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
package com.microsoft.applicationinsights.smoketestapp;
2+
3+
import java.io.IOException;
4+
import javax.servlet.ServletException;
5+
import javax.servlet.annotation.WebServlet;
6+
import javax.servlet.http.HttpServlet;
7+
import javax.servlet.http.HttpServletRequest;
8+
import javax.servlet.http.HttpServletResponse;
9+
10+
@WebServlet("/*")
11+
public class CustomInstrumentationController extends HttpServlet {
12+
13+
@Override
14+
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException {
15+
try {
16+
String response = doGetInternal(req);
17+
resp.getWriter().println(response);
18+
} catch (ServletException e) {
19+
throw e;
20+
} catch (Exception e) {
21+
throw new ServletException(e);
22+
}
23+
}
24+
25+
private String doGetInternal(HttpServletRequest req) throws Exception {
26+
String pathInfo = req.getPathInfo();
27+
if (pathInfo.equals("/")) {
28+
return "ok";
29+
} else if (pathInfo.equals("/customInstrumentationOne")) {
30+
return customInstrumentationOne();
31+
} else if (pathInfo.equals("/customInstrumentationTwo")) {
32+
return customInstrumentationTwo();
33+
} else if (pathInfo.equals("/customInstrumentationThree")) {
34+
return customInstrumentationThree();
35+
} else if (pathInfo.equals("/customInstrumentationFour")) {
36+
return customInstrumentationFour();
37+
} else if (pathInfo.equals("/customInstrumentationFive")) {
38+
return customInstrumentationFive();
39+
} else if (pathInfo.equals("/customInstrumentationSeven")) {
40+
return customInstrumentationSeven();
41+
} else if (pathInfo.equals("/customInstrumentationEight")) {
42+
return customInstrumentationEight();
43+
} else if (pathInfo.equals("/customInstrumentationNine")) {
44+
return customInstrumentationNine();
45+
} else {
46+
throw new ServletException("Unexpected url: " + pathInfo);
47+
}
48+
}
49+
50+
public String customInstrumentationOne() {
51+
return new TargetObject().one();
52+
}
53+
54+
public String customInstrumentationTwo() {
55+
return new TargetObject().two("Two");
56+
}
57+
58+
public String customInstrumentationThree() {
59+
try {
60+
return new TargetObject().three();
61+
} catch (Exception e) {
62+
return "Three";
63+
}
64+
}
65+
66+
public String customInstrumentationFour() {
67+
new TargetObject.NestedObject().four(false, null, null);
68+
return "Four";
69+
}
70+
71+
public String customInstrumentationFive() {
72+
return new TargetObject().five();
73+
}
74+
75+
public String customInstrumentationSeven() {
76+
return new TargetObject().seven("Seven");
77+
}
78+
79+
public String customInstrumentationEight() {
80+
return new TargetObject().eight("Eight");
81+
}
82+
83+
public String customInstrumentationNine() throws IOException {
84+
return new TargetObject().nine();
85+
}
86+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package com.microsoft.applicationinsights.smoketestapp;
2+
3+
import java.io.IOException;
4+
5+
import org.apache.http.client.methods.CloseableHttpResponse;
6+
import org.apache.http.client.methods.HttpGet;
7+
import org.apache.http.impl.client.CloseableHttpClient;
8+
import org.apache.http.impl.client.HttpClientBuilder;
9+
10+
class TargetObject {
11+
12+
String one() {
13+
return "One";
14+
}
15+
16+
String two() {
17+
return "Two";
18+
}
19+
20+
String two(String input) {
21+
return input;
22+
}
23+
24+
String three() throws Exception {
25+
throw new Exception("Three");
26+
}
27+
28+
String five() {
29+
return six("Five");
30+
}
31+
32+
String six(String arg) {
33+
one();
34+
two("two");
35+
return arg;
36+
}
37+
38+
String seven(String arg) {
39+
return seven("7", "77");
40+
}
41+
42+
String seven(String arg1, String arg2) {
43+
return "Seven";
44+
}
45+
46+
String eight(String arg) {
47+
return eight("8", "88");
48+
}
49+
50+
String eight(String arg1, String arg2) {
51+
return "Eight";
52+
}
53+
54+
String nine() throws IOException {
55+
String url = "https://www.bing.com";
56+
HttpGet get = new HttpGet(url);
57+
try (CloseableHttpClient httpClient = HttpClientBuilder.create().disableAutomaticRetries().build();
58+
CloseableHttpResponse response = httpClient.execute(get)) {
59+
60+
return response.getStatusLine().getReasonPhrase();
61+
}
62+
}
63+
64+
static class NestedObject {
65+
66+
void four(boolean x, int[] y, String[][] z) {
67+
}
68+
}
69+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings" schemaVersion="2014-05-30">
3+
4+
<!-- The key from the portal: -->
5+
6+
<InstrumentationKey>00000000-0000-0000-0000-0FEEDDADBEEF</InstrumentationKey>
7+
8+
<SDKLogger type="CONSOLE">
9+
<enabled>true</enabled>
10+
<UniquePrefix>JavaSDKLog</UniquePrefix>
11+
</SDKLogger>
12+
13+
<QuickPulse enabled="false" />
14+
15+
<!-- HTTP request component (not required for bare API) -->
16+
17+
<TelemetryModules>
18+
<Add type="com.microsoft.applicationinsights.web.extensibility.modules.WebRequestTrackingTelemetryModule" />
19+
<Add type="com.microsoft.applicationinsights.web.extensibility.modules.WebSessionTrackingTelemetryModule" />
20+
<Add type="com.microsoft.applicationinsights.web.extensibility.modules.WebUserTrackingTelemetryModule" />
21+
</TelemetryModules>
22+
23+
<!-- Events correlation (not required for bare API) -->
24+
<!-- These initializers add context data to each event -->
25+
26+
<TelemetryInitializers>
27+
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebOperationIdTelemetryInitializer" />
28+
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebOperationNameTelemetryInitializer" />
29+
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebSessionTelemetryInitializer" />
30+
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebUserTelemetryInitializer" />
31+
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebUserAgentTelemetryInitializer" />
32+
<Add type="com.microsoft.applicationinsights.extensibility.initializer.docker.DockerContextInitializer" />
33+
</TelemetryInitializers>
34+
35+
<Channel>
36+
<EndpointAddress>http://fakeingestion:60606/v2/track</EndpointAddress>
37+
<DeveloperMode>true</DeveloperMode>
38+
<FlushIntervalInSeconds>1</FlushIntervalInSeconds>
39+
</Channel>
40+
41+
</ApplicationInsights>

0 commit comments

Comments
 (0)