Skip to content
Snippets Groups Projects
Commit d55e8383 authored by Clayton, Brandon Scott's avatar Clayton, Brandon Scott
Browse files

Test web

parent dd91b2fd
No related branches found
No related tags found
1 merge request!793Test Web Service
...@@ -245,31 +245,6 @@ NSHM Tests: ...@@ -245,31 +245,6 @@ NSHM Tests:
tags: tags:
- nshmp - 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: YAML Lint:
allow_failure: true allow_failure: true
needs: [] needs: []
......
...@@ -100,21 +100,6 @@ task generateAlaska2023(type: JavaExec) { ...@@ -100,21 +100,6 @@ task generateAlaska2023(type: JavaExec) {
main = "gov.usgs.earthquake.nshmp.model.GenerateActual" 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 // Generate CONUS 2018 for CI
task generateConus2018(type: JavaExec) { task generateConus2018(type: JavaExec) {
description = "Generate conus-2018 acutal for CI/CD" description = "Generate conus-2018 acutal for CI/CD"
...@@ -222,32 +207,6 @@ task testAlaska2023(type: Test) { ...@@ -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 // Test CONUS 2018 NSHM
task testConus2018(type: Test) { task testConus2018(type: Test) {
description = "Test CONUS 2018 NSHM" description = "Test CONUS 2018 NSHM"
......
...@@ -2,9 +2,12 @@ package gov.usgs.earthquake.nshmp.model; ...@@ -2,9 +2,12 @@ package gov.usgs.earthquake.nshmp.model;
import java.io.IOException; import java.io.IOException;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.ExecutionException;
import gov.usgs.earthquake.nshmp.model.NshmTestUtils.Nshm; import gov.usgs.earthquake.nshmp.model.NshmTestUtils.Nshm;
import gov.usgs.earthquake.nshmp.model.NshmTestUtils.NshmModel; 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. * Generate actual results to compare to expected results.
...@@ -15,10 +18,20 @@ import gov.usgs.earthquake.nshmp.model.NshmTestUtils.NshmModel; ...@@ -15,10 +18,20 @@ import gov.usgs.earthquake.nshmp.model.NshmTestUtils.NshmModel;
*/ */
class GenerateActual { 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")); Nshm nshm = NshmTests.NSHMS.get(System.getProperty("NSHM"));
// Generate command line
NshmModel nshmModel = NshmTestUtils.loadModel(nshm); NshmModel nshmModel = NshmTestUtils.loadModel(nshm);
NshmTestUtils.writeExpecteds(nshmModel, Optional.of(NshmTests.DATA_PATH)); NshmTestUtils.writeExpecteds(nshmModel, Optional.of(NshmTests.DATA_PATH));
nshmModel.exec.shutdown(); 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();
} }
} }
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();
}
}
...@@ -27,6 +27,7 @@ import gov.usgs.earthquake.nshmp.site.NshmpSite; ...@@ -27,6 +27,7 @@ import gov.usgs.earthquake.nshmp.site.NshmpSite;
*/ */
class NshmTests { class NshmTests {
static Path DATA_PATH = Paths.get("src/test/resources/e2e/actual"); 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 */ /* Alaska test sites */
private static final List<NamedLocation> ALASKA_LOCATIONS = List.of( private static final List<NamedLocation> ALASKA_LOCATIONS = List.of(
...@@ -134,6 +135,7 @@ class NshmTests { ...@@ -134,6 +135,7 @@ class NshmTests {
final void testAlaska2007() throws IOException, InterruptedException, ExecutionException { final void testAlaska2007() throws IOException, InterruptedException, ExecutionException {
Nshm nshm = NSHMS.get("nshm-alaska-2007"); Nshm nshm = NSHMS.get("nshm-alaska-2007");
NshmTestUtils.testNshm(nshm, getDataPath(nshm)); NshmTestUtils.testNshm(nshm, getDataPath(nshm));
NshmTestUtils.testWebNshm(nshm, getWebDataPath(nshm));
} }
/** /**
...@@ -147,20 +149,9 @@ class NshmTests { ...@@ -147,20 +149,9 @@ class NshmTests {
final void testAlaska2023() throws IOException, InterruptedException, ExecutionException { final void testAlaska2023() throws IOException, InterruptedException, ExecutionException {
Nshm nshm = NSHMS.get("nshm-alaska-2023"); Nshm nshm = NSHMS.get("nshm-alaska-2023");
NshmTestUtils.testNshm(nshm, getDataPath(nshm)); 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 * Test CONUS 2018 NSHM
...@@ -173,6 +164,7 @@ class NshmTests { ...@@ -173,6 +164,7 @@ class NshmTests {
final void testConus2018() throws IOException, InterruptedException, ExecutionException { final void testConus2018() throws IOException, InterruptedException, ExecutionException {
Nshm nshm = NSHMS.get("nshm-conus-2018"); Nshm nshm = NSHMS.get("nshm-conus-2018");
NshmTestUtils.testNshm(nshm, getDataPath(nshm)); NshmTestUtils.testNshm(nshm, getDataPath(nshm));
NshmTestUtils.testWebNshm(nshm, getWebDataPath(nshm));
} }
/** /**
...@@ -186,6 +178,7 @@ class NshmTests { ...@@ -186,6 +178,7 @@ class NshmTests {
final void testConus2023() throws IOException, InterruptedException, ExecutionException { final void testConus2023() throws IOException, InterruptedException, ExecutionException {
Nshm nshm = NSHMS.get("nshm-conus-2023"); Nshm nshm = NSHMS.get("nshm-conus-2023");
NshmTestUtils.testNshm(nshm, getDataPath(nshm)); NshmTestUtils.testNshm(nshm, getDataPath(nshm));
NshmTestUtils.testWebNshm(nshm, getWebDataPath(nshm));
} }
/** /**
...@@ -199,6 +192,7 @@ class NshmTests { ...@@ -199,6 +192,7 @@ class NshmTests {
final void testHawaii2021() throws IOException, InterruptedException, ExecutionException { final void testHawaii2021() throws IOException, InterruptedException, ExecutionException {
Nshm nshm = NSHMS.get("nshm-hawaii-2021"); Nshm nshm = NSHMS.get("nshm-hawaii-2021");
NshmTestUtils.testNshm(nshm, getDataPath(nshm)); NshmTestUtils.testNshm(nshm, getDataPath(nshm));
NshmTestUtils.testWebNshm(nshm, getWebDataPath(nshm));
} }
/** /**
...@@ -216,4 +210,9 @@ class NshmTests { ...@@ -216,4 +210,9 @@ class NshmTests {
return Files.exists(DATA_PATH.resolve(nshm.modelName())) ? Optional.of(DATA_PATH) return Files.exists(DATA_PATH.resolve(nshm.modelName())) ? Optional.of(DATA_PATH)
: Optional.empty(); : Optional.empty();
} }
private static Optional<Path> getWebDataPath(Nshm nshm) {
return Files.exists(DATA_PATH.resolve(nshm.modelName())) ? Optional.of(DATA_PATH)
: Optional.empty();
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment