Trt 1989 benchmarking#3557
Conversation
|
Pipeline controller notification For optional jobs, comment This repository is configured in: automatic mode |
WalkthroughThis PR adds DSN-derived short connection naming, refactors benchmark summary output to build and optionally persist timestamped reports, expands getBenchmarkCases with multiple new report query benchmarks, and updates DB client and benchmark tests to thread the connection name into reporting. ChangesBenchmark Harness Enhancements
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 13 | ❌ 4❌ Failed checks (3 warnings, 1 inconclusive)
✅ Passed checks (13 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: neisw The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/flags/postgres_benchmarking_test.go`:
- Around line 39-49: The extractConnectionName function currently slices the DSN
after "@" but can include path or port and returns empty for hosts without dots;
update it to first isolate the authority portion (stop at the first "/" or "?"
after the "@"), then strip any ":port" if present, and finally return the host
portion — if a dot exists in that host return the substring before the first
dot, otherwise return the full host (so "localhost" yields "localhost" rather
than ""). Modify the function extractConnectionName to implement this parsing
order to avoid picking up dots from the DB path and to preserve common hosts
without dots.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited)
Review profile: CHILL
Plan: Enterprise
Run ID: 918a58a0-21dd-4ca6-83f0-aec0a76e4979
📒 Files selected for processing (1)
pkg/flags/postgres_benchmarking_test.go
| func extractConnectionName(dsn string) string { | ||
| atIdx := strings.Index(dsn, "@") | ||
| if atIdx < 0 { | ||
| return "" | ||
| } | ||
| host := dsn[atIdx+1:] | ||
| if dotIdx := strings.Index(host, "."); dotIdx > 0 { | ||
| return host[:dotIdx] | ||
| } | ||
| return "" | ||
| } |
There was a problem hiding this comment.
Connection-name parsing drops common DSNs and can generate invalid filename prefixes.
extractConnectionName returns "" for hosts without a dot (e.g. localhost), so file reporting is silently skipped. It can also accidentally include :port/ when a dot appears later in the DB path.
Proposed fix
func extractConnectionName(dsn string) string {
- atIdx := strings.Index(dsn, "@")
+ atIdx := strings.LastIndex(dsn, "@")
if atIdx < 0 {
return ""
}
- host := dsn[atIdx+1:]
- if dotIdx := strings.Index(host, "."); dotIdx > 0 {
- return host[:dotIdx]
+
+ hostPort := dsn[atIdx+1:]
+ if slashIdx := strings.Index(hostPort, "/"); slashIdx >= 0 {
+ hostPort = hostPort[:slashIdx]
+ }
+
+ host := hostPort
+ if colonIdx := strings.Index(host, ":"); colonIdx >= 0 {
+ host = host[:colonIdx]
+ }
+ if host == "" {
+ return ""
+ }
+
+ if dotIdx := strings.Index(host, "."); dotIdx > 0 {
+ return host[:dotIdx]
}
- return ""
+ return host
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| func extractConnectionName(dsn string) string { | |
| atIdx := strings.Index(dsn, "@") | |
| if atIdx < 0 { | |
| return "" | |
| } | |
| host := dsn[atIdx+1:] | |
| if dotIdx := strings.Index(host, "."); dotIdx > 0 { | |
| return host[:dotIdx] | |
| } | |
| return "" | |
| } | |
| func extractConnectionName(dsn string) string { | |
| atIdx := strings.LastIndex(dsn, "@") | |
| if atIdx < 0 { | |
| return "" | |
| } | |
| hostPort := dsn[atIdx+1:] | |
| if slashIdx := strings.Index(hostPort, "/"); slashIdx >= 0 { | |
| hostPort = hostPort[:slashIdx] | |
| } | |
| host := hostPort | |
| if colonIdx := strings.Index(host, ":"); colonIdx >= 0 { | |
| host = host[:colonIdx] | |
| } | |
| if host == "" { | |
| return "" | |
| } | |
| if dotIdx := strings.Index(host, "."); dotIdx > 0 { | |
| return host[:dotIdx] | |
| } | |
| return host | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@pkg/flags/postgres_benchmarking_test.go` around lines 39 - 49, The
extractConnectionName function currently slices the DSN after "@" but can
include path or port and returns empty for hosts without dots; update it to
first isolate the authority portion (stop at the first "/" or "?" after the
"@"), then strip any ":port" if present, and finally return the host portion —
if a dot exists in that host return the substring before the first dot,
otherwise return the full host (so "localhost" yields "localhost" rather than
""). Modify the function extractConnectionName to implement this parsing order
to avoid picking up dots from the DB path and to preserve common hosts without
dots.
There was a problem hiding this comment.
♻️ Duplicate comments (1)
pkg/flags/postgres_benchmarking_test.go (1)
39-49:⚠️ Potential issue | 🟠 Major | ⚡ Quick winFix DSN host parsing before deriving
connName.Line 44 currently takes everything after
@, sohostmay include:port//db, and hosts likelocalhostproduce emptyconnName. That causes report writing to be silently skipped and can generate malformed filename prefixes.Proposed fix
func extractConnectionName(dsn string) string { - atIdx := strings.Index(dsn, "@") + atIdx := strings.LastIndex(dsn, "@") if atIdx < 0 { return "" } - host := dsn[atIdx+1:] - if dotIdx := strings.Index(host, "."); dotIdx > 0 { - return host[:dotIdx] + + hostPort := dsn[atIdx+1:] + if slashIdx := strings.Index(hostPort, "/"); slashIdx >= 0 { + hostPort = hostPort[:slashIdx] + } + if qIdx := strings.Index(hostPort, "?"); qIdx >= 0 { + hostPort = hostPort[:qIdx] + } + + host := hostPort + if colonIdx := strings.Index(host, ":"); colonIdx >= 0 { + host = host[:colonIdx] + } + if host == "" { + return "" + } + if dotIdx := strings.Index(host, "."); dotIdx > 0 { + return host[:dotIdx] } - return "" + return host }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/flags/postgres_benchmarking_test.go` around lines 39 - 49, The extractConnectionName function incorrectly sets host to everything after "@" so it may include ":port", "/db", or URL path and returns empty for plain hosts like "localhost"; update extractConnectionName to first isolate the host portion by trimming any leading scheme/userinfo if present and then stripping port (after ':') and any path/query (after '/'), then derive and return the connection name by taking the substring before the first '.' (use variables atIdx, host, colonIdx, slashIdx and the function name extractConnectionName to locate the logic) so report filenames are generated correctly and no writes are skipped.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Duplicate comments:
In `@pkg/flags/postgres_benchmarking_test.go`:
- Around line 39-49: The extractConnectionName function incorrectly sets host to
everything after "@" so it may include ":port", "/db", or URL path and returns
empty for plain hosts like "localhost"; update extractConnectionName to first
isolate the host portion by trimming any leading scheme/userinfo if present and
then stripping port (after ':') and any path/query (after '/'), then derive and
return the connection name by taking the substring before the first '.' (use
variables atIdx, host, colonIdx, slashIdx and the function name
extractConnectionName to locate the logic) so report filenames are generated
correctly and no writes are skipped.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited)
Review profile: CHILL
Plan: Enterprise
Run ID: 64110f1e-09bd-4e10-95ba-5a5781462e10
📒 Files selected for processing (1)
pkg/flags/postgres_benchmarking_test.go
7752706 to
117d9e3
Compare
There was a problem hiding this comment.
♻️ Duplicate comments (1)
pkg/flags/postgres_benchmarking_test.go (1)
40-50:⚠️ Potential issue | 🟠 Major | ⚡ Quick winConnection-name parsing still drops common DSNs and can generate invalid filename prefixes.
This issue was flagged in a previous review and remains unaddressed.
extractConnectionNamereturns""for hosts without a dot (e.g.,localhost), causing file reporting to be silently skipped. It can also accidentally include:port/when a dot appears later in the DB path.Proposed fix from previous review
func extractConnectionName(dsn string) string { - atIdx := strings.Index(dsn, "@") + atIdx := strings.LastIndex(dsn, "@") if atIdx < 0 { return "" } - host := dsn[atIdx+1:] - if dotIdx := strings.Index(host, "."); dotIdx > 0 { - return host[:dotIdx] + + hostPort := dsn[atIdx+1:] + if slashIdx := strings.Index(hostPort, "/"); slashIdx >= 0 { + hostPort = hostPort[:slashIdx] + } + + host := hostPort + if colonIdx := strings.Index(host, ":"); colonIdx >= 0 { + host = host[:colonIdx] + } + if host == "" { + return "" + } + + if dotIdx := strings.Index(host, "."); dotIdx > 0 { + return host[:dotIdx] } - return "" + return host }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/flags/postgres_benchmarking_test.go` around lines 40 - 50, extractConnectionName currently slices from the first "@" to the first "." which drops hosts like "localhost" and can include ":port/" or path segments; update extractConnectionName to first extract the host portion between the "@" and the next "/" (or end), strip any trailing ":port" if present, then if the host contains a dot return the first label before the dot otherwise return the whole host; additionally sanitize the returned string to be a valid filename prefix (e.g., replace non-alphanumeric characters with underscores) so callers get a safe, non-empty connection name from extractConnectionName.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Duplicate comments:
In `@pkg/flags/postgres_benchmarking_test.go`:
- Around line 40-50: extractConnectionName currently slices from the first "@"
to the first "." which drops hosts like "localhost" and can include ":port/" or
path segments; update extractConnectionName to first extract the host portion
between the "@" and the next "/" (or end), strip any trailing ":port" if
present, then if the host contains a dot return the first label before the dot
otherwise return the whole host; additionally sanitize the returned string to be
a valid filename prefix (e.g., replace non-alphanumeric characters with
underscores) so callers get a safe, non-empty connection name from
extractConnectionName.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited)
Review profile: CHILL
Plan: Enterprise
Run ID: 4f74fb03-f283-43fb-97cd-f7e8a0063b1a
📒 Files selected for processing (1)
pkg/flags/postgres_benchmarking_test.go
|
@neisw: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Updates benchmarking queries and optionally writes report to file
Summary by CodeRabbit
Tests
Chores