Test Windows in CI (#6824)
This commit is contained in:
parent
2e8bf7f9a1
commit
ff4fe978e5
|
@ -23,6 +23,7 @@ jobs:
|
||||||
- macos-latest
|
- macos-latest
|
||||||
- macos-13
|
- macos-13
|
||||||
- ubuntu-latest
|
- ubuntu-latest
|
||||||
|
- windows-latest
|
||||||
test-java-version:
|
test-java-version:
|
||||||
- 8
|
- 8
|
||||||
- 11
|
- 11
|
||||||
|
@ -71,7 +72,8 @@ jobs:
|
||||||
./gradlew build
|
./gradlew build
|
||||||
${{ matrix.coverage && 'jacocoTestReport' || '' }}
|
${{ matrix.coverage && 'jacocoTestReport' || '' }}
|
||||||
-PtestJavaVersion=${{ matrix.test-java-version }}
|
-PtestJavaVersion=${{ matrix.test-java-version }}
|
||||||
-Porg.gradle.java.installations.paths=${{ steps.setup-java-test.outputs.path }},${{ steps.setup-java.outputs.path }}
|
"-Porg.gradle.java.installations.paths=${{ steps.setup-java-test.outputs.path }}"
|
||||||
|
"-Porg.gradle.java.installations.auto-download=false"
|
||||||
env:
|
env:
|
||||||
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
|
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
|
||||||
# JMH-based tests run only if this environment variable is set to true
|
# JMH-based tests run only if this environment variable is set to true
|
||||||
|
@ -79,7 +81,9 @@ jobs:
|
||||||
|
|
||||||
- name: Check for diff
|
- name: Check for diff
|
||||||
# The jApiCmp diff compares current to latest, which isn't appropriate for release branches, or for bot-generated PRs
|
# The jApiCmp diff compares current to latest, which isn't appropriate for release branches, or for bot-generated PRs
|
||||||
if: ${{ !startsWith(github.ref_name, 'release/') && !startsWith(github.base_ref, 'release/') && (github.actor != 'opentelemetrybot') }}
|
# this fails on windows because of the bash-specific if/then/else syntax, but that's ok
|
||||||
|
# because we only need to run this validation once (on any platform)
|
||||||
|
if: ${{ matrix.os != 'windows-latest' && !startsWith(github.ref_name, 'release/') && !startsWith(github.base_ref, 'release/') && (github.actor != 'opentelemetrybot') }}
|
||||||
run: |
|
run: |
|
||||||
# need to "git add" in case any generated files did not already exist
|
# need to "git add" in case any generated files did not already exist
|
||||||
git add docs/apidiffs
|
git add docs/apidiffs
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
package io.opentelemetry.context.internal.shaded;
|
package io.opentelemetry.context.internal.shaded;
|
||||||
|
|
||||||
|
import static org.awaitility.Awaitility.await;
|
||||||
import static org.hamcrest.CoreMatchers.is;
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
import static org.hamcrest.CoreMatchers.not;
|
import static org.hamcrest.CoreMatchers.not;
|
||||||
import static org.hamcrest.CoreMatchers.nullValue;
|
import static org.hamcrest.CoreMatchers.nullValue;
|
||||||
|
@ -75,8 +76,7 @@ class WeakConcurrentMapTest {
|
||||||
assertThat(map.getCleanerThread(), not(nullValue(Thread.class)));
|
assertThat(map.getCleanerThread(), not(nullValue(Thread.class)));
|
||||||
new MapTestCase(map).doTest();
|
new MapTestCase(map).doTest();
|
||||||
map.getCleanerThread().interrupt();
|
map.getCleanerThread().interrupt();
|
||||||
Thread.sleep(200L);
|
await().untilAsserted(() -> assertThat(map.getCleanerThread().isAlive(), is(false)));
|
||||||
assertThat(map.getCleanerThread().isAlive(), is(false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static class KeyEqualToWeakRefOfItself {
|
static class KeyEqualToWeakRefOfItself {
|
||||||
|
@ -152,8 +152,12 @@ class WeakConcurrentMapTest {
|
||||||
assertThat(values.isEmpty(), is(true));
|
assertThat(values.isEmpty(), is(true));
|
||||||
key1 = key2 = null; // Make eligible for GC
|
key1 = key2 = null; // Make eligible for GC
|
||||||
System.gc();
|
System.gc();
|
||||||
Thread.sleep(200L);
|
await()
|
||||||
triggerClean();
|
.untilAsserted(
|
||||||
|
() -> {
|
||||||
|
triggerClean();
|
||||||
|
assertThat(map.approximateSize(), is(2));
|
||||||
|
});
|
||||||
assertThat(map.get(key3), is(value3));
|
assertThat(map.get(key3), is(value3));
|
||||||
assertThat(map.getIfPresent(key3), is(value3));
|
assertThat(map.getIfPresent(key3), is(value3));
|
||||||
assertThat(map.get(key4), is(value4));
|
assertThat(map.get(key4), is(value4));
|
||||||
|
|
|
@ -322,8 +322,7 @@ public final class OtlpConfigUtil {
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
throw new ConfigurationException("Invalid OTLP certificate/key path: " + filePath);
|
throw new ConfigurationException("Invalid OTLP certificate/key path: " + filePath);
|
||||||
}
|
}
|
||||||
try {
|
try (RandomAccessFile raf = new RandomAccessFile(file, "r")) {
|
||||||
RandomAccessFile raf = new RandomAccessFile(file, "r");
|
|
||||||
byte[] bytes = new byte[(int) raf.length()];
|
byte[] bytes = new byte[(int) raf.length()];
|
||||||
raf.readFully(bytes);
|
raf.readFully(bytes);
|
||||||
return bytes;
|
return bytes;
|
||||||
|
|
|
@ -96,7 +96,8 @@ class PrometheusMetricReaderProviderTest {
|
||||||
.extracting("server", as(InstanceOfAssertFactories.type(HttpServer.class)))
|
.extracting("server", as(InstanceOfAssertFactories.type(HttpServer.class)))
|
||||||
.satisfies(
|
.satisfies(
|
||||||
server -> {
|
server -> {
|
||||||
assertThat(server.getAddress().getHostName()).isEqualTo("localhost");
|
assertThat(server.getAddress().getHostName())
|
||||||
|
.isIn("localhost", "127.0.0.1", "kubernetes.docker.internal");
|
||||||
assertThat(server.getAddress().getPort()).isEqualTo(port);
|
assertThat(server.getAddress().getPort()).isEqualTo(port);
|
||||||
});
|
});
|
||||||
assertThat(metricReader.getMemoryMode()).isEqualTo(MemoryMode.IMMUTABLE_DATA);
|
assertThat(metricReader.getMemoryMode()).isEqualTo(MemoryMode.IMMUTABLE_DATA);
|
||||||
|
|
|
@ -172,7 +172,7 @@ class RetryInterceptorTest {
|
||||||
client
|
client
|
||||||
.newCall(new Request.Builder().url("http://localhost:" + openPort).build())
|
.newCall(new Request.Builder().url("http://localhost:" + openPort).build())
|
||||||
.execute())
|
.execute())
|
||||||
.isInstanceOf(ConnectException.class);
|
.isInstanceOfAny(ConnectException.class, SocketTimeoutException.class);
|
||||||
|
|
||||||
verify(isRetryableException, times(5)).apply(any());
|
verify(isRetryableException, times(5)).apply(any());
|
||||||
// Should retry maxAttempts, and sleep maxAttempts - 1 times
|
// Should retry maxAttempts, and sleep maxAttempts - 1 times
|
||||||
|
|
|
@ -135,7 +135,7 @@ class SpanShimTest {
|
||||||
IntStream.range(0, baggageItemsCount)
|
IntStream.range(0, baggageItemsCount)
|
||||||
.forEach(i -> executor.execute(() -> spanShim.setBaggageItem("key-" + i, "value-" + i)));
|
.forEach(i -> executor.execute(() -> spanShim.setBaggageItem("key-" + i, "value-" + i)));
|
||||||
executor.shutdown();
|
executor.shutdown();
|
||||||
executor.awaitTermination(5, TimeUnit.SECONDS);
|
executor.awaitTermination(10, TimeUnit.SECONDS);
|
||||||
|
|
||||||
for (int i = 0; i < baggageItemsCount; i++) {
|
for (int i = 0; i < baggageItemsCount; i++) {
|
||||||
assertThat(spanShim.getBaggageItem("key-" + i)).isEqualTo("value-" + i);
|
assertThat(spanShim.getBaggageItem("key-" + i)).isEqualTo("value-" + i);
|
||||||
|
|
|
@ -541,13 +541,7 @@ public final class AutoConfiguredOpenTelemetrySdkBuilder implements AutoConfigur
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
logger.fine("Autoconfiguring from configuration file: " + configurationFile);
|
logger.fine("Autoconfiguring from configuration file: " + configurationFile);
|
||||||
FileInputStream fis;
|
try (FileInputStream fis = new FileInputStream(configurationFile)) {
|
||||||
try {
|
|
||||||
fis = new FileInputStream(configurationFile);
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
throw new ConfigurationException("Configuration file not found", e);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
Class<?> configurationFactory =
|
Class<?> configurationFactory =
|
||||||
Class.forName("io.opentelemetry.sdk.extension.incubator.fileconfig.FileConfiguration");
|
Class.forName("io.opentelemetry.sdk.extension.incubator.fileconfig.FileConfiguration");
|
||||||
Method parse = configurationFactory.getMethod("parse", InputStream.class);
|
Method parse = configurationFactory.getMethod("parse", InputStream.class);
|
||||||
|
@ -567,6 +561,8 @@ public final class AutoConfiguredOpenTelemetrySdkBuilder implements AutoConfigur
|
||||||
// resource
|
// resource
|
||||||
return AutoConfiguredOpenTelemetrySdk.create(
|
return AutoConfiguredOpenTelemetrySdk.create(
|
||||||
sdk, Resource.getDefault(), null, structuredConfigProperties);
|
sdk, Resource.getDefault(), null, structuredConfigProperties);
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
throw new ConfigurationException("Configuration file not found", e);
|
||||||
} catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException e) {
|
} catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException e) {
|
||||||
throw new ConfigurationException(
|
throw new ConfigurationException(
|
||||||
"Error configuring from file. Is opentelemetry-sdk-extension-incubator on the classpath?",
|
"Error configuring from file. Is opentelemetry-sdk-extension-incubator on the classpath?",
|
||||||
|
@ -577,6 +573,10 @@ public final class AutoConfiguredOpenTelemetrySdkBuilder implements AutoConfigur
|
||||||
throw (ConfigurationException) cause;
|
throw (ConfigurationException) cause;
|
||||||
}
|
}
|
||||||
throw new ConfigurationException("Unexpected error configuring from file", e);
|
throw new ConfigurationException("Unexpected error configuring from file", e);
|
||||||
|
} catch (IOException e) {
|
||||||
|
// IOException (other than FileNotFoundException which is caught above) is only thrown
|
||||||
|
// above by FileInputStream.close()
|
||||||
|
throw new ConfigurationException("Error closing file", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,12 +81,16 @@ class FileConfigurationCreateTest {
|
||||||
String rewrittenExampleContent =
|
String rewrittenExampleContent =
|
||||||
exampleContent
|
exampleContent
|
||||||
.replaceAll(
|
.replaceAll(
|
||||||
"certificate: .*\n", "certificate: " + certificatePath + System.lineSeparator())
|
"certificate: .*\n",
|
||||||
|
"certificate: " + certificatePath.replace("\\", "\\\\") + System.lineSeparator())
|
||||||
.replaceAll(
|
.replaceAll(
|
||||||
"client_key: .*\n", "client_key: " + clientKeyPath + System.lineSeparator())
|
"client_key: .*\n",
|
||||||
|
"client_key: " + clientKeyPath.replace("\\", "\\\\") + System.lineSeparator())
|
||||||
.replaceAll(
|
.replaceAll(
|
||||||
"client_certificate: .*\n",
|
"client_certificate: .*\n",
|
||||||
"client_certificate: " + clientCertificatePath + System.lineSeparator());
|
"client_certificate: "
|
||||||
|
+ clientCertificatePath.replace("\\", "\\\\")
|
||||||
|
+ System.lineSeparator());
|
||||||
InputStream is =
|
InputStream is =
|
||||||
new ByteArrayInputStream(rewrittenExampleContent.getBytes(StandardCharsets.UTF_8));
|
new ByteArrayInputStream(rewrittenExampleContent.getBytes(StandardCharsets.UTF_8));
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,9 @@ class AttributeAssertionTest {
|
||||||
.getAssertion()
|
.getAssertion()
|
||||||
.accept(AttributeAssertion.attributeValueAssertion(key, null)))
|
.accept(AttributeAssertion.attributeValueAssertion(key, null)))
|
||||||
.isInstanceOf(AssertionError.class)
|
.isInstanceOf(AssertionError.class)
|
||||||
.hasMessage("[STRING attribute 'flib'] \nExpecting actual not to be null");
|
.hasMessage(
|
||||||
|
"[STRING attribute 'flib'] "
|
||||||
|
+ System.lineSeparator()
|
||||||
|
+ "Expecting actual not to be null");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -687,7 +687,8 @@ class TraceAssertionsTest {
|
||||||
.hasTracesSatisfyingExactly(
|
.hasTracesSatisfyingExactly(
|
||||||
trace -> trace.hasSpansSatisfyingExactly(span -> span.hasSpanId(SPAN_ID1))))
|
trace -> trace.hasSpansSatisfyingExactly(span -> span.hasSpanId(SPAN_ID1))))
|
||||||
.isInstanceOf(AssertionError.class)
|
.isInstanceOf(AssertionError.class)
|
||||||
.hasMessageStartingWith("[Trace 0] \n" + "Expected size: 1 but was: 2");
|
.hasMessageStartingWith(
|
||||||
|
"[Trace 0] " + System.lineSeparator() + "Expected size: 1 but was: 2");
|
||||||
|
|
||||||
// test asserting spans in wrong oder
|
// test asserting spans in wrong oder
|
||||||
assertThatThrownBy(
|
assertThatThrownBy(
|
||||||
|
|
Loading…
Reference in New Issue