Skip to content

Commit fcd59bf

Browse files
committed
Add test to verify "The group should not be created or updated if it's not the pod-0"
1 parent dbe369c commit fcd59bf

File tree

1 file changed

+84
-2
lines changed

1 file changed

+84
-2
lines changed

test/e2e/separate_nodes_test.go

Lines changed: 84 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ func TestDefaultGroup(t *testing.T) {
369369

370370
tunnel.ForwardPort(t)
371371

372-
// Verify enode group creation failed given incorrect hostname
372+
// Verify only single group was created and it is default group
373373
groupStatusEndpoint := fmt.Sprintf("http://%s/manage/v2/groups?format=json", tunnel.Endpoint())
374374
groupStatus := digestAuth.NewRequest(username, password, "GET", groupStatusEndpoint, "")
375375
t.Logf(`groupStatusEndpoint: %s`, groupStatusEndpoint)
@@ -381,10 +381,92 @@ func TestDefaultGroup(t *testing.T) {
381381
}
382382
groupName := gjson.Get(string(body), "group-default-list.list-items.list-item[0].nameref")
383383
groupQuantity := gjson.Get(string(body), "group-default-list.list-items.list-count.value")
384-
385384
if groupName.Str != "Default" && groupQuantity.Num != 1 {
386385
t.Errorf("Only group should exist and it should be the Default group, instead %v groups exist and the first group is named %v", groupQuantity.Num, groupName.Str)
387386
}
388387

389388
t.Logf("Groups status response:\n" + string(body))
390389
}
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+
groupQuantity := gjson.Get(string(body), "group-default-list.list-items.list-count.value")
466+
467+
if groupQuantity.Num != 1 {
468+
t.Errorf("Only group should exist, instead %v groups exist", groupQuantity.Num)
469+
}
470+
471+
t.Logf("Groups status response:\n" + string(body))
472+
}

0 commit comments

Comments
 (0)