-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1330 from tdrwenski/use-test-containers-2
Use TestContainers
- Loading branch information
Showing
34 changed files
with
137 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
cdm-test-utils/src/main/java/ucar/unidata/util/test/DapTestContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package ucar.unidata.util.test; | ||
|
||
import java.lang.invoke.MethodHandles; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.testcontainers.containers.GenericContainer; | ||
import org.testcontainers.images.builder.ImageFromDockerfile; | ||
|
||
/** | ||
* Set up d4ts and dts servers using TestContainers to use for testing opendap, dap4, and httpservices. | ||
**/ | ||
public abstract class DapTestContainer { | ||
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); | ||
|
||
private static final GenericContainer<?> CONTAINER; | ||
|
||
public static final String NAME = "D4TS and DTS TestContainer"; | ||
public static final String D4TS_TEST_PATH = "d4ts/testfiles"; | ||
public static final String DTS_TEST_PATH = "dts"; | ||
|
||
public static final String HOST; | ||
public static final Integer PORT; | ||
public static final String SERVER; | ||
public static final String D4TS_PATH; | ||
public static final String DTS_PATH; | ||
|
||
static { | ||
CONTAINER = new GenericContainer<>( | ||
new ImageFromDockerfile().withFileFromClasspath("Dockerfile", "/ucar/unidata/util/test/Dockerfile")) | ||
.withExposedPorts(8080); | ||
CONTAINER.start(); | ||
|
||
HOST = CONTAINER.getHost(); | ||
PORT = CONTAINER.getFirstMappedPort(); | ||
SERVER = HOST + ":" + PORT; | ||
D4TS_PATH = SERVER + "/" + D4TS_TEST_PATH; | ||
DTS_PATH = SERVER + "/" + DTS_TEST_PATH; | ||
|
||
logger.info("Starting d4ts and dts using docker TestContainer at {}", SERVER); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
cdm-test-utils/src/main/resources/ucar/unidata/util/test/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
FROM unidata/tomcat-docker:8.5-jdk11 AS base | ||
|
||
MAINTAINER Unidata | ||
|
||
USER root | ||
|
||
# TODO use release version of d4ts | ||
#ENV D4TS_WAR_URL https://artifacts.unidata.ucar.edu/repository/unidata-releases/edu/ucar/d4ts/5.4/d4ts-5.4.war | ||
ENV D4TS_WAR_URL https://artifacts.unidata.ucar.edu/repository/unidata-snapshots/edu/ucar/d4ts/5.5-SNAPSHOT/d4ts-5.5-20240410.110406-179.war | ||
ENV DTS_WAR_URL https://artifacts.unidata.ucar.edu/repository/unidata-releases/edu/ucar/dtswar/5.4/dtswar-5.4.war | ||
|
||
# Install necessary packages | ||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends curl unzip && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
RUN curl -fSL "${D4TS_WAR_URL}" -o d4ts.war | ||
RUN curl -fSL "${DTS_WAR_URL}" -o dts.war | ||
|
||
RUN unzip d4ts.war -d ${CATALINA_HOME}/webapps/d4ts/ && \ | ||
rm -f d4ts.war && \ | ||
unzip dts.war -d ${CATALINA_HOME}/webapps/dts/ && \ | ||
rm -f dts.war && \ | ||
chmod 755 ${CATALINA_HOME}/bin/*.sh && \ | ||
mkdir -p ${CATALINA_HOME}/javaUtilPrefs/.systemPrefs | ||
|
||
EXPOSE 8080 8443 | ||
|
||
WORKDIR ${CATALINA_HOME} | ||
|
||
# Inherited from parent container | ||
ENTRYPOINT ["/entrypoint.sh"] | ||
|
||
# Start container | ||
CMD ["catalina.sh", "run"] | ||
|
||
HEALTHCHECK --interval=10s --timeout=3s \ | ||
CMD (curl --fail 'http://localhost:8080/d4ts/' && curl --fail 'http://localhost:8080/dts/')) || exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.