Skip to content

Commit

Permalink
Refactor cassandra integration tests to run on both cassandra v3.11 a…
Browse files Browse the repository at this point in the history
…nd v4.0.

Signed-off-by: Ashmita Bohara <ashmita.bohara152@gmail.com>
  • Loading branch information
Ashmita152 committed Aug 23, 2021
1 parent 9614068 commit 08cf2ac
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 20 deletions.
28 changes: 27 additions & 1 deletion .github/workflows/ci-cassandra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ on:
jobs:
cassandra:
runs-on: ubuntu-latest
strategy:
matrix:
version:
- image: cassandra
tag: 3.11
schema: v001 v002 v003
- image: cassandra
tag: 4.0
schema: v004 v004 v004
name: ${{ matrix.version.image }} ${{ matrix.version.tag }}
steps:
- uses: actions/checkout@v2.3.4

Expand All @@ -17,4 +27,20 @@ jobs:
go-version: ^1.17

- name: Run cassandra integration tests
run: bash scripts/cassandra-integration-test.sh
run: bash scripts/cassandra-integration-test.sh ${{ matrix.version.schema }}
services:
cassandra1:
image: ${{ matrix.version.image }}:${{ matrix.version.tag }}
ports:
- 9042:9042
- 9160:9160
cassandra2:
image: ${{ matrix.version.image }}:${{ matrix.version.tag }}
ports:
- 9043:9042
- 9161:9160
cassandra3:
image: ${{ matrix.version.image }}:${{ matrix.version.tag }}
ports:
- 9044:9042
- 9162:9160
22 changes: 3 additions & 19 deletions scripts/cassandra-integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,13 @@

set -ex

# Clean up before starting.
docker rm -f cassandra || true
docker rm -f cassandra2 || true
docker network rm integration_test || true

# Create a network so that the schema container can communicate with the cassandra containers.
docker network create integration_test

# Start cassandra containers whose ports are exposed to localhost to facilitate testing.
docker run -d --name cassandra --network integration_test -p 9042:9042 -p 9160:9160 cassandra:3.9
docker run -d --name cassandra2 --network integration_test -p 9043:9042 -p 9161:9160 cassandra:3.9

# Build the schema container and run it rather than using the existing container in Docker Hub since that
# requires this current build to succeed before this test can use it; chicken and egg problem.
docker build -t jaeger-cassandra-schema-integration-test plugin/storage/cassandra/
docker run --network integration_test -e CQLSH_HOST=cassandra -e TEMPLATE=/cassandra-schema/v001.cql.tmpl jaeger-cassandra-schema-integration-test
docker run --network integration_test -e CQLSH_HOST=cassandra2 -e TEMPLATE=/cassandra-schema/v002.cql.tmpl jaeger-cassandra-schema-integration-test
docker run -e CQLSH_HOST=localhost -e CQLSH_PORT=9042 -e TEMPLATE=/cassandra-schema/$1.cql.tmpl --network=host jaeger-cassandra-schema-integration-test
docker run -e CQLSH_HOST=localhost -e CQLSH_PORT=9043 -e TEMPLATE=/cassandra-schema/$2.cql.tmpl --network=host jaeger-cassandra-schema-integration-test
docker run -e CQLSH_HOST=localhost -e CQLSH_PORT=9044 -e TEMPLATE=/cassandra-schema/$3.cql.tmpl --network=host jaeger-cassandra-schema-integration-test

# Run the test.
export STORAGE=cassandra
make storage-integration-test

# Tear down after.
docker rm -f cassandra
docker rm -f cassandra2
docker network rm integration_test

0 comments on commit 08cf2ac

Please sign in to comment.