-
Notifications
You must be signed in to change notification settings - Fork 3
221 lines (200 loc) · 7.3 KB
/
cloud-e2e.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
name: Cloud E2E
on:
workflow_dispatch:
inputs:
TEST_TYPE:
description: "The specify version of GO (e.g. openapi-test)"
type: string
required: false
default: 'openapi-test'
TEST_ENGINES:
description: "The specify version of GO (e.g. mysql)"
type: string
required: false
default: 'mysql'
CLOUD_ENV_NAME:
description: "The cloud env name of test (e.g. dev) "
type: string
required: false
default: 'dev'
CLOUD_BRANCH:
description: "The cloud branch name (e.g. main) "
type: string
required: false
default: 'main'
GO_VERSION:
description: "The specify version of GO (e.g. 1.22)"
type: string
required: false
default: '1.22'
workflow_call:
inputs:
TEST_TYPE:
description: "The specify version of GO (e.g. openapi-test)"
type: string
required: false
default: 'openapi-test'
TEST_ENGINES:
description: "The specify version of GO (e.g. mysql)"
type: string
required: false
default: 'mysql'
CLOUD_ENV_NAME:
description: "The cloud env name of test (e.g. dev) "
type: string
required: false
default: 'dev'
CLOUD_BRANCH:
description: "The cloud branch name (e.g. main) "
type: string
required: false
default: 'main'
GO_VERSION:
description: "The specify version of GO (e.g. 1.22)"
type: string
required: false
default: '1.22'
run-name: E2E Test ${{ inputs.TEST_TYPE }} ${{ inputs.TEST_ENGINES }} on Env:${{ inputs.CLOUD_ENV_NAME }} Ref:${{ inputs.CLOUD_BRANCH }}
env:
ACK_KUBECONFIG_DEV: ${{ secrets.ACK_KUBECONFIG_DEV }}
ACK_KUBECONFIG_DEMO: ${{ secrets.ACK_KUBECONFIG_DEMO }}
IDC_KUBECONFIG_2: ${{ secrets.IDC_KUBECONFIG_2 }}
IDC_KUBECONFIG_4: ${{ secrets.IDC_KUBECONFIG_4 }}
ACK_KUBECONFIG_PROD: ${{ secrets.ACK_KUBECONFIG_PROD }}
ACK_KUBECONFIG_INTL_PROD: ${{ secrets.ACK_KUBECONFIG_INTL_PROD }}
VKE_KUBECONFIG_TEST: ${{ secrets.VKE_KUBECONFIG_TEST }}
GITHUB_USER: ${{ secrets.PERSONAL_ACCESS_USER }}
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
jobs:
e2e-test:
name: ${{ inputs.TEST_TYPE }}
runs-on: ubuntu-latest
steps:
- name: get apecloud branch
run: |
CLOUD_BRANCH="${{ inputs.CLOUD_BRANCH }}"
if [[ -z "$CLOUD_BRANCH" ]]; then
CLOUD_BRANCH="main"
fi
echo CLOUD_BRANCH="$CLOUD_BRANCH" >> $GITHUB_ENV
GO_VERSION="${{ inputs.GO_VERSION }}"
if [[ -z "$GO_VERSION" ]]; then
GO_VERSION="1.22"
fi
echo GO_VERSION="$GO_VERSION" >> $GITHUB_ENV
- name: Checkout apecloud Code
uses: actions/checkout@v4
with:
repository: apecloud/apecloud
path: ./
token: ${{ env.GITHUB_TOKEN }}
ref: ${{ env.CLOUD_BRANCH }}
- name: checkout apecloud-cd code
uses: actions/checkout@v4
with:
repository: apecloud/apecloud-cd
path: ./apecloud-cd
- name: Setup Go specify version
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: git config
run: |
git config --global url."https://${{ env.GITHUB_USER }}:${{ env.GITHUB_TOKEN }}@github.com".insteadof "https://github.com"
- name: Configure ACK Context ${{ inputs.CLOUD_ENV_NAME }}
id: cloud_env
run: |
mkdir -p $HOME/.kube
touch $HOME/.kube/config
CLOUD_ENV_NAME="${{ inputs.CLOUD_ENV_NAME }}"
if [[ -z "$CLOUD_ENV_NAME" ]]; then
CLOUD_ENV_NAME="dev"
fi
E2E_ENV_VARS=""
case "$CLOUD_ENV_NAME" in
dev)
echo '${{ env.ACK_KUBECONFIG_DEV }}' > $HOME/.kube/config
E2E_ENV_VARS="${{ vars.E2E_ENV_VARS_DEV }}"
;;
demo)
echo '${{ env.ACK_KUBECONFIG_DEMO }}' > $HOME/.kube/config
E2E_ENV_VARS="${{ vars.E2E_ENV_VARS_DEMO }}"
;;
idc2)
echo '${{ env.IDC_KUBECONFIG_2 }}' > $HOME/.kube/config
E2E_ENV_VARS="${{ vars.E2E_ENV_VARS_IDC2 }}"
;;
idc4)
echo '${{ env.IDC_KUBECONFIG_4 }}' > $HOME/.kube/config
E2E_ENV_VARS="${{ vars.E2E_ENV_VARS_IDC4 }}"
;;
prod)
echo '${{ env.ACK_KUBECONFIG_PROD }}' > $HOME/.kube/config
E2E_ENV_VARS="${{ vars.E2E_ENV_VARS_PROD }}"
;;
intl_prod)
echo '${{ env.ACK_KUBECONFIG_INTL_PROD }}' > $HOME/.kube/config
E2E_ENV_VARS="${{ vars.E2E_ENV_VARS_INTL_PROD }}"
;;
vke_test)
echo '${{ env.VKE_KUBECONFIG_TEST }}' > $HOME/.kube/config
E2E_ENV_VARS="${{ vars.E2E_ENV_VARS_VKE_TEST }}"
;;
esac
echo E2E_ENV_VARS="$E2E_ENV_VARS" >> $GITHUB_ENV
- name: install ginkgo
run: |
cd e2e
make module
make install-ginkgo
- name: openapi test
run: |
cd e2e
file_log="test_result.log"
touch ${file_log}
TEST_ENGINES="${{ inputs.TEST_ENGINES }}"
if [[ -z "$TEST_ENGINES" ]]; then
TEST_ENGINES="mysql"
fi
for env_vars in $(echo "${E2E_ENV_VARS}" | sed 's/|/ /g'); do
eval_cmd="export $env_vars"
echo "$eval_cmd"
eval "$eval_cmd"
done
if [[ -n "${TEST_ENGINES}" ]]; then
echo "export KB_CLOUD_TEST_ENGINES=${TEST_ENGINES}"
export KB_CLOUD_TEST_ENGINES=${TEST_ENGINES}
fi
TEST_TYPE="${{ inputs.TEST_TYPE }}"
if [[ -z "$TEST_TYPE" ]]; then
TEST_TYPE="openapi-test"
fi
make ${TEST_TYPE} | tee -a ${file_log}
test_ret="$( grep "Test Suite Failed" ${file_log} || true )"
if [[ -n "$test_ret" ]]; then
exit 1
fi
- name: send test result message
if: ${{ always() }}
run: |
cd e2e
file_log="test_result.log"
test_ret="$( grep "Test Suite Failed" ${file_log} || true )"
test_result="[PASSED]"
if [[ -n "$test_ret" ]]; then
test_result="[FAILED]"
fi
TEST_RESULT="openapi|${test_result}"
echo "${TEST_RESULT}"
TEST_RESULT=$( bash ${{ github.workspace }}/apecloud-cd/.github/utils/utils.sh --type 12 \
--github-repo "${{ github.repository }}" \
--github-token "${{ env.GITHUB_TOKEN }}" \
--test-result "${TEST_RESULT}" \
--run-id "$GITHUB_RUN_ID" )
echo $TEST_RESULT
date_ret=$(date +%Y-%m-%d-%T)
TEST_TITLE="[Cloud] OpenApi E2E Test on Env:${{ inputs.CLOUD_ENV_NAME }} [${date_ret}]"
python3 ${{ github.workspace }}/apecloud-cd/.github/utils/send_mesage.py \
--url "${{ vars.TEST_BOT_WEBHOOK }}" \
--title "$TEST_TITLE" \
--result "$TEST_RESULT"