88 "context"
99 "encoding/json"
1010 "encoding/xml"
11- "errors"
1211 "fmt"
1312 "io"
1413 "net/http"
@@ -28,6 +27,7 @@ import (
2827 "github.com/Azure/azure-container-networking/nmagent"
2928 "github.com/Azure/azure-container-networking/processlock"
3029 "github.com/Azure/azure-container-networking/store"
30+ "github.com/pkg/errors"
3131 "github.com/stretchr/testify/assert"
3232)
3333
@@ -86,15 +86,15 @@ var (
8686 }
8787
8888 nc1 = createOrUpdateNetworkContainerParams {
89- ncID : "ethWebApp1 " ,
89+ ncID : "f47ac10b-58cc-0372-8567-0e02b2c3d479 " ,
9090 ncIP : "11.0.0.5" ,
9191 ncType : cns .AzureContainerInstance ,
9292 ncVersion : "0" ,
9393 podName : "testpod" ,
9494 podNamespace : "testpodnamespace" ,
9595 }
9696 nc2 = createOrUpdateNetworkContainerParams {
97- ncID : "ethWebApp2 " ,
97+ ncID : "f47ac10b-58cc-0372-8567-0e02b2c3d478 " ,
9898 ncIP : "11.0.0.5" ,
9999 ncType : cns .AzureContainerInstance ,
100100 ncVersion : "0" ,
@@ -105,15 +105,15 @@ var (
105105 errMismatchedNCs = errors .New ("GetNetworkContainers failed because NCs not matched" )
106106
107107 nc3 = createOrUpdateNetworkContainerParams {
108- ncID : "1abc " ,
108+ ncID : "f47ac10b-58cc-0372-8567-0e02b2c3d477 " ,
109109 ncIP : "10.0.0.5" ,
110110 ncType : cns .AzureContainerInstance ,
111111 ncVersion : "0" ,
112112 podName : "testpod" ,
113113 podNamespace : "testpodnamespace" ,
114114 }
115115 nc4 = createOrUpdateNetworkContainerParams {
116- ncID : "2abc " ,
116+ ncID : "f47ac10b-58cc-0372-8567-0e02b2c3d476 " ,
117117 ncIP : "20.0.0.5" ,
118118 ncType : cns .AzureContainerInstance ,
119119 ncVersion : "0" ,
@@ -421,7 +421,7 @@ func TestDeleteNetworkContainers(t *testing.T) {
421421 t .Fatal (err )
422422 }
423423
424- if ncResponse .NetworkContainerID != "Swift_2abc" {
424+ if strings . TrimPrefix ( ncResponse .NetworkContainerID , cns . SwiftPrefix ) != nc4 . ncID {
425425 t .Fatal ("failed to check second nc" )
426426 }
427427
@@ -448,7 +448,7 @@ func TestCreateNetworkContainer(t *testing.T) {
448448 fmt .Println ("TestCreateNetworkContainer: JobObject" )
449449
450450 params := createOrUpdateNetworkContainerParams {
451- ncID : "testJobObject " ,
451+ ncID : "f47ac10b-58cc-0372-8567-0e02b2c3d476 " ,
452452 ncIP : "10.1.0.5" ,
453453 ncType : "JobObject" ,
454454 ncVersion : "0" ,
@@ -473,7 +473,7 @@ func TestCreateNetworkContainer(t *testing.T) {
473473 // Test create network container of type WebApps
474474 fmt .Println ("TestCreateNetworkContainer: WebApps" )
475475 params = createOrUpdateNetworkContainerParams {
476- ncID : "ethWebApp " ,
476+ ncID : "f47ac10b-58cc-0372-8567-0e02b2c3d475 " ,
477477 ncIP : "192.0.0.5" ,
478478 ncType : "WebApps" ,
479479 ncVersion : "0" ,
@@ -488,7 +488,7 @@ func TestCreateNetworkContainer(t *testing.T) {
488488 }
489489
490490 params = createOrUpdateNetworkContainerParams {
491- ncID : "ethWebApp " ,
491+ ncID : "f47ac10b-58cc-0372-8567-0e02b2c3d475 " ,
492492 ncIP : "192.0.0.6" ,
493493 ncType : "WebApps" ,
494494 ncVersion : "0" ,
@@ -512,7 +512,7 @@ func TestCreateNetworkContainer(t *testing.T) {
512512
513513 // Test create network container of type COW
514514 params = createOrUpdateNetworkContainerParams {
515- ncID : "testCOWContainer " ,
515+ ncID : "f47ac10b-58cc-0372-8567-0e02b2c3d474 " ,
516516 ncIP : "10.0.0.5" ,
517517 ncType : "COW" ,
518518 ncVersion : "0" ,
@@ -543,7 +543,7 @@ func TestGetNetworkContainerByOrchestratorContext(t *testing.T) {
543543 setOrchestratorType (t , cns .Kubernetes )
544544
545545 params := createOrUpdateNetworkContainerParams {
546- ncID : "ethWebApp " ,
546+ ncID : "f47ac10b-58cc-0372-8567-0e02b2c3d471 " ,
547547 ncIP : "11.0.0.5" ,
548548 ncType : cns .AzureContainerInstance ,
549549 ncVersion : "0" ,
@@ -605,7 +605,7 @@ func TestGetInterfaceForNetworkContainer(t *testing.T) {
605605 setOrchestratorType (t , cns .Kubernetes )
606606
607607 params := createOrUpdateNetworkContainerParams {
608- ncID : "ethWebApp " ,
608+ ncID : "f47ac10b-58cc-0372-8567-0e02b2c3d479 " ,
609609 ncIP : "11.0.0.5" ,
610610 ncType : "WebApps" ,
611611 ncVersion : "0" ,
@@ -673,7 +673,7 @@ func TestGetNetworkContainerVersionStatus(t *testing.T) {
673673 defer cleanupWSP ()
674674
675675 params := createOrUpdateNetworkContainerParams {
676- ncID : "nc-nma-success " ,
676+ ncID : "f47ac10b-58cc-0372-8567-0e02b2c3d475 " ,
677677 ncIP : "11.0.0.5" ,
678678 ncType : cns .AzureContainerInstance ,
679679 ncVersion : "0" ,
@@ -721,7 +721,7 @@ func TestGetNetworkContainerVersionStatus(t *testing.T) {
721721 // Testing the path where the NC version with CNS is higher than the one with NMAgent.
722722 // This indicates that the NMAgent is yet to program the NC version.
723723 params = createOrUpdateNetworkContainerParams {
724- ncID : "nc-nma-fail-version-mismatch " ,
724+ ncID : "f47ac10b-58cc-0372-8567-0e02b2c3d474 " ,
725725 ncIP : "11.0.0.5" ,
726726 ncType : cns .AzureContainerInstance ,
727727 ncVersion : "1" ,
@@ -760,7 +760,7 @@ func TestGetNetworkContainerVersionStatus(t *testing.T) {
760760
761761 // Testing the path where NMAgent response status code is not 200.
762762 params = createOrUpdateNetworkContainerParams {
763- ncID : "nc-nma-fail-500 " ,
763+ ncID : "f47ac10b-58cc-0372-8567-0e02b2c3d473 " ,
764764 ncIP : "11.0.0.5" ,
765765 ncType : cns .AzureContainerInstance ,
766766 ncVersion : "0" ,
@@ -802,7 +802,7 @@ func TestGetNetworkContainerVersionStatus(t *testing.T) {
802802
803803 // Testing the path where NMAgent response status code is 200 but embedded response is 401
804804 params = createOrUpdateNetworkContainerParams {
805- ncID : "nc-nma-fail-unavailable " ,
805+ ncID : "f47ac10b-58cc-0372-8567-0e02b2c3d472 " ,
806806 ncIP : "11.0.0.5" ,
807807 ncType : cns .AzureContainerInstance ,
808808 ncVersion : "0" ,
@@ -1362,7 +1362,7 @@ func getAllNetworkContainers(t *testing.T, ncParams []createOrUpdateNetworkConta
13621362 var resp cns.GetAllNetworkContainersResponse
13631363 err = decodeResponse (w , & resp )
13641364 if err != nil || resp .Response .ReturnCode != types .Success || len (resp .NetworkContainers ) != len (ncParams ) {
1365- return cns.GetAllNetworkContainersResponse {}, fmt . Errorf ( "GetNetworkContainers failed with response %+v Err: %w " , resp , err )
1365+ return cns.GetAllNetworkContainersResponse {}, errors . Wrapf ( err , "GetNetworkContainers failed with response %+v" , resp )
13661366 }
13671367
13681368 // If any NC in response is not found in ncParams, it means get all NCs failed
@@ -1446,7 +1446,7 @@ func postAllNetworkContainers(t *testing.T, ncParams []createOrUpdateNetworkCont
14461446 err = decodeResponse (w , & resp )
14471447
14481448 if err != nil || resp .Response .ReturnCode != types .Success {
1449- return fmt .Errorf ("post Network Containers failed with response %+v Err: %w" , resp , err )
1449+ return fmt .Errorf ("post Network Containers failed with response %+v: %w" , resp , err )
14501450 }
14511451 t .Logf ("Post Network Containers succeeded with response %+v\n " , resp )
14521452
0 commit comments