Skip to content

Commit 491c2e2

Browse files
authored
enable guardrail case in helm e2e tests (#384)
Signed-off-by: Yingchun Guo <[email protected]>
1 parent 59000c5 commit 491c2e2

File tree

3 files changed

+91
-162
lines changed

3 files changed

+91
-162
lines changed

.github/workflows/_helm-e2e.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ on:
1919
default: "xeon"
2020
required: true
2121
type: string
22+
valuefile:
23+
default: "values"
24+
required: true
25+
type: string
2226

2327
env:
2428
CHARTS_DIR: "helm-charts"
@@ -96,10 +100,7 @@ jobs:
96100
run: |
97101
set -xe
98102
echo "should_cleanup=true" >> $GITHUB_ENV
99-
value_file="values.yaml"
100-
if [ "${{ inputs.hardware }}" == "gaudi" ]; then
101-
value_file="gaudi-values.yaml"
102-
fi
103+
value_file="${{ inputs.valuefile }}.yaml"
103104
if [[ ! -f ${{ env.CHART_FOLDER }}/${value_file} ]]; then
104105
echo "No value file found, exist test!"
105106
echo "skip_validate=true" >> $GITHUB_ENV

.github/workflows/manual-helm-cd-workflow.yaml

Lines changed: 59 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ on:
1515
description: "Image tag to be tested"
1616
required: true
1717
type: string
18-
nodes:
19-
default: "xeon,gaudi"
20-
required: true
18+
opea_branch:
19+
default: "main"
20+
description: 'OPEA branch for image build'
21+
required: false
2122
type: string
22-
description: 'Hardwares used to run tests'
2323

2424
env:
2525
CHARTS_DIR: "helm-charts"
@@ -28,41 +28,80 @@ jobs:
2828
get-build-matrix:
2929
runs-on: ubuntu-latest
3030
outputs:
31-
services: ${{ steps.get-services.outputs.services }}
32-
nodes: ${{ steps.get-services.outputs.nodes }}
31+
run_matrix: ${{ steps.get-services.outputs.run_matrix }}
3332
steps:
3433
- name: Checkout out Repo
3534
uses: actions/checkout@v4
3635
with:
3736
fetch-depth: 0
37+
ref: ${{ inputs.opea_branch }}
3838

3939
- name: Get test Services
4040
id: get-services
4141
run: |
4242
set -x
43+
run_matrix="{\"include\":["
4344
if [[ -z "${{ inputs.workloads }}" ]]; then
44-
subfolders=$(find "$CHARTS_DIR" -mindepth 1 -maxdepth 1 -type d ! -name "common" -exec basename {} \; | sed 's/^/"/; s/$/"/' | paste -sd, -)
45-
common_subfolders=$(find "$CHARTS_DIR/common" -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | sed 's|^|"common/|; s/$/"/' | paste -sd, -)
46-
services="[$subfolders,$common_subfolders]"
47-
echo "services=$services" >> $GITHUB_OUTPUT
45+
find "$CHARTS_DIR" -mindepth 1 -maxdepth 1 -type d ! -name "common" -exec basename {} \; | while read -r subfolder; do
46+
for file in "$CHARTS_DIR/$subfolder"/*values.yaml; do
47+
if [ -f "$file" ]; then
48+
if [[ "$file" == *"nv-values.yaml" ]]; then
49+
continue
50+
fi
51+
filename=$(basename "$file" .yaml)
52+
if [[ "$filename" == *"gaudi"* ]]; then
53+
run_matrix="${run_matrix}{\"example\":\"${subfolder}\",\"hardware\":\"gaudi\", \"valuefile\":\"${filename}\"},"
54+
else
55+
run_matrix="${run_matrix}{\"example\":\"${subfolder}\",\"hardware\":\"xeon\", \"valuefile\":\"${filename}\"},"
56+
fi
57+
fi
58+
done
59+
done
60+
find "$CHARTS_DIR/common" -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | while read -r subfolder; do
61+
for file in "$CHARTS_DIR/common/$subfolder"/*values.yaml; do
62+
if [ -f "$file" ]; then
63+
if [[ "$file" == *"nv-values.yaml" ]]; then
64+
continue
65+
fi
66+
filename=$(basename "$file" .yaml)
67+
if [[ "$filename" == *"gaudi"* ]]; then
68+
run_matrix="${run_matrix}{\"example\":\"common/${subfolder}\",\"hardware\":\"gaudi\", \"valuefile\":\"${filename}\"},"
69+
else
70+
run_matrix="${run_matrix}{\"example\":\"common/${subfolder}\",\"hardware\":\"xeon\", \"valuefile\":\"${filename}\"},"
71+
fi
72+
fi
73+
done
74+
done
4875
else
4976
service_list=($(echo ${{ github.event.inputs.workloads }} | tr ',' ' '))
50-
services=$(printf '%s\n' "${service_list[@]}" | sort -u | jq -R '.' | jq -sc '.')
51-
echo "services=$services" >> $GITHUB_OUTPUT
77+
for service in $service_list; do
78+
for file in "$CHARTS_DIR/$service"/*values.yaml; do
79+
if [ -f "$file" ]; then
80+
if [[ "$file" == *"nv-values.yaml" ]]; then
81+
continue
82+
fi
83+
filename=$(basename "$file" .yaml)
84+
if [[ "$filename" == *"gaudi"* ]]; then
85+
run_matrix="${run_matrix}{\"example\":\"$service\",\"hardware\":\"gaudi\", \"valuefile\":\"${filename}\"},"
86+
else
87+
run_matrix="${run_matrix}{\"example\":\"$service\",\"hardware\":\"xeon\", \"valuefile\":\"${filename}\"},"
88+
fi
89+
fi
90+
done
91+
done
5292
fi
53-
node_list=($(echo ${{ github.event.inputs.nodes }} | tr ',' ' '))
54-
nodes=$(printf '%s\n' "${node_list[@]}" | sort -u | jq -R '.' | jq -sc '.')
55-
echo "nodes=$nodes" >> $GITHUB_OUTPUT
93+
run_matrix=$run_matrix"]}"
94+
echo "run_matrix=${run_matrix}"
95+
echo "run_matrix=${run_matrix}" >> $GITHUB_OUTPUT
5696
5797
helm-release:
5898
needs: get-build-matrix
5999
strategy:
60-
matrix:
61-
workload: ${{ fromJSON(needs.get-build-matrix.outputs.services) }}
62-
node: ${{ fromJSON(needs.get-build-matrix.outputs.nodes) }}
100+
matrix: ${{ fromJSON(needs.get-build-matrix.outputs.run_matrix) }}
63101
uses: ./.github/workflows/_helm-e2e.yaml
64102
with:
65103
tag: ${{ inputs.tag }}
66-
workload: ${{ matrix.workload }}
67-
hardware: ${{ matrix.node }}
104+
workload: ${{ matrix.example }}
105+
hardware: ${{ matrix.hardware }}
106+
valuefile: ${{ matrix.valuefile }}
68107
secrets: inherit

.github/workflows/pr-chart-e2e.yaml

Lines changed: 27 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,34 @@ jobs:
4747
cut -d'/' -f3 | sort -u )
4848
run_matrix="{\"include\":["
4949
for chart in ${e2e_charts}; do
50-
if [ -f $CHARTS_DIR/$chart/gaudi-values.yaml ]; then
51-
run_matrix="${run_matrix}{\"example\":\"${chart}\",\"hardware\":\"gaudi\"},"
52-
fi
53-
run_matrix="${run_matrix}{\"example\":\"${chart}\",\"hardware\":\"xeon\"},"
50+
for file in "$CHARTS_DIR/$chart"/*values.yaml; do
51+
if [ -f "$file" ]; then
52+
if [[ "$file" == *"nv-values.yaml" ]]; then
53+
continue
54+
fi
55+
filename=$(basename "$file" .yaml)
56+
if [[ "$filename" == *"gaudi"* ]]; then
57+
run_matrix="${run_matrix}{\"example\":\"${chart}\",\"hardware\":\"gaudi\", \"valuefile\":\"${filename}\"},"
58+
else
59+
run_matrix="${run_matrix}{\"example\":\"${chart}\",\"hardware\":\"xeon\", \"valuefile\":\"${filename}\"},"
60+
fi
61+
fi
62+
done
5463
done
5564
for chart in ${common_charts}; do
56-
if [ -f $CHARTS_DIR/common/$chart/gaudi-values.yaml ]; then
57-
run_matrix="${run_matrix}{\"example\":\"${chart}\",\"hardware\":\"gaudi\",\"directory\":\"common\"},"
58-
fi
59-
run_matrix="${run_matrix}{\"example\":\"${chart}\",\"hardware\":\"xeon\",\"directory\":\"common\"},"
65+
for file in "$CHARTS_DIR/common/$chart"/*values.yaml; do
66+
if [ -f "$file" ]; then
67+
if [[ "$file" == *"nv-values.yaml" ]]; then
68+
continue
69+
fi
70+
filename=$(basename "$file" .yaml)
71+
if [[ "$filename" == *"gaudi"* ]]; then
72+
run_matrix="${run_matrix}{\"example\":\"${chart}\",\"hardware\":\"gaudi\", \"valuefile\":\"${filename}\",\"directory\":\"common\"},"
73+
else
74+
run_matrix="${run_matrix}{\"example\":\"${chart}\",\"hardware\":\"xeon\", \"valuefile\":\"${filename}\",\"directory\":\"common\"},"
75+
fi
76+
fi
77+
done
6078
done
6179
run_matrix=$run_matrix"]}"
6280
echo "run_matrix=${run_matrix}"
@@ -71,134 +89,5 @@ jobs:
7189
with:
7290
workload: ${{ matrix.directory }}/${{ matrix.example }}
7391
hardware: ${{ matrix.hardware }}
74-
# tag: ${{ needs.image-build.outputs.image_tag }}
75-
# opea-branch: "main"
92+
valuefile: ${{ matrix.valuefile }}
7693
secrets: inherit
77-
78-
# needs: job1
79-
# if: always() && ${{ needs.job1.outputs.run_matrix.example.length }} > 0
80-
# strategy:
81-
# matrix: ${{ fromJSON(needs.job1.outputs.run_matrix) }}
82-
# runs-on: ${{ matrix.hardware }}
83-
# continue-on-error: true
84-
# outputs:
85-
# should_cleanup: ${{ steps.set_boolean.outputs.should_cleanup }}
86-
# steps:
87-
# - name: E2e test chart
88-
# run: |
89-
# echo "Matrix - chart: ${{ matrix.example }}"
90-
91-
# - name: Clean Up Working Directory
92-
# run: sudo rm -rf ${{github.workspace}}/*
93-
94-
# - name: Checkout out Repo
95-
# uses: actions/checkout@v4
96-
# with:
97-
# ref: "refs/pull/${{ github.event.number }}/merge"
98-
99-
# - name: Set variables
100-
# run: |
101-
# echo "RELEASE_NAME=${{ matrix.example }}$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV
102-
# echo "NAMESPACE=${{ matrix.example }}-$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV
103-
# echo "ROLLOUT_TIMEOUT_SECONDS=600s" >> $GITHUB_ENV
104-
# echo "KUBECTL_TIMEOUT_SECONDS=60s" >> $GITHUB_ENV
105-
# echo "should_cleanup=false" >> $GITHUB_ENV
106-
# echo "skip_validate=false" >> $GITHUB_ENV
107-
# echo "RELEASENAME=$RELEASE_NAME"
108-
# echo "NAMESPACE=$NAMESPACE"
109-
# if [ -n "${{ matrix.directory }}" ]; then
110-
# echo "CHART_FOLDER=$CHARTS_DIR/${{ matrix.directory }}/${{ matrix.example }}" >> $GITHUB_ENV
111-
# else
112-
# echo "CHART_FOLDER=$CHARTS_DIR/${{ matrix.example }}" >> $GITHUB_ENV
113-
# fi
114-
115-
# - name: Initialize chart testing
116-
# run: |
117-
# # Replace values for CI test environment
118-
# USER_ID=$(whoami)
119-
# CHART_MOUNT=/home/$USER_ID/.cache/huggingface/hub
120-
# HFTOKEN=$(cat /home/$USER_ID/.cache/huggingface/token)
121-
# pushd helm-charts
122-
# # insert a prefix before opea/.*, the prefix is OPEA_IMAGE_REPO
123-
# find . -name '*values.yaml' -type f -exec sed -i "s#repository: opea/*#repository: ${OPEA_IMAGE_REPO}opea/#g" {} \;
124-
# # set OPEA image tag to latest
125-
# find . -name '*values.yaml' -type f -exec sed -i 's#tag: ""#tag: latest#g' {} \;
126-
# # set huggingface token
127-
# find . -name '*values.yaml' -type f -exec sed -i "s#insert-your-huggingface-token-here#${HFTOKEN}#g" {} \;
128-
# # replace the mount dir "Volume: *" with "Volume: $CHART_MOUNT"
129-
# find . -name '*values.yaml' -type f -exec sed -i "s#modelUseHostPath: .*#modelUseHostPath: $CHART_MOUNT#g" {} \;
130-
# # replace the pull policy "IfNotPresent" with "Always"
131-
# find . -name '*values.yaml' -type f -exec sed -i "s#pullPolicy: IfNotPresent#pullPolicy: Always#g" {} \;
132-
# popd
133-
134-
# - name: Helm install
135-
# id: install
136-
# env:
137-
# GOOGLE_CSE_ID: ${{ secrets.GOOGLE_CSE_ID }}
138-
# GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
139-
# run: |
140-
# set -xe
141-
# echo "should_cleanup=true" >> $GITHUB_ENV
142-
# helm-charts/update_dependency.sh && helm dependency update ${{ env.CHART_FOLDER}}
143-
# value_file="values.yaml"
144-
# if [ "${{ matrix.hardware }}" == "gaudi" ]; then
145-
# value_file="gaudi-values.yaml"
146-
# fi
147-
# if ! helm install --create-namespace --namespace $NAMESPACE --wait \
148-
# --timeout "$ROLLOUT_TIMEOUT_SECONDS" \
149-
# --set autodependency.enabled=true \
150-
# --set GOOGLE_API_KEY=${{ env.GOOGLE_API_KEY}} \
151-
# --set GOOGLE_CSE_ID=${{ env.GOOGLE_CSE_ID}} \
152-
# --values ${{ env.CHART_FOLDER}}/${value_file} \
153-
# $RELEASE_NAME ${{ env.CHART_FOLDER}} ; then
154-
# echo "Failed to install chart ${{ matrix.example }}"
155-
# echo "skip_validate=true" >> $GITHUB_ENV
156-
# .github/workflows/scripts/e2e/chart_test.sh dump_pods_status $NAMESPACE
157-
# exit 1
158-
# fi
159-
160-
# - name: Validate e2e test
161-
# if: always()
162-
# run: |
163-
# set -xe
164-
# if $skip_validate; then
165-
# echo "Skip validate"
166-
# else
167-
# LOG_PATH=/home/$(whoami)/logs
168-
# chart=${{ matrix.example }}
169-
# helm test -n $NAMESPACE $RELEASE_NAME --logs |tee ${LOG_PATH}/charts-${chart}.log
170-
# exit_code=$?
171-
# if [ $exit_code -ne 0 ]; then
172-
# echo "Chart ${chart} test failed, please check the logs in ${LOG_PATH}!"
173-
# exit 1
174-
# fi
175-
176-
# echo "Checking response results, make sure the output is reasonable. "
177-
# teststatus=false
178-
# if [[ -f $LOG_PATH/charts-${chart}.log ]] && \
179-
# [[ $(grep -c "^Phase:.*Failed" $LOG_PATH/charts-${chart}.log) != 0 ]]; then
180-
# teststatus=false
181-
# .github/workflows/scripts/e2e/chart_test.sh dump_all_pod_logs $NAMESPACE
182-
# else
183-
# teststatus=true
184-
# fi
185-
186-
# if [ $teststatus == false ]; then
187-
# echo "Response check failed, please check the logs in artifacts!"
188-
# exit 1
189-
# else
190-
# echo "Response check succeed!"
191-
# exit 0
192-
# fi
193-
# fi
194-
195-
# - name: Helm uninstall
196-
# if: always()
197-
# run: |
198-
# if $should_cleanup; then
199-
# helm uninstall $RELEASE_NAME --namespace $NAMESPACE
200-
# if ! kubectl delete ns $NAMESPACE --timeout=$KUBECTL_TIMEOUT_SECONDS; then
201-
# kubectl delete pods --namespace $NAMESPACE --force --grace-period=0 --all
202-
# kubectl delete ns $NAMESPACE --force --grace-period=0 --timeout=$KUBECTL_TIMEOUT_SECONDS
203-
# fi
204-
# fi

0 commit comments

Comments
 (0)