Skip to content

Commit

Permalink
Fix rocketmq latest dep test (#8756)
Browse files Browse the repository at this point in the history
  • Loading branch information
laurit authored Jun 19, 2023
1 parent 7d1a271 commit a1ccaad
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ tasks.withType<Test>().configureEach {
jvmArgs("-Dotel.instrumentation.rocketmq-client.experimental-span-attributes=true")

systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean)

// required on jdk17
jvmArgs("--add-opens=java.base/sun.nio.ch=ALL-UNNAMED")
jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ dependencies {

tasks.withType<Test>().configureEach {
systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean)
// required on jdk17
jvmArgs("--add-opens=java.base/sun.nio.ch=ALL-UNNAMED")
jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package io.opentelemetry.instrumentation.rocketmqclient.v4_8.base;

import static java.util.Collections.emptyMap;
import static org.awaitility.Awaitility.await;

import io.opentelemetry.instrumentation.test.utils.PortUtils;
import java.io.File;
Expand All @@ -15,6 +16,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -147,13 +149,23 @@ public static void initTopic(String topic, String nsAddr, String clusterName) {
Class<?> mqAdmin = Class.forName("org.apache.rocketmq.test.util.MQAdminTestUtils");
Method createTopic =
mqAdmin.getMethod(
"createTopic", String.class, String.class, String.class, int.class, Map.class);
createTopic.invoke(null, nsAddr, clusterName, topic, 20, emptyMap());
} catch (ClassNotFoundException
| InvocationTargetException
| NoSuchMethodException
| IllegalAccessException ex) {
throw new LinkageError("Could not initialize topic", ex);
"createTopic",
String.class,
String.class,
String.class,
int.class,
Map.class,
int.class);
await()
.atMost(Duration.ofSeconds(30))
.ignoreException(InvocationTargetException.class)
.until(
() -> {
createTopic.invoke(null, nsAddr, clusterName, topic, 20, emptyMap(), 3);
return true;
});
} catch (ClassNotFoundException | NoSuchMethodException ex) {
throw new IllegalStateException("Could not initialize topic", ex);
}
}
}
Expand Down

0 comments on commit a1ccaad

Please sign in to comment.