From 94e52f35a61c37541f816b56c60bc1cc5e64b28e Mon Sep 17 00:00:00 2001 From: Dusan Malusev Date: Mon, 9 Sep 2024 14:23:54 +0200 Subject: [PATCH] feature(integration-tests): Run same gemini command as in SCT In order to be sure everything will work properly inside SCT, we are adding `integration-tests` CI pipeline, to run the same command with same arguments on every pull requests and push to the master branch Signed-off-by: Dusan Malusev --- .github/workflows/integration-tests.yml | 65 ++++++++++++++++++++++ Makefile | 72 ++++++++++++++++++------- scripts/docker-compose-cassandra.yml | 6 +-- scripts/docker-compose-scylla.yml | 10 ++-- scripts/prepare-environment.sh | 11 ---- 5 files changed, 124 insertions(+), 40 deletions(-) create mode 100644 .github/workflows/integration-tests.yml delete mode 100755 scripts/prepare-environment.sh diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml new file mode 100644 index 00000000..d0243cf3 --- /dev/null +++ b/.github/workflows/integration-tests.yml @@ -0,0 +1,65 @@ +name: Gemini Integrations Tests + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: + uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: "1.23" + - name: Build + run: make build + - uses: actions/upload-artifact@v4 + with: + name: bin + path: "./bin/gemini" + if-no-files-found: error + retention-days: 1 + test: + needs: [build] + runs-on: ubuntu-latest + strategy: + max-parallel: 1 + matrix: + gemini-features: ["basic", "normal", "all"] + gemini-concurrency: [16] + oracle-scylla-version: ["6.1.1"] + test-scylla-version: ["6.1.1"] + fail-fast: false + steps: + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + - name: Start ScyllaDB + id: scylla + run: | + make scylla-setup \ + SCYLLA_TEST_VERSION=${{ matrix.test-scylla-version }} \ + SCYLLA_ORACLE_VERSION=${{ matrix.oracle-scylla-version }} + - name: Test + shell: bash + run: | + make integration-test \ + CONCURRENCY=${{ matrix.gemini-concurrency }} \ + CQL_FEATURES=${{ matrix.gemini-features }} + - name: Shutdown ScyllaDB + run: | + make scylla-shutdown \ + SCYLLA_TEST_VERSION=${{ matrix.test-scylla-version }} \ + SCYLLA_ORACLE_VERSION=${{ matrix.oracle-scylla-version }} + + - uses: actions/upload-artifact@v4 + with: + path: | + ./results/gemini_result.log + ./results/gemini_seed + if-no-files-found: error + retention-days: 30 diff --git a/Makefile b/Makefile index e56f1c6e..566ede1a 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,12 @@ MAKEFILE_PATH := $(abspath $(dir $(abspath $(lastword $(MAKEFILE_LIST))))) GO111MODULE := on -# GO_UPGRADE - do not remove this comment, used by scripts/go-upgrade.sh GOOS := $(shell uname | tr '[:upper:]' '[:lower:]') GOARCH := $(shell go env GOARCH) +DOCKER_COMPOSE_TESTING := scylla +DOCKER_VERSION := latest + ifndef GOBIN export GOBIN := $(MAKEFILE_PATH)/bin endif @@ -23,26 +25,13 @@ $(GOBIN)/golangci-lint: GOLANGCI_VERSION = 1.60.3 $(GOBIN)/golangci-lint: Makefile $(call dl_tgz,golangci-lint,https://github.com/golangci/golangci-lint/releases/download/v$(GOLANGCI_VERSION)/golangci-lint-$(GOLANGCI_VERSION)-$(GOOS)-amd64.tar.gz) -.PHONY: check-golangci -check-golangci: $(GOBIN)/golangci-lint - $(GOBIN)/golangci-lint run - -# fix-golangci Automated fix for golangci-lint errors. -.PHONY: fix-golangci -fix-golangci: $(GOBIN)/golangci-lint - $(GOBIN)/golangci-lint run --fix - -# check Run all static code analysis. (use make fix to attempt automatic fix) .PHONY: check -check: check-golangci +check: $(GOBIN)/golangci-lint + $(GOBIN)/golangci-lint run -# fix make all static code analysis tools to fix the issues .PHONY: fix -fix: fix-golangci - -.PHONY: test -test: - go test -covermode=atomic -race -coverprofile=coverage.txt -timeout 5m -json -v ./... 2>&1 | gotestfmt -showteststatus +fix: $(GOBIN)/golangci-lint + $(GOBIN)/golangci-lint run --fix .PHONY: build build: @@ -53,4 +42,49 @@ debug-build: .PHONY: build-docker build-docker: - docker build --target production -t scylladb/gemini:latest --compress . + docker build --target production -t scylladb/gemini:$(DOCKER_VERSION) --compress . + +.PHONY: scylla-setup +scylla-setup: + @docker compose -f scripts/docker-compose-$(DOCKER_COMPOSE_TESTING).yml up -d + + until docker logs gemini-oracle 2>&1 | grep "Starting listening for CQL clients" > /dev/null; do sleep 0.2; done + until docker logs gemini-test 2>&1 | grep "Starting listening for CQL clients" > /dev/null; do sleep 0.2; done + +.PHONY: scylla-shutdown +scylla-shutdown: + docker compose -f scripts/docker-compose-$(DOCKER_COMPOSE_TESTING).yml down --volumes + +.PHONY: test +test: + go test -covermode=atomic -race -coverprofile=coverage.txt -timeout 5m -json -v ./... 2>&1 | gotestfmt -showteststatus + +CQL_FEATURES := normal +CONCURRENCY := 1 +DURATION := 10m +WARMUP := 1m + +.PHONY: integration-test +integration-test: + mkdir -p ./results + ./bin/gemini \ + --fail-fast \ + --dataset-size=small \ + --seed=$(date +%s | tee ./results/gemini_seed ) \ + --test-cluster=$(docker inspect --format='{{ .NetworkSettings.Networks.gemini.IPAddress }}' gemini-test) \ + --oracle-cluster=$(docker inspect --format='{{ .NetworkSettings.Networks.gemini.IPAddress }}' gemini-oracle) \ + --outfile ./results/gemini_result.log \ + --duration $(DURATION) \ + --warmup $(WARMUP) \ + -m mixed \ + --non-interactive \ + --cql-features $(CQL_FEATURES) \ + --request-timeout 180s \ + --connect-timeout 120s \ + --async-objects-stabilization-attempts 5 \ + --async-objects-stabilization-backoff 500ms \ + --replication-strategy "{'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}" \ + --oracle-replication-strategy "{'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}" \ + --max-mutation-retries 10 \ + --max-mutation-retries-backoff 500ms \ + -c $(CONCURRENCY) \ No newline at end of file diff --git a/scripts/docker-compose-cassandra.yml b/scripts/docker-compose-cassandra.yml index 8fa6e1f3..956b8052 100644 --- a/scripts/docker-compose-cassandra.yml +++ b/scripts/docker-compose-cassandra.yml @@ -1,5 +1,3 @@ -version: '3.5' - networks: gemini: name: gemini @@ -17,8 +15,8 @@ services: gemini: gemini-test: - image: scylladb/scylla:5.2.2 + image: scylladb/scylla:${SCYLLA_TEST_VERSION:-6.1.1} container_name: gemini-test - command: --smp 2 --memory 1024M --api-address 0.0.0.0 + command: --smp 1 --memory 512M --api-address 0.0.0.0 networks: gemini: diff --git a/scripts/docker-compose-scylla.yml b/scripts/docker-compose-scylla.yml index 1ce5fe94..34d8e451 100644 --- a/scripts/docker-compose-scylla.yml +++ b/scripts/docker-compose-scylla.yml @@ -1,5 +1,3 @@ -version: '3.5' - networks: gemini: name: gemini @@ -11,15 +9,15 @@ networks: services: gemini-oracle: - image: scylladb/scylla:5.2.2 + image: scylladb/scylla:${SCYLLA_ORACLE_VERSION:-6.1.1} container_name: gemini-oracle - command: --smp 2 --memory 512M --api-address 0.0.0.0 + command: --smp 1 --memory 512M --api-address 0.0.0.0 networks: gemini: gemini-test: - image: scylladb/scylla:5.2.2 + image: scylladb/scylla:${SCYLLA_TEST_VERSION:-6.1.1} container_name: gemini-test - command: --smp 2 --memory 512M --api-address 0.0.0.0 + command: --smp 1 --memory 512M --api-address 0.0.0.0 networks: gemini: diff --git a/scripts/prepare-environment.sh b/scripts/prepare-environment.sh deleted file mode 100755 index 5163059f..00000000 --- a/scripts/prepare-environment.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/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