From f233d92b2442fbebd0d3d516729301499699a347 Mon Sep 17 00:00:00 2001 From: Ondrej Polakovic Date: Tue, 15 Feb 2022 13:56:18 +0100 Subject: [PATCH] Use Github actions for CI travis-ci.org switched to travis-ci.com and we wanted to switch to Github Actions anyway. --- .github/workflows/main.yml | 177 +++++++++++++++++++++++++++++++++++++ .travis.yml | 56 ------------ 2 files changed, 177 insertions(+), 56 deletions(-) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..9d8d779fa --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,177 @@ +name: Build + +on: + push: + branches: + - master + pull_request: + types: [ opened, synchronize, reopened ] + +jobs: + build: + name: Unit tests + runs-on: ubuntu-18.04 + strategy: + matrix: + go: [ '1.16', '1.17' ] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-VERSION: ${{ matrix.go }} + - uses: actions/cache@v2 + id: gomod-cache + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('go.mod') }} + restore-keys: | + ${{ runner.os }}-go- + - run: go vet + - name: Run unit tests + run: go test -tags unit -race + integration-cassandra: + timeout-minutes: 10 + needs: + - build + name: Integration Tests + runs-on: ubuntu-18.04 + strategy: + fail-fast: false + matrix: + go: [ '1.16', '1.17' ] + cassandra_version: [ '3.0.24', '3.11.10' ] + auth: [ "false" ] + compressor: [ "snappy" ] + tags: [ "cassandra", "integration", "ccm" ] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go }} + - uses: actions/cache@v2 + id: gomod-cache + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('go.mod') }} + restore-keys: | + ${{ runner.os }}-go- + - name: Install CCM + run: pip install git+https://github.com/riptano/ccm.git@2.8.2 + - name: Start cassandra nodes + run: | + VERSION=${{ matrix.cassandra_version }} + keypath="$(pwd)/testdata/pki" + conf=( + "client_encryption_options.enabled: true" + "client_encryption_options.keystore: $keypath/.keystore" + "client_encryption_options.keystore_password: cassandra" + "client_encryption_options.require_client_auth: true" + "client_encryption_options.truststore: $keypath/.truststore" + "client_encryption_options.truststore_password: cassandra" + "concurrent_reads: 2" + "concurrent_writes: 2" + "rpc_server_type: sync" + "rpc_min_threads: 2" + "rpc_max_threads: 2" + "write_request_timeout_in_ms: 5000" + "read_request_timeout_in_ms: 5000" + "enable_user_defined_functions: true" + ) + + ccm remove test || true + + ccm create test -v $VERSION -n 3 -d --vnodes --jvm_arg="-Xmx256m -XX:NewSize=100m" + ccm updateconf "${conf[@]}" + + export JVM_EXTRA_OPTS=" -Dcassandra.test.fail_writes_ks=test -Dcassandra.custom_query_handler_class=org.apache.cassandra.cql3.CustomPayloadMirroringQueryHandler" + + ccm start --wait-for-binary-proto + ccm status + ccm node1 nodetool status + + proto=4 + if [[ $version == 3.*.* ]]; then + proto=5 + fi + + args="-gocql.timeout=60s -runssl -proto=$proto -rf=3 -clusterSize=3 -autowait=2000ms -compressor=${{ matrix.compressor }} -gocql.cversion=$VERSION -cluster=$(ccm liveset) ./..." + + echo "args=$args" >> $GITHUB_ENV + echo "JVM_EXTRA_OPTS=$JVM_EXTRA_OPTS" >> $GITHUB_ENV + - name: Integration tests + run: | + export JVM_EXTRA_OPTS="${{env.JVM_EXTRA_OPTS}}" + go test -tags "${{ matrix.tags }} gocql_debug" -timeout=5m -race ${{ env.args }} + integration-auth-cassandra: + timeout-minutes: 10 + needs: + - build + name: Integration Tests with auth + runs-on: ubuntu-18.04 + strategy: + fail-fast: false + matrix: + go: [ 1.16, 1.17 ] + cassandra_version: [ 3.11.10 ] + compressor: [ "snappy" ] + tags: [ "integration" ] + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go }} + - uses: actions/cache@v2 + id: gomod-cache + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('go.mod') }} + restore-keys: | + ${{ runner.os }}-go- + - name: Install CCM + run: pip install git+https://github.com/riptano/ccm.git@2.8.2 + - name: Start cassandra nodes + run: | + VERSION=${{ matrix.cassandra_version }} + keypath="$(pwd)/testdata/pki" + conf=( + "client_encryption_options.enabled: true" + "client_encryption_options.keystore: $keypath/.keystore" + "client_encryption_options.keystore_password: cassandra" + "client_encryption_options.require_client_auth: true" + "client_encryption_options.truststore: $keypath/.truststore" + "client_encryption_options.truststore_password: cassandra" + "concurrent_reads: 2" + "concurrent_writes: 2" + "rpc_server_type: sync" + "rpc_min_threads: 2" + "rpc_max_threads: 2" + "write_request_timeout_in_ms: 5000" + "read_request_timeout_in_ms: 5000" + "authenticator: PasswordAuthenticator" + "authorizer: CassandraAuthorizer" + "enable_user_defined_functions: true" + ) + + ccm remove test || true + + ccm create test -v $VERSION -n 1 -d --vnodes --jvm_arg="-Xmx256m -XX:NewSize=100m" + ccm updateconf "${conf[@]}" + + rm -rf $HOME/.ccm/test/node1/data/system_auth + + export JVM_EXTRA_OPTS=" -Dcassandra.test.fail_writes_ks=test -Dcassandra.custom_query_handler_class=org.apache.cassandra.cql3.CustomPayloadMirroringQueryHandler" + + ccm start --wait-for-binary-proto + ccm status + ccm node1 nodetool status + + args="-gocql.timeout=60s -runssl -proto=4 -rf=3 -clusterSize=1 -autowait=2000ms -compressor=${{ matrix.compressor }} -gocql.cversion=$VERSION -cluster=$(ccm liveset) ./..." + + echo "args=$args" >> $GITHUB_ENV + echo "JVM_EXTRA_OPTS=$JVM_EXTRA_OPTS" >> $GITHUB_ENV + sleep 30s + - name: Integration tests + run: | + export JVM_EXTRA_OPTS="${{env.JVM_EXTRA_OPTS}}" + go test -run=TestAuthentication -tags "${{ matrix.tags }} gocql_debug" -timeout=15s -runauth ${{ env.args }} diff --git a/.travis.yml b/.travis.yml index 269c7cf23..e69de29bb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,56 +0,0 @@ -language: go - -sudo: required -dist: trusty - -cache: - directories: - - $HOME/.ccm/repository - - $HOME/.local/lib/python2.7 - -matrix: - fast_finish: true - -branches: - only: - - master - -env: - global: - - GOMAXPROCS=2 - matrix: - - CASS=2.1.21 - AUTH=true - COMPRESSOR=snappy - - CASS=2.2.14 - AUTH=true - COMPRESSOR=snappy - - CASS=2.2.14 - AUTH=false - COMPRESSOR=snappy - - CASS=3.0.18 - AUTH=false - COMPRESSOR=snappy - - CASS=3.11.4 - AUTH=false - COMPRESSOR=snappy - -go: - - 1.16.x - - 1.17.x - -go_import_path: github.com/gocql/gocql - -install: - - ./install_test_deps.sh $TRAVIS_REPO_SLUG - - cd ../.. - - cd gocql/gocql - - go get . - -script: - - set -e - - PATH=$PATH:$HOME/.local/bin bash integration.sh $CASS $AUTH $COMPRESSOR - - go vet . - -notifications: - - email: false