From 40747373af6756c1a646d10d30c16bb4986e4aea Mon Sep 17 00:00:00 2001 From: joeyyy09 Date: Thu, 25 Jul 2024 23:42:00 +0530 Subject: [PATCH 1/3] Check elastic search gh workflow Signed-off-by: joeyyy09 --- .github/workflows/ci-e2e-elasticsearch.yml | 2 +- scripts/elasticsearch-integration-test.sh | 133 +++++++++++++++++++++ 2 files changed, 134 insertions(+), 1 deletion(-) create mode 100755 scripts/elasticsearch-integration-test.sh diff --git a/.github/workflows/ci-e2e-elasticsearch.yml b/.github/workflows/ci-e2e-elasticsearch.yml index c80dc0f8686..cb0574e5b6d 100644 --- a/.github/workflows/ci-e2e-elasticsearch.yml +++ b/.github/workflows/ci-e2e-elasticsearch.yml @@ -56,7 +56,7 @@ jobs: - uses: docker/setup-qemu-action@5927c834f5b4fdf503fca6f4c7eccda82949e1ee # v3.1.0 - name: Run ${{ matrix.version.distribution }} integration tests id: test-execution - run: bash scripts/es-integration-test.sh ${{ matrix.version.distribution }} ${{ matrix.version.major }} ${{ matrix.version.jaeger }} + run: bash scripts/elasticsearch-integration-test.sh ${{ matrix.version.distribution }} ${{ matrix.version.major }} ${{ matrix.version.jaeger }} - name: Output ${{ matrix.version.distribution }} logs diff --git a/scripts/elasticsearch-integration-test.sh b/scripts/elasticsearch-integration-test.sh new file mode 100755 index 00000000000..e1cdb90d046 --- /dev/null +++ b/scripts/elasticsearch-integration-test.sh @@ -0,0 +1,133 @@ +#!/bin/bash + +PS4='T$(date "+%H:%M:%S") ' +set -euf -o pipefail + +# use global variables to reflect status of db +db_is_up= + +usage() { + echo "Usage: $0 " + echo " backend: elasticsearch | opensearch" + echo " backend_version: major version, e.g. 7.x" + echo " jaeger_version: major version, e.g. v1 | v2" + exit 1 +} + +check_arg() { + if [ ! $# -eq 3 ]; then + echo "ERROR: need exactly three arguments" + usage + fi +} + +# start the elasticsearch/opensearch container +setup_db() { + local compose_file=$1 + docker-compose -f "${compose_file}" up -d + echo "docker_compose_file=${compose_file}" >> "${GITHUB_OUTPUT:-/dev/null}" +} + +# check if the storage is up and running +wait_for_storage() { + local distro=$1 + local url=$2 + local compose_file=$3 + local params=( + --silent + --output + /dev/null + --write-out + "%{http_code}" + ) + local max_attempts=60 + local attempt=0 + echo "Waiting for ${distro} to be available at ${url}..." + until [[ "$(curl "${params[@]}" "${url}")" == "200" ]] || (( attempt >= max_attempts )); do + attempt=$(( attempt + 1 )) + echo "Attempt: ${attempt} ${distro} is not yet available at ${url}..." + sleep 10 + done + + # if after all the attempts the storage is not accessible, terminate it and exit + if [[ "$(curl "${params[@]}" "${url}")" != "200" ]]; then + echo "ERROR: ${distro} is not ready at ${url} after $(( attempt * 10 )) seconds" + echo "::group::${distro} logs" + docker compose -f "${compose_file}" logs + echo "::endgroup::" + docker compose -f "${compose_file}" down + db_is_up=0 + else + echo "SUCCESS: ${distro} is available at ${url}" + db_is_up=1 + fi +} + +bring_up_storage() { + local distro=$1 + local version=$2 + local major_version=${version%%.*} + local compose_file="docker-compose/${distro}/v${major_version}/docker-compose.yml" + + echo "starting ${distro} ${major_version}" + for retry in 1 2 3 + do + echo "attempt $retry" + if [ "${distro}" = "elasticsearch" ] || [ "${distro}" = "opensearch" ]; then + setup_db "${compose_file}" + else + echo "Unknown distribution $distro. Valid options are opensearch or elasticsearch" + usage + fi + wait_for_storage "${distro}" "http://localhost:9200" "${compose_file}" + if [ ${db_is_up} = "1" ]; then + break + fi + done + if [ ${db_is_up} = "1" ]; then + # shellcheck disable=SC2064 + trap "teardown_storage ${compose_file}" EXIT + else + echo "ERROR: unable to start ${distro}" + exit 1 + fi +} + +# terminate the elasticsearch/opensearch container +teardown_storage() { + local compose_file=$1 + docker compose -f "${compose_file}" down +} + +build_local_img(){ + make build-es-index-cleaner GOOS=linux + make build-es-rollover GOOS=linux + make create-baseimg PLATFORMS="linux/$(go env GOARCH)" + #build es-index-cleaner and es-rollover images + GITHUB_SHA=local-test BRANCH=local-test bash scripts/build-upload-a-docker-image.sh -l -b -c jaeger-es-index-cleaner -d cmd/es-index-cleaner -t release -p "linux/$(go env GOARCH)" + GITHUB_SHA=local-test BRANCH=local-test bash scripts/build-upload-a-docker-image.sh -l -b -c jaeger-es-rollover -d cmd/es-rollover -t release -p "linux/$(go env GOARCH)" +} + +main() { + check_arg "$@" + local distro=$1 + local es_version=$2 + local j_version=$3 + + set -x + + bring_up_storage "${distro}" "${es_version}" + build_local_img + if [[ "${j_version}" == "v2" ]]; then + STORAGE=${distro} make jaeger-v2-storage-integration-test + elif [[ "${j_version}" == "v1" ]]; then + STORAGE=${distro} make storage-integration-test + make index-cleaner-integration-test + make index-rollover-integration-test + else + echo "ERROR: Invalid argument value jaeger_version=${j_version}, expecing v1/v2". + exit 1 + fi +} + +main "$@" From 566d42d5e7a3ca549447e260543bd8497b469d43 Mon Sep 17 00:00:00 2001 From: joeyyy09 Date: Thu, 25 Jul 2024 23:49:10 +0530 Subject: [PATCH 2/3] rename script Signed-off-by: joeyyy09 --- scripts/es-integration-test.sh | 133 --------------------------------- 1 file changed, 133 deletions(-) delete mode 100755 scripts/es-integration-test.sh diff --git a/scripts/es-integration-test.sh b/scripts/es-integration-test.sh deleted file mode 100755 index a9d98d9798e..00000000000 --- a/scripts/es-integration-test.sh +++ /dev/null @@ -1,133 +0,0 @@ -#!/bin/bash - -PS4='T$(date "+%H:%M:%S") ' -set -euf -o pipefail - -# use global variables to reflect status of db -db_is_up= - -usage() { - echo "Usage: $0 " - echo " backend: elasticsearch | opensearch" - echo " backend_version: major version, e.g. 7.x" - echo " jaeger_version: major version, e.g. v1 | v2" - exit 1 -} - -check_arg() { - if [ ! $# -eq 3 ]; then - echo "ERROR: need exactly three arguments" - usage - fi -} - -# start the elasticsearch/opensearch container -setup_db() { - local compose_file=$1 - docker compose -f "${compose_file}" up -d - echo "docker_compose_file=${compose_file}" >> "${GITHUB_OUTPUT:-/dev/null}" -} - -# check if the storage is up and running -wait_for_storage() { - local distro=$1 - local url=$2 - local compose_file=$3 - local params=( - --silent - --output - /dev/null - --write-out - "%{http_code}" - ) - local max_attempts=60 - local attempt=0 - echo "Waiting for ${distro} to be available at ${url}..." - until [[ "$(curl "${params[@]}" "${url}")" == "200" ]] || (( attempt >= max_attempts )); do - attempt=$(( attempt + 1 )) - echo "Attempt: ${attempt} ${distro} is not yet available at ${url}..." - sleep 10 - done - - # if after all the attempts the storage is not accessible, terminate it and exit - if [[ "$(curl "${params[@]}" "${url}")" != "200" ]]; then - echo "ERROR: ${distro} is not ready at ${url} after $(( attempt * 10 )) seconds" - echo "::group::${distro} logs" - docker compose -f "${compose_file}" logs - echo "::endgroup::" - docker compose -f "${compose_file}" down - db_is_up=0 - else - echo "SUCCESS: ${distro} is available at ${url}" - db_is_up=1 - fi -} - -bring_up_storage() { - local distro=$1 - local version=$2 - local major_version=${version%%.*} - local compose_file="docker-compose/${distro}/v${major_version}/docker-compose.yml" - - echo "starting ${distro} ${major_version}" - for retry in 1 2 3 - do - echo "attempt $retry" - if [ "${distro}" = "elasticsearch" ] || [ "${distro}" = "opensearch" ]; then - setup_db "${compose_file}" - else - echo "Unknown distribution $distro. Valid options are opensearch or elasticsearch" - usage - fi - wait_for_storage "${distro}" "http://localhost:9200" "${compose_file}" - if [ ${db_is_up} = "1" ]; then - break - fi - done - if [ ${db_is_up} = "1" ]; then - # shellcheck disable=SC2064 - trap "teardown_storage ${compose_file}" EXIT - else - echo "ERROR: unable to start ${distro}" - exit 1 - fi -} - -# terminate the elasticsearch/opensearch container -teardown_storage() { - local compose_file=$1 - docker compose -f "${compose_file}" down -} - -build_local_img(){ - make build-es-index-cleaner GOOS=linux - make build-es-rollover GOOS=linux - make create-baseimg PLATFORMS="linux/$(go env GOARCH)" - #build es-index-cleaner and es-rollover images - GITHUB_SHA=local-test BRANCH=local-test bash scripts/build-upload-a-docker-image.sh -l -b -c jaeger-es-index-cleaner -d cmd/es-index-cleaner -t release -p "linux/$(go env GOARCH)" - GITHUB_SHA=local-test BRANCH=local-test bash scripts/build-upload-a-docker-image.sh -l -b -c jaeger-es-rollover -d cmd/es-rollover -t release -p "linux/$(go env GOARCH)" -} - -main() { - check_arg "$@" - local distro=$1 - local es_version=$2 - local j_version=$3 - - set -x - - bring_up_storage "${distro}" "${es_version}" - build_local_img - if [[ "${j_version}" == "v2" ]]; then - STORAGE=${distro} SPAN_STORAGE_TYPE=${distro} make jaeger-v2-storage-integration-test - elif [[ "${j_version}" == "v1" ]]; then - STORAGE=${distro} make storage-integration-test - make index-cleaner-integration-test - make index-rollover-integration-test - else - echo "ERROR: Invalid argument value jaeger_version=${j_version}, expecing v1/v2". - exit 1 - fi -} - -main "$@" From e094df4f0f8262b4481fda366f2ac6847926a2d7 Mon Sep 17 00:00:00 2001 From: joeyyy09 Date: Thu, 25 Jul 2024 23:51:50 +0530 Subject: [PATCH 3/3] Fixes Signed-off-by: joeyyy09 --- .github/workflows/ci-e2e-opensearch.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-e2e-opensearch.yml b/.github/workflows/ci-e2e-opensearch.yml index 50ee0586386..46c89827010 100644 --- a/.github/workflows/ci-e2e-opensearch.yml +++ b/.github/workflows/ci-e2e-opensearch.yml @@ -54,7 +54,7 @@ jobs: - name: Run ${{ matrix.version.distribution }} integration tests id: test-execution - run: bash scripts/es-integration-test.sh ${{ matrix.version.distribution }} ${{ matrix.version.major }} ${{ matrix.version.jaeger }} + run: bash scripts/elasticsearch-integration-test.sh ${{ matrix.version.distribution }} ${{ matrix.version.major }} ${{ matrix.version.jaeger }} - name: Output ${{ matrix.version.distribution }} logs