Skip to content

Commit 7cad33b

Browse files
committed
Seperate tests into catagorys instead of all being in one file
Don't allow e2e.sh to used cached tests Change what digest_auth module we use
1 parent d5e4102 commit 7cad33b

File tree

7 files changed

+229
-192
lines changed

7 files changed

+229
-192
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ require (
3131
github.com/imdario/mergo v0.3.12 // indirect
3232
github.com/jmespath/go-jmespath v0.4.0 // indirect
3333
github.com/json-iterator/go v1.1.12 // indirect
34-
github.com/judgegregg/go-http-digest-auth-client v0.6.1
3534
github.com/mattn/go-zglob v0.0.2-0.20190814121620-e3c945676326 // indirect
3635
github.com/mitchellh/go-homedir v1.1.0 // indirect
3736
github.com/moby/spdystream v0.2.0 // indirect
@@ -44,6 +43,7 @@ require (
4443
github.com/russross/blackfriday/v2 v2.1.0 // indirect
4544
github.com/spf13/pflag v1.0.5 // indirect
4645
github.com/urfave/cli v1.22.2 // indirect
46+
github.com/xinsnake/go-http-digest-auth-client v0.6.0
4747
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
4848
golang.org/x/net v0.0.0-20210825183410-e898025ed96a // indirect
4949
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,8 +514,6 @@ github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHm
514514
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
515515
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
516516
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
517-
github.com/judgegregg/go-http-digest-auth-client v0.6.1 h1:r2N/KgSd0uS18kyoKSVSI3RQ+Rr6Wynk4iaaZUnjqq4=
518-
github.com/judgegregg/go-http-digest-auth-client v0.6.1/go.mod h1:Eq3vslaiSqDvLLWgenX2mpHiZHG0ZQSKT1Li5Vo5iaQ=
519517
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
520518
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
521519
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
@@ -785,6 +783,8 @@ github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2
785783
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
786784
github.com/xeipuuv/gojsonschema v0.0.0-20180618132009-1d523034197f/go.mod h1:5yf86TLmAcydyeJq5YvxkGPE2fm/u4myDekKRoLuqhs=
787785
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
786+
github.com/xinsnake/go-http-digest-auth-client v0.6.0 h1:nrYFWDrB2F7VwYlNravXZS0nOtg9axlATH3Jns55/F0=
787+
github.com/xinsnake/go-http-digest-auth-client v0.6.0/go.mod h1:QK1t1v7ylyGb363vGWu+6Irh7gyFj+N7+UZzM0L6g8I=
788788
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
789789
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
790790
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=

test/e2e/clustering_test.go

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package e2e
2+
3+
import (
4+
"fmt"
5+
"io/ioutil"
6+
"net/http"
7+
"path/filepath"
8+
"strings"
9+
"testing"
10+
"time"
11+
12+
"github.com/gruntwork-io/terratest/modules/helm"
13+
"github.com/gruntwork-io/terratest/modules/k8s"
14+
"github.com/gruntwork-io/terratest/modules/random"
15+
digest_auth "github.com/xinsnake/go-http-digest-auth-client"
16+
)
17+
18+
19+
func TestClusterJoin(t *testing.T) {
20+
// Path to the helm chart we will test
21+
helmChartPath, e := filepath.Abs("../../charts")
22+
if (e != nil) {
23+
t.Fatalf(e.Error())
24+
}
25+
username := "admin"
26+
password := "admin"
27+
var resp *http.Response
28+
var body []byte
29+
var err error
30+
namespaceName := "marklogic-" + strings.ToLower(random.UniqueId())
31+
kubectlOptions := k8s.NewKubectlOptions("", "", namespaceName)
32+
options := &helm.Options{
33+
KubectlOptions: kubectlOptions,
34+
SetValues: map[string]string{
35+
"persistence.enabled": "false",
36+
"replicaCount": "2",
37+
"image.repository": "marklogic-centos/marklogic-server-centos",
38+
"image.tag": "10-internal",
39+
"auth.adminUsername": username,
40+
"auth.adminPassword": password,
41+
},
42+
}
43+
44+
t.Logf("====Creating namespace: " + namespaceName)
45+
k8s.CreateNamespace(t, kubectlOptions, namespaceName)
46+
47+
defer t.Logf("====Deleting namespace: " + namespaceName)
48+
defer k8s.DeleteNamespace(t, kubectlOptions, namespaceName)
49+
50+
t.Logf("====Installing Helm Chart")
51+
releaseName := "test-join"
52+
helm.Install(t, options, helmChartPath, releaseName)
53+
54+
podName := releaseName + "-marklogic-1"
55+
56+
// wait until the pod is in Ready status
57+
k8s.WaitUntilPodAvailable(t, kubectlOptions, podName, 10, 20*time.Second)
58+
tunnel := k8s.NewTunnel(
59+
kubectlOptions, k8s.ResourceTypePod, podName, 8002, 8002)
60+
defer tunnel.Close()
61+
tunnel.ForwardPort(t)
62+
endpoint := fmt.Sprintf("http://%s/manage/v2/hosts", tunnel.Endpoint())
63+
t.Logf(`Endpoint: %s`, endpoint)
64+
65+
dr := digest_auth.NewRequest(username, password, "GET", endpoint, "")
66+
67+
if resp, err = dr.Execute(); err != nil {
68+
t.Fatalf(err.Error())
69+
}
70+
defer resp.Body.Close()
71+
72+
if body, err = ioutil.ReadAll(resp.Body); err != nil {
73+
t.Fatalf(err.Error())
74+
}
75+
76+
t.Logf("Response:\n" + string(body))
77+
if !strings.Contains(string(body), "<list-count units=\"quantity\">2</list-count>") {
78+
t.Errorf("Wrong number of hosts")
79+
}
80+
}

test/e2e/e2e.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ echo "=====Loading marklogc images to minikube cluster"
77
minikube image load marklogic-centos/marklogic-server-centos:10-internal
88

99
echo "=====Running tests"
10-
go test -v ./test/e2e/...
10+
go test -v -count=1 ./test/e2e/...
1111

1212
echo "=====Delete minikube cluster"
1313
minikube delete

test/e2e/e2e_test.go

Lines changed: 0 additions & 188 deletions
This file was deleted.

test/e2e/install_test.go

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package e2e
2+
3+
import (
4+
"crypto/tls"
5+
"fmt"
6+
"path/filepath"
7+
"strings"
8+
"testing"
9+
"time"
10+
11+
"github.com/gruntwork-io/terratest/modules/helm"
12+
http_helper "github.com/gruntwork-io/terratest/modules/http-helper"
13+
"github.com/gruntwork-io/terratest/modules/k8s"
14+
"github.com/gruntwork-io/terratest/modules/random"
15+
)
16+
17+
func TestHelmInstall(t *testing.T) {
18+
// Path to the helm chart we will test
19+
helmChartPath, e := filepath.Abs("../../charts")
20+
if (e != nil) {
21+
t.Fatalf(e.Error())
22+
}
23+
namespaceName := "marklogic-" + strings.ToLower(random.UniqueId())
24+
kubectlOptions := k8s.NewKubectlOptions("", "", namespaceName)
25+
options := &helm.Options{
26+
KubectlOptions: kubectlOptions,
27+
SetValues: map[string]string{
28+
"persistence.enabled": "false",
29+
"replicaCount": "1",
30+
"image.repository": "marklogic-centos/marklogic-server-centos",
31+
"image.tag": "10-internal",
32+
},
33+
}
34+
35+
t.Logf("====Creating namespace: " + namespaceName)
36+
k8s.CreateNamespace(t, kubectlOptions, namespaceName)
37+
38+
defer t.Logf("====Deleting namespace: " + namespaceName)
39+
defer k8s.DeleteNamespace(t, kubectlOptions, namespaceName)
40+
41+
t.Logf("====Installing Helm Chart")
42+
releaseName := "test-install"
43+
helm.Install(t, options, helmChartPath, releaseName)
44+
45+
tlsConfig := tls.Config{}
46+
podName := releaseName + "-marklogic-0"
47+
// wait until the pod is in Ready status
48+
k8s.WaitUntilPodAvailable(t, kubectlOptions, podName, 10, 15*time.Second)
49+
tunnel := k8s.NewTunnel(
50+
kubectlOptions, k8s.ResourceTypePod, podName, 7997, 7997)
51+
defer tunnel.Close()
52+
tunnel.ForwardPort(t)
53+
endpoint := fmt.Sprintf("http://%s", tunnel.Endpoint())
54+
t.Logf(`Endpoint: %s`, endpoint)
55+
56+
http_helper.HttpGetWithRetryWithCustomValidation(
57+
t,
58+
endpoint,
59+
&tlsConfig,
60+
10,
61+
15*time.Second,
62+
func(statusCode int, body string) bool {
63+
return statusCode == 200
64+
},
65+
)
66+
}

0 commit comments

Comments
 (0)