Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

Commit

Permalink
Merge pull request #389 from dexhorthy/values-update-370
Browse files Browse the repository at this point in the history
Starting on tests for merging chart values with customer values
  • Loading branch information
dexhorthy authored Aug 17, 2018
2 parents 198fd17 + 1b33995 commit 09df26e
Show file tree
Hide file tree
Showing 44 changed files with 486 additions and 331 deletions.
56 changes: 0 additions & 56 deletions integration/init__replicated.app/basic/expected/.ship/release.yml

This file was deleted.

This file was deleted.

This file was deleted.

56 changes: 0 additions & 56 deletions integration/init__replicated.app/basic/input/.ship/release.yml

This file was deleted.

2 changes: 0 additions & 2 deletions integration/init__replicated.app/basic/metadata.yaml

This file was deleted.

186 changes: 0 additions & 186 deletions integration/init__replicated.app/integration_test.go

This file was deleted.

17 changes: 16 additions & 1 deletion integration/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

. "github.com/onsi/gomega"
"github.com/pmezard/go-difflib/difflib"
"encoding/json"
)

// files and directories with non-deterministic output
Expand Down Expand Up @@ -78,12 +79,26 @@ func CompareDir(expected, actual string) (bool, error) {
actualContentsBytes, err := ioutil.ReadFile(actualFilePath)
Expect(err).NotTo(HaveOccurred())


// another hack for ease of testing -- pretty print json before comparing so diffs
// are easier to read
if strings.HasSuffix(actualFilePath, ".json") {
var obj interface{}
err = json.Unmarshal(expectedContentsBytes, &obj)
Expect(err).NotTo(HaveOccurred())
expectedContentsBytes, err = json.MarshalIndent(obj, "", " ")

obj = nil
err = json.Unmarshal(actualContentsBytes, &obj)
Expect(err).NotTo(HaveOccurred())
actualContentsBytes, err = json.MarshalIndent(obj, "", " ")
}

// kind of a hack -- remove any trailing newlines (because text editors are hard to use)
expectedContents := strings.TrimRight(string(expectedContentsBytes), "\n")
actualContents := strings.TrimRight(string(actualContentsBytes), "\n")



diff := difflib.UnifiedDiff{
A: difflib.SplitLines(expectedContents),
B: difflib.SplitLines(actualContents),
Expand Down
2 changes: 1 addition & 1 deletion integration/update/basic/expected/.ship/state.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"v1":{"config":{},"helmValues":"# Default values for basic.\n# This is a YAML-formatted file.\n# Declare variables to be passed into your templates.\n\nreplicaCount: 1\n\nimage:\n repository: nginx\n tag: stable\n pullPolicy: IfNotPresent\n\nservice:\n type: ClusterIP\n port: 80\n\ningress:\n enabled: false\n annotations: {}\n # kubernetes.io/ingress.class: nginx\n # kubernetes.io/tls-acme: \"true\"\n path: /\n hosts:\n - chart-example.local\n tls: []\n # - secretName: chart-example-tls\n # hosts:\n # - chart-example.local\n\nresources: {}\n # We usually recommend not to specify default resources and to leave this as a conscious\n # choice for the user. This also increases chances charts run on environments with little\n # resources, such as Minikube. If you do want to specify resources, uncomment the following\n # lines, adjust them as necessary, and remove the curly braces after 'resources:'.\n # limits:\n # cpu: 100m\n # memory: 128Mi\n # requests:\n # cpu: 100m\n # memory: 128Mi\n\nnodeSelector: {}\n\ntolerations: []\n\naffinity: {}\n","kustomize":{"overlays":{"ship":{"patches":{"/templates/deployment.yaml":"--- \napiVersion: apps/v1beta2\nkind: Deployment\nmetadata:\n name: 'basic'\n"}}}},"chartURL":"github.com/replicatedhq/test-charts/basic","contentSHA":"94d255c48a20929dbfbe341109a7ab86dae1ecfab3b8f01151bb36a2ebea7bbe"}}
{"v1":{"config":{},"helmValues":"# Default values for basic.\n# This is a YAML-formatted file.\n# Declare variables to be passed into your templates.\n\nreplicaCount: 5\n\nimage:\n repository: nginx\n tag: stable\n pullPolicy: IfNotPresent\n\nservice:\n type: ClusterIP\n port: 80\n\ningress:\n enabled: false\n annotations: {}\n # kubernetes.io/ingress.class: nginx\n # kubernetes.io/tls-acme: \"true\"\n path: /\n hosts:\n - chart-example.local\n tls: []\n # - secretName: chart-example-tls\n # hosts:\n # - chart-example.local\n\nresources: {}\n # We usually recommend not to specify default resources and to leave this as a conscious\n # choice for the user. This also increases chances charts run on environments with little\n # resources, such as Minikube. If you do want to specify resources, uncomment the following\n # lines, adjust them as necessary, and remove the curly braces after 'resources:'.\n # limits:\n # cpu: 100m\n # memory: 128Mi\n # requests:\n # cpu: 100m\n # memory: 128Mi\n\nnodeSelector: {}\n\ntolerations: []\n\naffinity: {}\n","kustomize":{"overlays":{"ship":{"patches":{"/templates/deployment.yaml":"--- \napiVersion: apps/v1beta2\nkind: Deployment\nmetadata:\n name: 'basic'\n"}}}},"chartURL":"github.com/replicatedhq/test-charts/basic","contentSHA":"94d255c48a20929dbfbe341109a7ab86dae1ecfab3b8f01151bb36a2ebea7bbe"}}
2 changes: 1 addition & 1 deletion integration/update/basic/expected/base/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ metadata:
release: basic
heritage: Tiller
spec:
replicas: 1
replicas: 5
selector:
matchLabels:
app: basic
Expand Down
5 changes: 5 additions & 0 deletions integration/update/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

type TestMetadata struct {
Args []string `yaml:"args"`
Skip bool `yaml:"skip"`

//debugging
SkipCleanup bool `yaml:"skip_cleanup"`
Expand Down Expand Up @@ -91,6 +92,10 @@ var _ = Describe("basic", func() {
}, 20)

It("Should output files matching those expected when running in update mode", func() {
if testMetadata.Skip {
return
}

cmd := cli.RootCmd()
buf := new(bytes.Buffer)
cmd.SetOutput(buf)
Expand Down
2 changes: 1 addition & 1 deletion integration/update/modify-chart/expected/.ship/state.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"v1":{"config":{},"helmValues":"# Default values for modify-chart.\n# This is a YAML-formatted file.\n# Declare variables to be passed into your templates.\n\nreplicaCount: 2\n\nimage:\n repository: nginx\n tag: stable\n pullPolicy: IfNotPresent\n\nservice:\n type: ClusterIP\n port: 80\n\ningress:\n enabled: false\n annotations: {}\n # kubernetes.io/ingress.class: nginx\n # kubernetes.io/tls-acme: \"true\"\n path: /\n hosts:\n - chart-example.local\n tls: []\n # - secretName: chart-example-tls\n # hosts:\n # - chart-example.local\n\nresources: {}\n # We usually recommend not to specify default resources and to leave this as a conscious\n # choice for the user. This also increases chances charts run on environments with little\n # resources, such as Minikube. If you do want to specify resources, uncomment the following\n # lines, adjust them as necessary, and remove the curly braces after 'resources:'.\n # limits:\n # cpu: 100m\n # memory: 128Mi\n # requests:\n # cpu: 100m\n # memory: 128Mi\n\nnodeSelector: {}\n\ntolerations: []\n\naffinity: {}\n","kustomize":{"overlays":{"ship":{"patches":{"/templates/deployment.yaml":""}}}},"chartURL":"github.com/replicatedhq/test-charts/modify-chart","contentSHA":"8f221c20ea01b45298094e4c631d10b7583885fd4a62a5eacce2883cd19f1c7f"}}
{"v1":{"config":{},"helmValues":"# Default values for modify-chart.\n# This is a YAML-formatted file.\n# Declare variables to be passed into your templates.\n\nreplicaCount: 1\n\nimage:\n repository: nginx\n tag: stable\n pullPolicy: IfNotPresent\n\nservice:\n type: ClusterIP\n port: 80\n\ningress:\n enabled: false\n annotations: {}\n # kubernetes.io/ingress.class: nginx\n # kubernetes.io/tls-acme: \"true\"\n path: /\n hosts:\n - chart-example.local\n tls: []\n # - secretName: chart-example-tls\n # hosts:\n # - chart-example.local\n\nresources: {}\n # We usually recommend not to specify default resources and to leave this as a conscious\n # choice for the user. This also increases chances charts run on environments with little\n # resources, such as Minikube. If you do want to specify resources, uncomment the following\n # lines, adjust them as necessary, and remove the curly braces after 'resources:'.\n # limits:\n # cpu: 100m\n # memory: 128Mi\n # requests:\n # cpu: 100m\n # memory: 128Mi\n\nnodeSelector: {}\n\ntolerations: []\n\naffinity: {}\n","kustomize":{"overlays":{"ship":{"patches":{"/templates/deployment.yaml":""}}}},"chartURL":"github.com/replicatedhq/test-charts/modify-chart","contentSHA":"8f221c20ea01b45298094e4c631d10b7583885fd4a62a5eacce2883cd19f1c7f"}}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ metadata:
release: modify-chart
heritage: Tiller
spec:
replicas: 2
replicas: 1
selector:
matchLabels:
app: modify-chart
Expand Down
Loading

0 comments on commit 09df26e

Please sign in to comment.