-
Notifications
You must be signed in to change notification settings - Fork 1
194 lines (166 loc) · 7.03 KB
/
custom_performance_test.yml
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
name: Custom Performance Test
on:
workflow_dispatch:
inputs:
cloud:
description: 'Choose Cloud Provider'
required: true
type: choice
default: Azure
options:
- Azure
- AWS
- GCP
custom_cluster_descriptor:
description: 'Custom Cluster Descriptor'
required: true
type: string
default: '.github/custom-tests/comparison/all/cluster.tf'
custom_deployments_descriptor:
description: 'Custom Deployments Descriptor'
required: true
type: string
default: '.github/custom-tests/comparison/all/deployments.tf'
custom_tests_descriptor:
description: 'Custom Tests Descriptor'
required: true
type: string
default: '.github/custom-tests/comparison/all/tests.tf'
env:
provider: ${{ inputs.cloud == 'Azure' && 'aks' || (inputs.cloud == 'AWS' && 'eks' || 'gke') }}
concurrency:
group: ${{ inputs.cloud }}
jobs:
performance_test:
name: "${{ inputs.cloud }} custom full performance test run"
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Configure AKS credentials
if: ${{ inputs.cloud == 'Azure' }}
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Configure AWS credentials
if: ${{ inputs.cloud == 'AWS' }}
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ vars.AWS_CLUSTER_LOCATION }}
- name: Authenticate into gcloud
if: ${{ inputs.cloud == 'GCP' }}
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_CREDENTIALS }}
- name: Install gcloud CLI
if: ${{ inputs.cloud == 'GCP' }}
uses: google-github-actions/[email protected]
- name: Install gcloud k8s auth component
if: ${{ inputs.cloud == 'GCP' }}
run: gcloud components install gke-gcloud-auth-plugin
- name: Install Terraform
uses: hashicorp/[email protected]
with:
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
terraform_version: "1.8.2"
- name: Create Terraform Cloud descriptors
run: |
cp ${{ env.provider }}/terraform.cloud.tf.example ${{ env.provider }}/terraform.cloud.tf
cp .github/${{ env.provider }}/deployments.tf deployments/terraform.cloud.tf
cp .github/${{ env.provider }}/tests.tf tests/terraform.cloud.tf
- name: Copy Terraform descriptor
run: |
cp ${{ inputs.custom_cluster_descriptor }} ${{ env.provider }}/main.tfvars
cp ${{ inputs.custom_deployments_descriptor }} deployments/main.tfvars
cp ${{ inputs.custom_tests_descriptor }} tests/main.tfvars
- name: AKS cluster
if: ${{ inputs.cloud == 'Azure' }}
run: |
cd aks
terraform init
terraform apply \
--var="cluster_location=${{ vars.AZURE_CLUSTER_LOCATION }}" \
--var="cluster_machine_type=${{ vars.AZURE_CLUSTER_MACHINE_TYPE }}" \
--var="upstream_machine_type=${{ vars.AZURE_UPSTREAM_MACHINE_TYPE }}" \
--var="tests_machine_type=${{ vars.AZURE_TEST_MACHINE_TYPE }}" \
--var-file=main.tfvars \
--auto-approve
- name: EKS cluster
if: ${{ inputs.cloud == 'AWS' }}
run: |
cd eks
terraform init
terraform apply \
--var="cluster_location=${{ vars.AWS_CLUSTER_LOCATION }}" \
--var="cluster_machine_type=${{ vars.AWS_CLUSTER_MACHINE_TYPE }}" \
--var="upstream_machine_type=${{ vars.AWS_UPSTREAM_MACHINE_TYPE }}" \
--var="tests_machine_type=${{ vars.AWS_TEST_MACHINE_TYPE }}" \
--var-file=main.tfvars \
--auto-approve
- name: GKE cluster
if: ${{ inputs.cloud == 'GCP' }}
run: |
cd gke
terraform init
terraform apply \
--var="project=${{ secrets.GCP_PROJECT }}" \
--var="cluster_location=${{ vars.GCP_CLUSTER_LOCATION }}" \
--var="cluster_machine_type=${{ vars.GCP_CLUSTER_MACHINE_TYPE }}" \
--var="upstream_machine_type=${{ vars.GCP_UPSTREAM_MACHINE_TYPE }}" \
--var="tests_machine_type=${{ vars.GCP_TEST_MACHINE_TYPE }}" \
--var-file=main.tfvars \
--auto-approve
- name: Connect to AKS cluster
if: ${{ inputs.cloud == 'Azure' }}
run: |
az aks get-credentials \
--resource-group "pt-${{ vars.AZURE_CLUSTER_LOCATION }}" \
--name "pt-${{ vars.AZURE_CLUSTER_LOCATION }}"
kubectl config rename-context $(kubectl config current-context) performance-testing
- name: Connect to EKS cluster
if: ${{ inputs.cloud == 'AWS' }}
run: |
aws eks --region "${{ vars.AWS_CLUSTER_LOCATION }}" update-kubeconfig --name "pt-${{ vars.AWS_CLUSTER_LOCATION }}"
kubectl config rename-context $(kubectl config current-context) performance-testing
- name: Connect to GKE cluster
if: ${{ inputs.cloud == 'GCP' }}
run: |
gcloud container clusters get-credentials "pt-${{ vars.GCP_CLUSTER_LOCATION }}" \
--zone "${{ vars.GCP_CLUSTER_LOCATION }}" \
--project "${{ secrets.GCP_PROJECT }}"
kubectl config rename-context $(kubectl config current-context) performance-testing
- name: Run Terraform action on deployments
run: |
cd deployments
terraform init
terraform apply \
--var="tyk_license=${{ secrets.DASH_LICENSE }}" \
--var-file=main.tfvars \
--var="kubernetes_config_context=performance-testing" \
--auto-approve
- name: Run Tests
run: |
cd tests
terraform init
terraform apply \
--var-file=main.tfvars \
--var="kubernetes_config_context=performance-testing" \
--auto-approve
- name: Test Grafana Snapshot
run: |
kubectl logs -n dependencies $(kubectl get pods -n dependencies --selector=app=snapshot-job -o jsonpath='{.items[-1].metadata.name}') --tail=1
- name: Destroy Tests
run: cd tests && terraform destroy --var="kubernetes_config_context=performance-testing" --auto-approve
- name: Destroy testing resources
run: cd deployments && terraform destroy --var="kubernetes_config_context=performance-testing" --auto-approve
- name: Destroy AKS cluster
if: ${{ inputs.cloud == 'Azure' }}
run: cd aks && terraform destroy --auto-approve
- name: Destroy EKS cluster
if: ${{ inputs.cloud == 'AWS' }}
run: cd eks && terraform destroy --auto-approve
- name: Destroy GKE cluster
if: ${{ inputs.cloud == 'GCP' }}
run: cd gke && terraform destroy --auto-approve