Skip to content

Commit 200e0f6

Browse files
author
SurbhiAgarwal1
committed
Update expected test outputs for set-namespace:latest
1 parent fcc8cca commit 200e0f6

File tree

1,032 files changed

+25748
-19825
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,032 files changed

+25748
-19825
lines changed

e2e/README.md

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
1-
# End-to-end testing of kpt
2-
3-
## kpt live e2e tests
4-
5-
We currently have two different solutions for running e2e tests for the kpt
6-
live functionality. We are working on reconciling this into one approach that
7-
we can use consistently.
8-
9-
All e2e tests for live requires that kind is available.
10-
11-
### Testing with go
12-
13-
We have a framework for running e2e tests based on specifying test cases
14-
under testdata/live-apply folder (tests for other kpt live commands will be
15-
added). The entry point for the test framework is in
16-
the `live_test.go` file.
17-
18-
In order to run all the tests for live apply, there is a make target
19-
```sh
20-
make test-live-apply
21-
```
22-
23-
It is possible to run a single test by specifying the name of the test case:
24-
```sh
25-
make test-live-apply T=crd-and-cr
26-
```
27-
28-
#### Structure of a test case
29-
30-
Each test case is a folder directly under `testdata/live-apply`. In the root
31-
of each test case folder there must be a `config.yaml` file that provides the
32-
configuration of the test case (like whether a clean cluster is required and
33-
the expected output). The package that will be applied with `kpt live apply` is
34-
provided in the `resources` folder.
35-
36-
#### Configuration options
37-
38-
These are the configuration options available in the `config.yaml` file:
39-
* `exitCode`: Defines the expected exit code after running the kpt live command. Defaults to 0.
40-
* `stdErr`: Defines the expected output to stdErr after running the command. Defaults to "".
41-
* `stdOut`: Defines the expected output to stdOut after running the command. Defaults to "".
42-
* `inventory`: Defines the expected inventory after running the command.
43-
* `requiresCleanCluster`: Defines whether a new kind cluster should be created prior to running the test.
44-
* `preinstallResourceGroup`: Defines whether the framework should make sure the RG CRD is available before running the test.
45-
* `kptArgs`: Defines the arguments that will be used with executing the kpt live command.
46-
47-
## Testing with bash
48-
49-
This approach uses a bash script that runs through several scenarios for
50-
kpt live in sequence. Run it by running
51-
```sh
52-
./live/end-to-end-test.sh
1+
# End-to-end testing of kpt
2+
3+
## kpt live e2e tests
4+
5+
We currently have two different solutions for running e2e tests for the kpt
6+
live functionality. We are working on reconciling this into one approach that
7+
we can use consistently.
8+
9+
All e2e tests for live requires that kind is available.
10+
11+
### Testing with go
12+
13+
We have a framework for running e2e tests based on specifying test cases
14+
under testdata/live-apply folder (tests for other kpt live commands will be
15+
added). The entry point for the test framework is in
16+
the `live_test.go` file.
17+
18+
In order to run all the tests for live apply, there is a make target
19+
```sh
20+
make test-live-apply
21+
```
22+
23+
It is possible to run a single test by specifying the name of the test case:
24+
```sh
25+
make test-live-apply T=crd-and-cr
26+
```
27+
28+
#### Structure of a test case
29+
30+
Each test case is a folder directly under `testdata/live-apply`. In the root
31+
of each test case folder there must be a `config.yaml` file that provides the
32+
configuration of the test case (like whether a clean cluster is required and
33+
the expected output). The package that will be applied with `kpt live apply` is
34+
provided in the `resources` folder.
35+
36+
#### Configuration options
37+
38+
These are the configuration options available in the `config.yaml` file:
39+
* `exitCode`: Defines the expected exit code after running the kpt live command. Defaults to 0.
40+
* `stdErr`: Defines the expected output to stdErr after running the command. Defaults to "".
41+
* `stdOut`: Defines the expected output to stdOut after running the command. Defaults to "".
42+
* `inventory`: Defines the expected inventory after running the command.
43+
* `requiresCleanCluster`: Defines whether a new kind cluster should be created prior to running the test.
44+
* `preinstallResourceGroup`: Defines whether the framework should make sure the RG CRD is available before running the test.
45+
* `kptArgs`: Defines the arguments that will be used with executing the kpt live command.
46+
47+
## Testing with bash
48+
49+
This approach uses a bash script that runs through several scenarios for
50+
kpt live in sequence. Run it by running
51+
```sh
52+
./live/end-to-end-test.sh
5353
```

e2e/fn_test.go

Lines changed: 93 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,93 @@
1-
//go:build docker
2-
// +build docker
3-
4-
// Copyright 2021,2026 The kpt Authors
5-
//
6-
// Licensed under the Apache License, Version 2.0 (the "License");
7-
// you may not use this file except in compliance with the License.
8-
// You may obtain a copy of the License at
9-
//
10-
// http://www.apache.org/licenses/LICENSE-2.0
11-
//
12-
// Unless required by applicable law or agreed to in writing, software
13-
// distributed under the License is distributed on an "AS IS" BASIS,
14-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15-
// See the License for the specific language governing permissions and
16-
// limitations under the License.
17-
18-
package e2e_test
19-
20-
import (
21-
"os"
22-
"path/filepath"
23-
"strings"
24-
"testing"
25-
26-
"github.com/kptdev/kpt/internal/fnruntime"
27-
"github.com/kptdev/kpt/pkg/test/runner"
28-
)
29-
30-
func TestFnRender(t *testing.T) {
31-
runAllTests(t, filepath.Join(".", "testdata", "fn-render"))
32-
}
33-
34-
func TestFnEval(t *testing.T) {
35-
runAllTests(t, filepath.Join(".", "testdata", "fn-eval"))
36-
}
37-
38-
func TestFnSink(t *testing.T) {
39-
runAllTests(t, filepath.Join(".", "testdata", "fn-sink"))
40-
}
41-
42-
// runTests will scan test cases in 'path', run the command
43-
// on all of the packages in path, and test that
44-
// the diff between the results and the original package is as
45-
// expected
46-
func runAllTests(t *testing.T, path string) {
47-
cases, err := runner.ScanTestCases(path)
48-
if err != nil {
49-
t.Fatalf("failed to scan test cases: %s", err)
50-
}
51-
// Run all the sequential tests first then run the parallel tests.
52-
runTests(t, cases, true)
53-
runTests(t, cases, false)
54-
}
55-
56-
func runTests(t *testing.T, cases *runner.TestCases, sequential bool) {
57-
for _, c := range *cases {
58-
c := c // capture range variable
59-
if c.Config.Sequential != sequential {
60-
continue
61-
}
62-
// If the current function runtime doesn't match, we skip this test case.
63-
currRuntime := strings.ToLower(os.Getenv(fnruntime.ContainerRuntimeEnv))
64-
if len(c.Config.Runtimes) > 0 {
65-
skip := true
66-
for _, rt := range c.Config.Runtimes {
67-
if currRuntime == strings.ToLower(rt) {
68-
skip = false
69-
break
70-
}
71-
}
72-
if skip {
73-
continue
74-
}
75-
}
76-
t.Run(c.Path, func(t *testing.T) {
77-
if !c.Config.Sequential {
78-
t.Parallel()
79-
}
80-
r, err := runner.NewRunner(t, c, c.Config.TestType)
81-
if err != nil {
82-
t.Fatalf("failed to create test runner: %s", err)
83-
}
84-
if r.Skip() {
85-
t.Skip()
86-
}
87-
err = r.Run()
88-
if err != nil {
89-
t.Fatalf("failed when running test: %s", err)
90-
}
91-
})
92-
}
93-
}
1+
//go:build docker
2+
// +build docker
3+
4+
// Copyright 2021,2026 The kpt Authors
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
18+
package e2e_test
19+
20+
import (
21+
"os"
22+
"path/filepath"
23+
"strings"
24+
"testing"
25+
26+
"github.com/kptdev/kpt/internal/fnruntime"
27+
"github.com/kptdev/kpt/pkg/test/runner"
28+
)
29+
30+
func TestFnRender(t *testing.T) {
31+
runAllTests(t, filepath.Join(".", "testdata", "fn-render"))
32+
}
33+
34+
func TestFnEval(t *testing.T) {
35+
runAllTests(t, filepath.Join(".", "testdata", "fn-eval"))
36+
}
37+
38+
func TestFnSink(t *testing.T) {
39+
runAllTests(t, filepath.Join(".", "testdata", "fn-sink"))
40+
}
41+
42+
// runTests will scan test cases in 'path', run the command
43+
// on all of the packages in path, and test that
44+
// the diff between the results and the original package is as
45+
// expected
46+
func runAllTests(t *testing.T, path string) {
47+
cases, err := runner.ScanTestCases(path)
48+
if err != nil {
49+
t.Fatalf("failed to scan test cases: %s", err)
50+
}
51+
// Run all the sequential tests first then run the parallel tests.
52+
runTests(t, cases, true)
53+
runTests(t, cases, false)
54+
}
55+
56+
func runTests(t *testing.T, cases *runner.TestCases, sequential bool) {
57+
for _, c := range *cases {
58+
c := c // capture range variable
59+
if c.Config.Sequential != sequential {
60+
continue
61+
}
62+
// If the current function runtime doesn't match, we skip this test case.
63+
currRuntime := strings.ToLower(os.Getenv(fnruntime.ContainerRuntimeEnv))
64+
if len(c.Config.Runtimes) > 0 {
65+
skip := true
66+
for _, rt := range c.Config.Runtimes {
67+
if currRuntime == strings.ToLower(rt) {
68+
skip = false
69+
break
70+
}
71+
}
72+
if skip {
73+
continue
74+
}
75+
}
76+
t.Run(c.Path, func(t *testing.T) {
77+
if !c.Config.Sequential {
78+
t.Parallel()
79+
}
80+
r, err := runner.NewRunner(t, c, c.Config.TestType)
81+
if err != nil {
82+
t.Fatalf("failed to create test runner: %s", err)
83+
}
84+
if r.Skip() {
85+
t.Skip()
86+
}
87+
err = r.Run()
88+
if err != nil {
89+
t.Fatalf("failed when running test: %s", err)
90+
}
91+
})
92+
}
93+
}

0 commit comments

Comments
 (0)