Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run CI/CD on Java 8, 11, 14 and 17. #121

Merged
merged 2 commits into from
Mar 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/ci-17.yml
Original file line number Diff line number Diff line change
@@ -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
Comment on lines +13 to +18
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also instead of duplicating the test information for each one of them, can we use github action matrix?

Something like

jobs:
  test:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-18.04]
        java: [8, 11, 14, 17]
      fail-fast: false   
    name: Test common-utils with JDK ${{ matrix.java }}, ${{ matrix.os }}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignore me :)
Just saw the description and it makes sense.


- name: Setup Java 11
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: 11

Comment on lines +20 to +25
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to test both Java 11 and 17 here?
If so, we should rename the file

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We build with 11 but test with 17 here, so really this is a 17 test.

- name: Build
run: |
./gradlew build --build-cache

- name: Setup Java 17
uses: actions/setup-java@v2
with:
distribution: 'temurin'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be a very dumb question. I dont understand Java distributions yet, but can we use with what with support on OpenSearch for consistency?
We use adoptium.

Ref: opensearch-project/OpenSearch#1358

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Temurin is a distribution of adoptium - https://adoptium.net/

java-version: 17

- name: Test
run: |
./gradlew test --build-cache


6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ jobs:
build:
strategy:
matrix:
java: [14]
java:
- 8
- 11
- 14

name: Build and Test
runs-on: ubuntu-latest
Expand All @@ -25,7 +28,6 @@ jobs:
with:
java-version: ${{ matrix.java }}

# common-utils
- name: Build and Test
run: |
./gradlew build
Expand Down
6 changes: 3 additions & 3 deletions DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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

Expand Down
14 changes: 11 additions & 3 deletions src/test/java/org/opensearch/commons/InjectSecurityTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String, String>() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Map.of doesn't exist in Java 8.

{
put("key", "value");
}
}));
// verify the set properties are not null and equal to what was set
assertNull(threadContext.getTransient("property"));
assertNotNull(threadContext.getTransient("property1"));
Expand All @@ -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<String, String>() {
{
put("key", "value");
}
}, threadContext.getTransient("property4"));
}
assertEquals("1", threadContext.getHeader("default"));
assertEquals("opendistro", threadContext.getHeader("name"));
Expand Down