Skip to content

Commit 1f5f953

Browse files
craig[bot]kyle-a-wong
andcommitted
Merge #154874
154874: log: sanitize log migration datadriven tests r=kyle-a-wong a=kyle-a-wong The datadriven tests for log migration allow for an arbitrary depth to be provided, which is used to identify what file and line number a log is being logged from. For the sake of this test, the specific line number is not necessary and makes the test more brittle, especially since it may result in logging the log line from an external library. To fix, `cleanLogEntries` has been updated to also set the line number in the structured event log output to be 0 for all logs. Epic: None Release note: None Co-authored-by: Kyle Wong <[email protected]>
2 parents e7cb6d4 + c0101d4 commit 1f5f953

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

pkg/util/log/migrator_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ func cleanLogEntries(logs []logpb.Entry) []logpb.Entry {
185185
for _, l := range logs {
186186
l.Time = 0
187187
l.Goroutine = 0
188+
l.Line = 0
188189
newLogs = append(newLogs, l)
189190
}
190191
return newLogs

pkg/util/log/testdata/log_migration

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ structured-event should_migrate=true new_channel=OPS
33
DEV Channel:
44
[]
55
OPS Channel:
6-
[{Severity:INFO Time:0 Goroutine:0 File:util/log_test/migrator_test.go Line:74 Message:Structured entry: {"Timestamp":1735689600000000000,"EventType":"test_event"} Tags: Counter:2 Redactable:true Channel:OPS StructuredEnd:76 StructuredStart:18 StackTraceStart:0 TenantID: TenantName:}]
6+
[{Severity:INFO Time:0 Goroutine:0 File:util/log_test/migrator_test.go Line:0 Message:Structured entry: {"Timestamp":1735689600000000000,"EventType":"test_event"} Tags: Counter:2 Redactable:true Channel:OPS StructuredEnd:76 StructuredStart:18 StackTraceStart:0 TenantID: TenantName:}]
77

88
structured-event should_migrate=false new_channel=OPS
99
----
1010
DEV Channel:
11-
[{Severity:INFO Time:0 Goroutine:0 File:util/log_test/migrator_test.go Line:74 Message:Structured entry: {"Timestamp":1735689600000000000,"EventType":"test_event"} Tags: Counter:5 Redactable:true Channel:DEV StructuredEnd:76 StructuredStart:18 StackTraceStart:0 TenantID: TenantName:}]
11+
[{Severity:INFO Time:0 Goroutine:0 File:util/log_test/migrator_test.go Line:0 Message:Structured entry: {"Timestamp":1735689600000000000,"EventType":"test_event"} Tags: Counter:5 Redactable:true Channel:DEV StructuredEnd:76 StructuredStart:18 StackTraceStart:0 TenantID: TenantName:}]
1212
OPS Channel:
1313
[]
1414

@@ -17,12 +17,12 @@ structured-event should_migrate=true new_channel=OPS depth=0
1717
DEV Channel:
1818
[]
1919
OPS Channel:
20-
[{Severity:INFO Time:0 Goroutine:0 File:util/log_test/migrator_test.go Line:72 Message:Structured entry: {"Timestamp":1735689600000000000,"EventType":"test_event"} Tags: Counter:8 Redactable:true Channel:OPS StructuredEnd:76 StructuredStart:18 StackTraceStart:0 TenantID: TenantName:}]
20+
[{Severity:INFO Time:0 Goroutine:0 File:util/log_test/migrator_test.go Line:0 Message:Structured entry: {"Timestamp":1735689600000000000,"EventType":"test_event"} Tags: Counter:8 Redactable:true Channel:OPS StructuredEnd:76 StructuredStart:18 StackTraceStart:0 TenantID: TenantName:}]
2121

2222
structured-event should_migrate=false new_channel=OPS depth=0
2323
----
2424
DEV Channel:
25-
[{Severity:INFO Time:0 Goroutine:0 File:util/log_test/migrator_test.go Line:72 Message:Structured entry: {"Timestamp":1735689600000000000,"EventType":"test_event"} Tags: Counter:11 Redactable:true Channel:DEV StructuredEnd:76 StructuredStart:18 StackTraceStart:0 TenantID: TenantName:}]
25+
[{Severity:INFO Time:0 Goroutine:0 File:util/log_test/migrator_test.go Line:0 Message:Structured entry: {"Timestamp":1735689600000000000,"EventType":"test_event"} Tags: Counter:11 Redactable:true Channel:DEV StructuredEnd:76 StructuredStart:18 StackTraceStart:0 TenantID: TenantName:}]
2626
OPS Channel:
2727
[]
2828

@@ -31,20 +31,20 @@ structured-event should_migrate=true new_channel=OPS depth=1
3131
DEV Channel:
3232
[]
3333
OPS Channel:
34-
[{Severity:INFO Time:0 Goroutine:0 File:datadriven/datadriven.go Line:119 Message:Structured entry: {"Timestamp":1735689600000000000,"EventType":"test_event"} Tags: Counter:14 Redactable:true Channel:OPS StructuredEnd:76 StructuredStart:18 StackTraceStart:0 TenantID: TenantName:}]
34+
[{Severity:INFO Time:0 Goroutine:0 File:datadriven/datadriven.go Line:0 Message:Structured entry: {"Timestamp":1735689600000000000,"EventType":"test_event"} Tags: Counter:14 Redactable:true Channel:OPS StructuredEnd:76 StructuredStart:18 StackTraceStart:0 TenantID: TenantName:}]
3535

3636
structured-event should_migrate=false new_channel=OPS depth=1
3737

3838
log should_migrate=true old_channel=TELEMETRY new_channel=SQL_EXEC
3939
----
4040
DEV Channel:
41-
[{Severity:INFO Time:0 Goroutine:0 File:datadriven/datadriven.go Line:119 Message:Structured entry: {"Timestamp":1735689600000000000,"EventType":"test_event"} Tags: Counter:17 Redactable:true Channel:DEV StructuredEnd:76 StructuredStart:18 StackTraceStart:0 TenantID: TenantName:}]
41+
[{Severity:INFO Time:0 Goroutine:0 File:datadriven/datadriven.go Line:0 Message:Structured entry: {"Timestamp":1735689600000000000,"EventType":"test_event"} Tags: Counter:17 Redactable:true Channel:DEV StructuredEnd:76 StructuredStart:18 StackTraceStart:0 TenantID: TenantName:}]
4242
OPS Channel:
4343
[]
4444

4545
log should_migrate=false old_channel=TELEMETRY new_channel=SQL_EXEC
4646
----
4747
TELEMETRY Channel:
48-
[{Severity:INFO Time:0 Goroutine:0 File:util/log_test/migrator_test.go Line:115 Message:‹migration log› Infof Tags: Counter:20 Redactable:true Channel:TELEMETRY StructuredEnd:0 StructuredStart:0 StackTraceStart:0 TenantID: TenantName:} {Severity:WARNING Time:0 Goroutine:0 File:util/log_test/migrator_test.go Line:116 Message:‹migration log› Warningf Tags: Counter:21 Redactable:true Channel:TELEMETRY StructuredEnd:0 StructuredStart:0 StackTraceStart:0 TenantID: TenantName:} {Severity:ERROR Time:0 Goroutine:0 File:util/log_test/migrator_test.go Line:117 Message:‹migration log› Errorf Tags: Counter:22 Redactable:true Channel:TELEMETRY StructuredEnd:0 StructuredStart:0 StackTraceStart:0 TenantID: TenantName:}]
48+
[{Severity:INFO Time:0 Goroutine:0 File:util/log_test/migrator_test.go Line:0 Message:‹migration log› Infof Tags: Counter:20 Redactable:true Channel:TELEMETRY StructuredEnd:0 StructuredStart:0 StackTraceStart:0 TenantID: TenantName:} {Severity:WARNING Time:0 Goroutine:0 File:util/log_test/migrator_test.go Line:0 Message:‹migration log› Warningf Tags: Counter:21 Redactable:true Channel:TELEMETRY StructuredEnd:0 StructuredStart:0 StackTraceStart:0 TenantID: TenantName:} {Severity:ERROR Time:0 Goroutine:0 File:util/log_test/migrator_test.go Line:0 Message:‹migration log› Errorf Tags: Counter:22 Redactable:true Channel:TELEMETRY StructuredEnd:0 StructuredStart:0 StackTraceStart:0 TenantID: TenantName:}]
4949
SQL_EXEC Channel:
5050
[]

0 commit comments

Comments
 (0)