File tree Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Original file line number Diff line number Diff line change 11package middlewares
22
33import (
4- "fmt"
5-
64 "github.com/Azure/azure-container-networking/cns"
75 "github.com/Azure/azure-container-networking/cns/middlewares/utils"
86 "github.com/Azure/azure-container-networking/crd/multitenancy/api/v1alpha1"
@@ -23,7 +21,6 @@ func (k *K8sSWIFTv2Middleware) setRoutes(podIPInfo *cns.PodIpInfo) error {
2321
2422 // add routes for infraNIC
2523 routes , err := k .SetInfraRoutes (podIPInfo )
26- fmt .Printf ("routes are %v" , routes )
2724 if err != nil {
2825 return errors .Wrap (err , "failed to set routes for infraNIC interface" )
2926 }
Original file line number Diff line number Diff line change 11package middlewares
22
33import (
4- "fmt"
54 "reflect"
65 "testing"
76
@@ -37,7 +36,6 @@ func TestSetRoutesSuccess(t *testing.T) {
3736 }
3837 for i := range podIPInfo {
3938 ipInfo := & podIPInfo [i ]
40- fmt .Printf ("ipInfo is %v" , ipInfo )
4139 err := middleware .setRoutes (ipInfo )
4240 assert .Equal (t , err , nil )
4341 if ipInfo .NICType == cns .InfraNIC {
@@ -48,6 +46,27 @@ func TestSetRoutesSuccess(t *testing.T) {
4846 }
4947}
5048
49+ func TestSetRoutesFailure (t * testing.T ) {
50+ // Failure due to env var not set
51+ middleware := K8sSWIFTv2Middleware {Cli : mock .NewClient ()}
52+ podIPInfo := []cns.PodIpInfo {
53+ {
54+ PodIPConfig : cns.IPSubnet {
55+ IPAddress : "10.0.1.10" ,
56+ PrefixLength : 32 ,
57+ },
58+ NICType : cns .InfraNIC ,
59+ },
60+ }
61+ for i := range podIPInfo {
62+ ipInfo := & podIPInfo [i ]
63+ err := middleware .setRoutes (ipInfo )
64+ if err == nil {
65+ t .Errorf ("SetRoutes should fail due to env var not set" )
66+ }
67+ }
68+ }
69+
5170func TestAssignSubnetPrefixSuccess (t * testing.T ) {
5271 middleware := K8sSWIFTv2Middleware {Cli : mock .NewClient ()}
5372
You can’t perform that action at this time.
0 commit comments