-
Notifications
You must be signed in to change notification settings - Fork 65
update kubernetes/openshift endpoint validation #1098
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -327,11 +327,25 @@ func TestValidateComponents(t *testing.T) { | |
wantErr: []string{sameTargetPortErr}, | ||
}, | ||
{ | ||
name: "Invalid container with same target ports in a single component", | ||
name: "Valid container with same target ports in a single component", | ||
components: []v1alpha2.Component{ | ||
generateDummyContainerComponent("name1", nil, []v1alpha2.Endpoint{endpointUrl18080, endpointUrl28080}, nil, v1alpha2.Annotation{}, false), | ||
}, | ||
wantErr: []string{sameTargetPortErr}, | ||
}, | ||
{ | ||
name: "Invalid Kube components with the same endpoint names", | ||
components: []v1alpha2.Component{ | ||
generateDummyKubernetesComponent("name1", []v1alpha2.Endpoint{endpointUrl18080}, ""), | ||
generateDummyKubernetesComponent("name2", []v1alpha2.Endpoint{endpointUrl18081}, ""), | ||
}, | ||
wantErr: []string{sameEndpointNameErr}, | ||
}, | ||
{ | ||
name: "Valid Kube components with the same endpoint target ports", | ||
components: []v1alpha2.Component{ | ||
generateDummyContainerComponent("name1", nil, []v1alpha2.Endpoint{endpointUrl18080}, nil, v1alpha2.Annotation{}, false), | ||
generateDummyKubernetesComponent("name2", []v1alpha2.Endpoint{endpointUrl28080}, ""), | ||
}, | ||
}, | ||
{ | ||
name: "Valid containers with valid resource requirement", | ||
|
@@ -538,8 +552,10 @@ func TestValidateComponents(t *testing.T) { | |
assert.Regexp(t, tt.wantErr[i], merr.Errors[i].Error(), "Error message should match") | ||
} | ||
} | ||
} else { | ||
} else if tt.wantErr == nil { | ||
assert.Equal(t, nil, err, "Error should be nil") | ||
} else if tt.wantErr != nil { | ||
assert.NotEqual(t, nil, err, "Error should not be nil") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For clarity, it might make sense to do these checks first -- as it stands it looks like we check a subcase of if tt.wantErr == nil {
assert.NoError(t, err, "Error should be nil")
return
} else {
if !assert.Error(t, err, "Should return error") {
return
}
}
merr, ok := err.(*multierror.Error)
if !ok {
t.Fatalf("Unexpected error: %w", err)
}
if assert.Equal(t, len(tt.wantErr), len(merr.Errors), "Error list length should match") {
for i := 0; i < len(merr.Errors); i++ {
assert.Regexp(t, tt.wantErr[i], merr.Errors[i].Error(), "Error message should match")
}
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated |
||
} | ||
}) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to double check -- is this test intended to use a container component and a kube component? I don't think duplicate endpoints between a container and kube component was ever an issue, was it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was an issue. previously we do not allow any port duplication across components
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, makes sense. Perhaps it makes sense to add another test case for two Kubernetes components that use the same port number as well? The name of this test case suggests it's covering something like
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added