-
Notifications
You must be signed in to change notification settings - Fork 459
e2e: fix kubectl-ko trace test #5108
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -316,25 +316,35 @@ var _ = framework.Describe("[group:kubectl-ko]", func() { | |
pod = podClient.CreateSync(pod) | ||
|
||
ginkgo.By("Checking trace output") | ||
var traceService bool | ||
subCmd := "ovn-trace" | ||
if f.VersionPriorTo(1, 12) { | ||
subCmd = "trace" | ||
} | ||
outputMatch := fmt.Sprintf("output to %q", ovs.PodNameToPortName(pod2Name, pod2.Namespace, util.OvnProvider)) | ||
matchPod := fmt.Sprintf("output to %q", ovs.PodNameToPortName(pod2Name, pod2.Namespace, util.OvnProvider)) | ||
matchLocalnet := fmt.Sprintf("output to %q", fmt.Sprintf("localnet.%s", util.DefaultSubnet)) | ||
checkFunc := func(output string) { | ||
ginkgo.GinkgoHelper() | ||
var match string | ||
if traceService && f.VersionPriorTo(1, 11) && f.IsUnderlay() { | ||
match = matchLocalnet | ||
} else { | ||
match = matchPod | ||
} | ||
if subCmd == "ovn-trace" { | ||
lines := strings.Split(strings.TrimSpace(output), "\n") | ||
framework.ExpectContainSubstring(lines[len(lines)-1], outputMatch) | ||
framework.ExpectContainSubstring(lines[len(lines)-1], match) | ||
} else { | ||
framework.ExpectContainSubstring(output, outputMatch) | ||
framework.ExpectContainSubstring(output, match) | ||
} | ||
} | ||
for protocol, port := range map[corev1.Protocol]int32{corev1.ProtocolTCP: tcpPort, corev1.ProtocolUDP: udpPort} { | ||
proto := strings.ToLower(string(protocol)) | ||
traceService = false | ||
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. Add a comment here to explain the purpose of // traceService is a flag to indicate whether we are tracing a service IP.
// When tracing a service IP, the output should match the localnet interface.
traceService = false |
||
for _, ip := range pod2.Status.PodIPs { | ||
execOrDie(fmt.Sprintf("ko %s %s/%s %s %s %d", subCmd, pod.Namespace, pod.Name, ip.IP, proto, port), checkFunc) | ||
} | ||
traceService = true | ||
for _, ip := range service.Spec.ClusterIPs { | ||
execOrDie(fmt.Sprintf("ko %s %s/%s %s %s %d", subCmd, pod.Namespace, pod.Name, ip, proto, port), checkFunc) | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 conditional logic could be simplified by combining the version and network mode checks. This would make the code easier to read and understand. Consider using a single if statement with combined conditions.