Skip to content

Commit

Permalink
flannel: move Windows tests to Ginkgo
Browse files Browse the repository at this point in the history
  • Loading branch information
rakelkar committed Oct 13, 2017
1 parent 575e7ff commit a2c0697
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 86 deletions.
72 changes: 72 additions & 0 deletions plugins/meta/flannel/flannel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"net"
)

var _ = Describe("Flannel", func() {
Expand Down Expand Up @@ -159,6 +160,77 @@ FLANNEL_IPMASQ=true
})
})

Describe("windowsOutboundNat", func() {
Context("when not set by user", func() {
It("sets it by adding a policy", func() {
// given a subnet config that requests ipmasq
_, nw, _ := net.ParseCIDR("192.168.0.0/16")
_, sn, _ := net.ParseCIDR("192.168.10.0/24")
ipmasq := true
fenv := &subnetEnv{
nw: nw,
sn: sn,
ipmasq: &ipmasq,
}

// apply it
delegate := make(map[string]interface{})
updateOutboundNat(delegate, fenv)

Expect(delegate).Should(HaveKey("AdditionalArgs"))

addlArgs := (delegate["AdditionalArgs"]).([]interface{})
Expect(addlArgs).Should(HaveLen(1))

policy := addlArgs[0].(map[string]interface{})
Expect(policy).Should(HaveKey("Name"))
Expect(policy).Should(HaveKey("Value"))
Expect(policy["Name"]).Should(Equal("EndpointPolicy"))

value := policy["Value"].(map[string]interface{})
Expect(value).Should(HaveKey("Type"))
Expect(value).Should(HaveKey("ExceptionList"))
Expect(value["Type"]).Should(Equal("OutBoundNAT"))

exceptionList := value["ExceptionList"].([]interface{})
Expect(exceptionList).Should(HaveLen(1))
Expect(exceptionList[0].(string)).Should(Equal(nw.String()))
})
})

Context("when set by user", func() {
It("appends exceptions to the existing policy", func() {
// given a subnet config that requests ipmasq
_, nw, _ := net.ParseCIDR("192.168.0.0/16")
_, sn, _ := net.ParseCIDR("192.168.10.0/24")
ipmasq := true
fenv := &subnetEnv{
nw: nw,
sn: sn,
ipmasq: &ipmasq,
}

// first set it
delegate := make(map[string]interface{})
updateOutboundNat(delegate, fenv)

// then attempt to update it
_, nw2, _ := net.ParseCIDR("10.244.0.0/16")
fenv.nw = nw2
updateOutboundNat(delegate, fenv)

// but it stays the same!
addlArgs := (delegate["AdditionalArgs"]).([]interface{})
policy := addlArgs[0].(map[string]interface{})
value := policy["Value"].(map[string]interface{})
exceptionList := value["ExceptionList"].([]interface{})

Expect(exceptionList[0].(string)).Should(Equal(nw.String()))
Expect(exceptionList[1].(string)).Should(Equal(nw2.String()))
})
})
})

Describe("loadFlannelNetConf", func() {
Context("when subnetFile and dataDir are specified", func() {
It("loads flannel network config", func() {
Expand Down
86 changes: 0 additions & 86 deletions plugins/meta/flannel/flannel_windows_test.go

This file was deleted.

0 comments on commit a2c0697

Please sign in to comment.