Skip to content

Commit

Permalink
Add additional expects for kdd veth name processing
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Brockbank authored and fasaxc committed Nov 21, 2017
1 parent cc9c6a5 commit b913976
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/backend/k8s/conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ var _ = Describe("Test Pod conversion", func() {
expectedLabels := map[string]string{"labelA": "valueA", "labelB": "valueB", "calico/k8s_ns": "default"}
Expect(wep.Value.(*model.WorkloadEndpoint).Labels).To(Equal(expectedLabels))

// Assert the interface name is fixed. The calculation of this name should be consistent
// between releases otherwise there will be issues upgrading a node with networked Pods.
// If this fails, fix the code not this expect!
Expect(wep.Value.(*model.WorkloadEndpoint).Name).To(Equal("cali7f94ce7c295"))

// Assert ResourceVersion is present.
Expect(wep.Revision.(string)).To(Equal("1234"))
})
Expand Down Expand Up @@ -147,7 +152,7 @@ var _ = Describe("Test Pod conversion", func() {
It("should parse a Pod with no labels", func() {
pod := k8sapi.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: "podA",
Name: "podB",
Namespace: "default",
},
Spec: k8sapi.PodSpec{
Expand All @@ -162,7 +167,7 @@ var _ = Describe("Test Pod conversion", func() {
Expect(err).NotTo(HaveOccurred())

// Assert key fields.
Expect(wep.Key.(model.WorkloadEndpointKey).WorkloadID).To(Equal("default.podA"))
Expect(wep.Key.(model.WorkloadEndpointKey).WorkloadID).To(Equal("default.podB"))
Expect(wep.Key.(model.WorkloadEndpointKey).Hostname).To(Equal("nodeA"))
Expect(wep.Key.(model.WorkloadEndpointKey).EndpointID).To(Equal("eth0"))
Expect(wep.Key.(model.WorkloadEndpointKey).OrchestratorID).To(Equal("k8s"))
Expand All @@ -172,6 +177,11 @@ var _ = Describe("Test Pod conversion", func() {
Expect(len(wep.Value.(*model.WorkloadEndpoint).IPv4Nets)).To(Equal(1))
Expect(wep.Value.(*model.WorkloadEndpoint).State).To(Equal("active"))
Expect(wep.Value.(*model.WorkloadEndpoint).Labels).To(Equal(map[string]string{"calico/k8s_ns": "default"}))

// Assert the interface name is fixed. The calculation of this name should be consistent
// between releases otherwise there will be issues upgrading a node with networked Pods.
// If this fails, fix the code not this expect!
Expect(wep.Value.(*model.WorkloadEndpoint).Name).To(Equal("cali92cf1f5e9f6"))
})

It("should Parse a Pod with no NodeName", func() {
Expand Down

0 comments on commit b913976

Please sign in to comment.