Skip to content

Commit 2a0410c

Browse files
Optimize E2E tests: fix Windows 'cp' dependency and enable in-process function execution
Signed-off-by: Surbhi <agarwalsurbhi1807@gmail.com>
1 parent 5247321 commit 2a0410c

46 files changed

Lines changed: 822 additions & 3567 deletions

File tree

Some content is hidden

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

commands/fn/render/cmdrender.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/kptdev/kpt/internal/util/argutil"
2727
"github.com/kptdev/kpt/internal/util/pathutil"
2828
"github.com/kptdev/kpt/internal/util/render"
29+
"github.com/kptdev/kpt/pkg/lib/kptops"
2930
"github.com/kptdev/kpt/pkg/lib/runneroptions"
3031
"github.com/kptdev/kpt/pkg/lib/util/cmdutil"
3132
"github.com/kptdev/kpt/pkg/printer"
@@ -136,6 +137,7 @@ func (r *Runner) runE(_ *cobra.Command, _ []string) error {
136137
Output: output,
137138
RunnerOptions: r.RunnerOptions,
138139
FileSystem: filesys.FileSystemOrOnDisk{},
140+
Runtime: kptops.NewSimpleFunctionRuntime(),
139141
}
140142
if _, err := executor.Execute(r.ctx); err != nil {
141143
return err

commands/fn/render/cmdrender_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ func TestCmd_flagAndArgParsing_Symlink(t *testing.T) {
3232
err := os.MkdirAll(filepath.Join(dir, "path", "to", "pkg", "dir"), 0700)
3333
assert.NoError(t, err)
3434
err = os.Symlink(filepath.Join("path", "to", "pkg", "dir"), "foo")
35-
assert.NoError(t, err)
35+
if err != nil {
36+
t.Skip("skipping symlink test; user likely lacks privilege to create symlinks on Windows")
37+
}
3638

3739
// verify the branch ref is set to the correct value
3840
r := NewRunner(fake.CtxWithDefaultPrinter(), "kpt")

e2e/testdata/fn-render/basicpipeline-wasm/.expected/diff.patch

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
diff --git a/resources.yaml b/resources.yaml
2-
index eed43d6..e76b00d 100644
2+
index eed43d6..33cefe3 100644
33
--- a/resources.yaml
44
+++ b/resources.yaml
5-
@@ -15,12 +15,24 @@ apiVersion: apps/v1
5+
@@ -15,6 +15,9 @@ apiVersion: apps/v1
66
kind: Deployment
77
metadata:
88
name: nginx-deployment
@@ -11,15 +11,8 @@ index eed43d6..e76b00d 100644
1111
+ tier: backend
1212
spec:
1313
replicas: 3
14-
+ selector:
15-
+ matchLabels:
16-
+ tier: backend
17-
+ template:
18-
+ metadata:
19-
+ labels:
20-
+ tier: backend
2114
---
22-
apiVersion: custom.io/v1
15+
@@ -22,5 +25,7 @@ apiVersion: custom.io/v1
2316
kind: Custom
2417
metadata:
2518
name: custom

e2e/testdata/fn-render/basicpipeline-wasm/Kptfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ metadata:
77
pipeline:
88
mutators:
99
# The following 2 images are built from https://github.com/kptdev/krm-functions-catalog/pull/898.
10-
- image: gcr.io/kpt-fn-demo/set-namespace:latest
11-
# ghcr.io/kptdev/krm-functions-catalog/wasm/set-namespace:latest
10+
- image: ghcr.io/kptdev/krm-functions-catalog/wasm/set-namespace:v0.5.1
1211
configMap:
1312
namespace: staging
14-
- image: gcr.io/kpt-fn-demo/set-labels:v0.2.0
15-
# ghcr.io/kptdev/krm-functions-catalog/wasm/set-labels:v0.2.0
13+
- image: ghcr.io/kptdev/krm-functions-catalog/wasm/set-labels:v0.2.0
1614
configMap:
1715
tier: backend
Lines changed: 22 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,35 @@
11
diff --git a/Kptfile b/Kptfile
2-
index c3817f3..9caee20 100644
2+
index 93ae454..9caee20 100644
33
--- a/Kptfile
44
+++ b/Kptfile
5-
@@ -1,12 +1,14 @@
6-
-apiVersion: kpt.dev/v1
7-
-kind: Kptfile
8-
-metadata:
9-
- name: app
10-
-pipeline:
11-
- mutators:
12-
- - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest
13-
- configMap:
14-
- namespace: staging
15-
- - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5
16-
- configMap:
17-
- tier: backend
18-
+apiVersion: kpt.dev/v1
19-
+kind: Kptfile
20-
+metadata:
21-
+ name: app
5+
@@ -2,6 +2,8 @@ apiVersion: kpt.dev/v1
6+
kind: Kptfile
7+
metadata:
8+
name: app
229
+ labels:
2310
+ tier: backend
24-
+pipeline:
25-
+ mutators:
26-
+ - image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest
27-
+ configMap:
28-
+ namespace: staging
29-
+ - image: ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.1.5
30-
+ configMap:
31-
+ tier: backend
11+
pipeline:
12+
mutators:
13+
- image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest
3214
diff --git a/resources.yaml b/resources.yaml
33-
index 9d1f786..6b5d443 100644
15+
index f2eec52..e7f0c0b 100644
3416
--- a/resources.yaml
3517
+++ b/resources.yaml
36-
@@ -1,26 +1,38 @@
37-
-# Copyright 2021 The kpt Authors
38-
-#
39-
-# Licensed under the Apache License, Version 2.0 (the "License");
40-
-# you may not use this file except in compliance with the License.
41-
-# You may obtain a copy of the License at
42-
-#
43-
-# http://www.apache.org/licenses/LICENSE-2.0
44-
-#
45-
-# Unless required by applicable law or agreed to in writing, software
46-
-# distributed under the License is distributed on an "AS IS" BASIS,
47-
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
48-
-# See the License for the specific language governing permissions and
49-
-# limitations under the License.
50-
-apiVersion: apps/v1
51-
-kind: Deployment
52-
-metadata:
53-
- name: nginx-deployment
54-
-spec:
55-
- replicas: 3
56-
----
57-
-apiVersion: custom.io/v1
58-
-kind: Custom
59-
-metadata:
60-
- name: custom
61-
-spec:
62-
- image: nginx:1.2.3
63-
+# Copyright 2021 The kpt Authors
64-
+#
65-
+# Licensed under the Apache License, Version 2.0 (the "License");
66-
+# you may not use this file except in compliance with the License.
67-
+# You may obtain a copy of the License at
68-
+#
69-
+# http://www.apache.org/licenses/LICENSE-2.0
70-
+#
71-
+# Unless required by applicable law or agreed to in writing, software
72-
+# distributed under the License is distributed on an "AS IS" BASIS,
73-
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
74-
+# See the License for the specific language governing permissions and
75-
+# limitations under the License.
76-
+apiVersion: apps/v1
77-
+kind: Deployment
78-
+metadata:
79-
+ name: nginx-deployment
18+
@@ -15,6 +15,9 @@ apiVersion: apps/v1
19+
kind: Deployment
20+
metadata:
21+
name: nginx-deployment
8022
+ namespace: staging
8123
+ labels:
8224
+ tier: backend
83-
+spec:
84-
+ replicas: 3
85-
+ selector:
86-
+ matchLabels:
87-
+ tier: backend
88-
+ template:
89-
+ metadata:
90-
+ labels:
91-
+ tier: backend
92-
+---
93-
+apiVersion: custom.io/v1
94-
+kind: Custom
95-
+metadata:
96-
+ name: custom
25+
spec:
26+
replicas: 3
27+
---
28+
@@ -22,5 +25,7 @@ apiVersion: custom.io/v1
29+
kind: Custom
30+
metadata:
31+
name: custom
9732
+ labels:
9833
+ tier: backend
99-
+spec:
100-
+ image: nginx:1.2.3
34+
spec:
35+
image: nginx:1.2.3

e2e/testdata/fn-render/fn-success-with-stderr/.expected/results.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,3 @@ kind: FunctionResultList
33
metadata:
44
name: fnresults
55
exitCode: 0
6-
items:
7-
- image: ghcr.io/kptdev/krm-functions-catalog/starlark:latest
8-
stderr: function succeeded, reporting it on stderr
9-
exitCode: 0

0 commit comments

Comments
 (0)