From 5863430fa0c22679ff843abdd717ac8cf8fb6828 Mon Sep 17 00:00:00 2001 From: mehul gautam Date: Tue, 4 Jun 2024 01:27:11 +0530 Subject: [PATCH] Use docker compose for cassandra integration tests (#5520) ## Which problem is this PR solving? - https://github.com/jaegertracing/jaeger/issues/5485 ## Description of the changes - updated `cassandra-integration-test.sh` to use docker compose - update dependabot config ## How was this change tested? - `bash scripts/cassandra-integration-test.sh 3 v003 v1` ` bash scripts/cassandra-integration-test.sh 3 v003 v2 ` bash `scripts/cassandra-integration-test.sh 4 v004 v1` `scripts/cassandra-integration-test.sh 4 v004 v2` ## Checklist - [ ] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [ ] I have signed all commits - [ ] I have added unit tests for the new functionality - [ ] I have run lint and test steps successfully - for `jaeger`: `make lint test` - for `jaeger-ui`: `yarn lint` and `yarn test` --------- Signed-off-by: Your Name Co-authored-by: Your Name --- .github/dependabot.yml | 7 +++++++ .github/workflows/ci-cassandra.yml | 6 ++---- docker-compose/cassandra/v3.yaml | 19 +++++++++++++++++++ docker-compose/cassandra/v4.yaml | 19 +++++++++++++++++++ scripts/cassandra-integration-test.sh | 25 +++++++++---------------- 5 files changed, 56 insertions(+), 20 deletions(-) create mode 100644 docker-compose/cassandra/v3.yaml create mode 100644 docker-compose/cassandra/v4.yaml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 32172214d17..131fc15ff02 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -136,3 +136,10 @@ updates: allow: - dependency-name: "bitnami/kafka" update-types: ["version-update:semver-minor"] + - package-ecosystem: docker + directory: /docker-compose/cassandra + schedule: + interval: daily + allow: + - dependency-name: "cassandra" + update-types: ["version-update:semver-minor"] diff --git a/.github/workflows/ci-cassandra.yml b/.github/workflows/ci-cassandra.yml index 8d5c08e8c2a..69219985d00 100644 --- a/.github/workflows/ci-cassandra.yml +++ b/.github/workflows/ci-cassandra.yml @@ -24,11 +24,9 @@ jobs: version: - distribution: cassandra major: 3.x - image: 3.11 schema: v003 - distribution: cassandra major: 4.x - image: 4.0 schema: v004 name: ${{ matrix.version.distribution }} ${{ matrix.version.major }} ${{ matrix.jaeger-version }} steps: @@ -45,10 +43,10 @@ jobs: - name: Run cassandra integration tests id: test-execution - run: bash scripts/cassandra-integration-test.sh ${{ matrix.version.image }} ${{ matrix.version.schema }} ${{ matrix.jaeger-version }} + run: bash scripts/cassandra-integration-test.sh ${{ matrix.version.major }} ${{ matrix.version.schema }} ${{ matrix.jaeger-version }} - name: Output Cassandra logs - run: docker logs ${{ steps.test-execution.outputs.cid }} + run: docker compose -f ${{ steps.test-execution.outputs.docker_compose_file }} logs if: ${{ failure() }} - name: Upload coverage to codecov diff --git a/docker-compose/cassandra/v3.yaml b/docker-compose/cassandra/v3.yaml new file mode 100644 index 00000000000..fefe7cc53fa --- /dev/null +++ b/docker-compose/cassandra/v3.yaml @@ -0,0 +1,19 @@ +version: '3.8' + +services: + cassandra: + image: cassandra:3.11 + ports: + - "9042:9042" + - "9160:9160" + networks: + - cassandra-net + healthcheck: + test: ["CMD", "cqlsh", "-e", "describe keyspaces"] + interval: 30s + timeout: 10s + retries: 5 + +networks: + cassandra-net: + driver: bridge diff --git a/docker-compose/cassandra/v4.yaml b/docker-compose/cassandra/v4.yaml new file mode 100644 index 00000000000..c891166191a --- /dev/null +++ b/docker-compose/cassandra/v4.yaml @@ -0,0 +1,19 @@ +version: '3.8' + +services: + cassandra: + image: cassandra:4.0 + ports: + - "9042:9042" + - "9160:9160" + networks: + - cassandra-net + healthcheck: + test: ["CMD", "cqlsh", "-e", "describe keyspaces"] + interval: 30s + timeout: 10s + retries: 5 + +networks: + cassandra-net: + driver: bridge diff --git a/scripts/cassandra-integration-test.sh b/scripts/cassandra-integration-test.sh index e73c628b59d..c02c2454363 100755 --- a/scripts/cassandra-integration-test.sh +++ b/scripts/cassandra-integration-test.sh @@ -15,22 +15,14 @@ check_arg() { } setup_cassandra() { - local tag=$1 - local image=cassandra - local params=( - --detach - --publish 9042:9042 - --publish 9160:9160 - ) - local cid - cid=$(docker run "${params[@]}" "${image}:${tag}") - echo "cid=${cid}" >> "$GITHUB_OUTPUT" - echo "${cid}" + local compose_file=$1 + docker compose -f "$compose_file" up -d + echo "docker_compose_file=${compose_file}" >> "${GITHUB_OUTPUT:-/dev/null}" } teardown_cassandra() { - local cid=$1 - docker kill "${cid}" + local compose_file=$1 + docker compose -f "$compose_file" down exit "${exit_status}" } @@ -53,13 +45,14 @@ apply_schema() { run_integration_test() { local version=$1 + local major_version=${version%%.*} local schema_version=$2 local jaegerVersion=$3 local primaryKeyspace="jaeger_v1_dc1" local archiveKeyspace="jaeger_v1_dc1_archive" + local compose_file="docker-compose/cassandra/v$major_version.yaml" - local cid - cid=$(setup_cassandra "${version}") + setup_cassandra "${compose_file}" apply_schema "$schema_version" "$primaryKeyspace" apply_schema "$schema_version" "$archiveKeyspace" @@ -76,7 +69,7 @@ run_integration_test() { fi # shellcheck disable=SC2064 - trap "teardown_cassandra ${cid}" EXIT + trap "teardown_cassandra ${compose_file}" EXIT }