@@ -319,16 +319,17 @@ import (
319
319
// asynchronously, subsequent queries that depend on the state of
320
320
// the query should be run with the "retry" option to ensure
321
321
// deterministic test results.
322
- // - kvtrace: runs the query and compares against the results of the
323
- // kv operations trace of the query. kvtrace optionally accepts
324
- // arguments of the form kvtrace(op,op,...). Op is one of
325
- // the accepted k/v arguments such as 'CPut', 'Scan' etc. It
326
- // also accepts arguments of the form 'prefix=...'. For example,
327
- // if kvtrace(CPut,Del,prefix=/Table/54,prefix=/Table/55), the
328
- // results will be filtered to contain messages starting with
329
- // CPut /Table/54, CPut /Table/55, Del /Table/54, Del /Table/55.
330
- // Tenant IDs do not need to be included in prefixes and will be
331
- // removed from results. Cannot be combined with noticetrace.
322
+ // - kvtrace: runs the query and compares against the results of the kv
323
+ // operations trace of the query. kvtrace optionally accepts arguments of the
324
+ // form kvtrace(op,op,...). Op is one of the accepted k/v arguments such as
325
+ // 'CPut', 'Scan' etc. It also accepts arguments of the form 'prefix=...'. For
326
+ // example, if kvtrace(CPut,Del,prefix=/Table/54,prefix=/Table/55), the results
327
+ // will be filtered to contain messages starting with CPut /Table/54, CPut
328
+ // /Table/55, Del /Table/54, Del /Table/55. The 'redactbytes' will redact the
329
+ // contents of /BYTES/ values to prevent test flakiness in the presence of
330
+ // nondeterminism and/or processor architecture differences. Tenant IDs do not
331
+ // need to be included in prefixes and will be removed from results. Cannot be
332
+ // combined with noticetrace.
332
333
// - noticetrace: runs the query and compares only the notices that
333
334
// appear. Cannot be combined with kvtrace.
334
335
// - nodeidx=N: runs the query on node N of the cluster.
@@ -944,6 +945,10 @@ type logicQuery struct {
944
945
// the particular operation types to filter on, such as CPut or Del.
945
946
kvOpTypes []string
946
947
keyPrefixFilters []string
948
+ // kvtraceRedactBytes can only be used when kvtrace is true. When active, BYTES
949
+ // values in keys are expunged from output (to prevent test failures where the
950
+ // BYTES value is nondeterministic or architecture dependent).
951
+ kvtraceRedactBytes bool
947
952
948
953
// nodeIdx determines which node on the cluster to execute a query on for the given query.
949
954
nodeIdx int
@@ -2835,6 +2840,8 @@ func (t *logicTest) processSubtest(
2835
2840
matched = "/Tenant/%" + matched
2836
2841
}
2837
2842
query .keyPrefixFilters = append (query .keyPrefixFilters , matched )
2843
+ } else if c == "redactbytes" {
2844
+ query .kvtraceRedactBytes = true
2838
2845
} else if isAllowedKVOp (c ) {
2839
2846
query .kvOpTypes = append (query .kvOpTypes , c )
2840
2847
} else {
@@ -2872,6 +2879,7 @@ func (t *logicTest) processSubtest(
2872
2879
query .kvtrace = true
2873
2880
query .kvOpTypes = nil
2874
2881
query .keyPrefixFilters = nil
2882
+ query .kvtraceRedactBytes = false
2875
2883
2876
2884
case "noticetrace" :
2877
2885
query .noticetrace = true
@@ -3017,7 +3025,13 @@ func (t *logicTest) processSubtest(
3017
3025
3018
3026
projection := `message`
3019
3027
if len (t .tenantApps ) != 0 || t .cluster .StartedDefaultTestTenant () {
3020
- projection = `regexp_replace(message, '/Tenant/\d+', '')`
3028
+ projection = `regexp_replace(message, '/Tenant/\d+', '', 'g')`
3029
+ }
3030
+ if query .kvtraceRedactBytes {
3031
+ projection = fmt .Sprintf (
3032
+ `regexp_replace(%s, '/BYTES/0x[abcdef\d]+', '/BYTES/:redacted:', 'g')` ,
3033
+ projection ,
3034
+ )
3021
3035
}
3022
3036
queryPrefix := fmt .Sprintf (`SELECT %s FROM [SHOW KV TRACE FOR SESSION] ` , projection )
3023
3037
buildQuery := func (ops []string , keyFilters []string ) string {
0 commit comments