Skip to content

Commit 2cc23fb

Browse files
author
Vipin Jain
committed
add sanity to check for container ip
1 parent 1b9fee6 commit 2cc23fb

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

systemtests/singlehost/sanity_test.go

+24-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ limitations under the License.
1616
package singlehost
1717

1818
import (
19+
"strings"
1920
"testing"
2021
"time"
2122

@@ -247,20 +248,40 @@ func TestSingleHostDefaultNetwork_sanity(t *testing.T) {
247248
utils.DockerCleanup(t, node, "myContainer2")
248249
}()
249250

251+
// confirm the default gateway in one of the containers
252+
output, err := node.RunCommandWithOutput("docker exec myContainer1 /sbin/ip route")
253+
if err != nil {
254+
t.Fatalf("Error - unable to get default ip route, output = '%s'", output)
255+
}
256+
if !strings.Contains(output, "default via 100.1.0.254") {
257+
t.Fatalf("Error - unable to confirm container's default ip route, output = '%s'", output)
258+
}
259+
250260
jsonCfg = `
251261
{
252262
"Tenants" : [ {
253263
"Name" : "tee-one",
254264
"Networks" : [ {
255-
"Name" : "orange"
265+
"Name" : "orange",
266+
"Endpoints" : [ {
267+
"Container" : "myContainer1",
268+
"Host" : "host1"
269+
} ]
256270
} ]
257271
} ]
258272
}`
259273

260274
// deletion would result into unassignment
261275
utils.DelConfig(t, jsonCfg, testbed.GetNodes()[0])
262276
time.Sleep(1 * time.Second)
263-
if utils.NetworkStateExists(node, "orange", "") == nil {
264-
t.Fatalf("Error - network %s doesn't seem to be deleted \n", "green")
277+
278+
// confirm the default gateway in one of the containers
279+
output, err = node.RunCommandWithOutput("docker exec myContainer1 /sbin/ip route")
280+
if err != nil {
281+
t.Fatalf("Error - unable to get default ip route, output = '%s'", output)
282+
}
283+
if strings.Contains(output, "default via 100.1.0.254") {
284+
t.Fatalf("Error - able to still find the default rout after network is deleted output = '%s'", output)
265285
}
286+
266287
}

0 commit comments

Comments
 (0)