-
Notifications
You must be signed in to change notification settings - Fork 20
301 lines (279 loc) · 11.3 KB
/
pmm-package-test-runner.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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
---
name: package-test-pipeline
on:
workflow_dispatch:
inputs:
package_testing_branch:
description: "Target branch for package-testing repository"
type: string
default: "master"
required: true
pmm_server_image:
description: "pmm-server docker image(auto detected if empty)"
required: false
type: string
default: "perconalab/pmm-server:dev-latest"
pmm_client_tarball:
description: "PMM Client tarball link or FB-code"
type: string
# package_repo: experimental | testing | main | pmm2-client-main
expected_version:
description: "expected version"
required: false
type: string
# TODO: investigate switch to actual repo name
repository:
description: "Select Repo to install PMM Client:"
required: true
default: "dev-latest"
type: choice
options:
- release
- release candidate
- dev-latest
metrics_mode:
description: "Select the Metrics Mode for PMM Client:"
required: true
default: "auto"
type: choice
options:
- auto
- push
- pull
playbook:
description: "Playbook file to run(without extension)"
type: string
default: "pmm2-client_integration"
required: true
test_name:
description: "Optional pretty test name"
type: string
required: false
os:
description: "Select OS to run test in:"
required: true
default: "jammy-x64"
type: choice
options:
- bionic-x64
- bullseye-x64
- buster-x64
- focal-x64
- jammy-x64
- centos-7-x64
- ol-8-x64
- ol-9-x64
workflow_call:
inputs:
package_testing_branch:
type: string
default: "master"
required: true
pmm_server_image:
required: false
type: string
pmm_client_tarball:
required: false
type: string
expected_version:
required: false
type: string
repository:
required: true
default: "dev-latest"
type: string
metrics_mode:
required: true
default: "auto"
type: string
playbook:
type: string
default: "pmm2-client_integration"
required: true
test_name:
type: string
required: false
os:
description: "Select OS to run test in:"
required: true
default: "jammy-x64"
type: string
jobs:
test:
name: ${{ inputs.test_name || inputs.playbook}}
runs-on: ubuntu-latest
timeout-minutes: 90
env:
SHA: ${{ inputs.sha || 'null' }}
PACKAGE_TESTING_BRANCH: ${{ inputs.package_testing_branch || 'master' }}
PMM_SERVER_IMAGE: ${{ inputs.pmm_server_image }}
TARBALL: ${{ inputs.pmm_server_image || 'null' }}
EXPECTED_VERSION: ${{ inputs.expected_version }}
REPO: ${{ inputs.repository || 'dev-latest' }}
METRICS_MODE: ${{ inputs.metrics_mode || 'auto' }}
PLAYBOOK: ${{ inputs.playbook }}
steps:
- name: "Create status check"
if: ${{ env.SHA != 'null' }}
uses: percona/gh-action-github-status-action@v1
continue-on-error: true
with:
authToken: ${{ secrets.GITHUB_TOKEN }}
context: "${{ inputs.test_name }} Package test"
description: "Test execution ${{ job.status }}"
state: "pending"
repository: ${{ github.repository }}
target_url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
sha: ${{ env.SHA }}
- name: 'Checkout package-testing: "${{ inputs.package_testing_branch }}"'
uses: actions/checkout@v3
with:
ref: ${{ inputs.package_testing_branch }}
- name: 'Convert choices'
run: |
### pmm-server docker image ###
if [[ -z "${{ env.PMM_SERVER_IMAGE }}" ]]; then
if [[ "${{ inputs.repository }}" = "dev-latest" ]]; then
echo "PMM_SERVER_IMAGE=perconalab/pmm-server:dev-latest" >> $GITHUB_ENV
fi
if [[ "${{ inputs.repository }}" =~ "candidate" ]]; then
rc_latest=$(wget -q "https://registry.hub.docker.com/v2/repositories/perconalab/pmm-client/tags?page_size=25&name=rc" -O - | jq -r .results[].name | grep 2.*.*-rc$ | sort -V | tail -n1)
echo "PMM_SERVER_IMAGE=perconalab/pmm-server:$rc_latest" >> $GITHUB_ENV
fi
if [[ "${{ inputs.repository }}" = "release" ]]; then
r_latest=$(wget -q https://registry.hub.docker.com/v2/repositories/percona/pmm-client/tags -O - | jq -r .results[].name | grep -v latest | sort -V | tail -n1)
echo "PMM_SERVER_IMAGE=percona/pmm-server:$r_latest" >> $GITHUB_ENV
fi
fi
echo "${{ env.PMM_SERVER_IMAGE }}"
### pmm2-client repository ###
if [[ "${{ inputs.repository }}" = "dev-latest" ]]; then
echo "REPO=experimental" >> $GITHUB_ENV
fi
if [[ "${{ inputs.repository }}" =~ "candidate" ]]; then
echo "REPO=testing" >> $GITHUB_ENV
fi
if [[ "${{ inputs.repository }}" = "release" ]]; then
echo "REPO=release" >> $GITHUB_ENV
fi
echo "${{ env.REPO }}"
### vagrant vm ###
if [[ "${{ inputs.os }}" =~ "buster" ]]; then
echo "VM_BOX=generic/debian10" >> $GITHUB_ENV
fi
if [[ "${{ inputs.os }}" =~ "bullseye" ]]; then
echo "VM_BOX=generic/debian11" >> $GITHUB_ENV
fi
if [[ "${{ inputs.os }}" =~ "bionic" ]]; then
echo "VM_BOX=generic/ubuntu1804" >> $GITHUB_ENV
fi
if [[ "${{ inputs.os }}" =~ "focal" ]]; then
echo "VM_BOX=ubuntu/focal64" >> $GITHUB_ENV
fi
if [[ "${{ inputs.os }}" =~ "jammy" ]]; then
echo "VM_BOX=generic/ubuntu2204" >> $GITHUB_ENV
fi
if [[ "${{ inputs.os }}" =~ "centos-7" ]]; then
echo "VM_BOX=generic/centos7" >> $GITHUB_ENV
fi
if [[ "${{ inputs.os }}" =~ "ol-8" ]]; then
echo "VM_BOX=generic/oracle8" >> $GITHUB_ENV
fi
if [[ "${{ inputs.os }}" =~ "ol-9" ]]; then
echo "VM_BOX=generic/oracle9" >> $GITHUB_ENV
fi
echo "${{ env.VM_BOX }}"
### test name -> playbook map ###
# basic -> pmm2-client.yml
# basic upgrade -> pmm2-client_upgrade.yml
# basic tarball -> pmm2-client_custom_path.yml
# config password -> pmm2-client_integration_auth_config.yml
# register password -> pmm2-client_integration_auth_register.yml
# tarball setup password -> pmm2-client_integration_auth_setup.yml
# tarball path -> pmm2-client_integration_custom_path.yml
# tarball port -> pmm2-client_integration_custom_port.yml
# integration upgrade port -> pmm2-client_integration_upgrade_custom_port.yml
######### Matrix tests
# integration -> pmm2-client_integration.yml
# integration upgrade -> pmm2-client_integration_upgrade.yml
# tarball upgrade path -> pmm2-client_integration_upgrade_custom_path.yml
- name: 'Setup "${{ env.PMM_SERVER_IMAGE }}"'
run: |
docker create -v /srv --name pmm-server-data ${{ env.PMM_SERVER_IMAGE }}
docker run -d -p 80:80 -p 443:443 -p 9000:9000 \
--volumes-from pmm-server-data --name pmm-server --restart always ${{ env.PMM_SERVER_IMAGE }}
- name: "Setup tools"
run: |
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates ansible virtualbox vagrant
if [[ "${{ inputs.os }}" =~ "buster" ]]; then
vagrant plugin install vagrant-vbguest
fi
- name: "Wait for PMM Server to be healthy"
run: |
timeout 240 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' http://127.0.0.1/v1/readyz)" != "200" ]]; do sleep 2; done' || false
- name: "Create vagrantfile"
working-directory: ./
run: |
pwd
# mkdir -p ~/test-vm/
# cat > ~/test-vm/Vagrantfile <<EOF
cat > Vagrantfile <<EOF
Vagrant.require_version ">= 1.7.0"
Vagrant.configure(2) do |config|
config.vm.box = "${{ env.VM_BOX }}"
${{ contains(env.VM_BOX, 'debian10') && 'config.vbguest.auto_update = true' }}
config.ssh.insert_key = false
config.vm.define :CLIENT_TEST do |t|
end
config.vm.synced_folder "/home/runner/work/package-testing/package-testing/", "/pmm/package-testing/"
config.vm.provision "shell", privileged: true, inline: <<-SHELL
## Set environment variables...
export PMM_SERVER_IP=10.0.2.2:443
export METRICS_MODE=${{ env.METRICS_MODE }}
export PMM_VERSION="${{ env.EXPECTED_VERSION }}"
export install_repo=${{ env.REPO }}
export tarball_link=${{ env.TARBALL }}
if [[ "${{ env.VM_BOX }}" =~ "centos7" ]]; then
sudo yum install -y epel-release
sudo yum -y update
sudo yum install -y ansible git wget
fi
if [[ "${{ env.VM_BOX }}" =~ "oracle" ]]; then
sudo yum install -y epel-release
sudo yum -y update
sudo yum install -y ansible-core git wget
fi
if [[ "${{ env.VM_BOX }}" =~ "debian" ]]; then
sudo apt-get install -y dirmngr gnupg2
echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" | sudo tee -a /etc/apt/sources.list > /dev/null
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367
sudo apt update -y
sudo apt-get install -y ansible git wget
fi
if [[ "${{ env.VM_BOX }}" =~ "ubuntu" ]]; then
sudo apt update -y
sudo apt install -y software-properties-common
sudo apt-add-repository --yes --update ppa:ansible/ansible
sudo apt-get install -y ansible git wget
fi
cd /pmm/package-testing/playbooks
ansible-playbook -vv --connection=local --inventory 127.0.0.1, --limit 127.0.0.1 ${{ env.PLAYBOOK }}.yml
SHELL
end
EOF
- name: "Run ${{ inputs.test_name }} test on ${{ inputs.os }}"
working-directory: ./
run: vagrant up
- name: "Create status check"
uses: percona/gh-action-github-status-action@v1
if: ${{ env.SHA != 'null' && always() }}
continue-on-error: true
with:
authToken: ${{ secrets.GITHUB_TOKEN }}
context: "${{ inputs.test_name }} Package test"
description: "Test execution ${{ job.status }}"
state: ${{ job.status }}
repository: ${{ github.repository }}
target_url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
sha: ${{ env.SHA }}