forked from kreuzwerker/terraform-provider-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunAccTests.bat
116 lines (99 loc) · 2.98 KB
/
runAccTests.bat
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
@echo off
setlocal
setlocal EnableDelayedExpansion
:: As of `go-dockerclient` v1.2.0, the default endpoint to the Docker daemon
:: is a UNIX socket. We need to force it to use the Windows named pipe when
:: running against Docker for Windows.
set DOCKER_HOST=npipe:////.//pipe//docker_engine
:: Note: quoting these values breaks the tests!
set DOCKER_REGISTRY_ADDRESS=127.0.0.1:15000
set DOCKER_REGISTRY_USER=testuser
set DOCKER_REGISTRY_PASS=testpwd
set DOCKER_PRIVATE_IMAGE=127.0.0.1:15000/tftest-service:v1
set TF_ACC=1
call:setup
if %ErrorLevel% neq 0 (
call:print "Failed to set up acceptance test fixtures."
exit /b %ErrorLevel%
)
call:run
if %ErrorLevel% neq 0 (
call:print "Acceptance tests failed."
set outcome=1
) else (
set outcome=0
)
call:cleanup
if %ErrorLevel% neq 0 (
call:print "Failed to clean up acceptance test fixtures."
exit /b %ErrorLevel%
)
exit /b %outcome%
:print
if "%~1" == "" (
echo.
) else (
echo %~1
)
exit /b 0
:log
call:print ""
call:print "##################################"
call:print "-------- %~1"
call:print "##################################"
exit /b 0
:setup
call:log "setup"
:: Setup testing files
echo | set /p=foo > "%~dp0testing\testingFile"
call openssl base64 -in "%~dp0testing\testingFile" -out "%~dp0testing\tmp.base64"
type nul > "%~dp0testing\testingFile.base64"
for /f "usebackq" %%x in ("%~dp0testing\tmp.base64") do echo | set /p=%%x >> "%~dp0testing\testingFile.base64"
del /Q "%~dp0testing\tmp.base64"
call "%~dp0testing\setup_private_registry.bat"
exit /b %ErrorLevel%
:run
call:log "run"
call go clean -testcache
call go test ./internal/provider -v -timeout 120m
exit /b %ErrorLevel%
:cleanup
call:log "cleanup"
call:print "### unset env ###"
del /Q "%~dp0testing\testingFile"
del /Q "%~dp0testing\testingFile.base64"
call:print "### deleted testing files ###"
for /F %%p in ('docker container ls -f "name=private_registry" -q') do (
call docker stop %%p
call docker rm -f -v %%p
)
call:print "### stopped private registry ###"
rmdir /q /s "%~dp0testing\auth"
rmdir /q /s "%~dp0testing\certs"
call:print "### removed auth and certs ###"
for %%r in ("container" "volume") do (
call docker %%r ls -f "name=tftest-" -q
for /F %%i in ('docker %%r ls -f "name=tf-test" -q') do (
echo Deleting %%r %%i
call docker %%r rm -f -v %%i
)
for /F %%i in ('docker %%r ls -f "name=tftest-" -q') do (
echo Deleting %%r %%i
call docker %%r rm -f -v %%i
)
call:print "### removed %%r ###"
)
for %%r in ("config" "secret" "network") do (
call docker %%r ls -f "name=tftest-" -q
for /F %%i in ('docker %%r ls -f "name=tftest-" -q') do (
echo Deleting %%r %%i
call docker %%r rm %%i
)
call:print "### removed %%r ###"
)
for /F %%i in ('docker images -aq 127.0.0.1:5000/tftest-service') do (
echo Deleting image %%i
docker rmi -f %%i
)
call:print "### removed service images ###"
exit /b %ErrorLevel%