diff --git a/docs/development.md b/docs/development.md index 6c4e7553..a1ce6d7d 100644 --- a/docs/development.md +++ b/docs/development.md @@ -6,23 +6,26 @@ The easiest way to run Gemini for development is to use: ```sh -./scripts/gemini-launcher +./scripts/test.sh ``` -The script starts a Scylla cluster as the system under test and an Apache Cassandra clusters a test oracle using [docker-compose](https://docs.docker.com/compose/) and starts a Gemini run using the two clusters. +The script starts two single node scylla clusters as the system under test and as an oracle using [docker-compose](https://docs.docker.com/compose/) and starts a Gemini run against these clusters + +You can make it to run Cassandra as an oracle: +```sh +./scripts/test.sh cassandra +``` You can also launch the clusters yourself with: ```sh -docker-compose -f scripts/docker-compose.yml up -d +./scripts/prepare-environment.sh ``` And run Gemini against the test oracle and system under test clusters as follows: ```sh -gemini \\ ---test-cluster=$(docker inspect --format='{{ .NetworkSettings.Networks.gemini.IPAddress }}' gemini-test) \\ ---oracle-cluster=$(docker inspect --format='{{ .NetworkSettings.Networks.gemini.IPAddress }}' gemini-oracle) +./scripts/run-gemini-test.sh ``` ### Running unit tests @@ -32,13 +35,3 @@ Geminis own test suite so far only consists of unit tests. Run these in the stan ``` go test -v -race -cover ``` - -The suite has one build tag that controls what is being run: `slow`. This tag should be used for standard unit tests that -for some reason take a long time to run perhaps because they do fuzzing or quick checks. - -Run these tests like this: - -``` -go test -v -race -tags slow -``` - diff --git a/scripts/compile-and-install-gemini.sh b/scripts/compile-and-install-gemini.sh new file mode 100755 index 00000000..38bd5d21 --- /dev/null +++ b/scripts/compile-and-install-gemini.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +function quit () { + echo $2 + exit $1 +} + +go mod download || quit $? "Downloading dependencies failed" +go install ./... || quit $? "Compilation failed" diff --git a/scripts/docker-compose-cassandra.yml b/scripts/docker-compose-cassandra.yml new file mode 100644 index 00000000..6e215338 --- /dev/null +++ b/scripts/docker-compose-cassandra.yml @@ -0,0 +1,25 @@ +version: '3.5' + +networks: + gemini: + name: gemini + driver: bridge + ipam: + driver: default + config: + - subnet: 192.168.100.0/24 + +services: + gemini-oracle: + image: scylladb/scylla:5.2.2 + container_name: gemini-oracle + command: --smp 1 --memory 128M --api-address 0.0.0.0 + networks: + gemini: + + gemini-test: + image: scylladb/scylla:5.2.2 + container_name: gemini-test + command: --smp 1 --memory 128M --api-address 0.0.0.0 + networks: + gemini: diff --git a/scripts/docker-compose.yml b/scripts/docker-compose-scylla.yml similarity index 87% rename from scripts/docker-compose.yml rename to scripts/docker-compose-scylla.yml index a8b746bb..4b707fa7 100644 --- a/scripts/docker-compose.yml +++ b/scripts/docker-compose-scylla.yml @@ -13,12 +13,11 @@ services: gemini-oracle: image: cassandra:3.11.3 container_name: gemini-oracle - restart: always networks: gemini: gemini-test: - image: scylladb/scylla:5.3.0-rc0 + image: scylladb/scylla:5.2.2 container_name: gemini-test command: --smp 1 --memory 128M --api-address 0.0.0.0 networks: diff --git a/scripts/gemini-launcher b/scripts/gemini-launcher deleted file mode 100755 index 909342ec..00000000 --- a/scripts/gemini-launcher +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - -set -e - -function quit () { - echo $2 - exit $1 -} - -ORACLE_NAME=gemini-oracle -TEST_NAME=gemini-test -GEMINI_CMD=/tmp/gemini - -docker-compose --log-level WARNING -f scripts/docker-compose.yml up -d - -ORACLE_IP=$(docker inspect --format='{{ .NetworkSettings.Networks.gemini.IPAddress }}' ${ORACLE_NAME}) -TEST_IP=$(docker inspect --format='{{ .NetworkSettings.Networks.gemini.IPAddress }}' ${TEST_NAME}) -SEED=$(date +%s%N) - -go mod download || quit $? "Downloading dependencies failed" -GOBIN="$(dirname ${GEMINI_CMD})" go install ./... || quit $? "Compilation failed" - -echo "Waiting for ${ORACLE_NAME} to start" -until docker logs ${ORACLE_NAME} 2>&1 | grep "Starting listening for CQL clients" > /dev/null; do sleep 2; done -echo "Waiting for ${TEST_NAME} to start" -until docker logs ${TEST_NAME} 2>&1 | grep "Starting listening for CQL clients" > /dev/null; do sleep 2; done - -$GEMINI_CMD \ - --duration=10m \ - --fail-fast \ - --seed=${SEED} \ - --dataset-size=small \ - --test-cluster=${TEST_IP} \ - --oracle-cluster=${ORACLE_IP} \ - "$@" -exit $? diff --git a/scripts/prepare-environment.sh b/scripts/prepare-environment.sh new file mode 100755 index 00000000..5163059f --- /dev/null +++ b/scripts/prepare-environment.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +docker-compose --log-level WARNING -f scripts/docker-compose-$1.yml up -d + +ORACLE_NAME=gemini-oracle +TEST_NAME=gemini-test + +echo "Waiting for ${ORACLE_NAME} to start" +until docker logs ${ORACLE_NAME} 2>&1 | grep "Starting listening for CQL clients" > /dev/null; do sleep 2; done +echo "Waiting for ${TEST_NAME} to start" +until docker logs ${TEST_NAME} 2>&1 | grep "Starting listening for CQL clients" > /dev/null; do sleep 2; done diff --git a/scripts/run-gemini-test.sh b/scripts/run-gemini-test.sh new file mode 100755 index 00000000..952dcbd6 --- /dev/null +++ b/scripts/run-gemini-test.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -e + +ORACLE_NAME=gemini-oracle +TEST_NAME=gemini-test + +ORACLE_IP=$(docker inspect --format='{{ .NetworkSettings.Networks.gemini.IPAddress }}' ${ORACLE_NAME}) +TEST_IP=$(docker inspect --format='{{ .NetworkSettings.Networks.gemini.IPAddress }}' ${TEST_NAME}) + +GEMINI_CMD=gemini +SEED=$(date +%s%N) +ABS_GEMINI_PATH=$(whereis ${GEMINI_CMD}) +ABS_GEMINI_PATH=${ABS_GEMINI_PATH//gemini: /} + +GOBIN="$(dirname $ABS_GEMINI_PATH)" +$GEMINI_CMD \ + --duration=10m \ + --fail-fast \ + --seed=${SEED} \ + --dataset-size=small \ + --test-cluster=${TEST_IP} \ + --oracle-cluster=${ORACLE_IP} \ + "$@" +exit $? diff --git a/scripts/test.sh b/scripts/test.sh new file mode 100755 index 00000000..74cb5881 --- /dev/null +++ b/scripts/test.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +test_gemini() { + echo -n "Compile gemini" + ./scripts/compile-and-install-gemini.sh || exit 1 + oracle="scylla" + if [ "$1" = "cassandra" ]; then + oracle="cassandra" + shift + fi + + echo -n "Preparing environment with $oracle as oracle" + ./scripts/prepare-environment.sh $oracle || exit 1 + + echo -n "Running test with $oracle as oracle for 'gemini $@' ... " + ./scripts/run-gemini-test.sh --drop-schema $@ + if [ $? -eq 0 ]; then + echo "OK" + else + echo "FAILED" + fi + + exit $? +} + +test_gemini $@ diff --git a/test.sh b/test.sh deleted file mode 100755 index c7a83f37..00000000 --- a/test.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -launcher_cmd=./scripts/gemini-launcher - -test_gemini() { - echo -n "Running test for 'gemini $@' ... " - $launcher_cmd --duration 1s --drop-schema $@ > /dev/null - if [ $? -eq 0 ] - then - echo "OK" - else - echo "FAILED" - fi - exit $? -} - -test_gemini "--non-interactive"