Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: added test to reproduce values bug #4478
Refs #4478 Signed-off-by: Timofey Kirillov <timofey.kirillov@flant.com>
- Loading branch information
1 parent
39a79d2
commit 4cf589c
Showing
6 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
integration/suites/deploy/helm_values1-001/.helm/templates/templates.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: mycm | ||
data: | ||
testkey: testvalue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
arr: | ||
- one | ||
- two | ||
- three |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
project: helm-values | ||
configVersion: 1 | ||
--- |
7 changes: 7 additions & 0 deletions
7
integration/suites/deploy/helm_values1-002/.helm/templates/templates.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: mycm | ||
data: | ||
testkey: testvalue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
project: helm-values | ||
configVersion: 1 | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package deploy_test | ||
|
||
import ( | ||
"strings" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
|
||
"github.com/werf/kubedog/pkg/kube" | ||
"github.com/werf/werf/pkg/util" | ||
"github.com/werf/werf/test/pkg/utils" | ||
"github.com/werf/werf/test/pkg/utils/liveexec" | ||
"sigs.k8s.io/yaml" | ||
) | ||
|
||
func getValues(params ...string) map[string]interface{} { | ||
output := utils.SucceedCommandOutputString( | ||
SuiteData.GetProjectWorktree(SuiteData.ProjectName), | ||
SuiteData.WerfBinPath, | ||
append([]string{"helm", "get", "values", SuiteData.ProjectName, "--namespace", SuiteData.ProjectName}, params...)..., | ||
) | ||
|
||
lines := util.SplitLines(output) | ||
lines = lines[1:] | ||
output = strings.Join(lines, "\n") | ||
|
||
var data map[string]interface{} | ||
err := yaml.Unmarshal([]byte(output), &data) | ||
Expect(err).To(Succeed()) | ||
|
||
return data | ||
} | ||
|
||
func getUserSuppliedValues() map[string]interface{} { | ||
return getValues() | ||
} | ||
|
||
func getComputedValues() map[string]interface{} { | ||
return getValues("--all") | ||
} | ||
|
||
var _ = Describe("Helm values", func() { | ||
BeforeEach(func() { | ||
Expect(kube.Init(kube.InitOptions{})).To(Succeed()) | ||
}) | ||
|
||
Context("explicit values param may break default values changes in further deploys: https://github.com/werf/werf/issues/4478", func() { | ||
It("ignores chagnes in the .helm/values.yaml", func() { | ||
By("Installing release first time with basic .helm/values.yaml") | ||
SuiteData.CommitProjectWorktree(SuiteData.ProjectName, "helm_values1-001", "initial commit") | ||
Expect(werfConverge(SuiteData.GetProjectWorktree(SuiteData.ProjectName), liveexec.ExecCommandOptions{})).To(Succeed()) | ||
|
||
{ | ||
uv := getUserSuppliedValues() | ||
Expect(len(uv)).To(Equal(0)) | ||
|
||
cv := getComputedValues() | ||
Expect(cv).To(Equal(map[string]interface{}{ | ||
"arr": []interface{}{"one", "two", "three"}, | ||
})) | ||
} | ||
|
||
By("Upgrading release with explicit --values param and the same values file") | ||
Expect(werfConverge(SuiteData.GetProjectWorktree(SuiteData.ProjectName), liveexec.ExecCommandOptions{}, "--values", ".helm/values.yaml")).To(Succeed()) | ||
|
||
{ | ||
uv := getUserSuppliedValues() | ||
Expect(uv).To(Equal(map[string]interface{}{ | ||
"arr": []interface{}{"one", "two", "three"}, | ||
})) | ||
|
||
cv := getComputedValues() | ||
Expect(cv).To(Equal(map[string]interface{}{ | ||
"arr": []interface{}{"one", "two", "three"}, | ||
})) | ||
} | ||
|
||
By("Upgrading release without explicit values param and changed values file") | ||
SuiteData.CommitProjectWorktree(SuiteData.ProjectName, "helm_values1-002", "append new value into default values array") | ||
Expect(werfConverge(SuiteData.GetProjectWorktree(SuiteData.ProjectName), liveexec.ExecCommandOptions{})).To(Succeed()) | ||
|
||
{ | ||
uv := getUserSuppliedValues() | ||
Expect(uv).To(Equal(map[string]interface{}{ | ||
"arr": []interface{}{"one", "two", "three"}, | ||
})) | ||
|
||
cv := getComputedValues() | ||
Expect(cv).To(Equal(map[string]interface{}{ | ||
"arr": []interface{}{"one", "two", "three"}, | ||
})) | ||
} | ||
}) | ||
}) | ||
}) |