Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test case for issue 4012 pkg update not updating kptfile #4030

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

michaelvl
Copy link
Contributor

@michaelvl michaelvl commented Aug 27, 2023

This PR adds a test-case for kpt pkg get/update that reproduce the issue reported in #4012

Note: Since this is a failing test-case it could be considered to disable the final and failing assertion until the problem have been resolved

This PR adds a Kptfile to dataset1 and dataset2 for the sub package mysql. The change between dataset1 and dataset2 are:

$ diff internal/testutil/testdata/dataset1/mysql/Kptfile internal/testutil/testdata/dataset2/mysql/Kptfile
6c6
<   description: kpt package for mysql
---
>   description: mysql package
12a13,16
>     - image: gcr.io/kpt-fn/set-labels:v0.2.0
>       configMap:
>         fruit: apple
>       name: set fruit label

The test-case basically does a kpt pkg get mysql@dataset1 followed by a kpt pkg update mysql@dataset2 and verifies the content of Kptfile. The issue from #4012 thus results in a test-case failure with the following diff between the local Kptfile vs dataset2 (i.e. the local version have 'removals' compared to dataset2 because the local Kptfile is not properly updated to dataset2):

Diff:
--- Expected
+++ Actual
@@ -19,3 +19,3 @@
 info:
-  description: mysql package
+  description: kpt package for mysql
 pipeline:
@@ -28,6 +28,2 @@
       configMap:
-        fruit: apple
-      name: set fruit label
-    - image: gcr.io/kpt-fn/set-labels:v0.2.0
-      configMap:
         color: orange

Note, a copy of the Kptfile from dataset2 have also been added to dataset4 and dataset5 since these are 'clones' of dataset2.

This PR also correct an issue in testutil.AssertKptfile related to sequence-nodes (this new test-case seems to be the first use of sequence-nodes in Kptfiles). The issue is, that kptfileutil.WriteFile() use encoder option yaml.WideSequenceStyle, while the encoding used in testutil.AssertKptfile is a compact encoding. Without this correction, the test-case would fail with additional whitespace differences, e.g. (this is the initial pkg get verification of dataset1 that fails):

Diff:
--- Expected
+++ Actual
@@ -22,10 +22,10 @@
   mutators:
-  - image: gcr.io/kpt-fn/set-namespace:v0.4.1
-    configMap:
-      namespace: example-ns
-    name: set namespace
-  - image: gcr.io/kpt-fn/set-labels:v0.2.0
-    configMap:
-      color: orange
-    name: set color label
+    - image: gcr.io/kpt-fn/set-namespace:v0.4.1
+      configMap:
+        namespace: example-ns
+      name: set namespace
+    - image: gcr.io/kpt-fn/set-labels:v0.2.0
+      configMap:
+        color: orange
+      name: set color label

@michaelvl michaelvl requested a review from a team as a code owner August 27, 2023 06:47
@michaelvl michaelvl changed the title Bug/pkg update not updating kptfile Test case for issue 4012 pkg update not updating kptfile Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant