From 1bb50c959f9e3c112ac84765a9280f167106cf1a Mon Sep 17 00:00:00 2001 From: Russ Poetker Date: Mon, 28 Oct 2024 08:10:19 -0400 Subject: [PATCH] Update IT pass-core container config --- pass-data-client/pom.xml | 17 ---------- .../support/client/JsonApiPassClientIT.java | 31 +++++++++++++++++-- .../deposit/AbstractDepositSubmissionIT.java | 9 ++++-- .../grant/AbstractIntegrationTest.java | 9 ++++-- .../nihms/NihmsSubmissionEtlITBase.java | 9 ++++-- .../service/NotificationServiceIT.java | 9 ++++-- 6 files changed, 52 insertions(+), 32 deletions(-) diff --git a/pass-data-client/pom.xml b/pass-data-client/pom.xml index 779d8eeb..cd366df3 100644 --- a/pass-data-client/pom.xml +++ b/pass-data-client/pom.xml @@ -11,7 +11,6 @@ - 3.2.1 4.12.0 4.12.0 1.1.0 @@ -78,13 +77,6 @@ test - - org.springframework.boot - spring-boot-starter-test - ${spring-boot-maven-plugin.version} - test - - org.testcontainers junit-jupiter @@ -113,13 +105,6 @@ - - - ${pass.core.url} - ${pass.core.user} - ${pass.core.password} - - @@ -167,14 +152,12 @@ org.testcontainers:: com.github.docker-java:: - org.springframework:spring-test ch.qos.logback:logback-classic org.junit.jupiter:junit-jupiter - org.springframework.boot:spring-boot-starter-test diff --git a/pass-data-client/src/test/java/org/eclipse/pass/support/client/JsonApiPassClientIT.java b/pass-data-client/src/test/java/org/eclipse/pass/support/client/JsonApiPassClientIT.java index 9da4a613..9f08daae 100644 --- a/pass-data-client/src/test/java/org/eclipse/pass/support/client/JsonApiPassClientIT.java +++ b/pass-data-client/src/test/java/org/eclipse/pass/support/client/JsonApiPassClientIT.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Johns Hopkins University + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.eclipse.pass.support.client; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; @@ -27,6 +42,8 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.Logger; import com.github.dockerjava.api.model.ExposedPort; import com.github.dockerjava.api.model.PortBinding; import com.github.dockerjava.api.model.Ports; @@ -59,15 +76,15 @@ import org.eclipse.pass.support.client.model.UserRole; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.test.annotation.DirtiesContext; +import org.slf4j.LoggerFactory; 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; @Testcontainers -@DirtiesContext public class JsonApiPassClientIT { private static final DockerImageName PASS_CORE_IMG; @@ -83,11 +100,19 @@ public class JsonApiPassClientIT { System.setProperty("pass.core.url", "http://localhost:8080"); System.setProperty("pass.core.user", "backend"); - System.setProperty("pass.core.password", "moo"); + System.setProperty("pass.core.password", "backend"); + + Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); + root.setLevel(Level.WARN); } @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") .withCreateContainerCmdModifier(cmd -> { cmd.getHostConfig().withPortBindings(new PortBinding(Ports.Binding.bindPort(8080), new ExposedPort(8080))); diff --git a/pass-deposit-services/deposit-core/src/test/java/org/eclipse/pass/deposit/AbstractDepositSubmissionIT.java b/pass-deposit-services/deposit-core/src/test/java/org/eclipse/pass/deposit/AbstractDepositSubmissionIT.java index 342d1e19..7cafac00 100644 --- a/pass-deposit-services/deposit-core/src/test/java/org/eclipse/pass/deposit/AbstractDepositSubmissionIT.java +++ b/pass-deposit-services/deposit-core/src/test/java/org/eclipse/pass/deposit/AbstractDepositSubmissionIT.java @@ -59,6 +59,7 @@ import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.utility.DockerImageName; +import org.testcontainers.utility.MountableFile; /** * Provides convenience methods for depositing Submissions in PASS. @@ -93,9 +94,11 @@ public abstract class AbstractDepositSubmissionIT { @Container protected static final GenericContainer PASS_CORE_CONTAINER = new GenericContainer<>(PASS_CORE_IMG) - .withEnv("PASS_CORE_BASE_URL", "http://localhost:8080") - .withEnv("PASS_CORE_USER", "backend") - .withEnv("PASS_CORE_PASSWORD", "backend") + .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")) .withExposedPorts(8080); diff --git a/pass-grant-loader/src/test/java/org/eclipse/pass/support/grant/AbstractIntegrationTest.java b/pass-grant-loader/src/test/java/org/eclipse/pass/support/grant/AbstractIntegrationTest.java index 183f4dbe..014b1abf 100644 --- a/pass-grant-loader/src/test/java/org/eclipse/pass/support/grant/AbstractIntegrationTest.java +++ b/pass-grant-loader/src/test/java/org/eclipse/pass/support/grant/AbstractIntegrationTest.java @@ -34,6 +34,7 @@ import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.utility.DockerImageName; +import org.testcontainers.utility.MountableFile; /** * @author Russ Poetker (rpoetke1@jh.edu) @@ -59,9 +60,11 @@ public abstract class AbstractIntegrationTest { @Container protected static final GenericContainer PASS_CORE_CONTAINER = new GenericContainer<>(PASS_CORE_IMG) - .withEnv("PASS_CORE_BASE_URL", "http://localhost:8080") - .withEnv("PASS_CORE_USER", "backend") - .withEnv("PASS_CORE_PASSWORD", "backend") + .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")) .withExposedPorts(8080); diff --git a/pass-nihms-loader/nihms-data-transform-load/src/test/java/org/eclipse/pass/loader/nihms/NihmsSubmissionEtlITBase.java b/pass-nihms-loader/nihms-data-transform-load/src/test/java/org/eclipse/pass/loader/nihms/NihmsSubmissionEtlITBase.java index 04b00d01..10b46389 100644 --- a/pass-nihms-loader/nihms-data-transform-load/src/test/java/org/eclipse/pass/loader/nihms/NihmsSubmissionEtlITBase.java +++ b/pass-nihms-loader/nihms-data-transform-load/src/test/java/org/eclipse/pass/loader/nihms/NihmsSubmissionEtlITBase.java @@ -63,6 +63,7 @@ import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.utility.DockerImageName; +import org.testcontainers.utility.MountableFile; /** * @author Karen Hanson @@ -92,9 +93,11 @@ public abstract class NihmsSubmissionEtlITBase { @Container protected static final GenericContainer PASS_CORE_CONTAINER = new GenericContainer<>(PASS_CORE_IMG) - .withEnv("PASS_CORE_BASE_URL", "http://localhost:8080") - .withEnv("PASS_CORE_USER", "backend") - .withEnv("PASS_CORE_PASSWORD", "backend") + .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")) .withExposedPorts(8080); diff --git a/pass-notification-service/src/test/java/org/eclipse/pass/notification/service/NotificationServiceIT.java b/pass-notification-service/src/test/java/org/eclipse/pass/notification/service/NotificationServiceIT.java index 7f7bab22..3cf0eb5a 100644 --- a/pass-notification-service/src/test/java/org/eclipse/pass/notification/service/NotificationServiceIT.java +++ b/pass-notification-service/src/test/java/org/eclipse/pass/notification/service/NotificationServiceIT.java @@ -57,6 +57,7 @@ import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.utility.DockerImageName; +import org.testcontainers.utility.MountableFile; /** * @author Russ Poetker (rpoetke1@jh.edu) @@ -88,9 +89,11 @@ public class NotificationServiceIT extends AbstractNotificationSpringIntegration @Container static final GenericContainer PASS_CORE_CONTAINER = new GenericContainer<>(PASS_CORE_IMG) - .withEnv("PASS_CORE_BASE_URL", "http://localhost:8080") - .withEnv("PASS_CORE_USER", "backend") - .withEnv("PASS_CORE_PASSWORD", "backend") + .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")) .withExposedPorts(8080);