Skip to content

Commit c4048a5

Browse files
anchitjemasab
andauthored
Run soak tests from EC2 (confluentinc#1908)
* Add OTEL config * Changes to run with EC2 * Remove Kubernetes based soak tests * Add otel collector installation to the bootstrap script * Checkout librdkafka and use same order as build.sh for bootstrap.sh * Use a local librdkafka installation different for every started test * Use test code from the checked out branch instead of the selected CKPy version * Bootstrap the same way as when changing version: with `build.sh` * Migrate to Prometheus remote write * Remove log collector * Initialize error counters to zero * Use test id as client.id * Script to configure all versions of librdkafka and confluent-kafka-python to soak test * PEP8 compliance * Keep last two log files of 50MB max --------- Co-authored-by: Emanuele Sabellico <[email protected]>
1 parent 9ad4e3a commit c4048a5

File tree

18 files changed

+250
-432
lines changed

18 files changed

+250
-432
lines changed

tests/soak/Dockerfile

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/soak/README.md

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,24 @@ OpenTelemetry reporting supported through OTLP.
1010

1111
# Installation
1212

13-
TESTID=normal \
14-
LK_VERSION=v2.2.0 \
15-
CKPY_VERSION=v2.2.0 \
16-
CC_BOOSTRAP_SERVERS=_ \
17-
CC_USERNAME=_ \
18-
CC_PASSWORD=_ \
19-
DOCKER_REPOSITORY=_ ./install.sh
13+
1. Edit `ccloud.config`
14+
15+
2. Edit `otel-config.yaml`
16+
17+
3. the first time:
18+
```bash
19+
./bootstrap.sh <python-branch/tag> <librdkafka-branch/tag>
20+
```
21+
4. next times:
22+
```bash
23+
./build.sh <python-branch/tag> <librdkafka-branch/tag>
24+
```
25+
26+
5.
27+
```bash
28+
. venv/bin/activate
29+
30+
5. Run some tests
31+
```bash
32+
TESTID=<testid> ./run.sh ccloud.config
33+
```

tests/soak/bootstrap.sh

Lines changed: 50 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,58 +2,69 @@
22
#
33
#
44

5-
# Bootstrap EC2 instance (Ubuntu 18.04) for soak client use
5+
# Bootstrap EC2 instance (Ubuntu) for soak client use
66
#
77
# Usage:
88
# $0 <python-branch/tag> <librdkafka-branch/tag>
99

1010
set -e
1111

1212
if [[ $# != 2 ]]; then
13-
echo "Usage: $0 <python-client-branch/tag> <librdkafka-branch/tag>"
13+
echo "Usage: $0 <librdkafka-branch/tag> <python-client-branch/tag>"
1414
exit 1
1515
fi
1616

17-
python_branch=$1
18-
librdkafka_branch=$2
19-
venv=$PWD/venv
17+
librdkafka_branch=$1
18+
python_branch=$2
19+
otel_collector_version=0.130.0
20+
otel_collector_package_url="https://github.com/open-telemetry/"\
21+
"opentelemetry-collector-releases/releases/download/"\
22+
"v${otel_collector_version}/otelcol-contrib_${otel_collector_version}_linux_amd64.deb"
23+
24+
validate_config() {
25+
local errors=0
26+
27+
if grep -q "FILL_IN_REGION_HERE" otel-config.yaml; then
28+
echo "ERROR: AWS region not configured in otel-config.yaml"
29+
echo "Please set AWS_REGION in the file"
30+
errors=$((errors + 1))
31+
fi
32+
33+
if grep -q "FILL_IN_ROLE_ARN_HERE" otel-config.yaml; then
34+
echo "ERROR: AWS Role ARN not configured in otel-config.yaml"
35+
echo "Please set AWS_ROLE_ARN in the file"
36+
errors=$((errors + 1))
37+
fi
38+
39+
if grep -q "FILL_IN_REMOTE_WRITE_ENDPOINT_HERE" otel-config.yaml; then
40+
echo "ERROR: Prometheus endpoint not configured"
41+
echo "Please set PROMETHEUS_ENDPOINT in the file"
42+
errors=$((errors + 1))
43+
fi
44+
45+
if [[ $errors -gt 0 ]]; then
46+
echo "Configuration validation failed. Please fix the above errors."
47+
exit 1
48+
fi
49+
50+
echo "Configuration validation passed."
51+
}
52+
validate_config
2053

2154
sudo apt update
22-
sudo apt install -y git curl make gcc g++ zlib1g-dev libssl-dev libzstd-dev \
23-
python3-dev python3-pip python3-venv
24-
25-
if [[ ! -d confluent-kafka-python ]]; then
26-
git clone https://github.com/confluentinc/confluent-kafka-python
27-
fi
28-
29-
pushd confluent-kafka-python
30-
31-
git checkout $python_branch
32-
33-
echo "Installing librdkafka $librdkafka_branch"
34-
tools/bootstrap-librdkafka.sh --require-ssl $librdkafka_branch /usr
35-
rm -rf tmp-build
36-
37-
# echo "Installing interceptors"
38-
# tools/install-interceptors.sh
39-
40-
echo "Setting up virtualenv in $venv"
41-
if [[ ! -d $venv ]]; then
42-
python3 -m venv $venv
43-
fi
44-
source $venv/bin/activate
45-
46-
pip install -U pip
47-
48-
pip install -v .[soaktest]
49-
50-
popd # ..python
51-
52-
echo "Verifying python client installation"
53-
python -c "import confluent_kafka; print(confluent_kafka.version(), confluent_kafka.libversion())"
54-
55-
deactivate
55+
sudo apt install -y git curl wget make gcc g++ zlib1g-dev libssl-dev \
56+
libzstd-dev python3-dev python3-pip python3-venv
57+
wget -O otel_collector_package.deb $otel_collector_package_url
58+
sudo dpkg -i otel_collector_package.deb
59+
rm otel_collector_package.deb
60+
sudo cp otel-config.yaml /etc/otelcol-contrib/config.yaml
61+
sudo systemctl restart otelcol-contrib
62+
cp setup_all_versions.py $HOME/setup_all_versions.py
63+
chmod +x $HOME/setup_all_versions.py
64+
65+
./build.sh $librdkafka_branch $python_branch
5666

67+
venv=$PWD/venv
5768
echo "All done, activate the virtualenv in $venv before running the client:"
5869
echo "source $venv/bin/activate"
5970

tests/soak/build.sh

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,50 @@ fi
1111

1212
set -eu
1313

14+
testdir=$PWD
15+
mkdir -p $testdir/librdkafka-installation
1416

17+
if [[ ! -d confluent-kafka-python ]]; then
18+
git clone https://github.com/confluentinc/confluent-kafka-python
19+
fi
20+
21+
venv=$PWD/venv
22+
if [[ ! -d $venv ]]; then
23+
echo "Setting up virtualenv in $venv"
24+
python3 -m venv $venv
25+
source $venv/bin/activate
26+
pip install -U pip
27+
pip install -r $testdir/../../requirements/requirements-soaktest.txt
28+
deactivate
29+
fi
1530

1631
echo "Building and installing librdkafka $librdkafka_version"
32+
if [[ ! -d librdkafka ]]; then
33+
git clone https://github.com/confluentinc/librdkafka.git
34+
fi
1735
pushd librdkafka
18-
sudo make uninstall
1936
git fetch --tags
2037
git checkout $librdkafka_version
21-
./configure --reconfigure
38+
echo "Configuring librdkafka $librdkafka_version with prefix $testdir/librdkafka-installation"
39+
./configure --prefix=$testdir/librdkafka-installation
40+
make uninstall
2241
make clean
2342
make -j
24-
sudo make install
43+
make install
2544
popd
2645

46+
export LIBRARY_PATH=$testdir/librdkafka-installation/lib
47+
export LD_LIBRARY_PATH=$testdir/librdkafka-installation/lib
48+
export CPLUS_INCLUDE_PATH=$testdir/librdkafka-installation/include
49+
export C_INCLUDE_PATH=$testdir/librdkafka-installation/include
2750

2851
echo "Building confluent-kafka-python $cflpy_version"
2952
set +u
3053
source venv/bin/activate
54+
python3 -m pip uninstall -y confluent-kafka
3155
set -u
3256
pushd confluent-kafka-python
57+
rm -rf ./build
3358
git fetch --tags
3459
git checkout $cflpy_version
3560
python3 -m pip install .
@@ -38,4 +63,3 @@ popd
3863
echo ""
3964
echo "=============================================================================="
4065
(cd / ; python3 -c 'import confluent_kafka as c; print("python", c.version(), "librdkafka", c.libversion())')
41-

tests/soak/ccloud.config.example

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
bootstrap.servers=<add your bootstraps here>
2+
sasl.mechanisms=PLAIN
3+
security.protocol=SASL_SSL
4+
sasl.username=<your ccloud access key>
5+
sasl.password=<your ccloud secret>
6+
enable.idempotence=true
7+
debug=eos,generic,broker,security,consumer
8+
linger.ms=2
9+
compression.type=lz4

tests/soak/install.sh

Lines changed: 0 additions & 48 deletions
This file was deleted.

tests/soak/njc-py-soak-tests/.helmignore

Lines changed: 0 additions & 23 deletions
This file was deleted.

tests/soak/njc-py-soak-tests/Chart.yaml

Lines changed: 0 additions & 24 deletions
This file was deleted.

tests/soak/njc-py-soak-tests/templates/NOTES.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/soak/njc-py-soak-tests/templates/_helpers.tpl

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)