Skip to content

Commit 967d3cb

Browse files
committed
cli, log: fix up tests
1 parent 6128999 commit 967d3cb

File tree

9 files changed

+81
-27
lines changed

9 files changed

+81
-27
lines changed

pkg/cli/testdata/logflags

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,15 +479,15 @@ run
479479
start
480480
--log=capture-stray-errors: {enable: false}, sinks: {stderr: {filter: INFO}}
481481
----
482-
error: yaml: did not find expected key
482+
error: yaml: while parsing a block mapping at <unknown position>: <unknown position>: did not find expected key
483483

484484

485485
# This configuration becomes possible if redactability is explicitly retracted.
486486
run
487487
start
488488
--log=capture-stray-errors: {enable: false}, sinks: {stderr: {filter: INFO, redactable: false}}
489489
----
490-
error: yaml: did not find expected key
490+
error: yaml: while parsing a block mapping at <unknown position>: <unknown position>: did not find expected key
491491

492492
subtest end
493493

pkg/sql/schemachanger/testdata/end_to_end/create_complex/create_complex.side_effects

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,11 @@ write *eventpb.CreateFunction to event log:
112112
functionName: defaultdb.public.t
113113
sql:
114114
descriptorId: 107
115-
statement: "CREATE FUNCTION ‹defaultdb›.‹public›.‹t›()\n\tRETURNS INT8\n\tLANGUAGE SQL\n\tAS $$SELECT ‹1›;$$"
115+
statement: |-
116+
CREATE FUNCTION ‹defaultdb›.‹public›.‹t›()
117+
RETURNS INT8
118+
LANGUAGE SQL
119+
AS $$SELECT ‹1›;$$
116120
tag: CREATE FUNCTION
117121
user: root
118122
## StatementPhase stage 1 of 1 with 11 MutationType ops

pkg/sql/schemachanger/testdata/end_to_end/create_function/create_function.side_effects

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ write *eventpb.CreateFunction to event log:
3636
functionName: defaultdb.public.f
3737
sql:
3838
descriptorId: 110
39-
statement: "CREATE FUNCTION ‹defaultdb›.‹public›.‹f›(‹a› ‹notmyworkday›)\n\tRETURNS INT8\n\tVOLATILE\n\tLANGUAGE SQL\n\tAS $$SELECT ‹a› FROM ‹defaultdb›.‹public›.‹t›; SELECT ‹b› FROM ‹defaultdb›.‹public›.‹t›@‹t_idx_b›; SELECT ‹c› FROM ‹defaultdb›.‹public›.‹t›@‹t_idx_c›; SELECT ‹a› FROM ‹defaultdb›.‹public›.‹v›; SELECT nextval(‹'sq1'›);$$"
39+
statement: |-
40+
CREATE FUNCTION ‹defaultdb›.‹public›.‹f›(‹a› ‹notmyworkday›)
41+
RETURNS INT8
42+
VOLATILE
43+
LANGUAGE SQL
44+
AS $$SELECT ‹a› FROM ‹defaultdb›.‹public›.‹t›; SELECT ‹b› FROM ‹defaultdb›.‹public›.‹t›@‹t_idx_b›; SELECT ‹c› FROM ‹defaultdb›.‹public›.‹t›@‹t_idx_c›; SELECT ‹a› FROM ‹defaultdb›.‹public›.‹v›; SELECT nextval(‹'sq1'›);$$
4045
tag: CREATE FUNCTION
4146
user: root
4247
## StatementPhase stage 1 of 1 with 12 MutationType ops

pkg/sql/schemachanger/testdata/end_to_end/create_function_calling_function/create_function_calling_function.side_effects

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ write *eventpb.CreateFunction to event log:
4242
functionName: defaultdb.public.f3
4343
sql:
4444
descriptorId: 112
45-
statement: "CREATE FUNCTION ‹defaultdb›.‹public›.‹f3›(‹a› ‹notmyworkday›)\n\tRETURNS INT8\n\tVOLATILE\n\tLANGUAGE SQL\n\tAS $$SELECT ‹public›.‹f2›(‹a›) + ‹public›.‹f›(‹a›);$$"
45+
statement: |-
46+
CREATE FUNCTION ‹defaultdb›.‹public›.‹f3›(‹a› ‹notmyworkday›)
47+
RETURNS INT8
48+
VOLATILE
49+
LANGUAGE SQL
50+
AS $$SELECT ‹public›.‹f2›(‹a›) + ‹public›.‹f›(‹a›);$$
4651
tag: CREATE FUNCTION
4752
user: root
4853
## StatementPhase stage 1 of 1 with 12 MutationType ops

pkg/sql/schemachanger/testdata/end_to_end/create_function_in_txn/create_function_in_txn.side_effects

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ write *eventpb.CreateFunction to event log:
1616
functionName: defaultdb.public.t
1717
sql:
1818
descriptorId: 105
19-
statement: "CREATE FUNCTION ‹defaultdb›.‹public›.‹t›()\n\tRETURNS INT8\n\tLANGUAGE SQL\n\tAS $$SELECT ‹1›;$$"
19+
statement: |-
20+
CREATE FUNCTION ‹defaultdb›.‹public›.‹t›()
21+
RETURNS INT8
22+
LANGUAGE SQL
23+
AS $$SELECT ‹1›;$$
2024
tag: CREATE FUNCTION
2125
user: root
2226
## StatementPhase stage 1 of 1 with 11 MutationType ops
@@ -173,8 +177,16 @@ upsert descriptor #105
173177
+ name: t
174178
+ relevantStatements:
175179
+ - statement:
176-
+ redactedStatement: "CREATE FUNCTION ‹defaultdb›.‹public›.‹t›()\n\tRETURNS INT8\n\tLANGUAGE SQL\n\tAS $$SELECT ‹1›;$$"
177-
+ statement: "CREATE FUNCTION t()\n\tRETURNS INT8\n\tLANGUAGE SQL\n\tAS $$ SELECT 1 $$"
180+
+ redactedStatement: |-
181+
+ CREATE FUNCTION ‹defaultdb›.‹public›.‹t›()
182+
+ RETURNS INT8
183+
+ LANGUAGE SQL
184+
+ AS $$SELECT ‹1›;$$
185+
+ statement: |-
186+
+ CREATE FUNCTION t()
187+
+ RETURNS INT8
188+
+ LANGUAGE SQL
189+
+ AS $$ SELECT 1 $$
178190
+ statementTag: CREATE FUNCTION
179191
+ revertible: true
180192
+ targetRanks: <redacted>
@@ -252,8 +264,16 @@ upsert descriptor #104
252264
+ name: t
253265
+ relevantStatements:
254266
+ - statement:
255-
+ redactedStatement: "CREATE FUNCTION ‹defaultdb›.‹public›.‹t›()\n\tRETURNS INT8\n\tLANGUAGE SQL\n\tAS $$SELECT ‹1›;$$"
256-
+ statement: "CREATE FUNCTION t()\n\tRETURNS INT8\n\tLANGUAGE SQL\n\tAS $$ SELECT 1 $$"
267+
+ redactedStatement: |-
268+
+ CREATE FUNCTION ‹defaultdb›.‹public›.‹t›()
269+
+ RETURNS INT8
270+
+ LANGUAGE SQL
271+
+ AS $$SELECT ‹1›;$$
272+
+ statement: |-
273+
+ CREATE FUNCTION t()
274+
+ RETURNS INT8
275+
+ LANGUAGE SQL
276+
+ AS $$ SELECT 1 $$
257277
+ statementTag: CREATE FUNCTION
258278
+ - statement:
259279
+ redactedStatement: CREATE UNIQUE INDEX ‹idx› ON ‹defaultdb›.‹public›.‹t› (‹b›)
@@ -566,7 +586,7 @@ upsert descriptor #104
566586
+ version: "7"
567587
upsert descriptor #105
568588
...
569-
statement: "CREATE FUNCTION t()\n\tRETURNS INT8\n\tLANGUAGE SQL\n\tAS $$ SELECT 1 $$"
589+
AS $$ SELECT 1 $$
570590
statementTag: CREATE FUNCTION
571591
- revertible: true
572592
targetRanks: <redacted>
@@ -614,8 +634,16 @@ upsert descriptor #104
614634
- name: t
615635
- relevantStatements:
616636
- - statement:
617-
- redactedStatement: "CREATE FUNCTION ‹defaultdb›.‹public›.‹t›()\n\tRETURNS INT8\n\tLANGUAGE SQL\n\tAS $$SELECT ‹1›;$$"
618-
- statement: "CREATE FUNCTION t()\n\tRETURNS INT8\n\tLANGUAGE SQL\n\tAS $$ SELECT 1 $$"
637+
- redactedStatement: |-
638+
- CREATE FUNCTION ‹defaultdb›.‹public›.‹t›()
639+
- RETURNS INT8
640+
- LANGUAGE SQL
641+
- AS $$SELECT ‹1›;$$
642+
- statement: |-
643+
- CREATE FUNCTION t()
644+
- RETURNS INT8
645+
- LANGUAGE SQL
646+
- AS $$ SELECT 1 $$
619647
- statementTag: CREATE FUNCTION
620648
- - statement:
621649
- redactedStatement: CREATE UNIQUE INDEX ‹idx› ON ‹defaultdb›.‹public›.‹t› (‹b›)
@@ -645,8 +673,16 @@ upsert descriptor #105
645673
- name: t
646674
- relevantStatements:
647675
- - statement:
648-
- redactedStatement: "CREATE FUNCTION ‹defaultdb›.‹public›.‹t›()\n\tRETURNS INT8\n\tLANGUAGE SQL\n\tAS $$SELECT ‹1›;$$"
649-
- statement: "CREATE FUNCTION t()\n\tRETURNS INT8\n\tLANGUAGE SQL\n\tAS $$ SELECT 1 $$"
676+
- redactedStatement: |-
677+
- CREATE FUNCTION ‹defaultdb›.‹public›.‹t›()
678+
- RETURNS INT8
679+
- LANGUAGE SQL
680+
- AS $$SELECT ‹1›;$$
681+
- statement: |-
682+
- CREATE FUNCTION t()
683+
- RETURNS INT8
684+
- LANGUAGE SQL
685+
- AS $$ SELECT 1 $$
650686
- statementTag: CREATE FUNCTION
651687
- targetRanks: <redacted>
652688
- targets: <redacted>

pkg/util/log/logconfig/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ func (c *ChannelFilters) UnmarshalYAML(value *yaml.Node) error {
949949
// We recognize two formats here: either a map of
950950
// severity to channel lists, or a single channel list.
951951
var a ChannelList
952-
err := value.Decode(&a)
952+
err := a.UnmarshalYAML(value)
953953
if err == nil /* no error: it's a simple channel list */ {
954954
c.Filters = map[logpb.Severity]ChannelList{
955955
logpb.Severity_UNKNOWN: a,

pkg/util/log/logconfig/config_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"github.com/cockroachdb/cockroach/pkg/util/yamlutil"
1414
"github.com/cockroachdb/datadriven"
1515
"github.com/kr/pretty"
16-
"go.yaml.in/yaml/v4"
1716
)
1817

1918
func TestConfig(t *testing.T) {
@@ -24,7 +23,7 @@ func TestConfig(t *testing.T) {
2423
}
2524
t.Logf("%# v", pretty.Formatter(c))
2625
var buf bytes.Buffer
27-
b, err := yaml.Marshal(&c)
26+
b, err := yamlutil.Marshal(&c)
2827
if err != nil {
2928
fmt.Fprintf(&buf, "ERROR: %v\n", err)
3029
} else {

pkg/util/log/logconfig/testdata/yaml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ sinks:
102102
stderr:
103103
channels: [all,dev]
104104
----
105-
ERROR: cannot use ALL if there are other channel names present in the list
105+
ERROR: yaml: unmarshal errors:
106+
line 3: cannot use ALL if there are other channel names present in the list
106107

107108

108109
# Verify that the inverse of a channel list can be selected.
@@ -205,7 +206,8 @@ sinks:
205206
stderr:
206207
channels: DEV,DEV
207208
----
208-
ERROR: duplicate channel name: "DEV"
209+
ERROR: yaml: unmarshal errors:
210+
line 3: duplicate channel name: "DEV"
209211

210212
# Check that supported permission formats are accepted.
211213
yaml
@@ -235,22 +237,26 @@ yaml
235237
file-defaults:
236238
file-permissions: foobar
237239
----
238-
ERROR: file-permissions unparsable: foobar
240+
ERROR: yaml: unmarshal errors:
241+
line 2: file-permissions unparsable: foobar
239242

240243
yaml
241244
file-defaults:
242245
file-permissions: 02222
243246
----
244-
ERROR: file-permissions out-of-range: 02222
247+
ERROR: yaml: unmarshal errors:
248+
line 2: file-permissions out-of-range: 02222
245249

246250
yaml
247251
file-defaults:
248252
file-permissions: -222
249253
----
250-
ERROR: file-permissions out-of-range: -222
254+
ERROR: yaml: unmarshal errors:
255+
line 2: file-permissions out-of-range: -222
251256

252257
yaml
253258
file-defaults:
254259
file-permissions: 0454
255260
----
256-
ERROR: file-permissions must not be executable: 0454
261+
ERROR: yaml: unmarshal errors:
262+
line 2: file-permissions must not be executable: 0454

pkg/util/log/logconfig/validate_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212

1313
"github.com/cockroachdb/cockroach/pkg/util/yamlutil"
1414
"github.com/cockroachdb/datadriven"
15-
"go.yaml.in/yaml/v4"
1615
)
1716

1817
func TestValidate(t *testing.T) {
@@ -23,7 +22,7 @@ func TestValidate(t *testing.T) {
2322
}
2423
var buf bytes.Buffer
2524
fmt.Fprintln(&buf, "## before validate:\n#")
26-
b, err := yaml.Marshal(&c)
25+
b, err := yamlutil.Marshal(&c)
2726
if err != nil {
2827
t.Fatal(err)
2928
}
@@ -37,7 +36,7 @@ func TestValidate(t *testing.T) {
3736
} else {
3837
clearExpectedValues(&c)
3938

40-
b, err := yaml.Marshal(&c)
39+
b, err := yamlutil.Marshal(&c)
4140
if err != nil {
4241
t.Fatal(err)
4342
}

0 commit comments

Comments
 (0)