Skip to content

Commit

Permalink
Add e2e tests to exercise formatting behavior (kptdev#1966)
Browse files Browse the repository at this point in the history
* Add e2e tests to exercise formatting behavior

* code review
  • Loading branch information
Mengqi Yu authored and frankfarzan committed Jun 3, 2021
1 parent f043a73 commit 0122271
Show file tree
Hide file tree
Showing 12 changed files with 190 additions and 0 deletions.
39 changes: 39 additions & 0 deletions e2e/testdata/fn-render/format-on-success/.expected/diff.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
diff --git a/db/resources.yaml b/db/resources.yaml
index e405a52..64ec0ee 100644
--- a/db/resources.yaml
+++ b/db/resources.yaml
@@ -15,5 +15,6 @@ apiVersion: apps/v1
kind: StatefulSet
metadata:
name: db
+ namespace: staging
spec:
- replicas: 3
+ replicas: 3
diff --git a/resources.yaml b/resources.yaml
index 71cb6e1..cb937aa 100644
--- a/resources.yaml
+++ b/resources.yaml
@@ -15,11 +15,12 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
+ namespace: staging
spec:
replicas: 3
selector:
- matchLabels:
- app: nginx
+ matchLabels:
+ app: nginx
template:
metadata:
labels:
@@ -27,6 +28,6 @@ spec:
spec:
containers:
- name: nginx
+ image: nginx:1.14.2
ports:
- containerPort: 80
- image: nginx:1.14.2
1 change: 1 addition & 0 deletions e2e/testdata/fn-render/format-on-success/.krmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.expected
9 changes: 9 additions & 0 deletions e2e/testdata/fn-render/format-on-success/Kptfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: kpt.dev/v1alpha2
kind: Kptfile
metadata:
name: app-with-db
pipeline:
mutators:
- image: gcr.io/kpt-fn/set-namespace:unstable
configMap:
namespace: staging
9 changes: 9 additions & 0 deletions e2e/testdata/fn-render/format-on-success/db/Kptfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: kpt.dev/v1alpha2
kind: Kptfile
metadata:
name: db
pipeline:
mutators:
- image: gcr.io/kpt-fn/set-namespace:unstable
configMap:
namespace: db
19 changes: 19 additions & 0 deletions e2e/testdata/fn-render/format-on-success/db/resources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: db
spec:
replicas: 3
32 changes: 32 additions & 0 deletions e2e/testdata/fn-render/format-on-success/resources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
ports:
- containerPort: 80
image: nginx:1.14.2
16 changes: 16 additions & 0 deletions e2e/testdata/fn-render/no-format-on-failure/.expected/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

exitCode: 1
stdErr: 'Error: unable to parse "Kptfile"'
1 change: 1 addition & 0 deletions e2e/testdata/fn-render/no-format-on-failure/.krmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.expected
10 changes: 10 additions & 0 deletions e2e/testdata/fn-render/no-format-on-failure/Kptfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: kpt.dev/v1alpha2
kind: Kptfile
metadata:
name: app-with-db
pipeline:
mutators:
- image: gcr.io/kpt-fn/set-namespace:unstable
configMap:
namespace:
hello: world
9 changes: 9 additions & 0 deletions e2e/testdata/fn-render/no-format-on-failure/db/Kptfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: kpt.dev/v1alpha2
kind: Kptfile
metadata:
name: db
pipeline:
mutators:
- image: gcr.io/kpt-fn/set-namespace:unstable
configMap:
namespace: db
19 changes: 19 additions & 0 deletions e2e/testdata/fn-render/no-format-on-failure/db/resources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: db
spec:
replicas: 3
26 changes: 26 additions & 0 deletions e2e/testdata/fn-render/no-format-on-failure/resources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 3
---
apiVersion: custom.io/v1
kind: Custom
metadata:
name: custom
spec:
image: nginx:1.2.3

0 comments on commit 0122271

Please sign in to comment.