-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathmqtt5-java-canary-test.yml
More file actions
69 lines (66 loc) · 2.8 KB
/
mqtt5-java-canary-test.yml
File metadata and controls
69 lines (66 loc) · 2.8 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
version: 0.2
env:
shell: bash
variables:
CANARY_DURATION: 300
CANARY_THREADS: 3
CANARY_TPS: 50
CANARY_CLIENT_COUNT: 10
CANARY_LOG_FILE: 'canary_log.txt'
CANARY_LOG_LEVEL: 'Error'
PACKAGE_NAME: 'aws-crt-java'
CANARY_SERVER_ARN: Mqtt5MosquittoSever
CANARY_BUILD_S3_DST: mqtt5-canary/s3
CODEBUILD_TICKET_ITEM: "IoT SDK for Java"
phases:
install:
commands:
- apt-get update -y
- sudo apt-get install cmake -y
- git submodule update --init --recursive
# Install necessary lib for canary wrapper
- sudo apt-get install gcc python3-dev -y -f
- sudo apt-get install pip -y -f
- python3 -m pip install psutil
- python3 -m pip install boto3
pre_build:
commands:
# Retrieve the private key from Secrets Manager
- DEPLOY_KEY=$(aws secretsmanager get-secret-value --secret-id Aws-crt-canaries-deploy-key --query SecretString --output text)
# Set up SSH configuration
- mkdir -p ~/.ssh
- echo "$DEPLOY_KEY" > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
# Add GitHub to known hosts to avoid host verification prompt
- ssh-keyscan -H github.com >> ~/.ssh/known_hosts
# Configure SSH to use the key for GitHub
- |
cat > ~/.ssh/config << EOF
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa
StrictHostKeyChecking no
EOF
- chmod 600 ~/.ssh/config
build:
commands:
- echo Build started on `date`
# pull and copy canary scripts
- git clone git@github.com:awslabs/aws-crt-canaries.git
- cp aws-crt-canaries/source/mqtt5/*.py codebuild
# Build CRT
- mvn install -DskipTests
# Get secrets needed
- export S3_DST=$(aws secretsmanager get-secret-value --secret-id "$CANARY_BUILD_S3_DST" --query "SecretString" | cut -f2,3 -d":" | sed -e 's/[\\\"\}]//g')
- export GIT_HASH=$(git rev-parse HEAD)
# Get the endpoint, certificate, and key for connecting to IoT Core
- export ENDPOINT=$(aws secretsmanager get-secret-value --secret-id ${CANARY_SERVER_ARN} --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g')
# Run the Canary
- cd ./utils/Canary
- python3 ../../codebuild/CanaryWrapper.py --canary_executable mvn --canary_arguments "compile exec:java -Dexec.mainClass=canary.mqtt5.Mqtt5Canary -Dexec.args=\"--endpoint \"${ENDPOINT}\" --port 1883 --seconds ${CANARY_DURATION} --threads ${CANARY_THREADS} --tps ${CANARY_TPS} --clients ${CANARY_CLIENT_COUNT}\"" --git_hash ${GIT_HASH} --git_repo_name $PACKAGE_NAME --ticket_item "${CODEBUILD_TICKET_ITEM}" --cloudwatch_namespace mqtt5_canary
post_build:
commands:
- echo Build completed on `date`
# Clean up SSH keys for security
- rm -rf ~/.ssh/id_rsa ~/.ssh/config