From da2282495ad0fcf02df2aac01989123c1d3cfae8 Mon Sep 17 00:00:00 2001 From: Amit Galitzky Date: Fri, 28 Oct 2022 11:44:40 -0700 Subject: [PATCH] windows CI for AD (#703) Signed-off-by: Amit Galitzky (cherry picked from commit 06e5edb68686bb8ca9dfb63f7a9c92b0b44bc295) --- .github/workflows/CI.yml | 24 +++++++++++++++++++ .../opensearch/ad/ml/CheckpointDaoTests.java | 12 ++++++---- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 160ff5810..febebcbe4 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -8,6 +8,30 @@ on: - "*" jobs: + Build-ad-windows: + strategy: + matrix: + java: [ 11, 17 ] + name: Build and Test Anomaly Detection Plugin on Windows + runs-on: windows-latest + steps: + - name: Setup Java ${{ matrix.java }} + uses: actions/setup-java@v1 + with: + java-version: ${{ matrix.java }} + # checkout Anomaly Detection + - name: Checkout Anomaly Detection + uses: actions/checkout@v2 + + - name: Build and Run Tests + run: | + ./gradlew.bat build + - name: Publish to Maven Local + run: | + ./gradlew publishToMavenLocal + - name: Multi Nodes Integration Testing + run: | + ./gradlew integTest -PnumNodes=3 Build-ad: strategy: matrix: diff --git a/src/test/java/org/opensearch/ad/ml/CheckpointDaoTests.java b/src/test/java/org/opensearch/ad/ml/CheckpointDaoTests.java index 1a41f3d28..df11518b5 100644 --- a/src/test/java/org/opensearch/ad/ml/CheckpointDaoTests.java +++ b/src/test/java/org/opensearch/ad/ml/CheckpointDaoTests.java @@ -32,6 +32,7 @@ import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; +import java.net.URI; import java.net.URISyntaxException; import java.nio.charset.Charset; import java.nio.file.Files; @@ -1010,7 +1011,8 @@ private double[] getPoint(int dimensions, Random random) { // The checkpoint used for this test is from a single-stream detector public void testDeserializeRCFModelPreINIT() throws Exception { // Model in file 1_3_0_rcf_model_pre_init.json not passed initialization yet - String filePath = getClass().getResource("1_3_0_rcf_model_pre_init.json").getPath(); + URI uri = ClassLoader.getSystemResource("org/opensearch/ad/ml/1_3_0_rcf_model_pre_init.json").toURI(); + String filePath = Paths.get(uri).toString(); String json = Files.readString(Paths.get(filePath), Charset.defaultCharset()); Map map = gson.fromJson(json, Map.class); String model = (String) ((Map) ((Map) ((ArrayList) ((Map) map.get("hits")).get("hits")).get(0)).get("_source")).get("modelV2"); @@ -1023,7 +1025,8 @@ public void testDeserializeRCFModelPreINIT() throws Exception { // The checkpoint used for this test is from a single-stream detector public void testDeserializeRCFModelPostINIT() throws Exception { // Model in file rc1_model_single_running is from RCF-3.0-rc1 - String filePath = getClass().getResource("rc1_model_single_running.json").getPath(); + URI uri = ClassLoader.getSystemResource("org/opensearch/ad/ml/rc1_model_single_running.json").toURI(); + String filePath = Paths.get(uri).toString(); String json = Files.readString(Paths.get(filePath), Charset.defaultCharset()); Map map = gson.fromJson(json, Map.class); String model = (String) ((Map) ((Map) ((ArrayList) ((Map) map.get("hits")).get("hits")).get(0)).get("_source")).get("modelV2"); @@ -1039,8 +1042,9 @@ public void testDeserializeRCFModelPostINIT() throws Exception { // The scores and grades in this method were produced from AD running with RCF3.0-rc1 dependency // and this test runs with the most recent RCF dependency that is being pulled by this project. public void testDeserializeTRCFModel() throws Exception { - // Model in file rc1_model_single_running is from RCF-3.0-rc1 - String filePath = getClass().getResource("rc1_trcf_model_direct.json").getPath(); + // Model in file rc1_trcf_model_direct is a checkpoint creatd by RCF-3.0-rc1 + URI uri = ClassLoader.getSystemResource("org/opensearch/ad/ml/rc1_trcf_model_direct.json").toURI(); + String filePath = Paths.get(uri).toString(); String json = Files.readString(Paths.get(filePath), Charset.defaultCharset()); // For the parsing of .toTrcf to work I had to manually change "\u003d" in code back to =. // In the byte array it doesn't seem like this is an issue but whenever reading the byte array response into a file it