From a2777c1398e98291df1b23300a70aa6afcc68a46 Mon Sep 17 00:00:00 2001 From: "Daniel Doubrovkine (dB.)" Date: Tue, 1 Mar 2022 17:09:12 -0500 Subject: [PATCH] Run CI/CD on Java 8, 11, 14 and 17. (#121) * Run CI/CD on Java 8, 11, 14 and 17. Signed-off-by: dblock * Add JDK 17. Signed-off-by: dblock --- .github/workflows/ci-17.yml | 40 +++++++++++++++++++ .github/workflows/ci.yml | 6 ++- DEVELOPER_GUIDE.md | 6 +-- .../commons/InjectSecurityTest.java | 14 +++++-- 4 files changed, 58 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/ci-17.yml diff --git a/.github/workflows/ci-17.yml b/.github/workflows/ci-17.yml new file mode 100644 index 00000000..a6a8a1e2 --- /dev/null +++ b/.github/workflows/ci-17.yml @@ -0,0 +1,40 @@ +name: Build and Test +on: + push: + branches: + - "*" + pull_request: + branches: + - "*" + +jobs: + build: + + name: Build and Test (17) + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup Java 11 + uses: actions/setup-java@v2 + with: + distribution: 'temurin' + java-version: 11 + + - name: Build + run: | + ./gradlew build --build-cache + + - name: Setup Java 17 + uses: actions/setup-java@v2 + with: + distribution: 'temurin' + java-version: 17 + + - name: Test + run: | + ./gradlew test --build-cache + + diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c35e0c0a..e3e495c4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,10 @@ jobs: build: strategy: matrix: - java: [14] + java: + - 8 + - 11 + - 14 name: Build and Test runs-on: ubuntu-latest @@ -25,7 +28,6 @@ jobs: with: java-version: ${{ matrix.java }} - # common-utils - name: Build and Test run: | ./gradlew build diff --git a/DEVELOPER_GUIDE.md b/DEVELOPER_GUIDE.md index d162eccb..27fc15b3 100644 --- a/DEVELOPER_GUIDE.md +++ b/DEVELOPER_GUIDE.md @@ -1,7 +1,7 @@ - [Developer Guide](#developer-guide) - [Forking and Cloning](#forking-and-cloning) - [Install Prerequisites](#install-prerequisites) - - [JDK 14](#jdk-14) + - [JDK 11](#jdk-11) - [Building](#building) - [Using IntelliJ IDEA](#using-intellij-idea) - [Submitting Changes](#submitting-changes) @@ -16,9 +16,9 @@ Fork this repository on GitHub, and clone locally with `git clone`. ### Install Prerequisites -#### JDK 14 +#### JDK 11 -OpenSearch components build using Java 14 at a minimum. This means you must have a JDK 14 installed with the environment variable `JAVA_HOME` referencing the path to Java home for your JDK 14 installation, e.g. `JAVA_HOME=/usr/lib/jvm/jdk-14`. +OpenSearch components build using Java 11 at a minimum. This means you must have a JDK 11 installed with the environment variable `JAVA_HOME` referencing the path to Java home for your JDK 11 installation, e.g. `JAVA_HOME=/usr/lib/jvm/jdk-11`. ### Building diff --git a/src/test/java/org/opensearch/commons/InjectSecurityTest.java b/src/test/java/org/opensearch/commons/InjectSecurityTest.java index 5a69de07..818aa9c7 100644 --- a/src/test/java/org/opensearch/commons/InjectSecurityTest.java +++ b/src/test/java/org/opensearch/commons/InjectSecurityTest.java @@ -15,7 +15,7 @@ import static org.opensearch.commons.ConfigConstants.OPENSEARCH_SECURITY_USE_INJECTED_USER_FOR_PLUGINS; import java.util.Arrays; -import java.util.Map; +import java.util.HashMap; import org.junit.jupiter.api.Test; import org.opensearch.common.settings.Settings; @@ -114,7 +114,11 @@ public void testInjectProperty() { assertTrue(helper.injectProperty("property1", true)); assertTrue(helper.injectProperty("property2", "some value")); assertTrue(helper.injectProperty("property3", "")); - assertTrue(helper.injectProperty("property4", Map.of("key", "value"))); + assertTrue(helper.injectProperty("property4", new HashMap() { + { + put("key", "value"); + } + })); // verify the set properties are not null and equal to what was set assertNull(threadContext.getTransient("property")); assertNotNull(threadContext.getTransient("property1")); @@ -124,7 +128,11 @@ public void testInjectProperty() { assertNotNull(threadContext.getTransient("property3")); assertEquals("", threadContext.getTransient("property3")); assertNotNull(threadContext.getTransient("property4")); - assertEquals(Map.of("key", "value"), threadContext.getTransient("property4")); + assertEquals(new HashMap() { + { + put("key", "value"); + } + }, threadContext.getTransient("property4")); } assertEquals("1", threadContext.getHeader("default")); assertEquals("opendistro", threadContext.getHeader("name"));