diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9b24982b5f34ec8ef6f323698eb370962e6c691a..024d92156aba0c6ed1dbf156a60eab4b6e9798f8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -245,31 +245,6 @@ NSHM Tests: tags: - nshmp -NSHM Web Tests: - artifacts: - paths: - - ${JACOCO_HTML_DIR} - reports: - junit: ${JUNIT_FILES} - coverage: '/Total.*?([0-9]{1,3})%/' - needs: [] - parallel: - matrix: - # - NSHM: Alaska2007 - - NSHM: WebAlaska2023 - # - NSHM: Conus2018 - # - NSHM: Conus2023 - # - NSHM: Hawaii2021 - script: - - CI_RUNNER_MEMORY="$(awk '/MemTotal/ {printf( "%d\n", $2 / 1024 / 1024 * .90 )}' /proc/meminfo)g" - - export CI_RUNNER_MEMORY - - ./gradlew generate${NSHM} --info - - ./gradlew test${NSHM} --info - - cat ${JACOCO_HTML_DIR}/index.html - stage: test - tags: - - nshmp - YAML Lint: allow_failure: true needs: [] diff --git a/gradle/nshm.gradle b/gradle/nshm.gradle index d4bce26cdb9d159e07625094247fc994b689a848..2bcfe0831e6ac942d904f3b7f9d62b2609253667 100644 --- a/gradle/nshm.gradle +++ b/gradle/nshm.gradle @@ -100,21 +100,6 @@ task generateAlaska2023(type: JavaExec) { main = "gov.usgs.earthquake.nshmp.model.GenerateActual" } -// Generate Alaska 2023 for CI -task generateWebAlaska2023(type: JavaExec) { - description = "Generate alaska-2023 acutal for CI/CD" - classpath = sourceSets.test.runtimeClasspath - - doFirst { - downloadNshm(findNshm("nshm-alaska", 2023)) - } - - jvmArgs("-DNSHM=nshm-alaska-2023") - - main = "gov.usgs.earthquake.nshmp.model.GenerateWebActual" -} - - // Generate CONUS 2018 for CI task generateConus2018(type: JavaExec) { description = "Generate conus-2018 acutal for CI/CD" @@ -222,32 +207,6 @@ task testAlaska2023(type: Test) { } } -// Test Alaska 2023 NSHM -task testWebAlaska2023(type: Test) { - description = "Test Alaska 2023 NSHM" - group = "verification" - - doFirst { - downloadNshm(findNshm("nshm-alaska", 2023)) - } - - testLogging { - exceptionFormat "full" - } - - systemProperties(System.getProperties()) - - useJUnitPlatform() - jvmArgs( - "-Xms2g", - "-Xmx${xmx}", - ) - - filter { - includeTestsMatching "gov.usgs.earthquake.nshmp.model.NshmTests.testWebAlaska2023" - } -} - // Test CONUS 2018 NSHM task testConus2018(type: Test) { description = "Test CONUS 2018 NSHM" diff --git a/src/test/java/gov/usgs/earthquake/nshmp/model/GenerateActual.java b/src/test/java/gov/usgs/earthquake/nshmp/model/GenerateActual.java index 4a9c54d1114efbee5f249eafb6a582df206ca2f9..1f868a1985eb4c47102c7998b7c522276306f2aa 100644 --- a/src/test/java/gov/usgs/earthquake/nshmp/model/GenerateActual.java +++ b/src/test/java/gov/usgs/earthquake/nshmp/model/GenerateActual.java @@ -2,9 +2,12 @@ package gov.usgs.earthquake.nshmp.model; import java.io.IOException; import java.util.Optional; +import java.util.concurrent.ExecutionException; import gov.usgs.earthquake.nshmp.model.NshmTestUtils.Nshm; import gov.usgs.earthquake.nshmp.model.NshmTestUtils.NshmModel; +import gov.usgs.earthquake.nshmp.www.Application; +import io.micronaut.runtime.Micronaut; /** * Generate actual results to compare to expected results. @@ -15,10 +18,20 @@ import gov.usgs.earthquake.nshmp.model.NshmTestUtils.NshmModel; */ class GenerateActual { - public static void main(String[] args) throws IOException { + public static void main(String[] args) throws IOException, InterruptedException, ExecutionException { Nshm nshm = NshmTests.NSHMS.get(System.getProperty("NSHM")); + + // Generate command line NshmModel nshmModel = NshmTestUtils.loadModel(nshm); NshmTestUtils.writeExpecteds(nshmModel, Optional.of(NshmTests.DATA_PATH)); nshmModel.exec.shutdown(); + + // Generate web + var context = Micronaut + .build("--model=" + nshm.modelPath()) + .mainClass(Application.class) + .start(); + NshmTestUtils.writeWebExpecteds(nshm, Optional.of(NshmTests.WEB_DATA_PATH)); + context.close(); } } diff --git a/src/test/java/gov/usgs/earthquake/nshmp/model/GenerateWebActual.java b/src/test/java/gov/usgs/earthquake/nshmp/model/GenerateWebActual.java deleted file mode 100644 index 20072a3596d5a210433d68e8895c9c5ee25d06b9..0000000000000000000000000000000000000000 --- a/src/test/java/gov/usgs/earthquake/nshmp/model/GenerateWebActual.java +++ /dev/null @@ -1,25 +0,0 @@ -package gov.usgs.earthquake.nshmp.model; - -import java.io.IOException; -import java.util.Optional; -import java.util.concurrent.ExecutionException; - -import gov.usgs.earthquake.nshmp.model.NshmTestUtils.Nshm; -import gov.usgs.earthquake.nshmp.www.Application; - -import io.micronaut.runtime.Micronaut; - -public class GenerateWebActual { - - public static void main(String[] args) - throws InterruptedException, ExecutionException, IOException { - Nshm nshm = NshmTests.NSHMS.get(System.getProperty("NSHM")); - var context = Micronaut - .build("--model=" + nshm.modelPath()) - .mainClass(Application.class) - .start(); - NshmTestUtils.writeWebExpecteds(nshm, Optional.of(NshmTests.DATA_PATH)); - context.close(); - } - -} diff --git a/src/test/java/gov/usgs/earthquake/nshmp/model/NshmTests.java b/src/test/java/gov/usgs/earthquake/nshmp/model/NshmTests.java index 928bf90d18f47c28bb64303f7db5b29ce8867896..3545c1f989fcf8ac0e90d0aee298d87f8d8be1c1 100644 --- a/src/test/java/gov/usgs/earthquake/nshmp/model/NshmTests.java +++ b/src/test/java/gov/usgs/earthquake/nshmp/model/NshmTests.java @@ -27,6 +27,7 @@ import gov.usgs.earthquake.nshmp.site.NshmpSite; */ class NshmTests { static Path DATA_PATH = Paths.get("src/test/resources/e2e/actual"); + static Path WEB_DATA_PATH = Paths.get("src/test/resources/e2e/actual/web"); /* Alaska test sites */ private static final List<NamedLocation> ALASKA_LOCATIONS = List.of( @@ -134,6 +135,7 @@ class NshmTests { final void testAlaska2007() throws IOException, InterruptedException, ExecutionException { Nshm nshm = NSHMS.get("nshm-alaska-2007"); NshmTestUtils.testNshm(nshm, getDataPath(nshm)); + NshmTestUtils.testWebNshm(nshm, getWebDataPath(nshm)); } /** @@ -147,20 +149,9 @@ class NshmTests { final void testAlaska2023() throws IOException, InterruptedException, ExecutionException { Nshm nshm = NSHMS.get("nshm-alaska-2023"); NshmTestUtils.testNshm(nshm, getDataPath(nshm)); + NshmTestUtils.testWebNshm(nshm, getWebDataPath(nshm)); } - /** - * Test Alaska 2023 NSHM - * - * To run test: ./gradlew testWebAlaska2023 - * @throws ExecutionException - * @throws InterruptedException - */ - @Test - final void testWebAlaska2023() throws IOException, InterruptedException, ExecutionException { - Nshm nshm = NSHMS.get("nshm-alaska-2023"); - NshmTestUtils.testWebNshm(nshm, getDataPath(nshm)); - } /** * Test CONUS 2018 NSHM @@ -173,6 +164,7 @@ class NshmTests { final void testConus2018() throws IOException, InterruptedException, ExecutionException { Nshm nshm = NSHMS.get("nshm-conus-2018"); NshmTestUtils.testNshm(nshm, getDataPath(nshm)); + NshmTestUtils.testWebNshm(nshm, getWebDataPath(nshm)); } /** @@ -186,6 +178,7 @@ class NshmTests { final void testConus2023() throws IOException, InterruptedException, ExecutionException { Nshm nshm = NSHMS.get("nshm-conus-2023"); NshmTestUtils.testNshm(nshm, getDataPath(nshm)); + NshmTestUtils.testWebNshm(nshm, getWebDataPath(nshm)); } /** @@ -199,6 +192,7 @@ class NshmTests { final void testHawaii2021() throws IOException, InterruptedException, ExecutionException { Nshm nshm = NSHMS.get("nshm-hawaii-2021"); NshmTestUtils.testNshm(nshm, getDataPath(nshm)); + NshmTestUtils.testWebNshm(nshm, getWebDataPath(nshm)); } /** @@ -216,4 +210,9 @@ class NshmTests { return Files.exists(DATA_PATH.resolve(nshm.modelName())) ? Optional.of(DATA_PATH) : Optional.empty(); } + + private static Optional<Path> getWebDataPath(Nshm nshm) { + return Files.exists(DATA_PATH.resolve(nshm.modelName())) ? Optional.of(DATA_PATH) + : Optional.empty(); + } }