From 1a13ac174e543c4e6bd9279756475bfc4f21002d Mon Sep 17 00:00:00 2001 From: Sam Wronski Date: Sun, 7 Feb 2021 18:04:20 -0800 Subject: [PATCH] Continue on error test (#1370) * WIP: Continue on error test * Update continue-on-error test --- e2e/live/end-to-end-test.sh | 9 +++++ e2e/live/testdata/continue-on-error/Kptfile | 6 ++++ .../continue-on-error/inventory-template.yaml | 34 +++++++++++++++++++ .../testdata/continue-on-error/namespace.yaml | 7 ++++ .../testdata/continue-on-error/pod-a.yaml | 13 +++++++ .../testdata/continue-on-error/pod-b.yaml | 16 +++++++++ 6 files changed, 85 insertions(+) create mode 100644 e2e/live/testdata/continue-on-error/Kptfile create mode 100644 e2e/live/testdata/continue-on-error/inventory-template.yaml create mode 100644 e2e/live/testdata/continue-on-error/namespace.yaml create mode 100644 e2e/live/testdata/continue-on-error/pod-a.yaml create mode 100644 e2e/live/testdata/continue-on-error/pod-b.yaml diff --git a/e2e/live/end-to-end-test.sh b/e2e/live/end-to-end-test.sh index 6ac0b613a2..6712e0d3d3 100755 --- a/e2e/live/end-to-end-test.sh +++ b/e2e/live/end-to-end-test.sh @@ -871,6 +871,15 @@ assertPodNotExists "pod-c" "test-namespace" assertPodNotExists "pod-d" "test-namespace" printResult +# Test 20: kpt live apply continue-on-error +echo "Testing continue-on-error" +echo "kpt live apply e2e/live/testdata/continue-on-error" +${BIN_DIR}/kpt live apply e2e/live/testdata/continue-on-error > $OUTPUT_DIR/status +assertCMInventory "test-namespace" "1" +assertPodExists "pod-a" "test-namespace" +assertPodNotExists "pod-B" "test-namespace" +printResult + # Clean-up the k8s cluster echo "Cleaning up cluster" kind delete cluster diff --git a/e2e/live/testdata/continue-on-error/Kptfile b/e2e/live/testdata/continue-on-error/Kptfile new file mode 100644 index 0000000000..4cee5107d0 --- /dev/null +++ b/e2e/live/testdata/continue-on-error/Kptfile @@ -0,0 +1,6 @@ +apiVersion: kpt.dev/v1alpha1 +kind: Kptfile +metadata: + name: continue-on-error +packageMetadata: + shortDescription: sample description diff --git a/e2e/live/testdata/continue-on-error/inventory-template.yaml b/e2e/live/testdata/continue-on-error/inventory-template.yaml new file mode 100644 index 0000000000..21a39e99e8 --- /dev/null +++ b/e2e/live/testdata/continue-on-error/inventory-template.yaml @@ -0,0 +1,34 @@ +# NOTE: auto-generated. Some fields should NOT be modified. +# Date: 2021-01-15 15:23:11 PST +# +# Contains the "inventory object" template ConfigMap. +# When this object is applied, it is handled specially, +# storing the metadata of all the other objects applied. +# This object and its stored inventory is subsequently +# used to calculate the set of objects to automatically +# delete (prune), when an object is omitted from further +# applies. When applied, this "inventory object" is also +# used to identify the entire set of objects to delete. +# +# NOTE: The name of this inventory template file +# does NOT have any impact on group-related functionality +# such as deletion or pruning. +# +apiVersion: v1 +kind: ConfigMap +metadata: + # DANGER: Do not change the inventory object namespace. + # Changing the namespace will cause a loss of continuity + # with previously applied grouped objects. Set deletion + # and pruning functionality will be impaired. + namespace: test-namespace + # NOTE: The name of the inventory object does NOT have + # any impact on group-related functionality such as + # deletion or pruning. + name: inventory-10220562 + labels: + # DANGER: Do not change the value of this label. + # Changing this value will cause a loss of continuity + # with previously applied grouped objects. Set deletion + # and pruning functionality will be impaired. + cli-utils.sigs.k8s.io/inventory-id: 3da10960-c1d8-46ae-988e-f330acdc8e15 diff --git a/e2e/live/testdata/continue-on-error/namespace.yaml b/e2e/live/testdata/continue-on-error/namespace.yaml new file mode 100644 index 0000000000..e5e747b2c6 --- /dev/null +++ b/e2e/live/testdata/continue-on-error/namespace.yaml @@ -0,0 +1,7 @@ +# Copyright 2019 The Kubernetes Authors. +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: v1 +kind: Namespace +metadata: + name: test-namespace diff --git a/e2e/live/testdata/continue-on-error/pod-a.yaml b/e2e/live/testdata/continue-on-error/pod-a.yaml new file mode 100644 index 0000000000..f57ca9b58f --- /dev/null +++ b/e2e/live/testdata/continue-on-error/pod-a.yaml @@ -0,0 +1,13 @@ +# This pod description should be valid and is expected to successfully deploy + +apiVersion: v1 +kind: Pod +metadata: + name: pod-a + namespace: test-namespace + labels: + name: test-pod-label-foo +spec: + containers: + - name: kubernetes-pause + image: k8s.gcr.io/pause:2.0 diff --git a/e2e/live/testdata/continue-on-error/pod-b.yaml b/e2e/live/testdata/continue-on-error/pod-b.yaml new file mode 100644 index 0000000000..213f59da9b --- /dev/null +++ b/e2e/live/testdata/continue-on-error/pod-b.yaml @@ -0,0 +1,16 @@ +# This pod definition has errors and will fail to deploy + +apiVersion: v1 +kind: Pod +metadata: + # It is invalid for a pod to be named with a capital letter + # Expected error: + # The Pod "pod-B" is invalid: metadata.name: Invalid value: "pod-B" + name: pod-B + namespace: test-namespace + labels: + name: test-pod-label-foo +spec: + containers: + - name: kubernetes-pause + image: k8s.gcr.io/pause:2.0