Skip to content

Commit e4e3c2c

Browse files
committed
Changes based on PR comments
1 parent 0e4f7f6 commit e4e3c2c

File tree

2 files changed

+36
-165
lines changed

2 files changed

+36
-165
lines changed

test/e2e/install_test.go

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package e2e
33
import (
44
"crypto/tls"
55
"fmt"
6+
"io/ioutil"
7+
"net/http"
68
"os"
79
"path/filepath"
810
"strings"
@@ -13,6 +15,8 @@ import (
1315
http_helper "github.com/gruntwork-io/terratest/modules/http-helper"
1416
"github.com/gruntwork-io/terratest/modules/k8s"
1517
"github.com/gruntwork-io/terratest/modules/random"
18+
"github.com/tidwall/gjson"
19+
digestAuth "github.com/xinsnake/go-http-digest-auth-client"
1620
)
1721

1822
func TestHelmInstall(t *testing.T) {
@@ -23,6 +27,11 @@ func TestHelmInstall(t *testing.T) {
2327
}
2428
imageRepo, repoPres := os.LookupEnv("dockerRepository")
2529
imageTag, tagPres := os.LookupEnv("dockerVersion")
30+
username := "admin"
31+
password := "admin"
32+
var resp *http.Response
33+
var body []byte
34+
var err error
2635

2736
if !repoPres {
2837
imageRepo = "marklogic-centos/marklogic-server-centos"
@@ -40,9 +49,11 @@ func TestHelmInstall(t *testing.T) {
4049
KubectlOptions: kubectlOptions,
4150
SetValues: map[string]string{
4251
"persistence.enabled": "false",
43-
"replicaCount": "1",
52+
"replicaCount": "2",
4453
"image.repository": imageRepo,
4554
"image.tag": imageTag,
55+
"auth.adminUsername": username,
56+
"auth.adminPassword": password,
4657
"logCollection.enabled": "false",
4758
},
4859
}
@@ -78,4 +89,27 @@ func TestHelmInstall(t *testing.T) {
7889
return statusCode == 200
7990
},
8091
)
92+
93+
tunnel_8002 := k8s.NewTunnel(
94+
kubectlOptions, k8s.ResourceTypePod, podName, 8002, 8002)
95+
defer tunnel_8002.Close()
96+
tunnel_8002.ForwardPort(t)
97+
98+
// Verify no groups beyond enode were created/modified
99+
groupStatusEndpoint := fmt.Sprintf("http://%s/manage/v2/groups?format=json", tunnel_8002.Endpoint())
100+
groupStatus := digestAuth.NewRequest(username, password, "GET", groupStatusEndpoint, "")
101+
t.Logf(`groupStatusEndpoint: %s`, groupStatusEndpoint)
102+
if resp, err = groupStatus.Execute(); err != nil {
103+
t.Fatalf(err.Error())
104+
}
105+
if body, err = ioutil.ReadAll(resp.Body); err != nil {
106+
t.Fatalf(err.Error())
107+
}
108+
groupQuantityJSON := gjson.Get(string(body), "group-default-list.list-items.list-count.value")
109+
110+
if groupQuantityJSON.Num != 1 {
111+
t.Errorf("Only one group should exist, instead %v groups exist", groupQuantityJSON.Num)
112+
}
113+
114+
t.Logf("Groups status response:\n" + string(body))
81115
}

test/e2e/separate_nodes_test.go

Lines changed: 1 addition & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -306,167 +306,4 @@ func TestIncorrectBootsrapHostname(t *testing.T) {
306306
t.Logf("Enode group status response:\n" + string(body))
307307
}
308308

309-
func TestDefaultGroup(t *testing.T) {
310-
var resp *http.Response
311-
var body []byte
312-
var err error
313-
314-
username := "admin"
315-
password := "admin"
316-
imageRepo, repoPres := os.LookupEnv("dockerRepository")
317-
imageTag, tagPres := os.LookupEnv("dockerVersion")
318-
namespaceName := "marklogic-" + strings.ToLower(random.UniqueId())
319-
kubectlOptions := k8s.NewKubectlOptions("", "", namespaceName)
320-
releaseName := "test-default-group"
321-
podName := releaseName + "-marklogic-0"
322-
323-
// Path to the helm chart we will test
324-
helmChartPath, e := filepath.Abs("../../charts")
325-
326-
if e != nil {
327-
t.Fatalf(e.Error())
328-
}
329-
330-
if !repoPres {
331-
imageRepo = "marklogic-centos/marklogic-server-centos"
332-
t.Logf("No imageRepo variable present, setting to default value: " + imageRepo)
333-
}
334-
335-
if !tagPres {
336-
imageTag = "10-internal"
337-
t.Logf("No imageTag variable present, setting to default value: " + imageTag)
338-
}
339-
340-
// Helm options for enode creation
341-
noGroupOptions := &helm.Options{
342-
KubectlOptions: kubectlOptions,
343-
SetValues: map[string]string{
344-
"replicaCount": "1",
345-
"image.repository": imageRepo,
346-
"image.tag": imageTag,
347-
"auth.adminUsername": username,
348-
"auth.adminPassword": password,
349-
"logCollection.enabled": "false",
350-
},
351-
}
352-
353-
t.Logf("====Creating namespace: " + namespaceName)
354-
k8s.CreateNamespace(t, kubectlOptions, namespaceName)
355-
356-
defer t.Logf("====Deleting namespace: " + namespaceName)
357-
defer k8s.DeleteNamespace(t, kubectlOptions, namespaceName)
358-
359-
t.Logf("====Installing No Group Helm Chart " + releaseName)
360-
helm.Install(t, noGroupOptions, helmChartPath, releaseName)
361-
362-
// wait until the pod is in ready status
363-
k8s.WaitUntilPodAvailable(t, kubectlOptions, podName, 10, 20*time.Second)
364-
365-
tunnel := k8s.NewTunnel(
366-
kubectlOptions, k8s.ResourceTypePod, podName, 8002, 8002)
367-
368-
defer tunnel.Close()
369-
370-
tunnel.ForwardPort(t)
371-
372-
// Verify only single group was created and it is default group
373-
groupStatusEndpoint := fmt.Sprintf("http://%s/manage/v2/groups?format=json", tunnel.Endpoint())
374-
groupStatus := digestAuth.NewRequest(username, password, "GET", groupStatusEndpoint, "")
375-
t.Logf(`groupStatusEndpoint: %s`, groupStatusEndpoint)
376-
if resp, err = groupStatus.Execute(); err != nil {
377-
t.Fatalf(err.Error())
378-
}
379-
if body, err = ioutil.ReadAll(resp.Body); err != nil {
380-
t.Fatalf(err.Error())
381-
}
382-
groupNameJSON := gjson.Get(string(body), "group-default-list.list-items.list-item[0].nameref")
383-
groupQuantityJSON := gjson.Get(string(body), "group-default-list.list-items.list-count.value")
384-
if groupNameJSON.Str != "Default" && groupQuantityJSON.Num != 1 {
385-
t.Errorf("Only group should exist and it should be the Default group, instead %v groups exist and the first group is named %v", groupQuantityJSON.Num, groupNameJSON.Str)
386-
}
387-
388-
t.Logf("Groups status response:\n" + string(body))
389-
}
390-
391-
func TestSingleGroupCreated(t *testing.T) {
392-
var resp *http.Response
393-
var body []byte
394-
var err error
395-
396-
username := "admin"
397-
password := "admin"
398-
imageRepo, repoPres := os.LookupEnv("dockerRepository")
399-
imageTag, tagPres := os.LookupEnv("dockerVersion")
400-
namespaceName := "marklogic-" + strings.ToLower(random.UniqueId())
401-
kubectlOptions := k8s.NewKubectlOptions("", "", namespaceName)
402-
releaseName := "test-default-group"
403-
podName := releaseName + "-marklogic-0"
404-
405-
// Path to the helm chart we will test
406-
helmChartPath, e := filepath.Abs("../../charts")
407-
408-
if e != nil {
409-
t.Fatalf(e.Error())
410-
}
411-
412-
if !repoPres {
413-
imageRepo = "marklogic-centos/marklogic-server-centos"
414-
t.Logf("No imageRepo variable present, setting to default value: " + imageRepo)
415-
}
416-
417-
if !tagPres {
418-
imageTag = "10-internal"
419-
t.Logf("No imageTag variable present, setting to default value: " + imageTag)
420-
}
421-
422-
// Helm options for enode creation
423-
noGroupOptions := &helm.Options{
424-
KubectlOptions: kubectlOptions,
425-
SetValues: map[string]string{
426-
"replicaCount": "3",
427-
"image.repository": imageRepo,
428-
"image.tag": imageTag,
429-
"auth.adminUsername": username,
430-
"auth.adminPassword": password,
431-
"logCollection.enabled": "false",
432-
"group.name": "enode",
433-
},
434-
}
435-
436-
t.Logf("====Creating namespace: " + namespaceName)
437-
k8s.CreateNamespace(t, kubectlOptions, namespaceName)
438-
439-
defer t.Logf("====Deleting namespace: " + namespaceName)
440-
defer k8s.DeleteNamespace(t, kubectlOptions, namespaceName)
441-
442-
t.Logf("====Installing No Group Helm Chart " + releaseName)
443-
helm.Install(t, noGroupOptions, helmChartPath, releaseName)
444-
445-
// wait until the pod is in ready status
446-
k8s.WaitUntilPodAvailable(t, kubectlOptions, podName, 10, 20*time.Second)
447-
448-
tunnel := k8s.NewTunnel(
449-
kubectlOptions, k8s.ResourceTypePod, podName, 8002, 8002)
450-
451-
defer tunnel.Close()
452-
453-
tunnel.ForwardPort(t)
454-
455-
// Verify no groups beyond enode were created/modified
456-
groupStatusEndpoint := fmt.Sprintf("http://%s/manage/v2/groups?format=json", tunnel.Endpoint())
457-
groupStatus := digestAuth.NewRequest(username, password, "GET", groupStatusEndpoint, "")
458-
t.Logf(`groupStatusEndpoint: %s`, groupStatusEndpoint)
459-
if resp, err = groupStatus.Execute(); err != nil {
460-
t.Fatalf(err.Error())
461-
}
462-
if body, err = ioutil.ReadAll(resp.Body); err != nil {
463-
t.Fatalf(err.Error())
464-
}
465-
groupQuantityJSON := gjson.Get(string(body), "group-default-list.list-items.list-count.value")
466-
467-
if groupQuantityJSON.Num != 1 {
468-
t.Errorf("Only group should exist, instead %v groups exist", groupQuantityJSON.Num)
469-
}
470-
471-
t.Logf("Groups status response:\n" + string(body))
472-
}
309+

0 commit comments

Comments
 (0)