forked from alexbrainman/odbc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
105 lines (89 loc) · 2.62 KB
/
Makefile
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
DB_NAME=test
PASSWORD=Passw0rd
help:
echo "use start or stop target"
# Microsoft SQL Server
MSSQL_CONTAINER_NAME=mssql_test
MSSQL_SA_PASSWORD=$(PASSWORD)
MSSQL_NETWORK=mssqlnetwork
MSSQL_DRIVER_NAME=ODBC Driver 17 for SQL Server
start-mssql:
docker network create ${MSSQL_NETWORK}
docker run \
--name $(MSSQL_CONTAINER_NAME) \
--hostname $(MSSQL_CONTAINER_NAME) \
-e 'ACCEPT_EULA=Y' \
-e 'MSSQL_SA_PASSWORD=$(MSSQL_SA_PASSWORD)' \
-d \
-p 1433:1433 \
--network=${MSSQL_NETWORK} \
mcr.microsoft.com/mssql/server:2022-latest
echo -n "starting $(MSSQL_CONTAINER_NAME) "; \
while ! \
docker logs $(MSSQL_CONTAINER_NAME) 2>&1 | \
grep SQL.Server.is.now.ready.for.client.connections >/dev/null ; \
do echo -n .; sleep 2; done; echo " done"
echo -n "creating database $(DB_NAME) "; \
while ! \
docker exec $(MSSQL_CONTAINER_NAME) \
/opt/mssql-tools/bin/sqlcmd \
-S localhost \
-U SA \
-P '$(MSSQL_SA_PASSWORD)' \
-Q 'create database $(DB_NAME)' >/dev/null 2>&1 ; \
do echo -n .; sleep 2; done; echo " done"
build-unixodbc:
docker build \
-t unixodbc \
-f unixodbc.Dockerfile \
.
test-mssql:
docker run \
-it \
--network=${MSSQL_NETWORK} \
-v .:/src \
unixodbc \
sh /src/mssqltest.sh \
"$(MSSQL_DRIVER_NAME)" \
"$(MSSQL_CONTAINER_NAME)" \
"$(DB_NAME)" \
"$(MSSQL_SA_PASSWORD)"
test-mssql-freetds:
docker run \
-it \
--network=${MSSQL_NETWORK} \
-v .:/src \
unixodbc \
sh /src/mssqltest.sh \
"freetds" \
"$(MSSQL_CONTAINER_NAME)" \
"$(DB_NAME)" \
"$(MSSQL_SA_PASSWORD)"
test-mssql-race:
docker run \
-it \
--network=${MSSQL_NETWORK} \
-v .:/src \
unixodbc \
sh /src/mssqltest.sh \
"$(MSSQL_DRIVER_NAME)" \
"$(MSSQL_CONTAINER_NAME)" \
"$(DB_NAME)" \
"$(MSSQL_SA_PASSWORD)" \
"--race"
stop-mssql:
docker stop $(MSSQL_CONTAINER_NAME)
docker rm $(MSSQL_CONTAINER_NAME)
docker network rm ${MSSQL_NETWORK}
# MySQL
MYSQL_CONTAINER_NAME=mysql_test
MYSQL_ROOT_PASSWORD=$(PASSWORD)
start-mysql:
docker run --name=$(MYSQL_CONTAINER_NAME) -e 'MYSQL_ROOT_PASSWORD=$(MYSQL_ROOT_PASSWORD)' -d -p 127.0.0.1:3306:3306 mysql
echo -n "starting $(MYSQL_CONTAINER_NAME) "; while ! docker logs $(MYSQL_CONTAINER_NAME) 2>&1 | grep ^Version.*port:.3306 >/dev/null ; do echo -n .; sleep 1; done; echo " done"
docker exec $(MYSQL_CONTAINER_NAME) sh -c 'echo "create database $(DB_NAME)" | MYSQL_PWD=$(MYSQL_ROOT_PASSWORD) mysql -hlocalhost -uroot'
test-mysql:
go test -v -mydb=$(DB_NAME) -mypass=$(MYSQL_ROOT_PASSWORD) -mysrv=127.0.0.1 -myuser=root -run=MYSQL
stop-mysql:
docker stop $(MYSQL_CONTAINER_NAME)
docker rm $(MYSQL_CONTAINER_NAME)