|
26 | 26 | testPod4GUID = "b21e1ee1-fb7e-4e6d-8c68-22ee5049944e" |
27 | 27 | testPod4Info = cns.NewPodInfo("b21e1e-eth0", testPod4GUID, "testpod4", "testpod4namespace") |
28 | 28 |
|
29 | | - testPod5GUID = "898fb8f1-f93e-4c96-9c31-6b89098949a3" |
30 | | - testPod5Info = cns.NewPodInfo("898fb8-eth0", testPod5GUID, "testpod5", "testpod5namespace") |
31 | | - |
32 | 29 | testPod6GUID = "898fb8f1-f93e-4c96-9c31-6b89098949a3" |
33 | 30 | testPod6Info = cns.NewPodInfo("898fb8-eth0", testPod6GUID, "testpod6", "testpod6namespace") |
34 | 31 |
|
@@ -358,25 +355,30 @@ func TestAddRoutes(t *testing.T) { |
358 | 355 | GatewayIPAddress: gatewayIP, |
359 | 356 | }, |
360 | 357 | } |
361 | | - assert.Equal(t, expectedRoutes, routes, "expected routes to match the expected routes") |
| 358 | + if len(routes) != len(expectedRoutes) { |
| 359 | + t.Fatalf("expected %d routes, got %d", len(expectedRoutes), len(routes)) |
| 360 | + } |
| 361 | + for i := range routes { |
| 362 | + if routes[i] != expectedRoutes[i] { |
| 363 | + t.Errorf("route %d: expected %+v, got %+v", i, expectedRoutes[i], routes[i]) |
| 364 | + } |
| 365 | + } |
362 | 366 | } |
363 | 367 |
|
364 | 368 | func TestNICTypeConfigSuccess(t *testing.T) { |
365 | 369 | middleware := K8sSWIFTv2Middleware{Cli: mock.NewClient()} |
366 | 370 |
|
367 | | - // Test Accelnet Frontend NIC type |
368 | | - ipInfos, err := middleware.getIPConfig(context.TODO(), testPod6Info) |
369 | | - assert.Equal(t, err, nil) |
370 | | - // Ensure that the length of ipInfos matches the number of InterfaceInfos |
371 | | - // Adjust this according to the test setup |
372 | | - assert.Equal(t, len(ipInfos), 1) |
373 | | - assert.Equal(t, ipInfos[0].NICType, cns.NodeNetworkInterfaceAccelnetFrontendNIC) |
374 | | - |
375 | 371 | // Test Backend NIC type |
376 | | - ipInfos2, err := middleware.getIPConfig(context.TODO(), testPod5Info) |
377 | | - assert.Equal(t, err, nil) |
378 | | - assert.Equal(t, len(ipInfos2), 1) |
379 | | - assert.Equal(t, ipInfos2[0].NICType, cns.BackendNIC) |
| 372 | + ipInfos, err := middleware.getIPConfig(context.TODO(), testPod6Info) |
| 373 | + if err != nil { |
| 374 | + t.Fatalf("unexpected error: %v", err) |
| 375 | + } |
| 376 | + if len(ipInfos) != 1 { |
| 377 | + t.Fatalf("expected 1 ipInfo, got %d", len(ipInfos)) |
| 378 | + } |
| 379 | + if ipInfos[0].NICType != cns.BackendNIC { |
| 380 | + t.Errorf("expected NIC type %v, got %v", cns.BackendNIC, ipInfos[0].NICType) |
| 381 | + } |
380 | 382 | } |
381 | 383 |
|
382 | 384 | func TestGetSWIFTv2IPConfigMultiInterfaceFailure(t *testing.T) { |
|
0 commit comments