From 799d6487b6aedfb40cdd3a81402af8384a9b1c77 Mon Sep 17 00:00:00 2001 From: Peter Nied Date: Fri, 6 Oct 2023 21:42:28 +0000 Subject: [PATCH] updates to CI systems Signed-off-by: Peter Nied --- .github/workflows/ci.yml | 28 ++++++++++++++++ .github/workflows/resources-workflows.yml | 36 --------------------- build.gradle | 39 +++++++++++++++-------- 3 files changed, 54 insertions(+), 49 deletions(-) delete mode 100644 .github/workflows/resources-workflows.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9e58ff4b4f..475b67d199 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,7 @@ on: env: GRADLE_OPTS: -Dhttp.keepAlive=false + CI_ENVIRONMENT: normal jobs: generate-test-list: @@ -108,6 +109,33 @@ jobs: arguments: | integrationTest -Dbuild.snapshot=false + resource-tests: + env: + CI_ENVIRONMENT: resource-test + strategy: + fail-fast: false + matrix: + jdk: [17] + platform: [ubuntu-latest] + runs-on: ${{ matrix.platform }} + + steps: + - name: Set up JDK for build and test + uses: actions/setup-java@v3 + with: + distribution: temurin # Temurin is a distribution of adoptium + java-version: ${{ matrix.jdk }} + + - name: Checkout security + uses: actions/checkout@v4 + + - name: Build and Test + uses: gradle/gradle-build-action@v2 + continue-on-error: true # Until retries are enable do not fail the workflow https://github.com/opensearch-project/security/issues/2184 + with: + cache-disabled: true + arguments: | + integrationTest -Dbuild.snapshot=false --tests org.opensearch.security.ResourceFocusedTests backward-compatibility-build: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/resources-workflows.yml b/.github/workflows/resources-workflows.yml deleted file mode 100644 index fc8c53e4b2..0000000000 --- a/.github/workflows/resources-workflows.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Resource-Tests - -on: - push: - pull_request: - -env: - GRADLE_OPTS: -Dhttp.keepAlive=false - -jobs: - integration-tests: - name: integration-tests - strategy: - fail-fast: false - matrix: - jdk: [17] - platform: [ubuntu-latest] - runs-on: ${{ matrix.platform }} - - steps: - - name: Set up JDK for build and test - uses: actions/setup-java@v3 - with: - distribution: temurin # Temurin is a distribution of adoptium - java-version: ${{ matrix.jdk }} - - - name: Checkout security - uses: actions/checkout@v4 - - - name: Build and Test - uses: gradle/gradle-build-action@v2 - continue-on-error: true # Until retries are enable do not fail the workflow https://github.com/opensearch-project/security/issues/2184 - with: - cache-disabled: true - arguments: | - integrationTest -Dbuild.snapshot=false --tests org.opensearch.security.ResourceFocusedTests diff --git a/build.gradle b/build.gradle index 298996d307..5babc00567 100644 --- a/build.gradle +++ b/build.gradle @@ -190,6 +190,16 @@ task listTasksAsJSON { test { include '**/*.class' + doFirst { + // Only run with retries while in CI systems + if (System.getenv('CI_ENVIRONMENT') == 'normal') { + retry { + failOnPassedAfterRetry = false + maxRetries = 5 + } + } + } + filter { excludeTestsMatching "org.opensearch.security.sanity.tests.*" } @@ -198,10 +208,6 @@ test { if (JavaVersion.current() > JavaVersion.VERSION_1_8) { jvmArgs += "--add-opens=java.base/java.io=ALL-UNNAMED" } - retry { - failOnPassedAfterRetry = false - maxRetries = 5 - } jacoco { excludes = [ "com.sun.jndi.dns.*", @@ -245,10 +251,6 @@ def setCommonTestConfig(Test task) { if (JavaVersion.current() > JavaVersion.VERSION_1_8) { task.jvmArgs += "--add-opens=java.base/java.io=ALL-UNNAMED" } - task.retry { - failOnPassedAfterRetry = false - maxRetries = 5 - } task.jacoco { excludes = [ "com.sun.jndi.dns.*", @@ -459,16 +461,27 @@ sourceSets { //add new task that runs integration tests task integrationTest(type: Test) { + doFirst { + // Only run resources tests on resource-test CI environments or locally + if (System.getenv('CI_ENVIRONMENT') == 'resource-test' || System.getenv('CI_ENVIRONMENT') == null) { + include '**/ResourceFocusedTests.class' + } else { + exclude '**/ResourceFocusedTests.class' + } + // Only run with retries while in CI systems + if (System.getenv('CI_ENVIRONMENT') == 'normal') { + retry { + failOnPassedAfterRetry = false + maxRetries = 2 + maxFailures = 10 + } + } + } description = 'Run integration tests.' group = 'verification' systemProperty "java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager" testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath - // retry { - // failOnPassedAfterRetry = false - // maxRetries = 2 - // maxFailures = 10 - // } //run the integrationTest task after the test task shouldRunAfter test }