-
Notifications
You must be signed in to change notification settings - Fork 19
234 lines (221 loc) · 10.8 KB
/
Perf_Env_PR_Test_CI.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
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
# This is Test PR CI Pipeline against Performance environment when pushing a PR
name: Perf Env PR Test CI
on:
pull_request_target:
types: [labeled, synchronize]
branches: [ main ]
workflow_dispatch:
# Ensures that only one deploy task per branch/environment will run at a time.
concurrency:
group: performance-environment
cancel-in-progress: false
jobs:
approve: # First step
# minimize potential vulnerabilities
if: ${{ contains(github.event.pull_request.labels.*.name, 'ok-to-test') }}
runs-on: ubuntu-latest
steps:
- name: Approve
run: echo For security reasons, all pull requests need to be approved first before running any automated CI.
unittest:
# run all python versions, in other jobs run the latest python
name: unittest
needs: [approve] # Require the first step to finish
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11', '3.12' ]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest pytest-cov
if [[ -f requirements.txt ]]; then pip install -r requirements.txt; fi
if [[ -f tests_requirements.txt ]]; then pip install -r tests_requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: ⚙️ Set Kubeconfig and hosts
env:
KUBECONFIG_CONTENTS: ${{ secrets.PERF_KUBECONFIG }}
RUNNER_PATH: ${{ secrets.RUNNER_PATH }}
OCP_HOSTS: ${{ secrets.PERF_OCP_HOSTS }}
run: |
mkdir -p "$RUNNER_PATH/.kube/"
echo "$KUBECONFIG_CONTENTS" > "$RUNNER_PATH/.kube/config"
echo "KUBECONFIG_PATH=$RUNNER_PATH/.kube/config" >> "$GITHUB_ENV"
sudo tee -a /etc/hosts <<< "$OCP_HOSTS" > /dev/null
- name: 📃 Unittest with pytest
env:
KUBEADMIN_PASSWORD: ${{ secrets.PERF_KUBEADMIN_PASSWORD }}
PIN_NODE1: ${{ secrets.PERF_PIN_NODE1 }}
PIN_NODE2: ${{ secrets.PERF_PIN_NODE2 }}
RUNNER_PATH: ${{ secrets.RUNNER_PATH }}
ELASTICSEARCH: ${{ secrets.PERF_ELASTICSEARCH }}
ELASTICSEARCH_PORT: ${{ secrets.PERF_ELASTICSEARCH_PORT }}
ELASTICSEARCH_USER: ${{ secrets.PERF_ELASTICSEARCH_USER }}
ELASTICSEARCH_PASSWORD: ${{ secrets.PERF_ELASTICSEARCH_PASSWORD }}
IBM_REGION_NAME: ${{ secrets.IBM_REGION_NAME }}
IBM_ENDPOINT_URL: ${{ secrets.IBM_ENDPOINT_URL }}
IBM_ACCESS_KEY_ID: ${{ secrets.IBM_ACCESS_KEY_ID }}
IBM_SECRET_ACCESS_KEY: ${{ secrets.IBM_SECRET_ACCESS_KEY }}
IBM_BUCKET: ${{ secrets.IBM_BUCKET }}
IBM_KEY: ${{ secrets.IBM_KEY }}
RUN_ARTIFACTS_URL: ${{ secrets.PERF_RUN_ARTIFACTS_URL }}
OCP_CLIENT_VERSION: ${{ secrets.PERF_OCP_CLIENT_VERSION }}
run: |
# Install Dockerfile content for pytest
# install oc/kubectl
curl -L "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/${OCP_CLIENT_VERSION}/openshift-client-linux-${OCP_CLIENT_VERSION}.tar.gz" -o "$RUNNER_PATH/openshift-client-linux-${OCP_CLIENT_VERSION}.tar.gz"
tar -xzvf $RUNNER_PATH/openshift-client-linux-${OCP_CLIENT_VERSION}.tar.gz -C $RUNNER_PATH/
rm $RUNNER_PATH/openshift-client-linux-${OCP_CLIENT_VERSION}.tar.gz
cp $RUNNER_PATH/kubectl /usr/local/bin/kubectl
cp $RUNNER_PATH/oc /usr/local/bin/oc
# clone benchmark-operator v1.0.3
git clone -b v1.0.3 https://github.com/cloud-bulldozer/benchmark-operator $RUNNER_PATH/benchmark-operator
# run pytest - only unittest
pytest -v tests/unittest/
integration_test:
name: integration_test
needs: [approve, unittest]
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.12' ]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest pytest-cov
if [[ -f requirements.txt ]]; then pip install -r requirements.txt; fi
if [[ -f tests_requirements.txt ]]; then pip install -r tests_requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: ⚙️ Set Kubeconfig and hosts
env:
KUBECONFIG_CONTENTS: ${{ secrets.PERF_KUBECONFIG }}
RUNNER_PATH: ${{ secrets.RUNNER_PATH }}
OCP_HOSTS: ${{ secrets.PERF_OCP_HOSTS }}
run: |
mkdir -p "$RUNNER_PATH/.kube/"
echo "$KUBECONFIG_CONTENTS" > "$RUNNER_PATH/.kube/config"
echo "KUBECONFIG_PATH=$RUNNER_PATH/.kube/config" >> "$GITHUB_ENV"
sudo tee -a /etc/hosts <<< "$OCP_HOSTS" > /dev/null
- name: 📃 Integration test with pytest
env:
KUBEADMIN_PASSWORD: ${{ secrets.PERF_KUBEADMIN_PASSWORD }}
PIN_NODE1: ${{ secrets.PERF_PIN_NODE1 }}
PIN_NODE2: ${{ secrets.PERF_PIN_NODE2 }}
RUNNER_PATH: ${{ secrets.RUNNER_PATH }}
ELASTICSEARCH: ${{ secrets.PERF_ELASTICSEARCH }}
ELASTICSEARCH_PORT: ${{ secrets.PERF_ELASTICSEARCH_PORT }}
ELASTICSEARCH_USER: ${{ secrets.PERF_ELASTICSEARCH_USER }}
ELASTICSEARCH_PASSWORD: ${{ secrets.PERF_ELASTICSEARCH_PASSWORD }}
IBM_REGION_NAME: ${{ secrets.IBM_REGION_NAME }}
IBM_ENDPOINT_URL: ${{ secrets.IBM_ENDPOINT_URL }}
IBM_ACCESS_KEY_ID: ${{ secrets.IBM_ACCESS_KEY_ID }}
IBM_SECRET_ACCESS_KEY: ${{ secrets.IBM_SECRET_ACCESS_KEY }}
IBM_BUCKET: ${{ secrets.IBM_BUCKET }}
IBM_KEY: ${{ secrets.IBM_KEY }}
RUN_ARTIFACTS_URL: ${{ secrets.PERF_RUN_ARTIFACTS_URL }}
GRAFANA_URL: ${{ secrets.PERF_GRAFANA_URL }}
GRAFANA_API_KEY: ${{ secrets.PERF_GRAFANA_API_KEY }}
GRAFANA_JSON_PATH: ${{ secrets.PERF_GRAFANA_JSON_PATH }}
OCP_CLIENT_VERSION: ${{ secrets.PERF_OCP_CLIENT_VERSION }}
run: |
# Install Dockerfile content for pytest
# install oc/kubectl
curl -L "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/${OCP_CLIENT_VERSION}/openshift-client-linux-${OCP_CLIENT_VERSION}.tar.gz" -o "$RUNNER_PATH/openshift-client-linux-${OCP_CLIENT_VERSION}.tar.gz"
tar -xzvf $RUNNER_PATH/openshift-client-linux-${OCP_CLIENT_VERSION}.tar.gz -C $RUNNER_PATH/
rm $RUNNER_PATH/openshift-client-linux-${OCP_CLIENT_VERSION}.tar.gz
cp $RUNNER_PATH/kubectl /usr/local/bin/kubectl
cp $RUNNER_PATH/oc /usr/local/bin/oc
# install virtctl for VNC
virtctl_version="1.0.0"
curl -L "https://github.com/kubevirt/kubevirt/releases/download/v${virtctl_version}/virtctl-v${virtctl_version}-linux-amd64" -o "$RUNNER_PATH/virtctl"
chmod +x $RUNNER_PATH/virtctl
cp $RUNNER_PATH/virtctl /usr/local/bin/virtctl
rm -rf $RUNNER_PATH/virtctl
# clone benchmark-operator v1.0.3
git clone -b v1.0.3 https://github.com/cloud-bulldozer/benchmark-operator $RUNNER_PATH/benchmark-operator
# run pytest
pytest
e2e:
name: e2e
needs: [approve, unittest, integration_test]
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.12' ]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest pytest-cov
if [[ -f requirements.txt ]]; then pip install -r requirements.txt; fi
if [[ -f tests_requirements.txt ]]; then pip install -r tests_requirements.txt; fi
- name: ⚙️ Set Kubeconfig and hosts
env:
KUBECONFIG_CONTENTS: ${{ secrets.PERF_KUBECONFIG }}
RUNNER_PATH: ${{ secrets.RUNNER_PATH }}
OCP_HOSTS: ${{ secrets.PERF_OCP_HOSTS }}
run: |
mkdir -p "$RUNNER_PATH/.kube/"
echo "$KUBECONFIG_CONTENTS" > "$RUNNER_PATH/.kube/config"
echo "KUBECONFIG_PATH=$RUNNER_PATH/.kube/config" >> "$GITHUB_ENV"
sudo tee -a /etc/hosts <<< "$OCP_HOSTS" > /dev/null
- name: 📃 E2E test
env:
WORKLOAD: "stressng_pod"
KUBEADMIN_PASSWORD: ${{ secrets.PERF_KUBEADMIN_PASSWORD }}
PIN_NODE_BENCHMARK_OPERATOR: ${{ secrets.PERF_PIN_NODE_BENCHMARK_OPERATOR }}
PIN_NODE1: ${{ secrets.PERF_PIN_NODE1 }}
PIN_NODE2: ${{ secrets.PERF_PIN_NODE2 }}
RUNNER_PATH: ${{ secrets.RUNNER_PATH }}
ELASTICSEARCH: ${{ secrets.PERF_ELASTICSEARCH }}
ELASTICSEARCH_PORT: ${{ secrets.PERF_ELASTICSEARCH_PORT }}
ELASTICSEARCH_USER: ${{ secrets.PERF_ELASTICSEARCH_USER }}
ELASTICSEARCH_PASSWORD: ${{ secrets.PERF_ELASTICSEARCH_PASSWORD }}
OCP_CLIENT_VERSION: ${{ secrets.PERF_OCP_CLIENT_VERSION }}
run: |
# Install Dockerfile content for pytest
# install oc/kubectl
curl -L "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/${OCP_CLIENT_VERSION}/openshift-client-linux-${OCP_CLIENT_VERSION}.tar.gz" -o "$RUNNER_PATH/openshift-client-linux-${OCP_CLIENT_VERSION}.tar.gz"
tar -xzvf $RUNNER_PATH/openshift-client-linux-${OCP_CLIENT_VERSION}.tar.gz -C $RUNNER_PATH/
rm $RUNNER_PATH/openshift-client-linux-${OCP_CLIENT_VERSION}.tar.gz
cp $RUNNER_PATH/kubectl /usr/local/bin/kubectl
cp $RUNNER_PATH/oc /usr/local/bin/oc
# clone benchmark-operator v1.0.3
git clone -b v1.0.3 https://github.com/cloud-bulldozer/benchmark-operator $RUNNER_PATH/benchmark-operator
# run main
PYTHONPATH=. python benchmark_runner/main/main.py