Skip to content

Commit 93e5829

Browse files
committed
Makefile: support running examples
The `run-examples` target is added to the Makefile to run examples. The examples are built and run against a ScyllaDB instance running in a Docker container. The `SCYLLA_EXAMPLES_TO_RUN` variable is used to specify which examples to build and run. As some examples create the `examples` keyspace and some assume it is not present, a special example `drop_examples_keyspace` is added to drop the `examples` keyspace before running any example. This lets us avoid adding a dependency on `cqlsh` to the system.
1 parent b7856f4 commit 93e5829

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

Makefile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ CASSANDRA_NO_VALGRIND_TEST_FILTER := $(subst ${SPACE},${EMPTY},AsyncTests.Integr
120120
:HeartbeatTests.Integration_Cassandra_HeartbeatFailed)
121121
endif
122122

123+
ifndef SCYLLA_EXAMPLES_URI
124+
SCYLLA_EXAMPLES_URI := 172.43.0.2
125+
endif
126+
123127
ifndef SCYLLA_EXAMPLES_TO_RUN
124128
SCYLLA_EXAMPLES_TO_RUN := \
125129
async \
@@ -151,6 +155,9 @@ SCYLLA_EXAMPLES_TO_RUN := \
151155
# cloud <- out of interest for us, not related to ScyllaDB
152156
# dse <- out of interest for us, not related to ScyllaDB
153157
endif
158+
# The special example `drop_examples_keyspace` is used to drop the `examples` keyspace before running any example,
159+
# because some examples create the keyspace and some assume it is not present.
160+
SCYLLA_EXAMPLES_TO_RUN += drop_examples_keyspace
154161

155162
ifndef CCM_COMMIT_ID
156163
export CCM_COMMIT_ID := master
@@ -330,3 +337,28 @@ endif
330337

331338
run-test-unit: install-cargo-if-missing _update-rust-tooling
332339
@cd ${CURRENT_DIR}/scylla-rust-wrapper; RUSTFLAGS="--cfg cpp_rust_unstable --cfg cpp_integration_testing" cargo test
340+
341+
# Currently not used.
342+
CQLSH := cqlsh
343+
344+
run-examples-scylla: build-examples
345+
@sudo sh -c "echo 2097152 >> /proc/sys/fs/aio-max-nr"
346+
@# Keep `SCYLLA_EXAMPLES_URI` in sync with the `scylla` service in `docker-compose.yml`.
347+
@docker compose -f tests/examples_cluster/docker-compose.yml up -d --wait
348+
349+
@# Instead of using cqlsh, which would impose another dependency on the system,
350+
@# we use a special example `drop_examples_keyspace` to drop the `examples` keyspace.
351+
@# CQLSH_HOST=${SCYLLA_EXAMPLES_URI} ${CQLSH} -e "DROP KEYSPACE IF EXISTS EXAMPLES"; \
352+
353+
@echo "Running examples on scylla ${SCYLLA_VERSION}"
354+
@for example in ${SCYLLA_EXAMPLES_TO_RUN} ; do \
355+
echo -e "\nRunning example: $${example}"; \
356+
build/examples/drop_examples_keyspace/drop_examples_keyspace ${SCYLLA_EXAMPLES_URI} || exit 1; \
357+
build/examples/$${example}/$${example} ${SCYLLA_EXAMPLES_URI} || { \
358+
echo "Example \`$${example}\` has failed!"; \
359+
docker compose -f tests/examples_cluster/docker-compose.yml down; \
360+
exit 42; \
361+
}; \
362+
done
363+
364+
@docker compose -f tests/examples_cluster/docker-compose.yml down --remove-orphans

0 commit comments

Comments
 (0)