From 2a33173a0e24b1dd6d78543d67591d6fd637df33 Mon Sep 17 00:00:00 2001 From: Hailong Cui Date: Thu, 25 Jan 2024 04:34:30 +0800 Subject: [PATCH] Upadte admin credential in integration test (#1076) --- .github/workflows/docker-security-test-workflow.yml | 9 +++++++-- build.gradle | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-security-test-workflow.yml b/.github/workflows/docker-security-test-workflow.yml index a3177cd1b..951811e57 100644 --- a/.github/workflows/docker-security-test-workflow.yml +++ b/.github/workflows/docker-security-test-workflow.yml @@ -56,11 +56,16 @@ jobs: else echo "imagePresent=false" >> $GITHUB_ENV fi + - name: Generate Password For Admin + id: genpass + run: | + PASSWORD=$(openssl rand -base64 20 | tr -dc 'A-Za-z0-9!@#$%^&*()_+=-') + echo "password=$PASSWORD" >> $GITHUB_OUTPUT - name: Run Docker Image if: env.imagePresent == 'true' run: | cd .. - container_id=`docker run -p 9200:9200 -d -p 9600:9600 -e "discovery.type=single-node" opensearch-index-management:test` + container_id=`docker run -p 9200:9200 -d -p 9600:9600 -e "discovery.type=single-node" -e OPENSEARCH_INITIAL_ADMIN_PASSWORD=${{ steps.genpass.outputs.password }} opensearch-index-management:test` sleep 120 echo `docker logs $container_id` - name: Run Index Management Test for security enabled test cases @@ -74,7 +79,7 @@ jobs: if [ $security -gt 0 ] then echo "Security plugin is available" - ./gradlew integTest -Dtests.rest.cluster=localhost:9200 -Dtests.cluster=localhost:9200 -Dtests.clustername=docker-cluster -Dsecurity=true -Dhttps=true -Duser=admin -Dpassword=admin --tests '*SecurityBehaviorIT' + ./gradlew integTest -Dtests.rest.cluster=localhost:9200 -Dtests.cluster=localhost:9200 -Dtests.clustername=docker-cluster -Dsecurity=true -Dhttps=true -Duser=admin -Dpassword=${{ steps.genpass.outputs.password }} --tests '*SecurityBehaviorIT' else echo "Security plugin is NOT available skipping this run as tests without security have already been run" fi diff --git a/build.gradle b/build.gradle index ebd7703ab..3bc620731 100644 --- a/build.gradle +++ b/build.gradle @@ -509,7 +509,8 @@ def waitForClusterSetup(OpenSearchCluster cluster, Boolean securityEnabled) { Predicate pred = { String protocol = securityEnabled ? "https" : "http" - WaitForClusterYellow wait = new WaitForClusterYellow(protocol, cluster.getFirstNode().getHttpSocketURI(), cluster.nodes.size()) + String host = System.getProperty("tests.cluster", cluster.getFirstNode().getHttpSocketURI()) + WaitForClusterYellow wait = new WaitForClusterYellow(protocol, host, cluster.nodes.size()) wait.setUsername(System.getProperty("user", "admin")) wait.setPassword(System.getProperty("password", "admin")) return wait.wait(180000)