-
Notifications
You must be signed in to change notification settings - Fork 58
184 lines (168 loc) · 6.6 KB
/
integration-tests-against-emulator.yaml
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
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
on:
schedule:
- cron: "0 0 * * *"
push:
branches:
- master
pull_request:
name: integration-tests-against-emulator
jobs:
integration-tests:
runs-on: ubuntu-latest
env:
# set PostgreSQL related environment variables
PGHOST: localhost
PGPORT: 5432
PGUSER: postgres
PGDATABASE: postgres
PGPASSWORD: postgres
# set MySQL related environment variables
DB_HOST: localhost
MYSQLHOST: localhost
MYSQLPORT: 3306
MYSQLUSER: root
MYSQLDATABASE: test_interleave_table_data
MYSQLPWD: root
# set DynamoDB related environment variables
AWS_ACCESS_KEY_ID: dummyId
AWS_SECRET_ACCESS_KEY: dummyKey
AWS_REGION: dummyRegion
DYNAMODB_ENDPOINT_OVERRIDE: http://localhost:8000
# sql server envs
# Password for connection as SA
MSSQL_SA_PASSWORD: tCUE9c1&Ucp0
services:
spanner_emulator:
image: gcr.io/cloud-spanner-emulator/emulator:1.5.19
ports:
- 9010:9010
- 9020:9020
postgres:
image: postgres:9.6
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
mariadb:
image: mariadb:10.11
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: test
ports:
- 3306:3306
# needed because the mysql container does not provide a healthcheck
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
dynamodb_emulator:
image: amazon/dynamodb-local:1.16.0
ports:
- 8000:8000
options: --workdir /home/dynamodblocal --health-cmd "curl --fail http://127.0.0.1:8000/shell/ || exit 1" --health-interval 10s --health-timeout 5s --health-retries 5
sqlserver:
image: mcr.microsoft.com/mssql/server
env:
SA_PASSWORD: ${{env.MSSQL_SA_PASSWORD}}
MSSQL_PID: Express
ACCEPT_EULA: Y
ports:
- 1433:1433
options:
--health-cmd "/opt/mssql-tools/bin/sqlcmd -U sa -P $SA_PASSWORD -Q 'select 1' -b -o /dev/null"
--health-interval 10s --health-timeout 5s --health-retries 3
oracle:
image: oracleinanutshell/oracle-xe-11g
ports:
- 1521:1521
steps:
- uses: actions/checkout@v3
# init a PostgresSQL database from the test_data
- name: Install PostgreSQL 12 client required for loading .sql files
run: |
sudo apt-get update
sudo apt-get -yq install postgresql-client
- run: psql --version
- run: psql -f test_data/pg_dump.test.out
# init a MySQL database from the test_data
- run: mysql --version
- run: mysql -v -P 3306 --protocol=tcp -u root -proot test < test_data/mysqldump.test.out
- run: mysql -v -P 3306 --protocol=tcp -u root -proot < test_data/mysql_interleave_dump.test.out
# init sql server with test_data
- name: Install sqlcmd required for loading .sql files
run: |
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
sudo apt-get update
sudo apt-get install mssql-tools unixodbc-dev
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
- run: sqlcmd -?
- run: sqlcmd -U sa -P ${MSSQL_SA_PASSWORD} -i test_data/sqlserver.test.out
# sqlplus set up init oracle db.
- name: Install sqlplus required for loading .sql files
run: |
sudo apt-get update
sudo apt-get install -y libaio1 rpm2cpio cpio
curl -O https://download.oracle.com/otn_software/linux/instantclient/2340000/oracle-instantclient-basic-23.4.0.24.05-1.el9.x86_64.rpm
curl -O https://download.oracle.com/otn_software/linux/instantclient/2340000/oracle-instantclient-sqlplus-23.4.0.24.05-1.el9.x86_64.rpm
rpm2cpio oracle-instantclient-basic-23.4.0.24.05-1.el9.x86_64.rpm | sudo cpio -idmv
sudo cp -r usr/* /usr/
rpm2cpio oracle-instantclient-sqlplus-23.4.0.24.05-1.el9.x86_64.rpm | sudo cpio -idmv
sudo cp -r usr/* /usr/
sudo sh -c 'echo /usr/lib/oracle/23/client64/lib/ > /etc/ld.so.conf.d/oracle.conf'
sudo ldconfig
- run: sqlplus SYS/[email protected]:1521/xe as sysdba @test_data/oracle.test.out
# create a spanner instance
- uses: actions/setup-python@v4
with:
python-version: '3.8'
- uses: google-github-actions/setup-gcloud@v0
with:
version: "410.0.0"
- run: gcloud info
- run: gcloud config configurations create emulator
- run: gcloud config set auth/disable_credentials true
- run: gcloud config set project emulator-test-project
- run: gcloud config set api_endpoint_overrides/spanner http://localhost:9020/
- run: gcloud spanner instances create test-instance --config=emulator-config --description="Test Instance" --nodes=1
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 16
- name: Install Dependencies
run: |
cd ui
npm ci
- name: Start Local Server
run: |
cd ui
npm start &
- name: Wait for Local Server to Start
run: npx wait-on http://localhost:4200 -t 30000
- name: Cypress run
run: |
cd ui
npx cypress run
- uses: actions/setup-go@v2
with:
go-version: "1.19"
- run: go version
- run: go test -v ./...
env:
SPANNER_EMULATOR_HOST: localhost:9010
SPANNER_MIGRATION_TOOL_TESTS_GCLOUD_PROJECT_ID: emulator-test-project
SPANNER_MIGRATION_TOOL_TESTS_GCLOUD_INSTANCE_ID: test-instance