Skip to content

Commit

Permalink
add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
cadmuxe committed Jan 15, 2020
1 parent 7b59c92 commit f1d1825
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions cmd/e2e-test/asm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ func TestASMServiceAndDestinationRule(t *testing.T) {
svcName := "service"
svcSkipName := "service-skip"

// Create deployments used by the Service and DestinationRules.
// The deployment will contain two label pairs: {"app": "porter", "version": "*"}
// Different versions will be used as DestinationRule: subset
for _, deployment := range []struct {
deploymentName string
replics int32
Expand All @@ -100,35 +103,35 @@ func TestASMServiceAndDestinationRule(t *testing.T) {
}
}

for _, tc := range []struct {
// Creates Services and validates service level NEGs, NEG controller shouldn't create service level NEGs for those services in the skip namespace.
for _, svc := range []struct {
desc string
svcName string
inSkipNamespace bool
}{
{desc: "NEG Controller should create NEGs for all ports for a service by default", svcName: svcName, inSkipNamespace: false},
{desc: "NEG Controller shouldn't create NEGs for all ports for a service if it's in a skip namespace", svcName: svcSkipName, inSkipNamespace: true},
} {
t.Logf("Running test case: %s", tc.desc)
t.Logf("Running test case: %s", svc.desc)
sandbox := s
noPresentTest := false
if tc.inSkipNamespace {
if svc.inSkipNamespace {
sandbox = sSkip
noPresentTest = true
}
if err := e2e.CreatePorterService(sandbox, tc.svcName); err != nil {
if err := e2e.CreatePorterService(sandbox, svc.svcName); err != nil {
t.Errorf("Failed to create service, Error: %s", err)
}

// Test the Service Annotations
negStatus, err := e2e.WaitForNegStatus(sandbox, tc.svcName, []string{strconv.Itoa(int(porterPort))}, noPresentTest)
negStatus, err := e2e.WaitForNegStatus(sandbox, svc.svcName, []string{strconv.Itoa(int(porterPort))}, noPresentTest)
if err != nil {
t.Errorf("Failed to wait for Service NEGAnnotation, error: %s", err)

}
if tc.inSkipNamespace {
if svc.inSkipNamespace {
if negStatus != nil {
t.Errorf("Service: %s/%s is in the ASM skip namespace, shoudln't have NEG Status. ASM Config: %v, NEGStatus got: %v",
sandbox.Namespace, tc.svcName, asmConfig, negStatus)
sandbox.Namespace, svc.svcName, asmConfig, negStatus)
}
} else {
if negName, ok := negStatus.NetworkEndpointGroups[strconv.Itoa(int(porterPort))]; ok {
Expand Down Expand Up @@ -188,7 +191,6 @@ func TestASMServiceAndDestinationRule(t *testing.T) {
if err := e2e.WaitForNegs(ctx, Framework.Cloud, negName, zones, false, endpointCount); err != nil {
t.Errorf("Failed to wait Negs, error: %s", err)
}

}

}
Expand Down

0 comments on commit f1d1825

Please sign in to comment.