Skip to content

Commit e831e30

Browse files
feature(cassandra-stress): use ScyllaDB fork of Cassandra Stress instead of downloading Apache Cassandra
Signed-off-by: Dusan Malusev <[email protected]>
1 parent 01ce49a commit e831e30

File tree

10 files changed

+195
-104
lines changed

10 files changed

+195
-104
lines changed

.dockerignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cassandra-download/
2+
target/
3+
.github/

.github/workflows/dockerhub-description.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ jobs:
1818
with:
1919
username: ${{ secrets.DOCKERHUB_USERNAME }}
2020
password: ${{ secrets.DOCKERHUB_TOKEN }}
21-
repository: scylladb/latte
21+
repository: scylladb/cql-stress
2222
short-description: ${{ github.event.repository.description }}
2323
enable-url-completion: true

.github/workflows/release.yml

+44-34
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ name: "Release"
33
on:
44
push:
55
tags:
6-
- "*"
6+
- "v*"
7+
8+
env:
9+
RUSTFLAGS: "--cfg fetch_extended_version_info"
10+
CARGO_TERM_COLOR: always
11+
PYTHONUNBUFFERED: "1"
712

813
jobs:
914
get_tag:
@@ -18,26 +23,22 @@ jobs:
1823
uses: olegtarasov/[email protected]
1924
id: version_tag
2025
with:
21-
tagRegex: "(.*)"
26+
tagRegex: "v(.*)"
2227

2328
release:
2429
runs-on: ubuntu-24.04
30+
needs: [get_tag]
2531
steps:
2632
- name: Create release
2733
env:
28-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29-
tag: ${{ github.ref_name }}
34+
GH_TOKEN: ${{ github.token }}
35+
shell: bash
3036
run: |
3137
set +e
32-
if [[ "$(gh release view $tag 2>&1)" == "release not found" ]]; then
33-
echo "Release '$tag' not found. Creating..."
34-
gh release create "$tag" \
35-
--repo="$GITHUB_REPOSITORY" \
36-
--title="${GITHUB_REPOSITORY#*/} ${tag#}" \
37-
--generate-notes
38-
else
39-
echo "Release '$tag' found. Skipping this step..."
40-
fi
38+
gh release create "v${{ needs.get_tag.outputs.tag }}" \
39+
--repo="$GITHUB_REPOSITORY" \
40+
--title="v${{ needs.get_tag.outputs.tag }}" \
41+
--generate-notes
4142
4243
docker_build:
4344
uses: ./.github/workflows/docker.yml
@@ -59,35 +60,44 @@ jobs:
5960
uses: actions/checkout@v4
6061
- uses: actions-rust-lang/setup-rust-toolchain@v1
6162

62-
- name: Build Binary
63-
uses: actions-rs/cargo@v1
64-
with:
65-
command: build
66-
args: --release
67-
68-
- name: Set Binary Name
69-
id: set_binary_name
70-
run: |
71-
BIN_NAME="cql-stress-${{ needs.get_tag.outputs.tag }}-${{ matrix.os }}"
72-
echo "BIN_NAME=$BIN_NAME" >> $GITHUB_ENV
73-
echo "BIN_NAME=$BIN_NAME"
74-
shell: bash
75-
7663
- name: Get Release Upload URL
77-
id: get_upload_url
64+
shell: bash
7865
run: |
79-
UPLOAD_URL=$(gh release view ${{ inputs.version }} --json uploadUrl -q '.uploadUrl' | sed 's/{.*//')
80-
echo "UPLOAD_URL=${UPLOAD_URL}?name=${{ env.BIN_NAME }}" >> $GITHUB_ENV
66+
UPLOAD_URL=$(gh release view v${{ needs.get_tag.outputs.tag }} --json uploadUrl -q '.uploadUrl' | sed 's/{.*//')
67+
BIN_NAME_CS="cql-stress-cassandra-stress-${{ needs.get_tag.outputs.tag }}-${{ matrix.os }}"
68+
BIN_NAME_SB="cql-stress-scylla-bench-${{ needs.get_tag.outputs.tag }}-${{ matrix.os }}"
69+
echo "BIN_NAME_CS=$BIN_NAME_CS" >> $GITHUB_ENV
70+
echo "BIN_NAME_CS=$BIN_NAME_CS"
71+
echo "BIN_NAME_SB=$BIN_NAME_SB" >> $GITHUB_ENV
72+
echo "BIN_NAME_SB=$BIN_NAME_SB"
73+
echo "UPLOAD_URL_CS=$UPLOAD_URL?name=$BIN_NAME_CS" >> $GITHUB_ENV
74+
echo "UPLOAD_URL_SB=$UPLOAD_URL?name=$BIN_NAME_SB" >> $GITHUB_ENV
8175
env:
8276
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8377

78+
- name: Build
79+
uses: actions-rs/cargo@v1
80+
with:
81+
command: build
82+
args: --profile dist --all
83+
84+
- name: Upload Release Asset
85+
id: upload-release-asset-cs
86+
uses: actions/upload-release-asset@v1
87+
env:
88+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
89+
with:
90+
upload_url: ${{ env.UPLOAD_URL_CS }}
91+
asset_path: ./target/dist/cql-stress-cassandra-stress
92+
asset_name: ${{ env.BIN_NAME_CS }}
93+
asset_content_type: application/octet-stream
8494
- name: Upload Release Asset
85-
id: upload-release-asset-unix
95+
id: upload-release-asset-sb
8696
uses: actions/upload-release-asset@v1
8797
env:
8898
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8999
with:
90-
upload_url: ${{ env.UPLOAD_URL }}
91-
asset_path: ./target/release/cql-stress
92-
asset_name: ${{ env.BIN_NAME }}
100+
upload_url: ${{ env.UPLOAD_URL_SB }}
101+
asset_path: ./target/dist/cql-stress-scylla-bench
102+
asset_name: ${{ env.BIN_NAME_SB }}
93103
asset_content_type: application/octet-stream

.github/workflows/rust.yml

+28-36
Original file line numberDiff line numberDiff line change
@@ -52,75 +52,67 @@ jobs:
5252
uses: actions-rs/cargo@v1
5353
with:
5454
command: build
55-
args: --release --bin cql-stress-cassandra-stress
56-
- name: Build cql-stress-scylla-bench binary
57-
uses: actions-rs/cargo@v1
58-
with:
59-
command: build
60-
args: --release --bin cql-stress-scylla-bench
55+
args: --profile dist --all
6156

6257
- uses: actions/upload-artifact@v4
6358
with:
6459
name: cql-stress-cassandra-stress
65-
path: "./target/release/cql-stress-cassandra-stress"
60+
path: "./target/dist/cql-stress-cassandra-stress"
6661
if-no-files-found: error
6762
retention-days: 1
6863
- uses: actions/upload-artifact@v4
6964
with:
7065
name: cql-stress-scylla-bench
71-
path: "./target/release/cql-stress-scylla-bench"
66+
path: "./target/dist/cql-stress-scylla-bench"
7267
if-no-files-found: error
7368
retention-days: 1
7469
test:
7570
runs-on: ubuntu-24.04
76-
services:
77-
scylladb:
78-
image: scylladb/scylla
79-
ports:
80-
- 9042:9042
81-
options: >-
82-
--name scylla-ci
83-
--health-cmd "cqlsh --debug"
84-
--health-interval 5s
85-
--health-retries 10
86-
volumes:
87-
- ${{ github.workspace }}:/workspace
8871
steps:
8972
- uses: actions/checkout@v4
9073
- uses: actions-rust-lang/setup-rust-toolchain@v1
9174
with:
9275
cache: true
76+
- name: Start ScyllaDB
77+
run: |
78+
docker compose -f ./docker/scylla-test/compose.yml up -d --wait
79+
until docker logs scylla_test 2>&1 | grep "Starting listening for CQL clients" > /dev/null; do sleep 0.2; done
9380
- uses: actions-rs/cargo@v1
9481
with:
9582
command: build
96-
args: --release --tests --features "user-profile"
83+
args: --tests --features "user-profile"
9784
- uses: actions-rs/cargo@v1
9885
with:
9986
command: test
10087
# test threads must be one because else database tests will run in parallel and will result in flaky tests
10188
args: --features "user-profile" -- --test-threads=1
10289

10390
integration-tests:
104-
needs: [build]
91+
needs: [build, test]
92+
cancel-timeout-minutes: 1
93+
timeout-minutes: 20
10594
runs-on: ubuntu-24.04
106-
services:
107-
scylladb:
108-
image: scylladb/scylla
109-
ports:
110-
- 9042:9042
111-
options: >-
112-
--name scylla-ci
113-
--health-cmd "cqlsh --debug"
114-
--health-interval 5s
115-
--health-retries 10
116-
volumes:
117-
- ${{ github.workspace }}:/workspace
95+
concurrency:
96+
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.binary }}
97+
strategy:
98+
max-parallel: 2
99+
matrix:
100+
binary: [cql-stress-cassandra-stress]
118101
steps:
119102
- uses: actions/checkout@v4
120-
- uses: actions/download-artifact@v4
121103
- name: Install python driver
122104
run: pip install scylla-driver
123105
- name: Install pytest
124106
run: pip install -U pytest
107+
- name: Start ScyllaDB
108+
run: |
109+
docker compose -f ./docker/scylla-test/compose.yml up -d --wait
110+
until docker logs scylla_test 2>&1 | grep "Starting listening for CQL clients" > /dev/null; do sleep 0.2; done
111+
- uses: actions/download-artifact@v4
112+
with:
113+
name: ${{ matrix.binary }}
125114
- name: C-S frontend tests
126-
run: pytest -s ./tools/cassandra_stress_ci.py
115+
run: |
116+
mv ${{ matrix.binary }} /usr/local/bin
117+
chmod +x /usr/local/bin/${{ matrix.binary }}
118+
pytest -s ./tools/${{ matrix.binary }}-ci.py

Cargo.toml

+28-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,31 @@ rust-version = "1.85.0"
66

77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
88

9+
[[bin]]
10+
name = "cql-stress-cassandra-stress"
11+
path = "src/bin/cql-stress-cassandra-stress/main.rs"
12+
13+
[[bin]]
14+
name = "cql-stress-scylla-bench"
15+
path = "src/bin/cql-stress-scylla-bench/main.rs"
16+
17+
[profile.release]
18+
codegen-units = 1
19+
lto = true
20+
panic = "abort"
21+
22+
[profile.dist]
23+
inherits = "release"
24+
opt-level = 3
25+
overflow-checks = false
26+
debug = false
27+
strip = true
28+
debug-assertions = false
29+
30+
[profile.dev-opt]
31+
inherits = "dev"
32+
opt-level = 2
33+
934
[dependencies]
1035
anyhow = "1.0.52"
1136
async-trait = "0.1.52"
@@ -62,4 +87,6 @@ scylla = { version = "1.0.0", features = [
6287
] }
6388

6489
[lints.rust]
65-
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(fetch_extended_version_info)'] }
90+
unexpected_cfgs = { level = "warn", check-cfg = [
91+
'cfg(fetch_extended_version_info)',
92+
] }

Dockerfile

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
FROM rust:1.85-slim-bookworm AS builder
2+
3+
WORKDIR /app
4+
5+
ENV RUSTFLAGS="--cfg fetch_extended_version_info"
6+
ENV CARGO_TERM_COLOR=always
7+
8+
COPY . .
9+
10+
RUN apt-get update && apt-get install -y \
11+
build-essential \
12+
cmake \
13+
libclang-dev \
14+
git \
15+
libssl-dev \
16+
pkg-config \
17+
&& cargo build --profile dist --all
18+
19+
FROM debian:bookworm-slim AS production
20+
21+
ENV PATH="${PATH}:/usr/local/bin"
22+
23+
LABEL org.opencontainers.image.source="https://github.com/scylladb/cql-stress"
24+
LABEL org.opencontainers.image.title="ScyllaDB cql-stress"
25+
26+
COPY --from=builder /app/target/dist/cql-stress-cassandra-stress /usr/local/bin/cql-stress-cassandra-stress
27+
COPY --from=builder /app/target/dist/cql-stress-scylla-bench /usr/local/bin/cql-stress-scylla-bench
28+
29+
RUN --mount=type=cache,target=/var/cache/apt apt-get update \
30+
&& apt-get upgrade -y \
31+
&& apt-get install -y libssl3 \
32+
&& apt-get autoremove -y \
33+
&& apt-get clean \
34+
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
35+
&& chmod +x /usr/local/bin/cql-stress-cassandra-stress /usr/local/bin/cql-stress-scylla-bench \
36+
&& ln -s /usr/local/bin/cql-stress-cassandra-stress /usr/local/bin/cassandra-stress \
37+
&& ln -s /usr/local/bin/cql-stress-scylla-bench /usr/local/bin/scylla-bench
38+
39+
ENTRYPOINT [ "bash" ]

docker/scylla_test/compose.yml renamed to docker/scylla-test/compose.yml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ services:
44
container_name: scylla_test
55
ports:
66
- 9042:9042
7+
- 19042:19042
78
healthcheck:
89
test: [ "CMD", "cqlsh", "-e", "select * from system.local" ]
910
interval: 5s

0 commit comments

Comments
 (0)