Fix test failure in threaded tests 79/94979/2
authorKiran Kamineni <kiran.k.kamineni@intel.com>
Wed, 4 Sep 2019 21:30:03 +0000 (14:30 -0700)
committerKiran Kamineni <kiran.k.kamineni@intel.com>
Wed, 4 Sep 2019 21:34:27 +0000 (14:34 -0700)
Fix bug in tests where they can fail in highly
threaded environments where a file can be accessed by two test
processes.
Fixed it by duplicating the test case.

Issue-ID: MULTICLOUD-689
Change-Id: I93b9862fac52eb307e52c355e3cb0d4332768b4f
Signed-off-by: Kiran Kamineni <kiran.k.kamineni@intel.com>
src/k8splugin/internal/helm/helm_test.go
src/k8splugin/mock_files/mock_charts/testchart2/Chart.yaml [new file with mode: 0644]
src/k8splugin/mock_files/mock_charts/testchart2/charts/subcharta/Chart.yaml [new file with mode: 0644]
src/k8splugin/mock_files/mock_charts/testchart2/charts/subcharta/templates/service.yaml [new file with mode: 0644]
src/k8splugin/mock_files/mock_charts/testchart2/charts/subcharta/values.yaml [new file with mode: 0644]
src/k8splugin/mock_files/mock_charts/testchart2/charts/subchartb/Chart.yaml [new file with mode: 0644]
src/k8splugin/mock_files/mock_charts/testchart2/charts/subchartb/templates/service.yaml [new file with mode: 0644]
src/k8splugin/mock_files/mock_charts/testchart2/charts/subchartb/values.yaml [new file with mode: 0644]
src/k8splugin/mock_files/mock_charts/testchart2/templates/NOTES.txt [new file with mode: 0644]
src/k8splugin/mock_files/mock_charts/testchart2/templates/service.yaml [new file with mode: 0644]
src/k8splugin/mock_files/mock_charts/testchart2/values.yaml [new file with mode: 0644]

index a13c67b..f95c0fd 100644 (file)
@@ -27,7 +27,7 @@ import (
 
 func TestProcessValues(t *testing.T) {
 
-       chartDir := "../../mock_files/mock_charts/testchart1"
+       chartDir := "../../mock_files/mock_charts/testchart2"
        profileDir := "../../mock_files/mock_profiles/profile1"
 
        testCases := []struct {
@@ -105,7 +105,7 @@ func TestProcessValues(t *testing.T) {
 
 func TestGenerateKubernetesArtifacts(t *testing.T) {
 
-       chartDir := "../../mock_files/mock_charts/testchart1"
+       chartDir := "../../mock_files/mock_charts/testchart2"
        profileDir := "../../mock_files/mock_profiles/profile1"
 
        testCases := []struct {
@@ -123,7 +123,7 @@ func TestGenerateKubernetesArtifacts(t *testing.T) {
                        values:     []string{},
                        //sha256 hash of the evaluated templates in each chart
                        expectedHashMap: map[string]string{
-                               "testchart1/templates/service.yaml": "bbd7257d1f6ab958680e642a8fbbbea2002ebbaa9276fb51fbd71b4b66a772cc",
+                               "testchart2/templates/service.yaml": "fdd6a2b6795486f0dd1d8c44379afb5ffe4072c09f9cf6594738e8ded4dd872d",
                                "subcharta/templates/service.yaml":  "570389588fffdb7193ab265888d781f3d751f3a40362533344f9aa7bb93a8bb0",
                                "subchartb/templates/service.yaml":  "5654e03d922e8ec49649b4bbda9dfc9e643b3b7c9c18b602cc7e26fd36a39c2a",
                        },
@@ -140,7 +140,7 @@ func TestGenerateKubernetesArtifacts(t *testing.T) {
                        },
                        //sha256 hash of the evaluated templates in each chart
                        expectedHashMap: map[string]string{
-                               "testchart1/templates/service.yaml": "4c5aa5d38b763fe4730fc31a759c40566a99a9c51f5e0fc7f93473c9affc2ca8",
+                               "testchart2/templates/service.yaml": "2bb96e791ecb6a3404bc5de3f6c4182aed881630269e2aa6766df38b0f852724",
                                "subcharta/templates/service.yaml":  "570389588fffdb7193ab265888d781f3d751f3a40362533344f9aa7bb93a8bb0",
                                "subchartb/templates/service.yaml":  "5654e03d922e8ec49649b4bbda9dfc9e643b3b7c9c18b602cc7e26fd36a39c2a",
                        },
diff --git a/src/k8splugin/mock_files/mock_charts/testchart2/Chart.yaml b/src/k8splugin/mock_files/mock_charts/testchart2/Chart.yaml
new file mode 100644 (file)
index 0000000..f2818e5
--- /dev/null
@@ -0,0 +1,4 @@
+apiVersion: v1
+description: A Helm chart for Kubernetes
+name: testchart2
+version: 0.1.0
diff --git a/src/k8splugin/mock_files/mock_charts/testchart2/charts/subcharta/Chart.yaml b/src/k8splugin/mock_files/mock_charts/testchart2/charts/subcharta/Chart.yaml
new file mode 100644 (file)
index 0000000..be3edce
--- /dev/null
@@ -0,0 +1,4 @@
+apiVersion: v1
+description: A Helm chart for Kubernetes
+name: subcharta
+version: 0.1.0
diff --git a/src/k8splugin/mock_files/mock_charts/testchart2/charts/subcharta/templates/service.yaml b/src/k8splugin/mock_files/mock_charts/testchart2/charts/subcharta/templates/service.yaml
new file mode 100644 (file)
index 0000000..fdf75aa
--- /dev/null
@@ -0,0 +1,15 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: {{ .Chart.Name }}
+  labels:
+    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
+spec:
+  type: {{ .Values.service.type }}
+  ports:
+  - port: {{ .Values.service.externalPort }}
+    targetPort: {{ .Values.service.internalPort }}
+    protocol: TCP
+    name: {{ .Values.service.name }}
+  selector:
+    app: {{ .Chart.Name }}
diff --git a/src/k8splugin/mock_files/mock_charts/testchart2/charts/subcharta/values.yaml b/src/k8splugin/mock_files/mock_charts/testchart2/charts/subcharta/values.yaml
new file mode 100644 (file)
index 0000000..f0381ae
--- /dev/null
@@ -0,0 +1,17 @@
+# Default values for subchart.
+# This is a YAML-formatted file.
+# Declare variables to be passed into your templates.
+# subchartA
+service:
+  name: apache
+  type: ClusterIP
+  externalPort: 80
+  internalPort: 80
+SCAdata:
+  SCAbool: false
+  SCAfloat: 3.1
+  SCAint: 55
+  SCAstring: "jabba"
+  SCAnested1:
+    SCAnested2: true
+
diff --git a/src/k8splugin/mock_files/mock_charts/testchart2/charts/subchartb/Chart.yaml b/src/k8splugin/mock_files/mock_charts/testchart2/charts/subchartb/Chart.yaml
new file mode 100644 (file)
index 0000000..c3c6bba
--- /dev/null
@@ -0,0 +1,4 @@
+apiVersion: v1
+description: A Helm chart for Kubernetes
+name: subchartb
+version: 0.1.0
diff --git a/src/k8splugin/mock_files/mock_charts/testchart2/charts/subchartb/templates/service.yaml b/src/k8splugin/mock_files/mock_charts/testchart2/charts/subchartb/templates/service.yaml
new file mode 100644 (file)
index 0000000..fdf75aa
--- /dev/null
@@ -0,0 +1,15 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: {{ .Chart.Name }}
+  labels:
+    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
+spec:
+  type: {{ .Values.service.type }}
+  ports:
+  - port: {{ .Values.service.externalPort }}
+    targetPort: {{ .Values.service.internalPort }}
+    protocol: TCP
+    name: {{ .Values.service.name }}
+  selector:
+    app: {{ .Chart.Name }}
diff --git a/src/k8splugin/mock_files/mock_charts/testchart2/charts/subchartb/values.yaml b/src/k8splugin/mock_files/mock_charts/testchart2/charts/subchartb/values.yaml
new file mode 100644 (file)
index 0000000..774fdd7
--- /dev/null
@@ -0,0 +1,35 @@
+# Default values for subchart.
+# This is a YAML-formatted file.
+# Declare variables to be passed into your templates.
+service:
+  name: nginx
+  type: ClusterIP
+  externalPort: 80
+  internalPort: 80
+
+SCBdata:
+  SCBbool: true
+  SCBfloat: 7.77
+  SCBint: 33
+  SCBstring: "boba"
+
+exports:
+  SCBexported1:
+    SCBexported1A:
+      SCBexported1B: 1965
+
+  SCBexported2:
+    SCBexported2A: "blaster"
+
+global:
+  kolla:
+    nova:
+      api:
+        all:
+          port: 8774
+      metadata:
+        all:
+          port: 8775
+
+
+
diff --git a/src/k8splugin/mock_files/mock_charts/testchart2/templates/NOTES.txt b/src/k8splugin/mock_files/mock_charts/testchart2/templates/NOTES.txt
new file mode 100644 (file)
index 0000000..4bdf443
--- /dev/null
@@ -0,0 +1 @@
+Sample notes for {{ .Chart.Name }}
\ No newline at end of file
diff --git a/src/k8splugin/mock_files/mock_charts/testchart2/templates/service.yaml b/src/k8splugin/mock_files/mock_charts/testchart2/templates/service.yaml
new file mode 100644 (file)
index 0000000..e06d19b
--- /dev/null
@@ -0,0 +1,22 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: {{ .Chart.Name }}
+  labels:
+    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
+    namespace: "{{ .Release.Namespace }}"
+    release-name: "{{ .Release.Name }}"
+    release-is-upgrade: "{{ .Release.IsUpgrade }}"
+    release-is-install: "{{ .Release.IsInstall }}"
+    kube-version/major: "{{ .Capabilities.KubeVersion.Major }}"
+    kube-version/minor: "{{ .Capabilities.KubeVersion.Minor }}"
+    kube-version/gitversion: "v{{ .Capabilities.KubeVersion.Major }}.{{ .Capabilities.KubeVersion.Minor }}.0"
+spec:
+  type: {{ .Values.service.type }}
+  ports:
+  - port: {{ .Values.service.externalPort }}
+    targetPort: {{ .Values.service.internalPort }}
+    protocol: TCP
+    name: {{ .Values.service.name }}
+  selector:
+    app: {{ .Chart.Name }}
diff --git a/src/k8splugin/mock_files/mock_charts/testchart2/values.yaml b/src/k8splugin/mock_files/mock_charts/testchart2/values.yaml
new file mode 100644 (file)
index 0000000..72d3fa5
--- /dev/null
@@ -0,0 +1,55 @@
+# Default values for subchart.
+# This is a YAML-formatted file.
+# Declare variables to be passed into your templates.
+# subchart1
+service:
+  name: nginx
+  type: ClusterIP
+  externalPort: 80
+  internalPort: 80
+
+
+SC1data:
+  SC1bool: true
+  SC1float: 3.14
+  SC1int: 100
+  SC1string: "dollywood"
+  SC1extra1: 11
+
+imported-chartA:
+  SC1extra2: 1.337
+
+overridden-chartA:
+  SCAbool: true
+  SCAfloat: 3.14
+  SCAint: 100
+  SCAstring: "jabathehut"
+  SC1extra3: true
+
+imported-chartA-B:
+  SC1extra5: "tiller"
+
+overridden-chartA-B:
+  SCAbool: true
+  SCAfloat: 3.33
+  SCAint: 555
+  SCAstring: "wormwood"
+  SCAextra1: 23
+
+  SCBbool: true
+  SCBfloat: 0.25
+  SCBint: 98
+  SCBstring: "murkwood"
+  SCBextra1: 13
+
+  SC1extra6: 77
+
+SCBexported1A:
+  SC1extra7: true
+
+exports:
+  SC1exported1:
+    global:
+      SC1exported2:
+        all:
+          SC1exported3: "SC1expstr"
\ No newline at end of file