Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(itest): replace JDP with agent-based discovery #1560

Draft
wants to merge 40 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
f8e46e4
move constant to more appropriate class
andrewazores Jun 16, 2023
b0abe0d
rename properties
andrewazores Jun 16, 2023
bcbd34a
set up itest harness to use sample apps with Cryostat Agent for disco…
andrewazores Jun 16, 2023
1531b39
update CredentialsIT for agent discovery
andrewazores Jun 16, 2023
708a35f
update Credentials v2.2 IT for agent-based discovery
andrewazores Jun 16, 2023
14fccd3
refactor to extract shared cleanup logic
andrewazores Jun 16, 2023
457f236
reduce wait time for external target discovery
andrewazores Jun 16, 2023
8b7f1d2
update AutoRulesIT for agent discovery
andrewazores Jun 19, 2023
a5d8814
update AutoRulesCleanupIT for agent discovery
andrewazores Jun 19, 2023
800de77
define Cryostat itself as a custom target to simulate old JDP self-di…
andrewazores Jun 19, 2023
0e871ae
update WrongServiceListeningOnPortIT for agent-based discovery
andrewazores Jun 19, 2023
1518e55
update JmxAuthIT for agent-based discovery
andrewazores Jun 19, 2023
783f616
update JvmIdIT for agent-based discovery
andrewazores Jun 19, 2023
d3f1a84
update InterleavedExternalTargetsRequestIT for agent-based discovery
andrewazores Jun 19, 2023
17e5529
update GraphQLIT for agent-based discovery
andrewazores Jun 19, 2023
0ffb1bb
update RecordingMetadataIT for agent-based discovery
andrewazores Jun 19, 2023
f0cfd1a
refactor
andrewazores Jun 19, 2023
4a5a099
remove printlns
andrewazores Jun 19, 2023
553f609
add non-null guards
andrewazores Jun 19, 2023
785b1d8
cleanup
andrewazores Jun 19, 2023
1bc6405
update CustomTargetsIT for new discovery setup
andrewazores Jun 19, 2023
fc76398
update DiscoveryIT for new discovery setup
andrewazores Jun 19, 2023
3e384db
remove unused method
andrewazores Jun 19, 2023
75edbb3
increase discovery timeout period
andrewazores Jun 19, 2023
b36b1dd
strip output for good measure
andrewazores Jun 19, 2023
40cbca6
ensure cleanup
andrewazores Jun 19, 2023
c1f42c1
print 'podman ps' between discovery wait loops
andrewazores Jun 19, 2023
12d3899
exponential discovery loop backoff
andrewazores Jun 19, 2023
3ac6d1c
print podman info before start
andrewazores Jun 19, 2023
7f60ab6
set short itest discovery ping period
andrewazores Jun 20, 2023
6543886
fixup! exponential discovery loop backoff
andrewazores Jun 20, 2023
15a155a
increase maximum discovery timeout
andrewazores Jun 20, 2023
fd90e2a
use h2 in-memory database
andrewazores Jun 20, 2023
9e2208d
publish Agent HTTP API ports for external access
andrewazores Jun 20, 2023
97b0efc
allow setting specific random seed to reproduce order
andrewazores Jun 20, 2023
40f8402
rebase fix, add missing import
andrewazores Jun 30, 2023
042d9b0
better output while waiting for discovery
andrewazores Jul 4, 2023
6e4ea0d
cleanup/refactor and adjust for non-JDP discovery
andrewazores Jul 4, 2023
20541a0
temporarily disable a test
andrewazores Jul 4, 2023
11d0cdd
remove override of discovery ping period
andrewazores Jul 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 30 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,34 @@
<skip>${skipBaseImage}</skip>
</configuration>
</execution>
<execution>
<id>print-podman-version</id>
<phase>pre-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>podman</executable>
<arguments>
<argument>version</argument>
</arguments>
<skip>${skipITs}</skip>
</configuration>
</execution>
<execution>
<id>print-podman-info</id>
<phase>pre-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>podman</executable>
<arguments>
<argument>info</argument>
</arguments>
<skip>${skipITs}</skip>
</configuration>
</execution>
<execution>
<id>create-pod</id>
<phase>pre-integration-test</phase>
Expand Down Expand Up @@ -571,21 +599,9 @@
<argument>--env</argument>
<argument>CRYOSTAT_JMX_CREDENTIALS_DB_PASSWORD=${cryostat.itest.jmx.db-passwd}</argument>
<argument>--env</argument>
<argument>CRYOSTAT_JDBC_URL=jdbc:h2:file:/opt/cryostat.d/conf.d/h2;INIT=create domain if not exists jsonb as varchar</argument>
<argument>--env</argument>
<argument>CRYOSTAT_JDBC_DRIVER=org.h2.Driver</argument>
<argument>--env</argument>
<argument>CRYOSTAT_JDBC_USERNAME=sa</argument>
<argument>--env</argument>
<argument>CRYOSTAT_JDBC_PASSWORD=""</argument>
<argument>--env</argument>
<argument>CRYOSTAT_HIBERNATE_DIALECT=org.hibernate.dialect.H2Dialect</argument>
<argument>--env</argument>
<argument>CRYOSTAT_HBM2DDL=update</argument>
<argument>--env</argument>
<argument>CRYOSTAT_LOG_DB_QUERIES=true</argument>
<argument>CRYOSTAT_ENABLE_JDP_BROADCAST=false</argument>
<argument>--env</argument>
<argument>CRYOSTAT_ENABLE_JDP_BROADCAST=true</argument>
<argument>CRYOSTAT_DISABLE_BUILTIN_DISCOVERY=true</argument>
<argument>--env</argument>
<argument>CRYOSTAT_TARGET_CACHE_TTL=30</argument>
<argument>--env</argument>
Expand Down
6 changes: 6 additions & 0 deletions repeated-integration-tests.bash
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ STARTFLAGS=(
"-Dcryostat.itest.imageTag=${ITEST_IMG_VERSION}"
"-Dcryostat.itest.pullImages=${PULL_IMAGES}"
"build-helper:regex-property@image-tag-to-lower"
"exec:exec@print-podman-version"
"exec:exec@print-podman-info"
"exec:exec@create-pod"
"exec:exec@start-jfr-datasource"
"exec:exec@start-grafana"
Expand All @@ -61,6 +63,10 @@ if [ -n "$2" ]; then
STARTFLAGS+=("-Dit.test=$2")
fi

if [ -n "${RANDOM_SEED}" ]; then
STARTFLAGS+=("-Dfailsafe.runOrder.random.seed=${RANDOM_SEED}")
fi

STOPFLAGS=(
"exec:exec@destroy-pod"
)
Expand Down
8 changes: 8 additions & 0 deletions smoketest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,21 @@ createPod() {
--publish 8082:8082 \
--publish 8083:8083 \
--publish 8082:8082 \
--publish 8910:8910 \
--publish 8911:8911 \
--publish 8912:8912 \
--publish 8082:8082 \
--publish 8082:8082 \
--publish 9990:9990 \
--publish 10001:10001 \
--publish 10010:10010
# 5432: postgres
# 8081: vertx-fib-demo-1 HTTP
# 8082: vertx-fib-demo-2 HTTP
# 8083: vertx-fib-demo-3 HTTP
# 8910: vertx-fib-demo-1 Agent HTTP
# 8911: vertx-fib-demo-2 Agent HTTP
# 8912: vertx-fib-demo-3 Agent HTTP
# 9990: Wildfly Admin Console
# 10001: cryostat-reports HTTP
# 10010: quarkus-test-agent-1 HTTP
Expand Down
39 changes: 9 additions & 30 deletions src/test/java/itest/AutoRulesCleanupIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@
*/
package itest;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;

import io.cryostat.net.web.http.HttpMimeType;

Expand All @@ -32,11 +30,10 @@
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import itest.bases.ExternalTargetsTest;
import itest.util.ITestCleanupFailedException;
import itest.util.Podman;
import org.apache.http.client.utils.URLEncodedUtils;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
Expand All @@ -47,12 +44,11 @@
@TestMethodOrder(OrderAnnotation.class)
class AutoRulesCleanupIT extends ExternalTargetsTest {

static final List<String> CONTAINERS = new ArrayList<>();
static final Map<String, String> NULL_RESULT = new HashMap<>();

final String jmxServiceUrl =
String.format("service:jmx:rmi:///jndi/rmi://%s:9093/jmxrmi", Podman.POD_NAME);
final String jmxServiceUrlEncoded = jmxServiceUrl.replaceAll("/", "%2F");
final String jmxServiceUrlEncoded = URLEncodedUtils.formatSegments(jmxServiceUrl).substring(1);

final String ruleName = "myrule";
final String recordingName = "auto_myrule";
Expand All @@ -64,29 +60,14 @@ class AutoRulesCleanupIT extends ExternalTargetsTest {
@BeforeAll
static void setup() throws Exception {
Podman.ImageSpec spec =
new Podman.ImageSpec(FIB_DEMO_IMAGESPEC, Map.of("JMX_PORT", String.valueOf(9093)));
CONTAINERS.add(Podman.run(spec));
CompletableFuture.allOf(
CONTAINERS.stream()
.map(id -> Podman.waitForContainerState(id, "running"))
.collect(Collectors.toList())
.toArray(new CompletableFuture[0]))
.join();
new Podman.ImageSpec(
"vertx-fib-demo",
FIB_DEMO_IMAGESPEC,
Map.of("JMX_PORT", String.valueOf(9093)));
CONTAINERS.add(Podman.runAppWithAgent(10_000, spec));
waitForDiscovery(CONTAINERS.size());
}

@AfterAll
static void cleanup() throws ITestCleanupFailedException {
for (String id : CONTAINERS) {
try {
Podman.kill(id);
} catch (Exception e) {
throw new ITestCleanupFailedException(
String.format("Failed to kill container instance with ID %s", id), e);
}
}
}

@Test
@Order(1)
void testAddRule() throws TimeoutException, InterruptedException, ExecutionException {
Expand Down Expand Up @@ -115,9 +96,7 @@ void testAddRule() throws TimeoutException, InterruptedException, ExecutionExcep

form.add("enabled", "true");
form.add("name", ruleName);
form.add(
"matchExpression",
"target.annotations.cryostat.JAVA_MAIN=='es.andrewazor.demo.Main'");
form.add("matchExpression", "/^vertx-fib-demo/.test(target.alias)");
form.add("description", "");
form.add("eventSpecifier", "template=Continuous,type=TARGET");
form.add("initialDelaySeconds", "0");
Expand Down Expand Up @@ -174,7 +153,7 @@ void testAddRule() throws TimeoutException, InterruptedException, ExecutionExcep
"eventSpecifier",
"template=Continuous,type=TARGET",
"matchExpression",
"target.annotations.cryostat.JAVA_MAIN=='es.andrewazor.demo.Main'",
"/^vertx-fib-demo/.test(target.alias)",
"archivalPeriodSeconds",
0,
"initialDelaySeconds",
Expand Down
Loading