(t *testing.T)
| 293 | } |
| 294 | |
| 295 | func TestAddPodDiffNs(t *testing.T) { |
| 296 | log.SetupZapLogger(log.GetDefaultLogOpts()) |
| 297 | ctrl := gomock.NewController(t) |
| 298 | defer ctrl.Finish() |
| 299 | p := pubsub.NewMockPubSubInterface(ctrl) |
| 300 | var wg sync.WaitGroup |
| 301 | wg.Add(3) |
| 302 | p.EXPECT().Publish(common.PubSubPods, gomock.Any()).Times(3).Do(func(pubsub.PubSubTopic, interface{}) { |
| 303 | wg.Done() |
| 304 | }) |
| 305 | p.EXPECT().Subscribe(common.PubSubAPIServer, gomock.Any()).Times(1) |
| 306 | c := New(p) |
| 307 | assert.NotNil(t, c) |
| 308 | |
| 309 | addEndpoints := common.NewRetinaEndpoint("pod1", "ns1", nil) |
| 310 | addEndpoints.SetLabels(map[string]string{ |
| 311 | "app": "app1", |
| 312 | }) |
| 313 | |
| 314 | addEndpoints.SetIPs(&common.IPAddresses{ |
| 315 | IPv4: net.IPv4(1, 2, 3, 4), |
| 316 | }) |
| 317 | |
| 318 | err := c.UpdateRetinaEndpoint(addEndpoints) |
| 319 | assert.NoError(t, err) |
| 320 | |
| 321 | addEndpoints = common.NewRetinaEndpoint("pod1", "ns2", nil) |
| 322 | addEndpoints.SetLabels(map[string]string{ |
| 323 | "app": "app1", |
| 324 | }) |
| 325 | |
| 326 | addEndpoints.SetIPs(&common.IPAddresses{ |
| 327 | IPv4: net.IPv4(1, 2, 3, 4), |
| 328 | }) |
| 329 | |
| 330 | err = c.UpdateRetinaEndpoint(addEndpoints) |
| 331 | assert.NoError(t, err) |
| 332 | |
| 333 | obj := c.GetObjByIP("1.2.3.4") |
| 334 | |
| 335 | assert.NotNil(t, obj) |
| 336 | ep := obj.(*common.RetinaEndpoint) |
| 337 | assert.Equal(t, addEndpoints.Name(), ep.Name()) |
| 338 | assert.Equal(t, addEndpoints.Namespace(), ep.Namespace()) |
| 339 | |
| 340 | wg.Wait() |
| 341 | } |
| 342 | |
| 343 | func TestFailDelete(t *testing.T) { |
| 344 | log.SetupZapLogger(log.GetDefaultLogOpts()) |
nothing calls this directly
no test coverage detected