-
Notifications
You must be signed in to change notification settings - Fork 16
289 lines (261 loc) · 11.1 KB
/
ci-integration-tests-csae.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
name: CI Integration Tests CSAE
on:
workflow_dispatch:
pull_request:
push:
branches:
- 'main'
jobs:
test:
strategy:
matrix:
python: ['3.8', '3.9', '3.10', '3.11']
runs-on: ubuntu-latest
name: Functional test
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Define CSAE env name
id: define-environment-name
run: |
PYTHON_VERSION=$(echo -n "$PYTHON_VERSION" | tr -d '.') # remove dots from version
echo "env-name=dbt-ci-$PYTHON_VERSION-$(date +%s%N)" >> $GITHUB_OUTPUT
env:
PYTHON_VERSION: ${{ matrix.python }}
- name: Create CSAE environments
id: create-csae-environments
shell: bash
run: |
chmod 777 .github/workflows/scripts/createTestEnvironments.sh
./.github/workflows/scripts/createTestEnvironments.sh
env:
CSAE_TOKEN: ${{ secrets.CSAE_TOKEN_DEVTOOLS }}
CSAE_ENV_PASSWORD: ${{ secrets.CSAE_ENV_PASSWORD }}
CSAE_ENV_NAME: ${{ steps.define-environment-name.outputs.env-name}}
- name: Install TTU
shell: bash
run: |
aws s3 cp "$AWS_S3_PATH_OF_TTU_BUNDLE"/"$TTU_BUNDLE_FILE_NAME" .
tar -xzf "$TTU_BUNDLE_FILE_NAME"
cd TeradataToolsAndUtilitiesBase
sudo ./setup.sh a
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }}
AWS_S3_PATH_OF_TTU_BUNDLE: ${{ secrets.AWS_S3_PATH_OF_TTU_BUNDLE }}
TTU_BUNDLE_FILE_NAME: ${{ secrets.TTU_BUNDLE_FILE_NAME }}
- name: Install requirements
run: |
python -m pip install --upgrade pip
pip install -r requirements_dev.txt
- name: Prepare database
shell: bash
run: |
export PATH=$PATH:"/opt/teradata/client/17.20/bin"
cd md5_20080530/md5/src
# prepare bteq script
cat << EOF > /tmp/install_md5.bteq
.SET EXITONDELAY ON MAXREQTIME 20
.logon $DBT_TERADATA_SERVER_NAME/$DBT_TERADATA_USERNAME,$DBT_TERADATA_PASSWORD
GRANT CREATE FUNCTION ON GLOBAL_FUNCTIONS TO $DBT_TERADATA_USERNAME;
DATABASE GLOBAL_FUNCTIONS;
.run file = hash_md5.btq
GRANT EXECUTE FUNCTION ON GLOBAL_FUNCTIONS TO PUBLIC WITH GRANT OPTION;
.logoff
EOF
bteq < /tmp/install_md5.bteq
cd ../../../tests/functional/adapter
cat << EOF > /tmp/create_procedure_in_tera.bteq
.SET EXITONDELAY ON MAXREQTIME 20
.logon $DBT_TERADATA_SERVER_NAME/$DBT_TERADATA_USERNAME,$DBT_TERADATA_PASSWORD
create user dummy_test_tmode from dbc as permanent=100000000 BYTES,password=dummy_test_tmode;
GRANT ALL ON dummy_test_tmode to dbc;
create multiset table dummy_test_tmode.currency_table (amount DECIMAL(18, 2), original_currency VARCHAR(3), converted_amount DECIMAL(18, 2));
.COMPILE file = CurrencyConversionProcedureTERA.sql
.logoff
EOF
bteq < /tmp/create_procedure_in_tera.bteq
cat << EOF > /tmp/create_procedure_in_ansi.bteq
.SET SESSION TRANSACTION ANSI;
.SET EXITONDELAY ON MAXREQTIME 20
.logon $DBT_TERADATA_SERVER_NAME/$DBT_TERADATA_USERNAME,$DBT_TERADATA_PASSWORD
.COMPILE file = CurrencyConversionProcedureANSI.sql
commit;
.logoff
EOF
bteq < /tmp/create_procedure_in_ansi.bteq
env:
DBT_TERADATA_SERVER_NAME: ${{ steps.create-csae-environments.outputs.teradata-server-name }}
DBT_TERADATA_USERNAME: dbc
DBT_TERADATA_PASSWORD: ${{ secrets.CSAE_ENV_PASSWORD }}
- name: Run pytest tests with ANSI mode
run: |
sed -i "s/localhost/$DBT_TERADATA_SERVER_NAME/g" tests/conftest.py
sed -i "s/username='dbc'/username='$DBT_TERADATA_USERNAME'/g" tests/conftest.py
sed -i "s/password='dbc'/password='$DBT_TERADATA_PASSWORD'/g" tests/conftest.py
export DBT_TEST_USER_1=test_grants_user1
export DBT_TEST_USER_2=test_grants_user2
export DBT_TEST_USER_3=test_grants_user3
pytest -v -k "not TestCurrentTimestamp and not TestProcedureANSIInTERA and not TestProcedureTERAInTERA and not Test_query_band" tests/functional
env:
DBT_TERADATA_SERVER_NAME: ${{ steps.create-csae-environments.outputs.teradata-server-name }}
DBT_TERADATA_USERNAME: dbc
DBT_TERADATA_PASSWORD: ${{ secrets.CSAE_ENV_PASSWORD }}
- name: Run pytest tests with TERA mode
run: |
sed -i "s/localhost/$DBT_TERADATA_SERVER_NAME/g" tests/conftest.py
sed -i "s/username='dbc'/username='$DBT_TERADATA_USERNAME'/g" tests/conftest.py
sed -i "s/password='dbc'/password='$DBT_TERADATA_PASSWORD'/g" tests/conftest.py
sed -i "s/tmode='ANSI'/tmode='$DBT_TERADATA_TMODE'/g" tests/conftest.py
export DBT_TEST_USER_1=test_grants_user1
export DBT_TEST_USER_2=test_grants_user2
export DBT_TEST_USER_3=test_grants_user3
pytest -v -k "not TestCurrentTimestamp and not TestProcedureTERAInANSI and not TestProcedureANSIInANSI" tests/functional
env:
DBT_TERADATA_SERVER_NAME: ${{ steps.create-csae-environments.outputs.teradata-server-name }}
DBT_TERADATA_USERNAME: dbc
DBT_TERADATA_PASSWORD: ${{ secrets.CSAE_ENV_PASSWORD }}
DBT_TERADATA_TMODE: TERA
- name: Setup environment with ANSI for performance and catalog tests
run: |
mkdir ~/.dbt
cat << EOF > ~/.dbt/profiles.yml
teradata:
outputs:
dbt_perf_test:
type: teradata
host: $DBT_TERADATA_SERVER_NAME
user: $DBT_TERADATA_USERNAME
password: $DBT_TERADATA_PASSWORD
logmech: TD2
schema: dbt_perf_test
tmode: ANSI
threads: 1
timeout_seconds: 300
priority: interactive
retries: 1
dbt_catalog_test:
type: teradata
host: $DBT_TERADATA_SERVER_NAME
user: $DBT_TERADATA_USERNAME
password: $DBT_TERADATA_PASSWORD
logmech: TD2
schema: dbt_catalog_test
tmode: ANSI
threads: 1
timeout_seconds: 300
priority: interactive
retries: 1
dbt_catalog_test_qvci:
type: teradata
host: $DBT_TERADATA_SERVER_NAME_QVCI
user: $DBT_TERADATA_USERNAME_QVCI
password: $DBT_TERADATA_PASSWORD_QVCI
logmech: TD2
schema: dbt_catalog_test
tmode: ANSI
threads: 1
timeout_seconds: 300
priority: interactive
retries: 1
EOF
env:
DBT_TERADATA_SERVER_NAME: ${{ steps.create-csae-environments.outputs.teradata-server-name }}
DBT_TERADATA_USERNAME: dbc
DBT_TERADATA_PASSWORD: ${{ secrets.CSAE_ENV_PASSWORD }}
DBT_TERADATA_SERVER_NAME_QVCI: ${{ steps.create-csae-environments.outputs.teradata-server-name-qvci }}
DBT_TERADATA_USERNAME_QVCI: dbc
DBT_TERADATA_PASSWORD_QVCI: ${{ secrets.CSAE_ENV_PASSWORD }}
- name: Run performance tests with ANSI
run: |
cd $GITHUB_WORKSPACE/test/performance
./run.sh
- name: Run catalog tests with ANSI
run: |
# cd $GITHUB_WORKSPACE/test/catalog/with_qvci
# ./run.sh
cd $GITHUB_WORKSPACE/test/catalog/without_qvci
./run.sh
- name: Setup environment with TERA for performance and catalog tests
run: |
rm ~/.dbt/profiles.yml
cat << EOF > ~/.dbt/profiles.yml
teradata:
outputs:
dbt_perf_test:
type: teradata
host: $DBT_TERADATA_SERVER_NAME
user: $DBT_TERADATA_USERNAME
password: $DBT_TERADATA_PASSWORD
logmech: TD2
schema: dbt_perf_test
tmode: TERA
threads: 1
timeout_seconds: 300
priority: interactive
retries: 1
dbt_catalog_test:
type: teradata
host: $DBT_TERADATA_SERVER_NAME
user: $DBT_TERADATA_USERNAME
password: $DBT_TERADATA_PASSWORD
logmech: TD2
schema: dbt_catalog_test
tmode: TERA
threads: 1
timeout_seconds: 300
priority: interactive
retries: 1
dbt_catalog_test_qvci:
type: teradata
host: $DBT_TERADATA_SERVER_NAME_QVCI
user: $DBT_TERADATA_USERNAME_QVCI
password: $DBT_TERADATA_PASSWORD_QVCI
logmech: TD2
schema: dbt_catalog_test
tmode: TERA
threads: 1
timeout_seconds: 300
priority: interactive
retries: 1
EOF
env:
DBT_TERADATA_SERVER_NAME: ${{ steps.create-csae-environments.outputs.teradata-server-name }}
DBT_TERADATA_USERNAME: dbc
DBT_TERADATA_PASSWORD: ${{ secrets.CSAE_ENV_PASSWORD }}
DBT_TERADATA_SERVER_NAME_QVCI: ${{ steps.create-csae-environments.outputs.teradata-server-name-qvci }}
DBT_TERADATA_USERNAME_QVCI: dbc
DBT_TERADATA_PASSWORD_QVCI: ${{ secrets.CSAE_ENV_PASSWORD }}
- name: Run performance tests with TERA
run: |
cd $GITHUB_WORKSPACE/test/performance
./run.sh
- name: Run catalog tests with TERA
run: |
# cd $GITHUB_WORKSPACE/test/catalog/with_qvci
# ./run.sh
cd $GITHUB_WORKSPACE/test/catalog/without_qvci
./run.sh
- name: Run nopi tests
run: |
sed -i "s/hostname=dbt.*/hostname='$DBT_TERADATA_SERVER_NAME'/g" tests/conftest.py
sed -i "s/username=demo.*/username='$DBT_TERADATA_USERNAME'/g" tests/conftest.py
sed -i "s/password=dbt.*/password='$DBT_TERADATA_PASSWORD'/g" tests/conftest.py
pytest tests/functional/adapter/test_nopi.py
env:
DBT_TERADATA_SERVER_NAME: ${{ steps.create-csae-environments.outputs.teradata-server-name }}
DBT_TERADATA_USERNAME: dbc
DBT_TERADATA_PASSWORD: ${{ secrets.CSAE_ENV_PASSWORD }}
- name: Delete CSAE environment
if: always()
run: |
chmod 777 .github/workflows/scripts/deleteTestEnvironments.sh
./.github/workflows/scripts/deleteTestEnvironments.sh
env:
CSAE_TOKEN: '${{ secrets.CSAE_TOKEN_DEVTOOLS }}'
CSAE_ENV_NAME: '${{ steps.define-environment-name.outputs.env-name}}'