Skip to content

Commit edf0ef6

Browse files
authored
Mqtt5 canary (#418)
* Add short-term MQTT5 Canary
1 parent 337b17a commit edf0ef6

12 files changed

+2004
-338
lines changed

codebuild/CanaryWrapper.py

Lines changed: 330 additions & 0 deletions
Large diffs are not rendered by default.

codebuild/CanaryWrapper_Classes.py

Lines changed: 1288 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Contains all of the metric reporting functions for the Canary Wrappers
2+
3+
# Needs to be installed prior to running
4+
import psutil
5+
6+
7+
cache_cpu_psutil_process = None
8+
def get_metric_total_cpu_usage(psutil_process : psutil.Process):
9+
global cache_cpu_psutil_process
10+
11+
try:
12+
if (psutil_process == None):
13+
print ("ERROR - No psutil.process passed! Cannot gather metric!", flush=True)
14+
return None
15+
# We always need to skip the first CPU poll
16+
if (cache_cpu_psutil_process != psutil_process):
17+
psutil.cpu_percent(interval=None)
18+
cache_cpu_psutil_process = psutil_process
19+
return None
20+
return psutil.cpu_percent(interval=None)
21+
except Exception as e:
22+
print ("ERROR - exception occurred gathering metrics!")
23+
print ("Exception: " + str(e), flush=True)
24+
return None
25+
26+
# Note: This value is in BYTES.
27+
def get_metric_total_memory_usage_value(psutil_process : psutil.Process):
28+
try:
29+
if (psutil_process == None):
30+
print ("ERROR - No psutil.process passed! Cannot gather metric!", flush=True)
31+
return None
32+
return psutil.virtual_memory()[3]
33+
except Exception as e:
34+
print ("ERROR - exception occurred gathering metrics!")
35+
print ("Exception: " + str(e), flush=True)
36+
return None
37+
38+
39+
def get_metric_total_memory_usage_percent(psutil_process : psutil.Process):
40+
try:
41+
if (psutil_process == None):
42+
print ("ERROR - No psutil.process passed! Cannot gather metric!", flush=True)
43+
return None
44+
return psutil.virtual_memory()[2]
45+
except Exception as e:
46+
print ("ERROR - exception occurred gathering metrics!")
47+
print ("Exception: " + str(e), flush=True)
48+
return None
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
set -euxo pipefail
4+
5+
env
6+
7+
git submodule update --init
8+
9+
# build package
10+
cd $CODEBUILD_SRC_DIR
11+
12+
export AWS_TEST_S3=YES
13+
python -m pip install --verbose .
14+
python codebuild/CanaryWrapper.py --canary_executable 'python test/mqtt5_canary.py' --git_hash ${GIT_HASH} --git_repo_name $PACKAGE_NAME --codebuild_log_path $CODEBUILD_LOG_PATH
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
version: 0.2
2+
#this build spec assumes the manylinux1 image for pypi
3+
#additional packages we installed: cmake 3.5, libcrypto 1.1.0j, gcc 4.8.4
4+
env:
5+
shell: bash
6+
variables:
7+
CANARY_DURATION: 25200
8+
CANARY_THREADS: 3
9+
CANARY_TPS: 50
10+
CANARY_CLIENT_COUNT: 10
11+
CANARY_LOG_FILE: 'canary_log.txt'
12+
CANARY_LOG_LEVEL: 'ERROR'
13+
BUILDER_VERSION: v0.9.21
14+
BUILDER_SOURCE: releases
15+
BUILDER_HOST: https://d19elf31gohf1l.cloudfront.net
16+
PACKAGE_NAME: aws-crt-python
17+
CANARY_TEST_EXE: 'python -m unittest --failfast --verbose 2>&1 | tee /tmp/tests.log test.test_mqtt5_canary'
18+
CANARY_SERVER_ARN: Mqtt5MosquittoSever
19+
phases:
20+
install:
21+
commands:
22+
- add-apt-repository ppa:ubuntu-toolchain-r/test
23+
- apt-get update -y
24+
- apt-get install gcc-7 cmake ninja-build python3 -y
25+
- python3 -m pip install psutil
26+
- python3 -m pip install boto3
27+
pre_build:
28+
commands:
29+
- export CC=gcc-7
30+
build:
31+
commands:
32+
- echo Build started on `date`
33+
- source ./codebuild/mqtt5_test_setup.sh s3://aws-crt-test-stuff/TestIotProdMQTT5EnvironmentVariables.txt us-east-1
34+
- export ENDPOINT=$(aws secretsmanager get-secret-value --secret-id "$CANARY_SERVER_ARN" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g')
35+
- export GIT_HASH=$(git rev-parse HEAD)
36+
- $CODEBUILD_SRC_DIR/codebuild/mqtt5-python-canary-test.sh
37+
post_build:
38+
commands:
39+
- echo Build completed on `date`

codebuild/mqtt5_test_setup.sh

100644100755
File mode changed.

source/mqtt5_client.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2048,4 +2048,4 @@ PyObject *aws_py_mqtt5_client_get_stats(PyObject *self, PyObject *args) {
20482048
Py_RETURN_NONE;
20492049
}
20502050
return NULL;
2051-
}
2051+
}

0 commit comments

Comments
 (0)