Skip to content

Commit 4f0a71f

Browse files
committed
Update tests to work with new changes and add new template test to validate the addition of a second container in each pod.
2 parents cc84007 + 46ce280 commit 4f0a71f

File tree

4 files changed

+53
-4
lines changed

4 files changed

+53
-4
lines changed

test/e2e/clustering_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func TestClusterJoin(t *testing.T) {
3737
"image.tag": "10-internal",
3838
"auth.adminUsername": username,
3939
"auth.adminPassword": password,
40+
"logging.enabled": "false",
4041
},
4142
}
4243

test/e2e/install_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func TestHelmInstall(t *testing.T) {
2929
"replicaCount": "1",
3030
"image.repository": "marklogic-centos/marklogic-server-centos",
3131
"image.tag": "10-internal",
32+
"logging.enabled": "false",
3233
},
3334
}
3435

test/e2e/upgrade_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func TestHelmUpgrade(t *testing.T) {
2929
"replicaCount": "1",
3030
"image.repository": "marklogic-centos/marklogic-server-centos",
3131
"image.tag": "10-internal",
32+
"logging.enabled": "false",
3233
},
3334
}
3435

@@ -48,6 +49,7 @@ func TestHelmUpgrade(t *testing.T) {
4849
"replicaCount": "2",
4950
"image.repository": "marklogic-centos/marklogic-server-centos",
5051
"image.tag": "10-internal",
52+
"logging.enabled": "false",
5153
},
5254
}
5355

test/template/template_test.go

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/gruntwork-io/terratest/modules/random"
1414
)
1515

16-
func TestChartTemplate(t *testing.T) {
16+
func TestChartTemplateNoLogging(t *testing.T) {
1717
t.Parallel()
1818

1919
// Path to the helm chart we will test
@@ -29,9 +29,10 @@ func TestChartTemplate(t *testing.T) {
2929
// Setup the args for helm install
3030
options := &helm.Options{
3131
SetValues: map[string]string{
32-
"image.repository": "store/marklogicdb/marklogic-server",
33-
"image.tag": "tag: 10.0-8.3-centos-1.0.0-ea3-test",
32+
"image.repository": "marklogicdb/marklogic-db",
33+
"image.tag": "latest",
3434
"persistence.enabled": "false",
35+
"logging.enabled": "false",
3536
},
3637
KubectlOptions: k8s.NewKubectlOptions("", "", namespaceName),
3738
}
@@ -47,8 +48,52 @@ func TestChartTemplate(t *testing.T) {
4748
require.Equal(t, namespaceName, statefulset.Namespace)
4849

4950
// Verify the image matches
50-
expectedImage := "store/marklogicdb/marklogic-server:tag: 10.0-8.3-centos-1.0.0-ea3-test"
51+
expectedImage := "marklogicdb/marklogic-db:latest"
5152
statefulSetContainers := statefulset.Spec.Template.Spec.Containers
5253
require.Equal(t, len(statefulSetContainers), 1)
5354
require.Equal(t, statefulSetContainers[0].Image, expectedImage)
5455
}
56+
57+
func TestChartTemplateLogging(t *testing.T) {
58+
t.Parallel()
59+
60+
// Path to the helm chart we will test
61+
helmChartPath, err := filepath.Abs("../../charts")
62+
releaseName := "marklogic-test"
63+
t.Log(helmChartPath, releaseName)
64+
require.NoError(t, err)
65+
66+
// Set up the namespace; confirm that the template renders the expected value for the namespace.
67+
namespaceName := "marklogic-" + strings.ToLower(random.UniqueId())
68+
t.Logf("Namespace: %s\n", namespaceName)
69+
70+
// Setup the args for helm install
71+
options := &helm.Options{
72+
SetValues: map[string]string{
73+
"image.repository": "marklogicdb/marklogic-db",
74+
"image.tag": "latest",
75+
"persistence.enabled": "false",
76+
"logging.enabled": "true",
77+
},
78+
KubectlOptions: k8s.NewKubectlOptions("", "", namespaceName),
79+
}
80+
81+
// render the tempate
82+
output := helm.RenderTemplate(t, options, helmChartPath, releaseName, []string{"templates/statefulset.yaml"})
83+
84+
var statefulset appsv1.Deployment
85+
helm.UnmarshalK8SYaml(t, output, &statefulset)
86+
// t.Log(statefulset)
87+
88+
// Verify the name and namespace matches
89+
require.Equal(t, namespaceName, statefulset.Namespace)
90+
91+
// Verify the image matches
92+
expectedImage1 := "marklogicdb/marklogic-db:latest"
93+
expectedImage2 := "fluent/fluent-bit:1.9.7"
94+
95+
statefulSetContainers := statefulset.Spec.Template.Spec.Containers
96+
require.Equal(t, len(statefulSetContainers), 2)
97+
require.Equal(t, statefulSetContainers[0].Image, expectedImage1)
98+
require.Equal(t, statefulSetContainers[1].Image, expectedImage2)
99+
}

0 commit comments

Comments
 (0)