Skip to content

Commit 80b4e35

Browse files
committed
chore: refactor and enhance e2e test script
This commit refactors the existing `e2e_test.sh` script, making it more generic, modular. Key updates include: - Replaces the use of environment variables with command line arguments for better clarity and flexiability. ``` 💡 Examples: # Run test with estimator e2e_test.sh --estimator # Run test with model server e2e_test.sh --server # Run test with dummy weight model or power request e2e_test.sh --test # Enable model database e2e_test.sh --db # Run test with both estimator and server e2e_test.sh --estimator --server # Run test with estimator, server, and model database e2e_test.sh --estimator --server --db ``` - Test logs and other useful information are now stored in the `tmp/e2e` directory for better organization and accessibility. - Adds a `utils.bash` file to store common utility functions - Updates existing GH workflows to align with the refactored script and adds a new step to upload test artifacts for easier debugging in case of failures. - Updates the `README.md` file Signed-off-by: vprashar2929 <[email protected]>
1 parent f9cb2d6 commit 80b4e35

File tree

6 files changed

+492
-186
lines changed

6 files changed

+492
-186
lines changed

.github/workflows/integration-test.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ env:
3535

3636
jobs:
3737
run-integration:
38-
if: ${{ (inputs.base_change != 'true') || ( (inputs.base_change == 'true') && (inputs.docker_secret == 'true') ) }}
3938
runs-on: ubuntu-20.04
4039
steps:
4140
- name: use Kepler action to deploy cluster
@@ -74,24 +73,31 @@ jobs:
7473
- name: test deploying with only estimator
7574
run: |
7675
make deploy
77-
make e2e-test
76+
./tests/e2e_test.sh --estimator ${{ inputs.additional_opts }}
7877
make cleanup
7978
env:
80-
OPTS: ESTIMATOR${{ inputs.additional_opts }}
79+
OPTS: ESTIMATOR
8180
KEPLER_IMAGE_VERSION: ${{ inputs.kepler_tag }}
8281
- name: test deploying with only server
8382
run: |
8483
make deploy
85-
make e2e-test
84+
./tests/e2e_test.sh --server ${{ inputs.additional_opts }}
8685
make cleanup
8786
env:
88-
OPTS: SERVER${{ inputs.additional_opts }}
87+
OPTS: SERVER
8988
KEPLER_IMAGE_VERSION: ${{ inputs.kepler_tag }}
9089
- name: test deploying with estimator and model server
9190
run: |
9291
make deploy
93-
make e2e-test
92+
./tests/e2e_test.sh --estimator --server ${{ inputs.additional_opts }}
9493
make cleanup
9594
env:
96-
OPTS: ESTIMATOR SERVER${{ inputs.additional_opts }}
95+
OPTS: ESTIMATOR SERVER
9796
KEPLER_IMAGE_VERSION: ${{ inputs.kepler_tag }}
97+
98+
- name: upload artifacts on failure
99+
if: ${{ failure() }}
100+
uses: actions/upload-artifact@v3
101+
with:
102+
name: integration-test-artifacts
103+
path: tmp/e2e

.github/workflows/pr.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ jobs:
208208
image_repo: ${{ vars.IMAGE_REPO || 'docker.io/library' }}
209209
image_tag: ${{ needs.check-branch.outputs.tag }}
210210
kepler_tag: release-0.7.11
211-
additional_opts: " TEST"
211+
additional_opts: --test
212212

213213
integration-test-with-exporter:
214214
needs: [check-secret, check-branch, check-change, base-image]
@@ -232,7 +232,7 @@ jobs:
232232
image_repo: ${{ vars.IMAGE_REPO || 'docker.io/library' }}
233233
image_tag: ${{ needs.check-branch.outputs.tag }}
234234
kepler_tag: release-0.7.11
235-
additional_opts: " DB"
235+
additional_opts: --db
236236

237237
integration-test-with-latest:
238238
needs: [check-secret, check-branch, check-change, base-image]
@@ -244,7 +244,7 @@ jobs:
244244
image_repo: ${{ vars.IMAGE_REPO || 'docker.io/library' }}
245245
image_tag: ${{ needs.check-branch.outputs.tag }}
246246
kepler_tag: latest
247-
additional_opts: " DB"
247+
additional_opts: --db
248248

249249
verify_model_training_script:
250250
runs-on: ubuntu-latest

Makefile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,6 @@ manifest:
209209
@./manifests/set.sh "${OPTS}"
210210
@$(MAKE) _print
211211

212-
e2e-test:
213-
chmod +x ./tests/e2e_test.sh
214-
./tests/e2e_test.sh test "${OPTS}"
215-
216212
patch-power-request-client:
217213
kubectl patch ds kepler-exporter -n kepler --patch-file ./manifests/test/power-request-client.yaml
218214

hack/utils.bash

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#
2+
# Copyright 2024.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
is_fn() {
18+
[[ $(type -t "$1") == "function" ]]
19+
return $?
20+
}
21+
22+
header() {
23+
local title=" 🔆🔆🔆 $* 🔆🔆🔆 "
24+
25+
local len=40
26+
if [[ ${#title} -gt $len ]]; then
27+
len=${#title}
28+
fi
29+
30+
echo -e "\n\n \033[1m${title}\033[0m"
31+
echo -n "━━━━━"
32+
printf '━%.0s' $(seq "$len")
33+
echo "━━━━━━━"
34+
35+
}
36+
37+
info() {
38+
echo -e " 🔔 $*" >&2
39+
}
40+
41+
err() {
42+
echo -e " 😱 $*" >&2
43+
}
44+
45+
warn() {
46+
echo -e "$*" >&2
47+
}
48+
49+
ok() {
50+
echo -e "$*" >&2
51+
}
52+
53+
skip() {
54+
echo -e " 🙈 SKIP: $*" >&2
55+
}
56+
57+
fail() {
58+
echo -e " ❌ FAIL: $*" >&2
59+
}
60+
61+
info_run() {
62+
echo -e "$*\n" >&2
63+
}
64+
65+
run() {
66+
echo -e "$*\n" >&2
67+
"$@"
68+
}
69+
70+
die() {
71+
echo -e "\n ✋ $* "
72+
echo -e "──────────────────── ⛔️⛔️⛔️ ────────────────────────\n"
73+
exit 1
74+
}
75+
76+
line() {
77+
local len="$1"
78+
local style="${2:-thin}"
79+
shift
80+
81+
local ch=''
82+
[[ "$style" == 'heavy' ]] && ch=""
83+
84+
printf "$ch%.0s" $(seq "$len") >&2
85+
echo
86+
}

tests/README.md

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -320,20 +320,19 @@ hatch run test -vvv -s ./tests/model_select_test.py
320320
## Integration Test
321321

322322
```bash
323-
./e2e_test.sh test "<deploy options>"
324-
# e.g., ./e2e_test.sh test "ESTIMATOR TEST"
323+
./e2e_test.sh <options>
325324
```
326325

327-
| scenario | test cases | deploy options | status |
328-
|---------------------------------------------|-----------------------------------------------------------------------|-----------------------|----------|
329-
| Kepler with estimator only | Latest Kepler image is connected to estimator | ESTIMATOR | &#x2714; |
330-
| | Estimator can load model from config | ESTIMATOR | &#x2714; |
331-
| | Dummy power request can be made to estimator | ESTIMATOR TEST | &#x2714; |
332-
| Kepler with model server only | Latest Kepler image can request weight model from model server | SERVER | &#x2714; |
333-
| | Dummy weight model request can be made to model server | SERVER TEST | &#x2714; |
334-
| Kepler with estimator and model server | Estimator can load model from model server | ESTIMATOR SERVER | &#x2714; |
335-
| | Model server can load initial model | ESTIMATOR SERVER | &#x2714; |
336-
| | Dummy power request can be made to estimator | ESTIMATOR SERVER TEST | &#x2714; |
337-
| Kepler with model server and online trainer | Kepler can provide metric to online trainer to train | ONLINE | WIP |
338-
| | Dummy prometheus server can provide metric to online trainer to train | ONLINE TEST | WIP |
339-
| | Trained model is updated to pipeline and availble on model server | | WIP |
326+
| scenario | test cases | deploy options | status |
327+
|---------------------------------------------|-----------------------------------------------------------------------|-----------------------------|----------|
328+
| Kepler with estimator only | Latest Kepler image is connected to estimator | --estimator | &#x2714; |
329+
| | Estimator can load model from config | --estimator | &#x2714; |
330+
| | Dummy power request can be made to estimator | --test --estimator | &#x2714; |
331+
| Kepler with model server only | Latest Kepler image can request weight model from model server | --server | &#x2714; |
332+
| | Dummy weight model request can be made to model server | --test --server | &#x2714; |
333+
| Kepler with estimator and model server | Estimator can load model from model server | --estimator --server | &#x2714; |
334+
| | Model server can load initial model | --estimator --server | &#x2714; |
335+
| | Dummy power request can be made to estimator | --test --estimator --server | &#x2714; |
336+
| Kepler with model server and online trainer | Kepler can provide metric to online trainer to train | ONLINE | WIP |
337+
| | Dummy prometheus server can provide metric to online trainer to train | ONLINE TEST | WIP |
338+
| | Trained model is updated to pipeline and availble on model server | | WIP |

0 commit comments

Comments
 (0)