From acee732b36da9175e3b0a0f1ddd93f518e97e301 Mon Sep 17 00:00:00 2001 From: Theo Nam Truong Date: Tue, 20 Aug 2024 13:18:43 -0600 Subject: [PATCH] Replaced `docker-compose` with `docker compose` in Makefile (#848) * Replaced `docker-compose` with `docker compose` in Makefile Locking Gradle version to 8.9 Signed-off-by: Theo Truong * # Use JDK 17 Signed-off-by: Theo Truong * # Removed Opensearch 1.x Signed-off-by: Theo Truong * # Restored 1.x test Signed-off-by: Theo Truong # Active mechanism to check for cluster readiness * # fixed Makefile syntax Signed-off-by: Theo Truong * # use temurin for JDK distribution and default to JDK 17 Signed-off-by: Theo Truong * # Fixed Makefile syntax Signed-off-by: Theo Truong * # Fixed Makefile syntax Signed-off-by: Theo Truong * # Moved waiting logic to scripts Signed-off-by: Theo Truong --------- Signed-off-by: Theo Truong --- .github/workflows/integration-unreleased.yml | 22 ++++++++----- CHANGELOG.md | 1 + Makefile | 10 +++--- scripts/wait-cluster.sh | 33 +++++++++----------- 4 files changed, 36 insertions(+), 30 deletions(-) diff --git a/.github/workflows/integration-unreleased.yml b/.github/workflows/integration-unreleased.yml index b06f7d576..34a07a6ee 100644 --- a/.github/workflows/integration-unreleased.yml +++ b/.github/workflows/integration-unreleased.yml @@ -19,10 +19,10 @@ jobs: fail-fast: false matrix: entry: - - { node_version: '16.x', opensearch_ref: '1.x' } - - { node_version: '16.x', opensearch_ref: '2.0' } - - { node_version: '16.x', opensearch_ref: '2.x' } - - { node_version: '16.x', opensearch_ref: 'main' } + - { node_version: '16.x', opensearch_ref: '1.x', jdk_version: '11' } + - { node_version: '16.x', opensearch_ref: '2.0', jdk_version: '17' } + - { node_version: '16.x', opensearch_ref: '2.x', jdk_version: '17' } + - { node_version: '16.x', opensearch_ref: 'main', jdk_version: '17' } steps: - name: Checkout OpenSearch uses: actions/checkout@v3 @@ -36,6 +36,7 @@ jobs: working-directory: opensearch run: echo key=`git log -1 --format='%H'` >> $GITHUB_OUTPUT + - name: Restore cached build id: cache-restore uses: actions/cache/restore@v3 @@ -43,10 +44,17 @@ jobs: path: opensearch/distribution/archives/linux-tar/build/distributions key: ${{ steps.get-key.outputs.key }} + - name: Setup Java JDK + uses: actions/setup-java@v3 + if: steps.cache-restore.outputs.cache-hit != 'true' + with: + distribution: 'temurin' + java-version: ${{ matrix.entry.jdk_version || '17' }} + - name: Assemble OpenSearch if: steps.cache-restore.outputs.cache-hit != 'true' working-directory: opensearch - run: ./gradlew :distribution:archives:linux-tar:assemble + run: ./gradlew :distribution:archives:linux-tar:assemble --stacktrace - name: Save cached build if: steps.cache-restore.outputs.cache-hit != 'true' @@ -72,7 +80,7 @@ jobs: fi echo '=====> waiting...' done - exit 1 + exit 1 - name: Checkout Javascript Client uses: actions/checkout@v3 @@ -100,4 +108,4 @@ jobs: with: name: opensearch-logs-${{ matrix.entry.opensearch_ref }}-js-${{ matrix.entry.node_version }} path: | - opensearch/distribution/archives/linux-tar/build/distributions/**/logs/* + opensearch/distribution/archives/linux-tar/build/distributions/**/logs/* \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 7526b646a..1860dbd65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Deprecated ### Removed ### Fixed +- Fixed docker-compose command in Makefile ([#845](https://github.com/opensearch-project/opensearch-js/issues/845)) ### Security ## [2.11.0] diff --git a/Makefile b/Makefile index 8a0f5085a..6e3a370dc 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,12 @@ cluster.opensearch.build: - docker-compose --project-directory .ci/opensearch build; + docker compose --project-directory .ci/opensearch build; cluster.opensearch.start: - docker-compose --project-directory .ci/opensearch up -d ; - sleep 60; + docker compose --project-directory .ci/opensearch up -d; + bash ./scripts/wait-cluster.sh; cluster.opensearch.stop: - docker-compose --project-directory .ci/opensearch down ; + docker compose --project-directory .ci/opensearch down; cluster.clean: ## Remove unused Docker volumes and networks @printf "\033[2m→ Cleaning up Docker assets...\033[0m\n" @@ -14,4 +14,4 @@ cluster.clean: ## Remove unused Docker volumes and networks docker network prune --force docker system prune --volumes --force -.PHONY: cluster.opensearch.build cluster.opensearch.start cluster.opensearch.stop cluster.clean +.PHONY: cluster.opensearch.build cluster.opensearch.start cluster.opensearch.stop cluster.clean \ No newline at end of file diff --git a/scripts/wait-cluster.sh b/scripts/wait-cluster.sh index 09eb85ee0..57219db43 100755 --- a/scripts/wait-cluster.sh +++ b/scripts/wait-cluster.sh @@ -1,21 +1,18 @@ #!/bin/bash -TEST_OPENSEARCH_SERVER=${TEST_OPENSEARCH_SERVER:-"http://localhost:9200"} +for attempt in {1..20}; do + echo "----- Waiting... $attempt"; + sleep 5; \ + if [ "$SECURE_INTEGRATION" = "true" ]; then + if curl -s -k https://localhost:9200; then + echo '----- Secured cluster ready' && exit 0; + fi; + else + if curl -s http://localhost:9200; then + echo '----- Unsecured cluster ready' && exit 0; + fi; + fi; +done; -attempt_counter=0 -max_attempts=5 -url="${TEST_OPENSEARCH_SERVER}/_cluster/health?wait_for_status=green&timeout=50s" - -echo "Waiting for OpenSearch..." -while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' --max-time 55 "$url")" != "200" ]]; do - if [ ${attempt_counter} -eq ${max_attempts} ];then - echo "\nCouldn't connect to OpenSearch" - exit 1 - fi - - printf '.' - attempt_counter=$(($attempt_counter+1)) - sleep 5 -done - -echo "\nReady" +echo '----- Timeout waiting for cluster to be ready'; +exit 1;