Skip to content

Commit

Permalink
windows CI for AD (#703)
Browse files Browse the repository at this point in the history
Signed-off-by: Amit Galitzky <[email protected]>
(cherry picked from commit 06e5edb)
  • Loading branch information
amitgalitz committed Oct 28, 2022
1 parent 62c6d91 commit 1bf862b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 8 additions & 4 deletions src/test/java/org/opensearch/ad/ml/CheckpointDaoTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand All @@ -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");
Expand All @@ -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
Expand Down

0 comments on commit 1bf862b

Please sign in to comment.