Skip to content

Commit e1ca7b9

Browse files
CLD-699 & CLD-698 add converters and license params (#107)
* Add license and converter parameters * change env order and update extraVolumes * revert to release tag * remove parallel option * provide valid test license
1 parent e0677d9 commit e1ca7b9

File tree

5 files changed

+261
-4
lines changed

5 files changed

+261
-4
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,9 @@ This table describes the list of available parameters for Helm Chart.
569569
| `bootstrapHostName` | Host name of MarkLogic bootstrap host | `""`
570570
| `group.name` | group name for joining MarkLogic cluster | `Default` |
571571
| `group.enableXdqpSsl` | SSL encryption for XDQP | `true` |
572+
| `license.key` | set MarkLogic license key installed | `""` |
573+
| `license.licensee` | set MarkLogic licensee information | `""` |
574+
| `enableConverters` | Installs converters for the client if they are not already installed | `false` |
572575
| `affinity` | Affinity property for pod assignment | `{}` |
573576
| `nodeSelector` | nodeSelector property for pod assignment | `{}` |
574577
| `persistence.enabled` | Enable MarkLogic data persistence using Persistence Volume Claim (PVC). If set to false, EmptyDir will be used | `true` |

charts/templates/statefulset.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ spec:
9494
volumeMounts:
9595
- name: datadir
9696
mountPath: /var/opt/MarkLogic
97-
{{- if .Values.extraVolumeMounts }}
98-
{{- toYaml .Values.extraVolumeMounts | nindent 12 }}
97+
{{- if .Values.additionalVolumeMounts }}
98+
{{- toYaml .Values.additionalVolumeMounts | nindent 12 }}
9999
{{- end }}
100100
- name: mladmin-secrets
101101
mountPath: /run/secrets/ml-secrets
@@ -113,6 +113,12 @@ spec:
113113
valueFrom:
114114
fieldRef:
115115
fieldPath: metadata.name
116+
- name: INSTALL_CONVERTERS
117+
value: {{ .Values.enableConverters | quote }}
118+
- name: LICENSE_KEY
119+
value: {{ .Values.license.key | quote }}
120+
- name: LICENSEE
121+
value: {{ .Values.license.licensee | quote }}
116122
envFrom:
117123
- configMapRef:
118124
name: {{ include "marklogic.fullname" . }}
@@ -275,8 +281,8 @@ spec:
275281
volumeMounts:
276282
- name: datadir
277283
mountPath: /var/opt/MarkLogic
278-
{{- if .Values.extraVolumeMounts }}
279-
{{- toYaml .Values.extraVolumeMounts | nindent 12 }}
284+
{{- if .Values.additionalVolumeMounts }}
285+
{{- toYaml .Values.additionalVolumeMounts | nindent 12 }}
280286
{{- end }}
281287
- name: {{ include "marklogic.fullname" . }}-fb-config-map
282288
mountPath: /fluent-bit/etc/

charts/values.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ auth:
6363
adminPassword: ""
6464
walletPassword: ""
6565

66+
# Optionally install converters package on MarkLogic
67+
enableConverters: false
68+
69+
# Supply license information for MarkLogic server
70+
license:
71+
key: ""
72+
licensee: ""
73+
6674
# Configure Affinity property for scheduling pods to nodes
6775
# ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity
6876
# Preferred anti affinity rule to schedule one marklogic pod per worker node

test/e2e/env_param_test.go

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
package e2e
2+
3+
import (
4+
"fmt"
5+
"io/ioutil"
6+
"net/http"
7+
"os"
8+
"path/filepath"
9+
"strings"
10+
"testing"
11+
"time"
12+
13+
"github.com/gruntwork-io/terratest/modules/helm"
14+
"github.com/gruntwork-io/terratest/modules/k8s"
15+
"github.com/gruntwork-io/terratest/modules/random"
16+
"github.com/stretchr/testify/assert"
17+
digestAuth "github.com/xinsnake/go-http-digest-auth-client"
18+
)
19+
20+
func TestEnableConvertersAndLicense(t *testing.T) {
21+
22+
// Path to the helm chart we will test
23+
helmChartPath, e := filepath.Abs("../../charts")
24+
if e != nil {
25+
t.Fatalf(e.Error())
26+
}
27+
imageRepo, repoPres := os.LookupEnv("dockerRepository")
28+
imageTag, tagPres := os.LookupEnv("dockerVersion")
29+
username := "admin"
30+
password := "admin"
31+
var resp *http.Response
32+
var body []byte
33+
var err error
34+
35+
if !repoPres {
36+
imageRepo = "marklogic-centos/marklogic-server-centos"
37+
t.Logf("No imageRepo variable present, setting to default value: " + imageRepo)
38+
}
39+
40+
if !tagPres {
41+
imageTag = "10-internal"
42+
t.Logf("No imageTag variable present, setting to default value: " + imageTag)
43+
}
44+
45+
namespaceName := "marklogic-" + strings.ToLower(random.UniqueId())
46+
kubectlOptions := k8s.NewKubectlOptions("", "", namespaceName)
47+
options := &helm.Options{
48+
KubectlOptions: kubectlOptions,
49+
SetValues: map[string]string{
50+
"persistence.enabled": "false",
51+
"replicaCount": "1",
52+
"image.repository": imageRepo,
53+
"image.tag": imageTag,
54+
"auth.adminUsername": username,
55+
"auth.adminPassword": password,
56+
"logCollection.enabled": "false",
57+
"enableConverters": "true",
58+
"license.key": "3981-CE27-75BB-9D3C-B81C-E067-1B39-DDFE-0875-C37E-D3F0-A76C-34E5-2F86-76BB-ADDD-E677-CB3F-D5FE-4773-C3CD-5EE8-87BC-36E5-3F71-0C15",
59+
"license.licensee": "MarkLogic - Version 9 QA Test License",
60+
},
61+
}
62+
63+
t.Logf("====Creating namespace: " + namespaceName)
64+
k8s.CreateNamespace(t, kubectlOptions, namespaceName)
65+
66+
defer t.Logf("====Deleting namespace: " + namespaceName)
67+
defer k8s.DeleteNamespace(t, kubectlOptions, namespaceName)
68+
69+
t.Logf("====Installing Helm Chart")
70+
releaseName := "test"
71+
helm.Install(t, options, helmChartPath, releaseName)
72+
73+
podName := releaseName + "-marklogic-0"
74+
// wait until the pod is in Ready status
75+
k8s.WaitUntilPodAvailable(t, kubectlOptions, podName, 10, 15*time.Second)
76+
tunnel := k8s.NewTunnel(
77+
kubectlOptions, k8s.ResourceTypePod, podName, 8001, 8001)
78+
defer tunnel.Close()
79+
tunnel.ForwardPort(t)
80+
endpoint := fmt.Sprintf("http://%s/admin/v1/timestamp", tunnel.Endpoint())
81+
t.Logf(`Endpoint: %s`, endpoint)
82+
83+
// Make request to server as soon as it is ready
84+
timestamp := digestAuth.NewRequest(username, password, "GET", endpoint, "")
85+
86+
if resp, err = timestamp.Execute(); err != nil {
87+
t.Fatalf(err.Error())
88+
}
89+
if body, err = ioutil.ReadAll(resp.Body); err != nil {
90+
t.Fatalf(err.Error())
91+
}
92+
93+
t.Logf("Timestamp response:\n" + string(body))
94+
95+
// Get logs from a running container
96+
podConfig := k8s.GetPod(t, kubectlOptions, podName)
97+
logs, err := k8s.GetPodLogsE(t, kubectlOptions, podConfig, "")
98+
if err != nil {
99+
t.Errorf("Failed to get logs for pod %s in namespace %s: %v", podName, namespaceName, err)
100+
}
101+
102+
// Verify that the license is getting installed
103+
assert.Contains(t, logs, "LICENSE_KEY and LICENSEE are defined")
104+
// Verify that converters are getting installed
105+
assert.Contains(t, logs, "converters.rpm to be installed")
106+
}

test/template/env_param_templ_test.go

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
package template_test
2+
3+
import (
4+
"path/filepath"
5+
"strings"
6+
"testing"
7+
8+
"github.com/stretchr/testify/require"
9+
appsv1 "k8s.io/api/apps/v1"
10+
11+
"github.com/gruntwork-io/terratest/modules/helm"
12+
"github.com/gruntwork-io/terratest/modules/k8s"
13+
"github.com/gruntwork-io/terratest/modules/random"
14+
)
15+
16+
func TestChartTemplateEnableConvertersEnabled(t *testing.T) {
17+
18+
// Path to the helm chart we will test
19+
helmChartPath, err := filepath.Abs("../../charts")
20+
releaseName := "marklogic-container-env-test"
21+
t.Log(helmChartPath, releaseName)
22+
require.NoError(t, err)
23+
24+
// Set up the namespace; confirm that the template renders the expected value for the namespace.
25+
namespaceName := "marklogic-" + strings.ToLower(random.UniqueId())
26+
t.Logf("Namespace: %s\n", namespaceName)
27+
28+
// Setup the args for helm install
29+
options := &helm.Options{
30+
SetValues: map[string]string{
31+
"image.repository": "marklogicdb/marklogic-db",
32+
"image.tag": "latest",
33+
"persistence.enabled": "false",
34+
"enableConverters": "true",
35+
},
36+
KubectlOptions: k8s.NewKubectlOptions("", "", namespaceName),
37+
}
38+
39+
// render the tempate
40+
output := helm.RenderTemplate(t, options, helmChartPath, releaseName, []string{"templates/statefulset.yaml"})
41+
42+
var statefulset appsv1.StatefulSet
43+
helm.UnmarshalK8SYaml(t, output, &statefulset)
44+
45+
// Verify the name and namespace matches
46+
require.Equal(t, namespaceName, statefulset.Namespace)
47+
48+
// Verify the value of enableConverters parameter
49+
expectedEnableConverters := "true"
50+
actualEnableConverters := statefulset.Spec.Template.Spec.Containers[0].Env[3].Value
51+
require.Equal(t, expectedEnableConverters, actualEnableConverters)
52+
}
53+
54+
func TestChartTemplateEnableConvertersDisabled(t *testing.T) {
55+
56+
// Path to the helm chart we will test
57+
helmChartPath, err := filepath.Abs("../../charts")
58+
releaseName := "marklogic-container-env-test"
59+
t.Log(helmChartPath, releaseName)
60+
require.NoError(t, err)
61+
62+
// Set up the namespace; confirm that the template renders the expected value for the namespace.
63+
namespaceName := "marklogic-" + strings.ToLower(random.UniqueId())
64+
t.Logf("Namespace: %s\n", namespaceName)
65+
66+
// Setup the args for helm install
67+
options := &helm.Options{
68+
SetValues: map[string]string{
69+
"image.repository": "marklogicdb/marklogic-db",
70+
"image.tag": "latest",
71+
"persistence.enabled": "false",
72+
"enableConverters": "false",
73+
},
74+
KubectlOptions: k8s.NewKubectlOptions("", "", namespaceName),
75+
}
76+
77+
// render the tempate
78+
output := helm.RenderTemplate(t, options, helmChartPath, releaseName, []string{"templates/statefulset.yaml"})
79+
80+
var statefulset appsv1.StatefulSet
81+
helm.UnmarshalK8SYaml(t, output, &statefulset)
82+
83+
// Verify the name and namespace matches
84+
require.Equal(t, namespaceName, statefulset.Namespace)
85+
86+
// Verify the value of enableConverters parameter
87+
expectedEnableConverters := "false"
88+
actualEnableConverters := statefulset.Spec.Template.Spec.Containers[0].Env[3].Value
89+
require.Equal(t, actualEnableConverters, expectedEnableConverters)
90+
91+
}
92+
93+
func TestChartTemplateLicenseValues(t *testing.T) {
94+
95+
// Path to the helm chart we will test
96+
helmChartPath, err := filepath.Abs("../../charts")
97+
releaseName := "marklogic-container-env-test"
98+
t.Log(helmChartPath, releaseName)
99+
require.NoError(t, err)
100+
101+
// Set up the namespace; confirm that the template renders the expected value for the namespace.
102+
namespaceName := "marklogic-" + strings.ToLower(random.UniqueId())
103+
t.Logf("Namespace: %s\n", namespaceName)
104+
105+
// Setup the args for helm install
106+
options := &helm.Options{
107+
SetValues: map[string]string{
108+
"image.repository": "marklogicdb/marklogic-db",
109+
"image.tag": "latest",
110+
"persistence.enabled": "false",
111+
"license.key": "Test License Key",
112+
"license.licensee": "Test Licensee",
113+
},
114+
KubectlOptions: k8s.NewKubectlOptions("", "", namespaceName),
115+
}
116+
117+
// render the tempate
118+
output := helm.RenderTemplate(t, options, helmChartPath, releaseName, []string{"templates/statefulset.yaml"})
119+
120+
var statefulset appsv1.StatefulSet
121+
helm.UnmarshalK8SYaml(t, output, &statefulset)
122+
123+
// Verify the name and namespace matches
124+
require.Equal(t, namespaceName, statefulset.Namespace)
125+
126+
// Verify the value of licenseKey and licensee parameters
127+
expectedLicenseKey := "Test License Key"
128+
expectedLicensee := "Test Licensee"
129+
actualLicenseKey := statefulset.Spec.Template.Spec.Containers[0].Env[4].Value
130+
actualLicensee := statefulset.Spec.Template.Spec.Containers[0].Env[5].Value
131+
132+
require.Equal(t, actualLicenseKey, expectedLicenseKey)
133+
require.Equal(t, actualLicensee, expectedLicensee)
134+
}

0 commit comments

Comments
 (0)