From eea46aa1b5695797a8534d66eb61212c1943b3ee Mon Sep 17 00:00:00 2001 From: Theo Truong Date: Tue, 20 Aug 2024 09:02:20 -0600 Subject: [PATCH 1/9] Replaced `docker-compose` with `docker compose` in Makefile Locking Gradle version to 8.9 Signed-off-by: Theo Truong --- .github/workflows/integration-unreleased.yml | 6 +++--- CHANGELOG.md | 1 + Makefile | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/integration-unreleased.yml b/.github/workflows/integration-unreleased.yml index b06f7d576..f6e0f78c1 100644 --- a/.github/workflows/integration-unreleased.yml +++ b/.github/workflows/integration-unreleased.yml @@ -46,7 +46,7 @@ jobs: - 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 --gradle-version=8.9 - name: Save cached build if: steps.cache-restore.outputs.cache-hit != 'true' @@ -72,7 +72,7 @@ jobs: fi echo '=====> waiting...' done - exit 1 + exit 1 - name: Checkout Javascript Client uses: actions/checkout@v3 @@ -100,4 +100,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..5e3583228 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 ; + sleep 90; 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" From 057a609501bb24ea5ef9dcac33030aeeb121d33f Mon Sep 17 00:00:00 2001 From: Theo Truong Date: Tue, 20 Aug 2024 10:44:17 -0600 Subject: [PATCH 2/9] # Use JDK 17 Signed-off-by: Theo Truong --- .github/workflows/integration-unreleased.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/integration-unreleased.yml b/.github/workflows/integration-unreleased.yml index f6e0f78c1..6905d8a78 100644 --- a/.github/workflows/integration-unreleased.yml +++ b/.github/workflows/integration-unreleased.yml @@ -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 17 + uses: actions/setup-java@v3 + if: steps.cache-restore.outputs.cache-hit != 'true' + with: + distribution: 'corretto' + java-version: '17' + - name: Assemble OpenSearch if: steps.cache-restore.outputs.cache-hit != 'true' working-directory: opensearch - run: ./gradlew :distribution:archives:linux-tar:assemble --gradle-version=8.9 + run: ./gradlew :distribution:archives:linux-tar:assemble --stacktrace - name: Save cached build if: steps.cache-restore.outputs.cache-hit != 'true' From cf00f8e413fa39fdeb481a1fbb3396611cf7c715 Mon Sep 17 00:00:00 2001 From: Theo Truong Date: Tue, 20 Aug 2024 10:52:30 -0600 Subject: [PATCH 3/9] # Removed Opensearch 1.x Signed-off-by: Theo Truong --- .github/workflows/integration-unreleased.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/integration-unreleased.yml b/.github/workflows/integration-unreleased.yml index 6905d8a78..7a77d7403 100644 --- a/.github/workflows/integration-unreleased.yml +++ b/.github/workflows/integration-unreleased.yml @@ -19,7 +19,6 @@ 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' } From f4aa27110205cb036c3baef1f7a0923443a6e352 Mon Sep 17 00:00:00 2001 From: Theo Truong Date: Tue, 20 Aug 2024 11:25:58 -0600 Subject: [PATCH 4/9] # Restored 1.x test Signed-off-by: Theo Truong # Active mechanism to check for cluster readiness --- .github/workflows/integration-unreleased.yml | 11 ++++++----- Makefile | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/.github/workflows/integration-unreleased.yml b/.github/workflows/integration-unreleased.yml index 7a77d7403..4d27e3152 100644 --- a/.github/workflows/integration-unreleased.yml +++ b/.github/workflows/integration-unreleased.yml @@ -19,9 +19,10 @@ jobs: fail-fast: false matrix: entry: - - { 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 @@ -43,12 +44,12 @@ jobs: path: opensearch/distribution/archives/linux-tar/build/distributions key: ${{ steps.get-key.outputs.key }} - - name: Setup Java JDK 17 + - name: Setup Java JDK uses: actions/setup-java@v3 if: steps.cache-restore.outputs.cache-hit != 'true' with: distribution: 'corretto' - java-version: '17' + java-version: ${{ matrix.entry.jdk_version }} - name: Assemble OpenSearch if: steps.cache-restore.outputs.cache-hit != 'true' diff --git a/Makefile b/Makefile index 5e3583228..ee49efd9c 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,21 @@ cluster.opensearch.build: cluster.opensearch.start: docker compose --project-directory .ci/opensearch up -d ; - sleep 90; + for attempt in {1..20}; do + 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 + echo '=====> waiting...' + done cluster.opensearch.stop: docker compose --project-directory .ci/opensearch down ; From 007ec5392605e7404769bfb6d5b26d6e5a77efd8 Mon Sep 17 00:00:00 2001 From: Theo Truong Date: Tue, 20 Aug 2024 11:39:34 -0600 Subject: [PATCH 5/9] # fixed Makefile syntax Signed-off-by: Theo Truong --- Makefile | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index ee49efd9c..8c9878ddd 100644 --- a/Makefile +++ b/Makefile @@ -3,24 +3,19 @@ cluster.opensearch.build: cluster.opensearch.start: docker compose --project-directory .ci/opensearch up -d ; - for attempt in {1..20}; do - 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 - echo '=====> waiting...' - done + for attempt in {1..20}; do \ + echo '=====> waiting...'; \ + 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; \ + exit 1; 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" @@ -28,4 +23,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 From 946372a4ba5b7b5629ac1d4581eae51924c152c6 Mon Sep 17 00:00:00 2001 From: Theo Truong Date: Tue, 20 Aug 2024 11:44:26 -0600 Subject: [PATCH 6/9] # use temurin for JDK distribution and default to JDK 17 Signed-off-by: Theo Truong --- .github/workflows/integration-unreleased.yml | 4 ++-- Makefile | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/integration-unreleased.yml b/.github/workflows/integration-unreleased.yml index 4d27e3152..34a07a6ee 100644 --- a/.github/workflows/integration-unreleased.yml +++ b/.github/workflows/integration-unreleased.yml @@ -48,8 +48,8 @@ jobs: uses: actions/setup-java@v3 if: steps.cache-restore.outputs.cache-hit != 'true' with: - distribution: 'corretto' - java-version: ${{ matrix.entry.jdk_version }} + distribution: 'temurin' + java-version: ${{ matrix.entry.jdk_version || '17' }} - name: Assemble OpenSearch if: steps.cache-restore.outputs.cache-hit != 'true' diff --git a/Makefile b/Makefile index 8c9878ddd..5394c5b53 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ cluster.opensearch.build: docker compose --project-directory .ci/opensearch build; cluster.opensearch.start: - docker compose --project-directory .ci/opensearch up -d ; + docker compose --project-directory .ci/opensearch up -d ; \ for attempt in {1..20}; do \ echo '=====> waiting...'; \ sleep 5; \ From a88f85b1f170c24f448bd883c686fd5dff03e46f Mon Sep 17 00:00:00 2001 From: Theo Truong Date: Tue, 20 Aug 2024 11:50:59 -0600 Subject: [PATCH 7/9] # Fixed Makefile syntax Signed-off-by: Theo Truong --- Makefile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 5394c5b53..84d6a537a 100644 --- a/Makefile +++ b/Makefile @@ -2,14 +2,18 @@ cluster.opensearch.build: docker compose --project-directory .ci/opensearch build; cluster.opensearch.start: - docker compose --project-directory .ci/opensearch up -d ; \ + docker compose --project-directory .ci/opensearch up -d; for attempt in {1..20}; do \ echo '=====> waiting...'; \ sleep 5; \ if [ "$$SECURE_INTEGRATION" = "true" ]; then \ - if curl -s -k https://localhost:9200; then echo '=====> secured cluster ready' && exit 0; fi; \ + 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; \ + if curl -s http://localhost:9200; then \ + echo '=====> unsecured cluster ready' && exit 0; \ + fi; \ fi; \ done; \ exit 1; From 41b0521b628dff9344f86dac67f54f43536acd83 Mon Sep 17 00:00:00 2001 From: Theo Truong Date: Tue, 20 Aug 2024 12:03:29 -0600 Subject: [PATCH 8/9] # Fixed Makefile syntax Signed-off-by: Theo Truong --- Makefile | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 84d6a537a..8eb43e64f 100644 --- a/Makefile +++ b/Makefile @@ -2,21 +2,27 @@ cluster.opensearch.build: docker compose --project-directory .ci/opensearch build; cluster.opensearch.start: - docker compose --project-directory .ci/opensearch up -d; + docker compose --project-directory .ci/opensearch up -d; \ + ready=false; \ for attempt in {1..20}; do \ echo '=====> waiting...'; \ sleep 5; \ if [ "$$SECURE_INTEGRATION" = "true" ]; then \ if curl -s -k https://localhost:9200; then \ - echo '=====> secured cluster ready' && exit 0; \ + ready=true; \ + echo '----- Secured cluster ready' && break; \ fi; \ else \ if curl -s http://localhost:9200; then \ - echo '=====> unsecured cluster ready' && exit 0; \ + ready=true; \ + echo '----- Unsecured cluster ready' && break; \ fi; \ fi; \ done; \ - exit 1; + if [ "$$ready" = "false" ]; then \ + echo '----- Timeout waiting for cluster to be ready'; \ + exit 1; \ + fi cluster.opensearch.stop: docker compose --project-directory .ci/opensearch down; From 69154cd166e1ae38c39120daf3aba8022dbf743c Mon Sep 17 00:00:00 2001 From: Theo Truong Date: Tue, 20 Aug 2024 12:20:20 -0600 Subject: [PATCH 9/9] # Moved waiting logic to scripts Signed-off-by: Theo Truong --- Makefile | 23 ++--------------------- scripts/wait-cluster.sh | 33 +++++++++++++++------------------ 2 files changed, 17 insertions(+), 39 deletions(-) diff --git a/Makefile b/Makefile index 8eb43e64f..6e3a370dc 100644 --- a/Makefile +++ b/Makefile @@ -2,27 +2,8 @@ cluster.opensearch.build: docker compose --project-directory .ci/opensearch build; cluster.opensearch.start: - docker compose --project-directory .ci/opensearch up -d; \ - ready=false; \ - for attempt in {1..20}; do \ - echo '=====> waiting...'; \ - sleep 5; \ - if [ "$$SECURE_INTEGRATION" = "true" ]; then \ - if curl -s -k https://localhost:9200; then \ - ready=true; \ - echo '----- Secured cluster ready' && break; \ - fi; \ - else \ - if curl -s http://localhost:9200; then \ - ready=true; \ - echo '----- Unsecured cluster ready' && break; \ - fi; \ - fi; \ - done; \ - if [ "$$ready" = "false" ]; then \ - echo '----- Timeout waiting for cluster to be ready'; \ - exit 1; \ - fi + docker compose --project-directory .ci/opensearch up -d; + bash ./scripts/wait-cluster.sh; cluster.opensearch.stop: docker compose --project-directory .ci/opensearch down; 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;