Skip to content

Commit 94659b1

Browse files
committed
Fix E2E test failures
pkg/lib/fnruntime/runner.go print format is slightly different from porch. These changes are required while using kpt fn render. Signed-off-by: aravind.est <aravindhan.a@est.tech>
1 parent 221190f commit 94659b1

File tree

9 files changed

+26
-42
lines changed

9 files changed

+26
-42
lines changed

e2e/testdata/fn-eval/exec-function-stderr/.expected/config.yaml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2021 The kpt Authors
1+
# Copyright 2021,2026 The kpt Authors
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -18,9 +18,4 @@ testType: eval
1818
stdErr: |
1919
[RUNNING] "./function.sh"
2020
[PASS] "./function.sh" in 0s
21-
Stderr:
22-
"Hello world 0!"
23-
"Hello world 1!"
24-
"Hello world 2!"
25-
"Hello world 3!"
26-
...(18 line(s) truncated, use '--truncate-output=false' to disable)
21+
Stderr: Hello world 0!, Hello world 1!, Hello world 2!, Hello world 3!, Hello world 4!, Hello world 5!, Hello world 6!, Hello world 7!, Hello world 8!, Hello world 9!, Hello world 10!, Hello world 11!, Hello world 12!, Hello world 13!, Hello world 14!, Hello world 15!, Hello world 16!, Hello world 17!, Hello world 18!, Hello world 19!, Hello world 20!,

e2e/testdata/fn-eval/out-of-place-fnchain-stdout/.expected/config.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ stdErr: |
1010
[PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" in 0s
1111
[RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest"
1212
[PASS] "ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest" in 0s
13-
Results:
14-
[info] metadata.annotations: set annotations: {"foo":"bar"}
15-
[info] spec.template.metadata.annotations: set annotations: {"foo":"bar"}
16-
[info] metadata.annotations: set annotations: {"foo":"bar"}
13+
[Results]: [info] metadata.annotations: set annotations: {"foo":"bar"}, [info] spec.template.metadata.annotations: set annotations: {"foo":"bar"}, [info] metadata.annotations: set annotations: {"foo":"bar"}
1714
[RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5"
1815
[PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" in 0s
1916

e2e/testdata/fn-eval/out-of-place-fnchain-unwrap/.expected/config.yaml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2021 The kpt Authors
1+
# Copyright 2021,2026 The kpt Authors
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -24,11 +24,7 @@ stdErr: |
2424
[PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" in 0s
2525
[RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest"
2626
[PASS] "ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest" in 0s
27-
Results:
28-
[info] metadata.annotations: set annotations: {"foo":"bar"}
29-
[info] metadata.annotations: set annotations: {"foo":"bar"}
30-
[info] spec.template.metadata.annotations: set annotations: {"foo":"bar"}
31-
[info] metadata.annotations: set annotations: {"foo":"bar"}
27+
[Results]: [info] metadata.annotations: set annotations: {"foo":"bar"}, [info] metadata.annotations: set annotations: {"foo":"bar"}, [info] spec.template.metadata.annotations: set annotations: {"foo":"bar"}, [info] metadata.annotations: set annotations: {"foo":"bar"}
3228
[RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5"
3329
[PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" in 0s
3430

e2e/testdata/fn-eval/selectors/out-of-place-fnchain-unwrap/.expected/config.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2021 The kpt Authors
1+
# Copyright 2021,2026 The kpt Authors
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -21,8 +21,7 @@ stdErr: |
2121
[PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" in 0s
2222
[RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest" on 1 resource(s)
2323
[PASS] "ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest" in 0s
24-
Results:
25-
[info] metadata.annotations: set annotations: {"foo":"bar"}
24+
[Results]: [info] metadata.annotations: set annotations: {"foo":"bar"}
2625
[RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5"
2726
[PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" in 0s
2827
Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2021 The kpt Authors
1+
# Copyright 2021,2026 The kpt Authors
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -14,11 +14,8 @@
1414

1515
allowExec: true
1616
stdErr: |
17-
[RUNNING] "./testdata/fn-render/exec-function-stderr/function.sh"
18-
[PASS] "./testdata/fn-render/exec-function-stderr/function.sh" in 0s
19-
Stderr:
20-
"Hello world 0!"
21-
"Hello world 1!"
22-
"Hello world 2!"
23-
"Hello world 3!"
24-
...(18 line(s) truncated, use '--truncate-output=false' to disable)
17+
Package: "exec-function-stderr"
18+
[RUNNING] "./testdata/fn-render/exec-function-stderr/function.sh"
19+
[PASS] "./testdata/fn-render/exec-function-stderr/function.sh" in 0s
20+
Stderr: Hello world 0!, Hello world 1!, Hello world 2!, Hello world 3!, Hello world 4!, Hello world 5!, Hello world 6!, Hello world 7!, Hello world 8!, Hello world 9!, Hello world 10!, Hello world 11!, Hello world 12!, Hello world 13!, Hello world 14!, Hello world 15!, Hello world 16!, Hello world 17!, Hello world 18!, Hello world 19!, Hello world 20!,
21+
Successfully executed 1 function(s) in 1 package(s).

e2e/testdata/fn-render/fn-failure/.expected/config.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2021 The kpt Authors
1+
# Copyright 2021,2026 The kpt Authors
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -16,7 +16,9 @@
1616
# non-zero exit code and no changes in the resources.
1717
exitCode: 1
1818
stdErr: |
19+
Package: "fn-failure"
1920
[RUNNING] "ghcr.io/kptdev/krm-functions-catalog/starlark:latest"
2021
[FAIL] "ghcr.io/kptdev/krm-functions-catalog/starlark:latest" in 0s
21-
Results:
22-
[error]: httpbin-gen:3:73: got newline, want primary expression
22+
[Results]: [error]: httpbin-gen:3:73: got newline, want primary expression
23+
Stderr: failed to evaluate function: error: function failure Exit code: 1
24+

e2e/testdata/fn-render/out-of-place-fnchain-stdout/.expected/config.yaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,13 @@ stdErrStripLines:
33
- " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\""
44

55
stdErr: |
6+
Package: "out-of-place-fnchain-stdout"
67
[RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0"
78
[PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" in 0s
8-
9+
910
[RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest"
1011
[PASS] "ghcr.io/kptdev/krm-functions-catalog/set-annotations:latest" in 0s
11-
Results:
12-
[info] metadata.annotations: set annotations: {"foo":"bar"}
13-
[info] metadata.annotations: set annotations: {"foo":"bar"}
14-
[info] spec.template.metadata.annotations: set annotations: {"foo":"bar"}
15-
[info] metadata.annotations: set annotations: {"foo":"bar"}
12+
[Results]: [info] metadata.annotations: set annotations: {"foo":"bar"}, [info] metadata.annotations: set annotations: {"foo":"bar"}, [info] spec.template.metadata.annotations: set annotations: {"foo":"bar"}, [info] metadata.annotations: set annotations: {"foo":"bar"}
1613
[RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5"
1714
[PASS] "ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5" in 0s
1815

pkg/lib/fnruntime/runner.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ func (fr *FunctionRunner) Filter(input []*yaml.RNode) (output []*yaml.RNode, err
254254
pr.Printf("[RUNNING] %q", fr.name)
255255
}
256256
}
257+
pr.Printf("\n")
257258
}
258259
t0 := time.Now()
259260
output, err = fr.do(input)
@@ -455,7 +456,7 @@ func printFnResult(ctx context.Context, fnResult *fnresult.Result, opt *printer.
455456
UseQuote: false,
456457
Separator: ", ",
457458
}
458-
pr.OptPrintf(opt, "%s", ri.String())
459+
pr.OptPrintf(opt, "%s\n", ri.String())
459460
}
460461
}
461462

@@ -477,7 +478,7 @@ func printFnStderr(ctx context.Context, stdErr string) {
477478
UseQuote: false,
478479
Separator: ", ",
479480
}
480-
pr.Printf("%s", errLine.String())
481+
pr.Printf(" %s", errLine.String())
481482
}
482483
}
483484

pkg/lib/fnruntime/runner_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ func TestPrintFnStderr(t *testing.T) {
594594
4
595595
5`,
596596
truncateOutput: true,
597-
expected: `Stderr: 0, 1, 2, 3, 4, 5`,
597+
expected: ` Stderr: 0, 1, 2, 3, 4, 5`,
598598
},
599599
"non-truncated output": {
600600
input: `0
@@ -604,7 +604,7 @@ func TestPrintFnStderr(t *testing.T) {
604604
4
605605
5`,
606606
truncateOutput: false,
607-
expected: `Stderr: 0, 1, 2, 3, 4, 5`,
607+
expected: ` Stderr: 0, 1, 2, 3, 4, 5`,
608608
},
609609
}
610610
cleanupFunc := func() func() {

0 commit comments

Comments
 (0)