forked from kata-containers/tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cassandra_stress.sh
executable file
·43 lines (35 loc) · 1.6 KB
/
cassandra_stress.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
#
# Copyright (c) 2023 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
set -o pipefail
# General env
SCRIPT_PATH=$(dirname "$(readlink -f "$0")")
source "${SCRIPT_PATH}/../metrics/lib/common.bash"
IMAGE="docker.io/library/cassandra:latest"
CONTAINER_NAME="${CONTAINER_NAME:-cassandra_test}"
DOCKER_IMAGE="cassandra:latest"
PAYLOAD_ARGS="${PAYLOAD_ARGS:-tail -f /dev/null}"
CMD="cassandra -R"
function main() {
local cmds=("docker")
init_env
check_cmds "${cmds[@]}"
sudo -E "${DOCKER_EXE}" pull "${DOCKER_IMAGE}"
sudo -E "${DOCKER_EXE}" save -o "${DOCKER_IMAGE}.tar" "${DOCKER_IMAGE}"
sudo -E "${CTR_EXE}" i import "${DOCKER_IMAGE}.tar"
sudo -E "${CTR_EXE}" run -d --runtime "${CTR_RUNTIME}" "${IMAGE}" "${CONTAINER_NAME}" sh -c "${PAYLOAD_ARGS}"
sudo -E "${CTR_EXE}" t exec --exec-id 1 "${CONTAINER_NAME}" sh -c "${CMD}"
info "Write one million rows"
local WRITE_CMD="./opt/cassandra/tools/bin/cassandra-stress write n=1000000 -rate threads=50"
sudo -E "${CTR_EXE}" t exec --exec-id 2 "${CONTAINER_NAME}" sh -c "${WRITE_CMD}"
info "Load one row with default schema"
local CQL_WRITE_CMD="./opt/cassandra/tools/bin/cassandra-stress write n=1 c1=one -mode native cql3 -log file-create_schema.log"
sudo -E "${CTR_EXE}" t exec --exec-id 3 "${CONTAINER_NAME}" sh -c "${CQL_WRITE_CMD}"
info "Run a write workload using CQL"
local REAL_WRITE_CMD="./opt/cassandra/tools/bin/cassandra-stress write n=1000000 cl=one -mode native cql3 -schema keyspace='keyspace1' -log file=load_1M_rows.log"
sudo -E "${CTR_EXE}" t exec --exec-id 4 "${CONTAINER_NAME}" sh -c "${REAL_WRITE_CMD}"
clean_env_ctr
}
main "$@"