-
Notifications
You must be signed in to change notification settings - Fork 344
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
Deterministic TagPair assertion of custom registry #1183
Changes from all 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 |
---|---|---|
|
@@ -164,21 +164,31 @@ func TestGetE2EImageTagPairs(t *testing.T) { | |
} | ||
expectedDefaultRegistry := defaultRegistry.v1_17() | ||
if len(imageTagPairs) != len(expectedDefaultRegistry) { | ||
t.Fatalf("Unexpected number of image tag pairs returned, expected %v, got %v", len(expectedDefaultRegistry), len(imageTagPairs)) | ||
t.Fatalf("unexpected number of image tag pairs returned, expected %v, got %v", len(expectedDefaultRegistry), len(imageTagPairs)) | ||
} | ||
|
||
// Check one of the returned image pairs to ensure correct format | ||
imageTagPair := imageTagPairs[0] | ||
if strings.HasPrefix(imageTagPair.Src, customRegistry) { | ||
t.Errorf("Src image should not have custom registry prefix: %q", imageTagPair.Src) | ||
// As a sample, check one of the images for E2E and assert their mapping | ||
var e2eImageTagPair TagPair | ||
for _, imageTagPair := range imageTagPairs { | ||
if strings.Contains(imageTagPair.Src, "e2e") { | ||
e2eImageTagPair = imageTagPair | ||
break | ||
} | ||
} | ||
|
||
if e2eImageTagPair == (TagPair{}) { | ||
t.Errorf("no e2eImageTagPair is found") | ||
} | ||
if strings.HasPrefix(e2eImageTagPair.Src, customRegistry) { | ||
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. Also, if that loop never break (above) does that create any initializiation hazard for var 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. ah yeah that's a good point. I think |
||
t.Errorf("src image should not have custom registry prefix: %q", e2eImageTagPair.Src) | ||
} | ||
|
||
imageComponents := strings.SplitAfter(imageTagPair.Src, "/") | ||
if !strings.HasPrefix(imageTagPair.Dst, customRegistry) { | ||
t.Errorf("Expected Dst image to have prefix %q, got %q", customRegistry, imageTagPair.Dst) | ||
imageComponents := strings.SplitAfter(e2eImageTagPair.Src, "/") | ||
if !strings.HasPrefix(e2eImageTagPair.Dst, customRegistry) { | ||
t.Errorf("expected Dst image to have prefix %q, got %q", customRegistry, e2eImageTagPair.Dst) | ||
} | ||
if !strings.HasSuffix(imageTagPair.Dst, imageComponents[len(imageComponents)-1]) { | ||
t.Errorf("Expected Dst image to have suffix %q, got %q", imageComponents[len(imageComponents)-1], imageTagPair.Dst) | ||
if !strings.HasSuffix(e2eImageTagPair.Dst, imageComponents[len(imageComponents)-1]) { | ||
t.Errorf("expected Dst image to have suffix %q, got %q", imageComponents[len(imageComponents)-1], e2eImageTagPair.Dst) | ||
} | ||
} | ||
|
||
|
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.
So this ensures the name of the image:tag contains
e2e
in the string ? Is that always the case ?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.
this ensures that what we validate is only the
e2e
in string, which should scope togcr.io/kubernetes-e2e-test-images
ork8s.gcr.io/e2e-test-images
-- both are overridable with custom registry