Skip to content

Commit

Permalink
fix(test.sh): split it into multiple files
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Kropachev committed Jun 11, 2023
1 parent cfbf0fd commit 249fecf
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 71 deletions.
25 changes: 9 additions & 16 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,26 @@ The easiest way to run Gemini for development is to use:


```sh
./scripts/gemini-launcher
./scripts/test.sh <test parameters>
```

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 <test parameters>
```

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 <test parameters>
```

### Running unit tests
Expand All @@ -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
```

9 changes: 9 additions & 0 deletions scripts/compile-and-install-gemini.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

function quit () {
echo $2
exit $1
}

go mod download || quit $? "Downloading dependencies failed"
go install ./... || quit $? "Compilation failed"
25 changes: 25 additions & 0 deletions scripts/docker-compose-cassandra.yml
Original file line number Diff line number Diff line change
@@ -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:
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
36 changes: 0 additions & 36 deletions scripts/gemini-launcher

This file was deleted.

11 changes: 11 additions & 0 deletions scripts/prepare-environment.sh
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions scripts/run-gemini-test.sh
Original file line number Diff line number Diff line change
@@ -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 $?
26 changes: 26 additions & 0 deletions scripts/test.sh
Original file line number Diff line number Diff line change
@@ -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 $@
17 changes: 0 additions & 17 deletions test.sh

This file was deleted.

0 comments on commit 249fecf

Please sign in to comment.