github.com/pingcap/chaos@v0.0.0-20190710112158-c86faf4b3719/pkg/util/net/net_test.go (about) 1 package net 2 3 import ( 4 "context" 5 "testing" 6 ) 7 8 func TestIsReachable(t *testing.T) { 9 t.Log("test can only be run in the chaos docker") 10 11 if !IsReachable(context.Background(), "n1") { 12 t.Fatal("n1 must be reachable") 13 } 14 15 if IsReachable(context.Background(), "n0") { 16 t.Fatal("n0 must not be reachable") 17 } 18 } 19 20 func TestHostIP(t *testing.T) { 21 t.Log("test can only be run in the chaos docker") 22 23 if HostIP("n1") == "" { 24 t.Fatal("must get a host IP for n1") 25 } 26 27 if HostIP("n0") != "" { 28 t.Fatal("must not get a host IP for n0") 29 } 30 }