Skip to content

Commit

Permalink
Update IT to use testcontainers
Browse files Browse the repository at this point in the history
And update pass-core container config
  • Loading branch information
rpoet-jh committed Oct 28, 2024
1 parent 1bb50c9 commit a32f853
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 74 deletions.
90 changes: 16 additions & 74 deletions pass-journal-loader/pass-journal-loader-nih/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@
<properties>
<!-- Properties for dependency versions -->
<wiremock.version>3.3.1</wiremock.version>
<!-- Properties for ITs -->
<pass.core.port>8080</pass.core.port>
<pass.core.url>http://localhost:8080</pass.core.url>
<pass.core.user>backend</pass.core.user>
<pass.core.password>backend</pass.core.password>
<testcontainers.version>1.19.4</testcontainers.version>
<maven-model.version>3.9.6</maven-model.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -69,6 +66,20 @@
<version>${wiremock.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>${maven-model.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand All @@ -93,68 +104,6 @@
</executions>
</plugin>

<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<executions>
<execution>
<id>start</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
<execution>
<id>build-after-its</id>
<phase>post-integration-test</phase>
<configuration>
<images>
<image>
<name>ghcr.io/eclipse-pass/pass-journal-loader:%v</name>
</image>
</images>
</configuration>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
<configuration>
<images>
<image>
<name>ghcr.io/eclipse-pass/pass-core-main:%v</name>
<run>
<platform>${docker.platforms}</platform>
<env>
<PASS_CORE_BASE_URL>${pass.core.url}</PASS_CORE_BASE_URL>
<PASS_CORE_USER>${pass.core.user}</PASS_CORE_USER>
<PASS_CORE_PASSWORD>${pass.core.password}</PASS_CORE_PASSWORD>
</env>
<wait>
<http>
<url>
${pass.core.url}/data/grant
</url>
<status>401</status>
</http>
<time>60000</time>
</wait>
<ports>
<port>${pass.core.port}:${pass.core.port}</port>
</ports>
</run>
</image>
</images>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
Expand All @@ -166,13 +115,6 @@
</goals>
</execution>
</executions>
<configuration>
<systemPropertyVariables>
<pass.core.url>${pass.core.url}</pass.core.url>
<pass.core.user>${pass.core.user}</pass.core.user>
<pass.core.password>${pass.core.password}</pass.core.password>
</systemPropertyVariables>
</configuration>
</plugin>

</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,71 @@
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.io.FileReader;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

import com.github.dockerjava.api.model.ExposedPort;
import com.github.dockerjava.api.model.PortBinding;
import com.github.dockerjava.api.model.Ports;
import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;
import com.github.tomakehurst.wiremock.junit5.WireMockTest;
import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.eclipse.pass.support.client.PassClient;
import org.eclipse.pass.support.client.PassClientSelector;
import org.eclipse.pass.support.client.model.Journal;
import org.eclipse.pass.support.client.model.PmcParticipation;
import org.junit.jupiter.api.Test;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
import org.testcontainers.utility.DockerImageName;
import org.testcontainers.utility.MountableFile;

/**
* @author [email protected]
*/
@Testcontainers
@WireMockTest
public class DepositIT {
private final PassClient client = PassClient.newInstance();

private static final DockerImageName PASS_CORE_IMG;

static {
MavenXpp3Reader reader = new MavenXpp3Reader();
try {
Model model = reader.read(new FileReader("pom.xml"));
String version = model.getParent().getVersion();
PASS_CORE_IMG = DockerImageName.parse("ghcr.io/eclipse-pass/pass-core-main:" + version);
} catch (Exception e) {
throw new RuntimeException(e);
}

System.setProperty("pass.core.url", "http://localhost:8080");
System.setProperty("pass.core.user", "backend");
System.setProperty("pass.core.password", "backend");
}

@Container
private static final GenericContainer<?> PASS_CORE_CONTAINER = new GenericContainer<>(PASS_CORE_IMG)
.withCopyFileToContainer(
MountableFile.forHostPath("../../pass-core-test-config/"),
"/tmp/pass-core-test-config/"
)
.withEnv("PASS_CORE_JAVA_OPTS", "-Dspring.config.import=file:/tmp/pass-core-test-config/application-test.yml")
.waitingFor(Wait.forHttp("/data/grant").forStatusCode(200).withBasicCredentials("backend", "backend"))
.withCreateContainerCmdModifier(cmd -> {
cmd.getHostConfig().withPortBindings(new PortBinding(Ports.Binding.bindPort(8080),
new ExposedPort(8080)));
})
.withExposedPorts(8080);

@Test
public void loadFromFileTest(WireMockRuntimeInfo wmRuntimeInfo) throws Exception {
String jmedlineJournals = Files.readString(
Expand Down
3 changes: 3 additions & 0 deletions pass-journal-loader/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@
<ignoredUsedUndeclaredDependencies>
<!-- These both come from junit-jupiter, so version is tied to that direct dependency -->
<ignoredUsedUndeclaredDependency>org.junit.jupiter:junit-jupiter-api:</ignoredUsedUndeclaredDependency>
<!-- These come from testcontainers junit-jupiter -->
<ignoredUsedUndeclaredDependency>org.testcontainers::</ignoredUsedUndeclaredDependency>
<ignoredUsedUndeclaredDependency>com.github.docker-java::</ignoredUsedUndeclaredDependency>
</ignoredUsedUndeclaredDependencies>
<ignoredUnusedDeclaredDependencies>
<!-- junit-jupiter is a module containing the junit api jars used directly -->
Expand Down

0 comments on commit a32f853

Please sign in to comment.