Skip to content

Commit 72e6c92

Browse files
committed
Makefile: support running examples
The `run-examples-scylla` 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 run to drop the `examples` keyspace before running any example. This lets us avoid adding a dependency on `cqlsh` to the system.
1 parent 90d635b commit 72e6c92

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

Makefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ CASSANDRA_NO_VALGRIND_TEST_FILTER := $(subst ${SPACE},${EMPTY},AsyncTests.Integr
122122
:HeartbeatTests.Integration_Cassandra_HeartbeatFailed)
123123
endif
124124

125+
ifndef SCYLLA_EXAMPLES_URI
126+
# In sync with the docker compose file.
127+
SCYLLA_EXAMPLES_URI := 172.43.0.2
128+
endif
129+
125130
ifndef SCYLLA_EXAMPLES_TO_RUN
126131
SCYLLA_EXAMPLES_TO_RUN := \
127132
async \
@@ -337,3 +342,28 @@ endif
337342

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

0 commit comments

Comments
 (0)