From b913976efb04bd65212b97dfc81a2fa9b898d984 Mon Sep 17 00:00:00 2001 From: Rob Brockbank Date: Tue, 14 Nov 2017 09:21:10 -0800 Subject: [PATCH] Add additional expects for kdd veth name processing --- lib/backend/k8s/conversion_test.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/backend/k8s/conversion_test.go b/lib/backend/k8s/conversion_test.go index d7df490e0..ba3956503 100644 --- a/lib/backend/k8s/conversion_test.go +++ b/lib/backend/k8s/conversion_test.go @@ -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")) }) @@ -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{ @@ -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")) @@ -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() {