Skip to content

Commit

Permalink
test(storage): deploy cryostat-storage rather than localstack (#764)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores authored Jan 7, 2025
1 parent 3c08619 commit b913b87
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,21 @@
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.utility.DockerImageName;

public class LocalStackResource
public class S3StorageResource
implements QuarkusTestResourceLifecycleManager, DevServicesContext.ContextAware {

private static int S3_PORT = 4566;
private static final String IMAGE_NAME = "docker.io/localstack/localstack:stable";
private static int S3_PORT = 8333;
private static final String IMAGE_NAME = "quay.io/cryostat/cryostat-storage:latest";
private static final Map<String, String> envMap =
Map.of(
"START_WEB", "0",
"SERVICES", "s3",
"EAGER_SERVICE_LOADING", "1",
"SKIP_SSL_CERT_DOWNLOAD", "1",
"DISABLE_EVENTS", "1");
private static final Logger logger = Logger.getLogger(LocalStackResource.class);
"DATA_DIR", "/data",
"IP_BIND", "0.0.0.0",
"WEED_V", "4",
"REST_ENCRYPTION_ENABLE", "1",
"CRYOSTAT_ACCESS_KEY", "access_key",
"CRYOSTAT_SECRET_KEY", "secret_key",
"CRYOSTAT_BUCKETS", "archivedrecordings,archivedreports,eventtemplates,probes");
private static final Logger logger = Logger.getLogger(S3StorageResource.class);
private Optional<String> containerNetworkId;
private GenericContainer<?> container;

Expand All @@ -48,7 +50,8 @@ public Map<String, String> start() {
new GenericContainer<>(DockerImageName.parse(IMAGE_NAME))
.withExposedPorts(S3_PORT)
.withEnv(envMap)
.waitingFor(Wait.forHealthcheck());
.withTmpFs(Map.of("/data", "rw"))
.waitingFor(Wait.forListeningPort());
containerNetworkId.ifPresent(container::withNetworkMode);

container.start();
Expand All @@ -62,8 +65,9 @@ public Map<String, String> start() {
properties.put("quarkus.s3.endpoint-override", properties.get("s3.url.override"));
properties.put("quarkus.s3.path-style-access", "true");
properties.put("quarkus.s3.aws.credentials.type", "static");
properties.put("quarkus.s3.aws.credentials.static-provider.access-key-id", "unused");
properties.put("quarkus.s3.aws.credentials.static-provider.secret-access-key", "unused");
properties.put("quarkus.s3.aws.credentials.static-provider.access-key-id", "access_key");
properties.put(
"quarkus.s3.aws.credentials.static-provider.secret-access-key", "secret_key");
properties.put(
"aws.access-key-id",
properties.get("quarkus.s3.aws.credentials.static-provider.access-key-id"));
Expand All @@ -72,18 +76,18 @@ public Map<String, String> start() {
"aws.secret-access-key",
properties.get("quarkus.s3.aws.credentials.static-provider.secret-access-key"));
properties.put("aws.secretAccessKey", properties.get("aws.secret-access-key"));
properties.entrySet().forEach(e -> System.setProperty(e.getKey(), e.getValue()));
logger.debugv("Configured properties: {0}", properties);

return properties;
}

@Override
public void stop() {
logger.info("stopping");
if (container != null) {
container.stop();
container.close();
}
logger.info("stopped");
}

@Override
Expand Down
4 changes: 4 additions & 0 deletions src/test/java/itest/CustomEventTemplateTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
*/
package itest;

import io.cryostat.resources.S3StorageResource;

import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.DisabledOnIntegrationTest;
import io.quarkus.test.junit.QuarkusTest;
import io.vertx.core.buffer.Buffer;
Expand All @@ -29,6 +32,7 @@
import org.junit.jupiter.api.Test;

@QuarkusTest
@QuarkusTestResource(S3StorageResource.class)
@DisabledOnIntegrationTest("classpath resources are not loadable in integration test")
public class CustomEventTemplateTest extends StandardSelfTest {

Expand Down
3 changes: 3 additions & 0 deletions src/test/java/itest/GraphQLTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@

import io.cryostat.discovery.DiscoveryNode;
import io.cryostat.graphql.RootNode;
import io.cryostat.resources.S3StorageResource;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusTest;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.json.JsonArray;
Expand All @@ -65,6 +67,7 @@
import org.junit.jupiter.params.provider.ValueSource;

@QuarkusTest
@QuarkusTestResource(S3StorageResource.class)
@TestMethodOrder(OrderAnnotation.class)
class GraphQLTest extends StandardSelfTest {

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/itest/RecordingWorkflowTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

import io.cryostat.resources.LocalStackResource;
import io.cryostat.resources.S3StorageResource;
import io.cryostat.util.HttpMimeType;

import io.quarkus.test.common.QuarkusTestResource;
Expand All @@ -48,7 +48,7 @@
import org.junit.jupiter.api.Test;

@QuarkusTest
@QuarkusTestResource(LocalStackResource.class)
@QuarkusTestResource(S3StorageResource.class)
public class RecordingWorkflowTest extends StandardSelfTest {

private final ExecutorService worker = ForkJoinPool.commonPool();
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/itest/ReportGenerationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;

import io.cryostat.resources.LocalStackResource;
import io.cryostat.resources.S3StorageResource;
import io.cryostat.util.HttpMimeType;

import io.quarkus.test.common.QuarkusTestResource;
Expand All @@ -43,7 +43,7 @@
import org.junit.jupiter.api.Test;

@QuarkusTest
@QuarkusTestResource(LocalStackResource.class)
@QuarkusTestResource(S3StorageResource.class)
public class ReportGenerationTest extends StandardSelfTest {

private final ExecutorService worker = ForkJoinPool.commonPool();
Expand Down

0 comments on commit b913b87

Please sign in to comment.