Skip to content
This repository was archived by the owner on Jul 11, 2023. It is now read-only.

Commit fa34b3c

Browse files
committed
fix broken test
Signed-off-by: Sean Teeling <[email protected]>
1 parent 0e8c653 commit fa34b3c

File tree

5 files changed

+7
-6
lines changed

5 files changed

+7
-6
lines changed

cmd/osm-healthcheck/osm-healthcheck_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ func TestGetHealthcheckHander(t *testing.T) {
5858
//#nosec G307
5959
defer listener.Close()
6060

61+
// required to avoid https://github.com/golang/go/wiki/CommonMistakes#using-goroutines-on-loop-iterator-variables
62+
test := test
6163
go func() {
6264
conn, err := listener.Accept()
6365
assert.Nil(err)

pkg/envoy/ads/response_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ var _ = Describe("Test ADS response functions", func() {
172172
CertType: secrets.ServiceCertType,
173173
}.String()))
174174

175-
Expect(metricsstore.DefaultMetricsStore.Contains(fmt.Sprintf("osm_proxy_response_send_success_count{proxy_name=%q,type=%q} 1\n", proxy.GetName(), envoy.TypeCDS))).To(BeTrue())
175+
Expect(metricsstore.DefaultMetricsStore.Contains(fmt.Sprintf("osm_proxy_response_send_success_count{identity=%q,proxy_uuid=%q,type=%q} 1\n", proxy.Identity, proxy.UUID, envoy.TypeCDS))).To(BeTrue())
176176
})
177177
})
178178

pkg/envoy/cds/response_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func TestNewResponse(t *testing.T) {
119119
_, err := kubeClient.CoreV1().Pods(tests.Namespace).Create(context.TODO(), newPod1, metav1.CreateOptions{})
120120
assert.Nil(err)
121121

122-
mockKubeController.EXPECT().GetPodForProxy(proxy).Return(&newPod1, nil)
122+
mockKubeController.EXPECT().GetPodForProxy(proxy).Return(newPod1, nil)
123123

124124
resp, err := NewResponse(mockCatalog, proxy, nil, mockConfigurator, nil, proxyRegistry)
125125
assert.Nil(err)

pkg/envoy/registry/services_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ var _ = Describe("Test Proxy-Service mapping", func() {
113113
}, nil).Times(1)
114114

115115
proxy := envoy.NewProxy(envoy.KindSidecar, proxyUUID, identity.New(tests.BookstoreServiceAccountName, tests.Namespace), nil)
116-
mockKubeController.EXPECT().GetPodForProxy(proxy).Return(&pod, nil).Times(1)
116+
mockKubeController.EXPECT().GetPodForProxy(proxy).Return(pod, nil).Times(1)
117117
meshServices, err := proxyRegistry.ListProxyServices(proxy)
118118
Expect(err).ToNot(HaveOccurred())
119119

@@ -150,7 +150,7 @@ var _ = Describe("Test Proxy-Service mapping", func() {
150150
expectedList := []service.MeshService{expected}
151151
mockKubeController.EXPECT().GetEndpoints(gomock.Any()).Return(nil, nil)
152152

153-
mockKubeController.EXPECT().GetPodForProxy(newProxy).Return(&newPod, nil).Times(1)
153+
mockKubeController.EXPECT().GetPodForProxy(newProxy).Return(newPod, nil).Times(1)
154154
// Subdomain gets called in the ListProxyServices
155155
meshServices, err := proxyRegistry.ListProxyServices(newProxy)
156156
Expect(err).ToNot(HaveOccurred())

pkg/k8s/client_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,6 @@ func TestGetPodForProxy(t *testing.T) {
10951095
for _, tc := range testCases {
10961096
t.Run(tc.name, func(t *testing.T) {
10971097
assert := tassert.New(t)
1098-
10991098
pod, err := kubeController.GetPodForProxy(tc.proxy)
11001099

11011100
assert.Equal(tc.pod, pod)
@@ -1109,7 +1108,7 @@ func monitoredNS(name string) *v1.Namespace {
11091108
ObjectMeta: metav1.ObjectMeta{
11101109
Name: name,
11111110
Labels: map[string]string{
1112-
constants.OSMKubeResourceMonitorAnnotation: "osm",
1111+
constants.OSMKubeResourceMonitorAnnotation: testMeshName,
11131112
},
11141113
},
11151114
}

0 commit comments

Comments
 (0)