Skip to content

Commit

Permalink
Merge pull request #19166 from danwinship/fix-sdn-cni-plugin-test
Browse files Browse the repository at this point in the history
Use a dummy ns.NetNS in sdn_cni_plugin_test.go
  • Loading branch information
openshift-merge-robot committed Mar 31, 2018
2 parents 4e073fa + 0b10ec4 commit 5de5511
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions pkg/network/sdn-cni-plugin/sdn_cni_plugin_test.go
Expand Up @@ -57,6 +57,24 @@ func clearEnv() {
}
}

type dummyHostNS struct{}

func (ns *dummyHostNS) Do(toRun func(ns.NetNS) error) error {
return toRun(ns)
}
func (ns *dummyHostNS) Set() error {
panic("should not be reached")
}
func (ns *dummyHostNS) Path() string {
panic("should not be reached")
}
func (ns *dummyHostNS) Fd() uintptr {
panic("should not be reached")
}
func (ns *dummyHostNS) Close() error {
panic("should not be reached")
}

func TestOpenshiftSdnCNIPlugin(t *testing.T) {
tmpDir, err := utiltesting.MkTmpdir("cniserver")
if err != nil {
Expand All @@ -70,12 +88,7 @@ func TestOpenshiftSdnCNIPlugin(t *testing.T) {
t.Fatalf("error starting CNI server: %v", err)
}

hostNS, err := ns.GetCurrentNS()
if err != nil {
panic(fmt.Sprintf("could not get current kernel netns: %v", err))
}
defer hostNS.Close()
cniPlugin := NewCNIPlugin(path, hostNS)
cniPlugin := NewCNIPlugin(path, &dummyHostNS{})

expectedIP, expectedNet, _ := net.ParseCIDR("10.0.0.2/24")
expectedResult = &cni020.Result{
Expand Down

0 comments on commit 5de5511

Please sign in to comment.