Skip to content

Commit 6bae6f6

Browse files
Resolve symlink for root directory and update tests (#2473)
* Resolve symlinks and update tests * Add tests for each command * Add apply test * symlink for cmdget * Add e2e tests for eval render * nit fix
1 parent 57b5210 commit 6bae6f6

File tree

32 files changed

+826
-61
lines changed

32 files changed

+826
-61
lines changed

e2e/live/end-to-end-test.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,46 @@ wait 2
556556
assertRGInventory "rg-test-namespace" "4"
557557
printResult
558558

559+
# Test: Basic kpt live apply on symlink
560+
# Apply run for "rg-test-case-1a" directory
561+
echo "[ResourceGroup] Testing basic apply on symlink"
562+
ln -s e2e/live/testdata/rg-test-case-1a/ link-to-rg-test-case-1a
563+
echo "kpt live apply link-to-rg-test-case-1a"
564+
${BIN_DIR}/kpt live apply link-to-rg-test-case-1a > $OUTPUT_DIR/status
565+
# The ResourceGroup CRD is already installed.
566+
assertNotContains "installing inventory ResourceGroup CRD"
567+
assertContains "namespace/rg-test-namespace unchanged"
568+
assertContains "1 resource(s) applied. 0 created, 1 unchanged, 0 configured, 0 failed"
569+
assertContains "pod/pod-a unchanged"
570+
assertContains "pod/pod-b unchanged"
571+
assertContains "pod/pod-c unchanged"
572+
assertContains "3 resource(s) applied. 0 created, 3 unchanged, 0 configured, 0 failed"
573+
wait 2
574+
# Validate resources in the cluster
575+
# ConfigMap inventory with four inventory items.
576+
assertRGInventory "rg-test-namespace" "4"
577+
printResult
578+
579+
# Test: Basic kpt live status on symlink
580+
# Apply run for "rg-test-case-1a" directory
581+
echo "[ResourceGroup] Testing basic status on symlink"
582+
ln -s e2e/live/testdata/rg-test-case-1a/ link-to-rg-test-case-1a
583+
echo "kpt live apply link-to-rg-test-case-1a"
584+
${BIN_DIR}/kpt live status link-to-rg-test-case-1a > $OUTPUT_DIR/status
585+
# The ResourceGroup CRD is already installed.
586+
assertNotContains "installing inventory ResourceGroup CRD"
587+
assertContains "namespace/rg-test-namespace is Current: Resource is current"
588+
assertContains "pod/pod-a is Current: Pod is Ready"
589+
assertContains "pod/pod-b is Current: Pod is Ready"
590+
assertContains "pod/pod-c is Current: Pod is Ready"
591+
wait 2
592+
# Validate resources in the cluster
593+
# ConfigMap inventory with four inventory items.
594+
assertRGInventory "rg-test-namespace" "4"
595+
printResult
596+
597+
rm -rf link-to-rg-test-case-1a
598+
559599
# Test: kpt live apply dry-run of with prune
560600
# "rg-test-case-1b" directory is "rg-test-case-1a" directory with "pod-a" removed and "pod-d" added.
561601
echo "[ResourceGroup] Testing basic apply dry-run"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
stdErr: |-
16+
[WARN] resolved symlink "new-link" to ".", please note that the symlinks within the package are ignored
17+
[RUNNING] "gcr.io/kpt-fn/set-namespace:v0.1.3"
18+
[PASS] "gcr.io/kpt-fn/set-namespace:v0.1.3"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
diff --git a/resources.yaml b/resources.yaml
2+
index 7a494c9..254b9cd 100644
3+
--- a/resources.yaml
4+
+++ b/resources.yaml
5+
@@ -15,6 +15,7 @@ apiVersion: apps/v1
6+
kind: Deployment
7+
metadata:
8+
name: nginx-deployment
9+
+ namespace: staging
10+
spec:
11+
replicas: 3
12+
---
13+
@@ -22,5 +23,6 @@ apiVersion: custom.io/v1
14+
kind: Custom
15+
metadata:
16+
name: custom
17+
+ namespace: staging
18+
spec:
19+
image: nginx:1.2.3
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#! /bin/bash
2+
# Copyright 2021 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -eo pipefail
17+
18+
ln -s ./ new-link
19+
20+
kpt fn eval new-link --image gcr.io/kpt-fn/set-namespace:v0.1.3 -- namespace=staging
21+
22+
rm -rf new-link
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.expected
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
apiVersion: apps/v1
15+
kind: Deployment
16+
metadata:
17+
name: nginx-deployment
18+
spec:
19+
replicas: 3
20+
---
21+
apiVersion: custom.io/v1
22+
kind: Custom
23+
metadata:
24+
name: custom
25+
spec:
26+
image: nginx:1.2.3
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
stdErr: |-
16+
[WARN] resolved symlink "new-link" to ".", please note that the symlinks within the package are ignored
17+
Package "basicpipeline-symlink":
18+
[RUNNING] "gcr.io/kpt-fn/set-namespace:v0.1.3"
19+
[PASS] "gcr.io/kpt-fn/set-namespace:v0.1.3"
20+
[RUNNING] "gcr.io/kpt-fn/set-labels:v0.1.4"
21+
[PASS] "gcr.io/kpt-fn/set-labels:v0.1.4"
22+
23+
Successfully executed 2 function(s) in 1 package(s).
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
diff --git a/resources.yaml b/resources.yaml
2+
index 7a494c9..a9dd224 100644
3+
--- a/resources.yaml
4+
+++ b/resources.yaml
5+
@@ -15,12 +15,25 @@ apiVersion: apps/v1
6+
kind: Deployment
7+
metadata:
8+
name: nginx-deployment
9+
+ namespace: staging
10+
+ labels:
11+
+ tier: backend
12+
spec:
13+
replicas: 3
14+
+ selector:
15+
+ matchLabels:
16+
+ tier: backend
17+
+ template:
18+
+ metadata:
19+
+ labels:
20+
+ tier: backend
21+
---
22+
apiVersion: custom.io/v1
23+
kind: Custom
24+
metadata:
25+
name: custom
26+
+ namespace: staging
27+
+ labels:
28+
+ tier: backend
29+
spec:
30+
image: nginx:1.2.3
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#! /bin/bash
2+
# Copyright 2021 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -eo pipefail
17+
18+
ln -s ./ new-link
19+
20+
kpt fn render new-link
21+
22+
rm -rf new-link
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.expected

0 commit comments

Comments
 (0)