@@ -19,11 +19,13 @@ import (
19
19
"fmt"
20
20
"strings"
21
21
"testing"
22
+
23
+ stu "github.com/contiv/systemtests-utils"
22
24
)
23
25
24
26
// DockerCleanupWithEnv kills and removes a container on a specified testbed node
25
27
// and with specified env-variables
26
- func DockerCleanupWithEnv (t * testing.T , node TestbedNode , contName string , env []string ) {
28
+ func DockerCleanupWithEnv (t * testing.T , node stu. TestbedNode , contName string , env []string ) {
27
29
if ! OkToCleanup (t .Failed ()) {
28
30
return
29
31
}
@@ -34,15 +36,15 @@ func DockerCleanupWithEnv(t *testing.T, node TestbedNode, contName string, env [
34
36
}
35
37
36
38
// DockerCleanup kills and removes a container on a specified testbed node
37
- func DockerCleanup (t * testing.T , node TestbedNode , contName string ) {
39
+ func DockerCleanup (t * testing.T , node stu. TestbedNode , contName string ) {
38
40
DockerCleanupWithEnv (t , node , contName , []string {})
39
41
}
40
42
41
43
// StartServerWithEnvAndArgs starts a server container with specified env-variables
42
- func StartServerWithEnvAndArgs (t * testing.T , node TestbedNode , contName string ,
44
+ func StartServerWithEnvAndArgs (t * testing.T , node stu. TestbedNode , contName string ,
43
45
env , dockerArgs []string ) {
44
46
cmdStr := "sudo %s docker run -d %s --name=" + contName +
45
- " ubuntu /bin/bash -c ' mkfifo foo && < foo' "
47
+ " ubuntu /bin/bash -c \" mkfifo foo && < foo\" "
46
48
cmdStr = fmt .Sprintf (cmdStr , strings .Join (env , " " ),
47
49
strings .Join (dockerArgs , " " ))
48
50
output , err := node .RunCommandWithOutput (cmdStr )
@@ -54,16 +56,16 @@ func StartServerWithEnvAndArgs(t *testing.T, node TestbedNode, contName string,
54
56
}
55
57
56
58
// StartServer starts a server container
57
- func StartServer (t * testing.T , node TestbedNode , contName string ) {
59
+ func StartServer (t * testing.T , node stu. TestbedNode , contName string ) {
58
60
StartServerWithEnvAndArgs (t , node , contName , []string {}, []string {})
59
61
}
60
62
61
63
// StartClientWithEnvAndArgs starts a client container with specified env-variables.
62
64
// It expects ping to server container to succeed
63
- func StartClientWithEnvAndArgs (t * testing.T , node TestbedNode , contName , ipAddress string ,
65
+ func StartClientWithEnvAndArgs (t * testing.T , node stu. TestbedNode , contName , ipAddress string ,
64
66
env , dockerArgs []string ) {
65
67
cmdStr := "sudo %s docker run %s --name=" + contName +
66
- " ubuntu /bin/bash -c ' ping -c5 " + ipAddress + "' "
68
+ " ubuntu /bin/bash -c \" ping -c5 " + ipAddress + "\" "
67
69
cmdStr = fmt .Sprintf (cmdStr , strings .Join (env , " " ),
68
70
strings .Join (dockerArgs , " " ))
69
71
output , err := node .RunCommandWithOutput (cmdStr )
@@ -90,16 +92,16 @@ func StartClientWithEnvAndArgs(t *testing.T, node TestbedNode, contName, ipAddre
90
92
}
91
93
92
94
// StartClient starts a client container. It expects ping to server container to succeed
93
- func StartClient (t * testing.T , node TestbedNode , contName , ipAddress string ) {
95
+ func StartClient (t * testing.T , node stu. TestbedNode , contName , ipAddress string ) {
94
96
StartClientWithEnvAndArgs (t , node , contName , ipAddress , []string {}, []string {})
95
97
}
96
98
97
99
// StartClientFailureWithEnvAndArgs starts a client container with specified env-variables.
98
100
// It expects ping to server container to failure
99
- func StartClientFailureWithEnvAndArgs (t * testing.T , node TestbedNode , contName , ipAddress string ,
101
+ func StartClientFailureWithEnvAndArgs (t * testing.T , node stu. TestbedNode , contName , ipAddress string ,
100
102
env , dockerArgs []string ) {
101
103
cmdStr := "sudo %s docker run %s --name=" + contName +
102
- " ubuntu /bin/bash -c ' ping -c5 " + ipAddress + "' "
104
+ " ubuntu /bin/bash -c \" ping -c5 " + ipAddress + "\" "
103
105
cmdStr = fmt .Sprintf (cmdStr , strings .Join (env , " " ),
104
106
strings .Join (dockerArgs , " " ))
105
107
output , err := node .RunCommandWithOutput (cmdStr )
@@ -117,11 +119,11 @@ func StartClientFailureWithEnvAndArgs(t *testing.T, node TestbedNode, contName,
117
119
}
118
120
119
121
// StartClientFailure starts a client container. It expects ping to server container to fail
120
- func StartClientFailure (t * testing.T , node TestbedNode , contName , ipAddress string ) {
122
+ func StartClientFailure (t * testing.T , node stu. TestbedNode , contName , ipAddress string ) {
121
123
StartClientFailureWithEnvAndArgs (t , node , contName , ipAddress , []string {}, []string {})
122
124
}
123
125
124
- func getContainerUUID (node TestbedNode , contName string ) (string , error ) {
126
+ func getContainerUUID (node stu. TestbedNode , contName string ) (string , error ) {
125
127
cmdStr := "sudo docker inspect --format='{{.Id}}' " + contName
126
128
output , err := node .RunCommandWithOutput (cmdStr )
127
129
if err != nil {
0 commit comments