Skip to content

Commit

Permalink
#22706 Testing testcontainers on cloud using GHA.
Browse files Browse the repository at this point in the history
  • Loading branch information
dcolina committed Jul 11, 2023
1 parent 4582b53 commit 93620b4
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
//package com.dotcms;
//
//import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
//import org.testcontainers.containers.DockerComposeContainer;
//import org.testcontainers.containers.wait.strategy.Wait;
//
//import java.io.File;
//import java.time.Duration;
//import java.util.HashMap;
//import java.util.Map;
//
//public class ContainerResource implements QuarkusTestResourceLifecycleManager {
//
// private static final int POSTGRES_SERVICE_PORT = 5432;
// private static final int ELASTICSEARCH_SERVICE_PORT = 9200;
// private static final int DOTCMS_SERVICE_PORT = 8080;
// private static final int STARTUP_TIMEOUT = 120;
// private static final boolean LOCAL_COMPOSE = false;
//
// static DockerComposeContainer<?> COMPOSE_CONTAINER =
// new DockerComposeContainer("dotcms-env", new File("src/test/resources/docker-compose.yaml"))
// .withExposedService("postgres", POSTGRES_SERVICE_PORT, Wait.forListeningPort().withStartupTimeout(Duration.ofSeconds(STARTUP_TIMEOUT)))
// .withExposedService("elasticsearch", ELASTICSEARCH_SERVICE_PORT, Wait.forHttp("/").forPort(ELASTICSEARCH_SERVICE_PORT).forStatusCode(200))
// .withExposedService("dotcms", DOTCMS_SERVICE_PORT, Wait.forListeningPort().withStartupTimeout(Duration.ofSeconds(STARTUP_TIMEOUT)))
// .withLocalCompose(LOCAL_COMPOSE); // need to be false to run on macOS
// @Override
// public Map<String, String> start() {
// COMPOSE_CONTAINER.start();
// final Map<String, String> conf = new HashMap<>();
// conf.put("%test.dotcms.url", COMPOSE_CONTAINER.getServiceHost("dotcms", DOTCMS_SERVICE_PORT) + ":" + COMPOSE_CONTAINER.getServicePort("dotcms", DOTCMS_SERVICE_PORT));
//
// return conf;
// }
//
// @Override
// public void stop() {
// COMPOSE_CONTAINER.stop();
// }
//}
package com.dotcms;

import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
import org.testcontainers.containers.DockerComposeContainer;
import org.testcontainers.containers.wait.strategy.Wait;

import java.io.File;
import java.time.Duration;
import java.util.HashMap;
import java.util.Map;

public class ContainerResource implements QuarkusTestResourceLifecycleManager {

private static final int POSTGRES_SERVICE_PORT = 5432;
private static final int ELASTICSEARCH_SERVICE_PORT = 9200;
private static final int DOTCMS_SERVICE_PORT = 8080;
private static final int STARTUP_TIMEOUT = 120;
private static final boolean LOCAL_COMPOSE = false;

static DockerComposeContainer<?> COMPOSE_CONTAINER =
new DockerComposeContainer("dotcms-env", new File("src/test/resources/docker-compose.yaml"))
.withExposedService("postgres", POSTGRES_SERVICE_PORT, Wait.forListeningPort().withStartupTimeout(Duration.ofSeconds(STARTUP_TIMEOUT)))
.withExposedService("elasticsearch", ELASTICSEARCH_SERVICE_PORT, Wait.forHttp("/").forPort(ELASTICSEARCH_SERVICE_PORT).forStatusCode(200))
.withExposedService("dotcms", DOTCMS_SERVICE_PORT, Wait.forListeningPort().withStartupTimeout(Duration.ofSeconds(STARTUP_TIMEOUT)))
.withLocalCompose(LOCAL_COMPOSE); // need to be false to run on macOS
@Override
public Map<String, String> start() {
COMPOSE_CONTAINER.start();
final Map<String, String> conf = new HashMap<>();
conf.put("%test.dotcms.url", COMPOSE_CONTAINER.getServiceHost("dotcms", DOTCMS_SERVICE_PORT) + ":" + COMPOSE_CONTAINER.getServicePort("dotcms", DOTCMS_SERVICE_PORT));

return conf;
}

@Override
public void stop() {
COMPOSE_CONTAINER.stop();
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.dotcms.api;


//import com.dotcms.ContainerResource;
import com.dotcms.ContainerResource;
import com.dotcms.api.client.RestClientFactory;
import com.dotcms.api.client.ServiceManager;
import com.dotcms.model.ResponseEntityView;
Expand All @@ -25,7 +25,7 @@
import java.util.Map;

@QuarkusTest
//@QuarkusTestResource(ContainerResource.class)
@QuarkusTestResource(ContainerResource.class)
class AssetAPITest {

@ConfigProperty(name = "com.dotcms.starter.site", defaultValue = "default")
Expand Down

0 comments on commit 93620b4

Please sign in to comment.