diff --git a/.github/workflows/ci-elasticsearch.yml b/.github/workflows/ci-elasticsearch.yml index 78d28a30a09..5547cc2c694 100644 --- a/.github/workflows/ci-elasticsearch.yml +++ b/.github/workflows/ci-elasticsearch.yml @@ -23,15 +23,12 @@ jobs: matrix: version: - major: 7.x - image: 7.14.0 distribution: elasticsearch jaeger: v1 - major: 8.x - image: 8.8.2 distribution: elasticsearch jaeger: v1 - major: 8.x - image: 8.8.2 distribution: elasticsearch jaeger: v2 name: ${{ matrix.version.distribution }} ${{ matrix.version.major }} ${{ matrix.version.jaeger }} @@ -57,10 +54,10 @@ jobs: run: make install-ci - uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 - - name: Run ${{ matrix.version.distribution }} integration tests id: test-execution - run: bash scripts/es-integration-test.sh ${{ matrix.version.distribution }} ${{ matrix.version.image }} ${{ matrix.version.jaeger }} + run: bash scripts/es-integration-test.sh ${{ matrix.version.distribution }} ${{ matrix.version.major }} ${{ matrix.version.jaeger }} + - name: Output ${{ matrix.version.distribution }} logs run: docker logs ${{ steps.test-execution.outputs.cid }} @@ -71,3 +68,4 @@ jobs: with: files: cover.out,cover-index-cleaner.out,cover-index-rollover.out flags: ${{ matrix.version.distribution }}-${{ matrix.version.major }}-${{ matrix.version.jaeger }} + diff --git a/.github/workflows/ci-opensearch.yml b/.github/workflows/ci-opensearch.yml index 9e8ff9c0896..0547b6e91b5 100644 --- a/.github/workflows/ci-opensearch.yml +++ b/.github/workflows/ci-opensearch.yml @@ -23,15 +23,12 @@ jobs: matrix: version: - major: 1.x - image: 1.3.7 distribution: opensearch jaeger: v1 - major: 2.x - image: 2.3.0 distribution: opensearch jaeger: v1 - major: 2.x - image: 2.3.0 distribution: opensearch jaeger: v2 name: ${{ matrix.version.distribution }} ${{ matrix.version.major }} ${{ matrix.version.jaeger }} @@ -60,7 +57,8 @@ jobs: - name: Run ${{ matrix.version.distribution }} integration tests id: test-execution - run: bash scripts/es-integration-test.sh ${{ matrix.version.distribution }} ${{ matrix.version.image }} ${{ matrix.version.jaeger }} + run: bash scripts/es-integration-test.sh ${{ matrix.version.distribution }} ${{ matrix.version.major }} ${{ matrix.version.jaeger }} + - name: Output ${{ matrix.version.distribution }} logs run: docker logs ${{ steps.test-execution.outputs.cid }} diff --git a/docker-compose/elasticsearch/v7.yml b/docker-compose/elasticsearch/v7.yml new file mode 100644 index 00000000000..035ec129f44 --- /dev/null +++ b/docker-compose/elasticsearch/v7.yml @@ -0,0 +1,14 @@ +version: '3.8' + +services: + elasticsearch: + image: docker.elastic.co/elasticsearch/elasticsearch:7.14.0 + environment: + - discovery.type=single-node + - http.host=0.0.0.0 + - transport.host=127.0.0.1 + - xpack.security.enabled=false # Disable security features + - xpack.security.http.ssl.enabled=false # Disable HTTPS + - xpack.monitoring.enabled=false # Disable monitoring features + ports: + - "9200:9200" \ No newline at end of file diff --git a/docker-compose/elasticsearch/v8.yml b/docker-compose/elasticsearch/v8.yml new file mode 100644 index 00000000000..89b895e513a --- /dev/null +++ b/docker-compose/elasticsearch/v8.yml @@ -0,0 +1,16 @@ +version: '3.8' + +services: + elasticsearch: + image: docker.elastic.co/elasticsearch/elasticsearch:8.8.2 + environment: + - discovery.type=single-node + - http.host=0.0.0.0 + - transport.host=127.0.0.1 + - xpack.security.enabled=false # Disable security features + - xpack.security.http.ssl.enabled=false # Disable HTTPS + - action.destructive_requires_name=false + - xpack.monitoring.collection.enabled=false # Disable monitoring features + ports: + - "9200:9200" + diff --git a/docker-compose/opensearch/v1.yml b/docker-compose/opensearch/v1.yml new file mode 100644 index 00000000000..2fdbe34b0cb --- /dev/null +++ b/docker-compose/opensearch/v1.yml @@ -0,0 +1,12 @@ +version: '3.8' + +services: + opensearch: + image: opensearchproject/opensearch:1.3.9 + environment: + - discovery.type=single-node + - plugins.security.disabled=true + - http.host=0.0.0.0 + - transport.host=127.0.0.1 + ports: + - "9200:9200" diff --git a/docker-compose/opensearch/v2.yml b/docker-compose/opensearch/v2.yml new file mode 100644 index 00000000000..41b152784e2 --- /dev/null +++ b/docker-compose/opensearch/v2.yml @@ -0,0 +1,13 @@ +version: '3.8' + +services: + opensearch: + image: opensearchproject/opensearch:2.5.0 + environment: + - discovery.type=single-node + - plugins.security.disabled=true + - http.host=0.0.0.0 + - transport.host=127.0.0.1 + ports: + - "9200:9200" + diff --git a/scripts/es-integration-test.sh b/scripts/es-integration-test.sh index df923692d1f..0539d08ea3a 100755 --- a/scripts/es-integration-test.sh +++ b/scripts/es-integration-test.sh @@ -18,54 +18,19 @@ check_arg() { fi } -setup_es() { - local tag=$1 - local image=docker.elastic.co/elasticsearch/elasticsearch - local params=( - --detach - --publish 9200:9200 - --env "http.host=0.0.0.0" - --env "transport.host=127.0.0.1" - --env "xpack.security.enabled=false" - ) - local major_version=${tag%%.*} - if (( major_version < 8 )); then - params+=(--env "xpack.monitoring.enabled=false") - else - params+=(--env "xpack.monitoring.collection.enabled=false") - fi - if (( major_version > 7 )); then - params+=( - --env "action.destructive_requires_name=false" - ) - fi - - local cid - cid=$(docker run "${params[@]}" "${image}:${tag}") - echo "cid=${cid}" >> "$GITHUB_OUTPUT" - echo "${cid}" -} - -setup_opensearch() { - local image=opensearchproject/opensearch - local tag=$1 - local params=( - --detach - --publish 9200:9200 - --env "http.host=0.0.0.0" - --env "transport.host=127.0.0.1" - --env "plugins.security.disabled=true" - ) - local cid - cid=$(docker run "${params[@]}" "${image}:${tag}") +setup_db() { + local distro=$1 + local compose_file=$2 + docker compose -f "${compose_file}" up -d + local cid + cid=$(docker compose -f "${compose_file}" ps -q "${distro}") echo "cid=${cid}" >> "$GITHUB_OUTPUT" - echo "${cid}" } wait_for_storage() { local distro=$1 local url=$2 - local cid=$3 + local compose_file=$3 local params=( --silent --output @@ -73,22 +38,24 @@ wait_for_storage() { --write-out "%{http_code}" ) - local counter=0 - local max_counter=60 - while [[ "$(curl "${params[@]}" "${url}")" != "200" && ${counter} -le ${max_counter} ]]; do - docker inspect "${cid}" | jq '.[].State' - echo "waiting for ${url} to be up..." + 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 - counter=$((counter+1)) done - # after the loop, do final verification and set status as global var + if [[ "$(curl "${params[@]}" "${url}")" != "200" ]]; then - echo "ERROR: ${distro} is not ready" - docker logs "${cid}" - docker kill "${cid}" + 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 ready" + echo "SUCCESS: ${distro} is available at ${url}" db_is_up=1 fi } @@ -96,28 +63,27 @@ wait_for_storage() { bring_up_storage() { local distro=$1 local version=$2 - local cid + local major_version=${version%%.*} + local compose_file="docker-compose/${distro}/v${major_version}.yml" echo "starting ${distro} ${version}" for retry in 1 2 3 do echo "attempt $retry" - if [ "${distro}" = "elasticsearch" ]; then - cid=$(setup_es "${version}") - elif [ "${distro}" == "opensearch" ]; then - cid=$(setup_opensearch "${version}") + if [ "${distro}" = "elasticsearch" ] || [ "${distro}" = "opensearch" ]; then + setup_db "${distro}" "${compose_file}" else echo "Unknown distribution $distro. Valid options are opensearch or elasticsearch" usage fi - wait_for_storage "${distro}" "http://localhost:9200" "${cid}" + 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 ${cid}" EXIT + trap "teardown_storage ${compose_file}" EXIT else echo "ERROR: unable to start ${distro}" exit 1 @@ -125,8 +91,8 @@ bring_up_storage() { } teardown_storage() { - local cid=$1 - docker kill "${cid}" + local compose_file=$1 + docker compose -f "${compose_file}" down } main() { @@ -146,4 +112,4 @@ main() { fi } -main "$@" +main "$@" \ No newline at end of file