-
Notifications
You must be signed in to change notification settings - Fork 7
129 lines (120 loc) · 4.68 KB
/
_run-stress-test.yaml
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: x (Reusable) Stress Test Loader Run Workflow
on:
workflow_call:
inputs:
GET_RESULTS:
type: boolean
default: false
EC2_IP:
type: string
required: true
REGIONS:
type: string
default: us-west-1, us-west-2
DESIRED_CAPACITY:
type: string
default: "2"
secrets:
GITHUB_ACTION_PULUMI_ACCESS_TOKEN:
required: true
STRESSTESTLOADER_S3_CLIENT_BUCKET_NAME:
required: true
STRESSTESTLOADER_S3_LOG_BUCKET_NAME:
required: true
TARGET_ACCOUNT:
required: true
STRESS_TEST_JSON:
required: true
STRESS_TEST_TOTAL_TIME:
required: true
SSH_PRIVATE_KEY:
required: true
CA_KEY:
required: true
jobs:
stress-test:
runs-on: ubuntu-latest
container:
image: ghcr.io/seconddinner/build:0.0.6
credentials:
username: ${{ github.actor }}
password: ${{ secrets.github_token }}
env:
SOURCE: ${{ github.ref_name }}
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
id-token: write
contents: read
packages: read
steps:
# workaround for the "fatal: detected dubious ownership in repository" error
# this should be a github's problem
# https://github.com/actions/runner-images/issues/6775
- name: Change Owner of Container Working Directory
run: chown root:root .
- name: Checkout
uses: actions/checkout@v3
with:
repository: seconddinner/stress-test-loader
path: stl
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: arn:aws:iam::${{ secrets.TARGET_ACCOUNT }}:role/githubaction-role
aws-region: us-west-2
- name: pulumi stress test infra (update allowed cidr)
run: |
cd infra-pulumi/Infra.Pulumi/Infra.Pulumi
public_ip=$(curl -s https://ipinfo.io/ip)
export stress_test_loader_allowed_cidr="$public_ip/32"
dotnet run --project-name stress-test-loader-pulumi --stack-name stress
working-directory: ./stl
env:
PULUMI_ACCESS_TOKEN: ${{ secrets.GITHUB_ACTION_PULUMI_ACCESS_TOKEN }}
PULUMI_CONFIG_PASSPHRASE: ${{ secrets.GITHUB_ACTION_PULUMI_ACCESS_TOKEN }}
public_key: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH0qfb2vF40fmeIB8GGfkpjlpZVoVrRUQCe75yoNEO9a SD_STRESSTESTLOADER
regions: ${{ inputs.REGIONS }}
desired_capacity: ${{ inputs.DESIRED_CAPACITY }}
s3_client_bucket_name: ${{ secrets.STRESSTESTLOADER_S3_CLIENT_BUCKET_NAME }}
s3_log_bucket_name: ${{ secrets.STRESSTESTLOADER_S3_LOG_BUCKET_NAME }}
- name: generate certs for ssl
run: |
cd stress-test-loader
rm -rf cert
mkdir cert
echo "${{ secrets.CA_KEY }}" > cert/ca-key.pem
bash gen_cert.sh
working-directory: ./stl
- name: run stress test
run: |
cd stress-test-loader/client
echo "${{ inputs.EC2_IP }}" > /tmp/IP.json
echo "${{ secrets.STRESS_TEST_JSON }}" > stresstest.json
aws s3 cp stresstest.json s3://${{ secrets.STRESSTESTLOADER_S3_LOG_BUCKET_NAME }}/stress-test-config-${{ github.run_id }}-${{ github.run_attempt }}.json
go run main.go stresstest.json /tmp/IP.json ${{ secrets.STRESS_TEST_TOTAL_TIME }}
working-directory: ./stl
- name: get stress test result
if: ${{ inputs.GET_RESULTS == true }}
run: |
echo "${{ secrets.SSH_PRIVATE_KEY }}" > id_ed25519
chmod 600 id_ed25519
cat /tmp/IP.json | jq -r '.[][] | .public_ip' > /tmp/IP.txt
cat /tmp/IP.txt | while read -r ip; do
echo "Connecting to $ip through ssh"
ssh -n -i id_ed25519 -o StrictHostKeyChecking=no ubuntu@$ip "tail -n 100 /tmp/stress-test-log"
done
- name: pulumi destroy stress test infra
if: always()
run: |
cd infra-pulumi/Infra.Pulumi/Infra.Pulumi
dotnet run --project-name stress-test-loader-pulumi --stack-name stress --destroy
working-directory: ./stl
env:
PULUMI_ACCESS_TOKEN: ${{ secrets.GITHUB_ACTION_PULUMI_ACCESS_TOKEN }}
PULUMI_CONFIG_PASSPHRASE: ${{ secrets.GITHUB_ACTION_PULUMI_ACCESS_TOKEN }}
public_key: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH0qfb2vF40fmeIB8GGfkpjlpZVoVrRUQCe75yoNEO9a SD_STRESSTESTLOADER
regions: ${{ inputs.REGIONS }}
desired_capacity: ${{ inputs.DESIRED_CAPACITY }}
stress_test_loader_allowed_cidr: "1.1.1.1/32" # dummy value
s3_client_bucket_name: ${{ secrets.STRESSTESTLOADER_S3_CLIENT_BUCKET_NAME }}
s3_log_bucket_name: ${{ secrets.STRESSTESTLOADER_S3_LOG_BUCKET_NAME }}