Skip to content

Commit

Permalink
Merge C* and Scylla tests (#316)
Browse files Browse the repository at this point in the history
  • Loading branch information
whatyouhide committed Aug 7, 2023
1 parent 8a28a81 commit 47cabaa
Show file tree
Hide file tree
Showing 10 changed files with 154 additions and 192 deletions.
6 changes: 1 addition & 5 deletions .dialyzer_ignore.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
[
{"lib/xandra/protocol/v3.ex", :call_without_opaque},
{"lib/xandra/protocol/v4.ex", :call_without_opaque},
{"lib/xandra/protocol/v5.ex", :call_without_opaque},
]
[]
171 changes: 69 additions & 102 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,59 +7,63 @@ on:
- main

env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MIX_ENV: test

jobs:
lint:
name: Lint

runs-on: ubuntu-20.04

strategy:
fail-fast: true
matrix:
otp: ["25.3"]
elixir: ["1.14"]

steps:
- name: Clone the repository
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Install OTP and Elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}
otp-version: "25.3"
elixir-version: "1.15.4"

- name: Cache dependencies
id: cache-deps
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
deps
_build
key: ${{ runner.os }}-otp${{ matrix.otp }}-elixir${{ matrix.elixir }}-${{ hashFiles('**/mix.lock') }}
key: |
${{ runner.os }}-otp${{ matrix.otp }}-elixir${{ matrix.elixir }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-otp${{ matrix.otp }}-elixir${{ matrix.elixir }}-
- name: Install and compile dependencies
if: steps.cache-deps.outputs.cache-hit != 'true'
run: mix do deps.get --only test, deps.compile
run: mix do deps.get + deps.compile

- name: Check formatting
run: mix format --check-formatted

- name: Check no unused dependencies
run: mix do deps.get, deps.unlock --check-unused
run: mix deps.unlock --check-unused
if: ${{ steps.cache-deps.outputs.cache-hit != 'true' }}

- name: Compile with --warnings-as-errors
run: mix compile --warnings-as-errors --force

# Don't cache PLTs based on mix.lock hash, as Dialyzer can incrementally update even old ones
# Cache key based on Elixir & Erlang version (also useful when running in matrix)
- name: Cache Dialyzer's PLT
uses: actions/cache@v2
uses: actions/cache@v3
id: cache-plt
with:
path: priv/plts
key: ${{ runner.os }}-otp${{ matrix.otp }}-elixir${{ matrix.elixir }}
key: |
${{ runner.os }}-otp${{ matrix.otp }}-elixir${{ matrix.elixir }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-otp${{ matrix.otp }}-elixir${{ matrix.elixir }}-
# Create PLTs if no cache was found
- name: Create PLTs
Expand All @@ -70,34 +74,58 @@ jobs:
run: mix dialyzer --format github

test:
name: Test (Elixir ${{ matrix.elixir }}, OTP ${{ matrix.otp }}, C* ${{ matrix.cassandra_version }}, Native protocols ${{ matrix.cassandra_native_protocols }})
name: >-
Test (
Elixir ${{ matrix.elixir }},
OTP ${{ matrix.otp }},
C* ${{ matrix.server_versions.cassandra }},
Scylla ${{ matrix.server_versions.scylla }},
Native protocol ${{ matrix.cassandra_native_protocol }}
)
runs-on: ubuntu-20.04

strategy:
fail-fast: false

matrix:
otp:
- "25.3"
elixir:
- "1.15.4"
server_versions:
- cassandra: "4.1"
scylla: "5.1.6"
- cassandra: "3"
scylla: "4.6.3"
cassandra_native_protocol:
- "v3"
- "v4"
include:
# Only C* 4.1+ supports native protocol v5.
- otp: "25.3"
elixir: "1.14"
elixir: "1.15.4"
test_only_cassandra: true
cassandra_version: "4.1"
cassandra_native_protocols: "v4,v5"
lint: true
- otp: "25.3"
elixir: "1.14"
cassandra_version: "3"
cassandra_native_protocols: "v3,v4"
cassandra_native_protocol: "v4"

# Oldest supported Elixir/OTP matrix. We support down to Erlang 21, but
# rustler_precompiled (which we use for nimble_lz4, which we use for testing)
# requires OTP 23+.
- otp: "23.3"
elixir: "1.11"
test_only_cassandra: true
cassandra_version: "3"
cassandra_native_protocols: "v3"
cassandra_native_protocol: "v3"

env:
CASSANDRA_VERSION: ${{ matrix.cassandra_version }}
CASSANDRA_VERSION: ${{ matrix.server_versions.cassandra }}
SCYLLA_VERSION: ${{ matrix.server_versions.scylla }}
CASSANDRA_NATIVE_PROTOCOL: ${{ matrix.cassandra_native_protocol }}

steps:
- name: Clone the repository
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Start Docker and wait for it to be up
run: |
Expand All @@ -107,27 +135,33 @@ jobs:
- name: Install OTP and Elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{matrix.otp}}
elixir-version: ${{matrix.elixir}}
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}

- name: Cache dependencies
id: cache-deps
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
deps
_build
key: ${{ runner.os }}-mix-otp${{ matrix.otp }}-elixir${{ matrix.elixir }}-${{ hashFiles('**/mix.lock') }}
key: |
${{ runner.os }}-mix-otp${{ matrix.otp }}-elixir${{ matrix.elixir }}-${{ hashFiles('**/mix.lock') }}
restore-keys:
${{ runner.os }}-mix-otp${{ matrix.otp }}-elixir${{ matrix.elixir }}-

- name: Install and compile dependencies
if: steps.cache-deps.outputs.cache-hit != 'true'
run: |
mix deps.get --only test
mix deps.compile
run: mix do deps.get --only test, deps.compile

# TODO: eventually figure out why we can't run encryption tests on CI.
- name: Run tests
run: mix test.native_protocols --only-protocols ${{ matrix.cassandra_native_protocols }} --trace --exclude encryption
- name: Run tests for Cassandra and Scylla
if: ${{ !matrix.test_only_cassandra }}
run: mix test.all --trace --exclude encryption

- name: Run tests for Cassandra only
if: ${{ matrix.test_only_cassandra }}
run: mix test --trace --exclude encryption

- name: Dump Docker logs on failure
uses: jwalton/gh-docker-logs@v1
Expand All @@ -144,7 +178,6 @@ jobs:
elixir: "1.13"
cassandra_version: "4.1"
cassandra_native_protocol: "v5"
lint: true
- otp: "24.2"
elixir: "1.13"
cassandra_version: "4.1"
Expand All @@ -167,7 +200,6 @@ jobs:
env:
CASSANDRA_VERSION: ${{ matrix.cassandra_version }}
CASSANDRA_NATIVE_PROTOCOL: ${{ matrix.cassandra_native_protocol }}
NIMBLELZ4_FORCE_BUILD: ${{ matrix.elixir == '1.9' && 'true' }}

steps:
- name: Clone the repository
Expand Down Expand Up @@ -205,68 +237,3 @@ jobs:
- name: Dump Docker logs on failure
uses: jwalton/gh-docker-logs@v1
if: failure()

test_scylla:
name: Test ScyllaDB (Elixir ${{ matrix.elixir }}, OTP ${{ matrix.otp }}, Scylla ${{ matrix.scylla_version }}, Native protocol ${{ matrix.cassandra_native_protocol }})
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
include:
- otp: "24.2"
elixir: "1.13"
scylla_version: "5.1.6"
cassandra_native_protocol: "v4"
- otp: "24.2"
elixir: "1.13"
scylla_version: "4.6.3"
cassandra_native_protocol: "v4"
- otp: "24.2"
elixir: "1.13"
scylla_version: "2.3.1"
cassandra_native_protocol: "v4"
- otp: "24.2"
elixir: "1.13"
scylla_version: "2.3.1"
cassandra_native_protocol: "v3"

env:
SCYLLA_VERSION: ${{ matrix.scylla_version }}
CASSANDRA_NATIVE_PROTOCOL: ${{ matrix.cassandra_native_protocol }}

steps:
- name: Clone the repository
uses: actions/checkout@v2

- name: Start Docker and wait for it to be up
run: |
docker-compose --file docker-compose.scylladb.yml up --detach
./test/docker/health-check-services.sh
- name: Install OTP and Elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{matrix.otp}}
elixir-version: ${{matrix.elixir}}

- name: Cache dependencies
id: cache-deps
uses: actions/cache@v2
with:
path: |
deps
_build
key: ${{ runner.os }}-mix-otp${{ matrix.otp }}-elixir${{ matrix.elixir }}-${{ hashFiles('**/mix.lock') }}

- name: Install and compile dependencies
if: steps.cache-deps.outputs.cache-hit != 'true'
run: |
mix deps.get --only test
mix deps.compile
- name: Run tests
run: mix test.scylladb

- name: Dump Docker logs on failure
uses: jwalton/gh-docker-logs@v1
if: failure()
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
/cover
/deps
/doc
/priv/plts
erl_crash.dump
*.ez
15 changes: 2 additions & 13 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,16 @@ mix test
```

The `--daemon` flag runs the instances as daemons in the background. Give it a
minute between starting the services and running `mix test` since Cassandra
minute between starting the services and running `mix test.all` since Cassandra
takes a while to start. You can check whether the Docker containers are ready
with `docker-compose ps`. To stop the services, run `docker-compose stop`.

To run tests for Scylla, you'll need a different set of services and a different
test task:

```bash
docker-compose --file docker-compose.scylladb.yml up --daemon
mix test.scylladb
```

Use `docker-compose --file docker-compose.scylladb.yml stop` to stop Scylla when
done.

By default, tests run for native protocol *v5* except for a few specific tests
that run on other protocols. If you want to limit the test suite to a native
protocol, use:

```bash
CASSANDRA_NATIVE_PROTOCOL=v4 mix test
CASSANDRA_NATIVE_PROTOCOL=v4 mix test.all
```

[Docker]: https://www.docker.com
Expand Down
45 changes: 0 additions & 45 deletions docker-compose.scylladb.yml

This file was deleted.

Loading

0 comments on commit 47cabaa

Please sign in to comment.