@@ -2,10 +2,15 @@ package e2e
2
2
3
3
import (
4
4
"context"
5
+ "flag"
6
+ "fmt"
7
+ "strings"
5
8
"testing"
6
9
"time"
7
10
8
11
databasev1alpha1 "github.com/marklogic/marklogic-kubernetes-operator/api/v1alpha1"
12
+ coreV1 "k8s.io/api/core/v1"
13
+ "k8s.io/apimachinery/pkg/api/resource"
9
14
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
10
15
11
16
"github.com/marklogic/marklogic-kubernetes-operator/test/utils"
@@ -16,14 +21,17 @@ import (
16
21
"sigs.k8s.io/e2e-framework/pkg/features"
17
22
)
18
23
19
- var replicas = int32 ( 1 )
24
+ var verifyHugePages = flag . Bool ( "verifyHugePages" , false , "Test hugePages configuration" )
20
25
21
26
const (
22
27
groupName = "node"
23
28
mlNamespace = "default"
24
29
)
25
30
26
31
var (
32
+ replicas = int32 (1 )
33
+ adminUsername = "admin"
34
+ adminPassword = "Admin@8001"
27
35
marklogiccluster = & databasev1alpha1.MarklogicCluster {
28
36
TypeMeta : metav1.TypeMeta {
29
37
APIVersion : "marklogic.com/v1alpha1" ,
35
43
},
36
44
Spec : databasev1alpha1.MarklogicClusterSpec {
37
45
Image : marklogicImage ,
46
+ Auth : & databasev1alpha1.AdminAuth {
47
+ AdminUsername : & adminUsername ,
48
+ AdminPassword : & adminPassword ,
49
+ },
38
50
MarkLogicGroups : []* databasev1alpha1.MarklogicGroups {
39
51
{
40
52
Name : groupName ,
@@ -93,6 +105,55 @@ func TestMarklogicCluster(t *testing.T) {
93
105
94
106
})
95
107
108
+ // Run hugepages verification tests if verifyHugePages flag is set
109
+ if * verifyHugePages {
110
+ t .Log ("Running HugePages verification tests" )
111
+
112
+ // Update the MarkLogic group resources
113
+ feature .Setup (func (ctx context.Context , t * testing.T , c * envconf.Config ) context.Context {
114
+ t .Log ("Updating MarkLogic group resources" )
115
+ client := c .Client ()
116
+ var mlcluster databasev1alpha1.MarklogicCluster
117
+ var resources = coreV1.ResourceRequirements {
118
+ Requests : coreV1.ResourceList {
119
+ "memory" : resource .MustParse ("8Gi" ),
120
+ },
121
+ Limits : coreV1.ResourceList {
122
+ "memory" : resource .MustParse ("8Gi" ),
123
+ "hugepages-2Mi" : resource .MustParse ("1Gi" ),
124
+ },
125
+ }
126
+ if err := client .Resources ().Get (ctx , "marklogicclusters" , mlNamespace , & mlcluster ); err != nil {
127
+ t .Fatal (err )
128
+ }
129
+
130
+ mlcluster .Spec .MarkLogicGroups [0 ].Resources = & resources
131
+ if err := client .Resources ().Update (ctx , & mlcluster ); err != nil {
132
+ t .Log ("Failed to update MarkLogic group resources" )
133
+ t .Fatal (err )
134
+ }
135
+ return ctx
136
+ })
137
+
138
+ // Assessment to verify the hugepages is configured
139
+ feature .Assess ("Verify Huge pages" , func (ctx context.Context , t * testing.T , c * envconf.Config ) context.Context {
140
+ podName := "node-0"
141
+ containerName := "marklogic-server"
142
+ cmd := fmt .Sprintf ("cat /var/opt/MarkLogic/Logs/ErrorLog.txt" )
143
+
144
+ output , err := utils .ExecCmdInPod (podName , mlNamespace , containerName , cmd )
145
+ if err != nil {
146
+ t .Fatalf ("Failed to execute kubectl command in pod: %v" , err )
147
+ }
148
+ expectedOutput := "Linux Huge Pages: detected 1280"
149
+
150
+ if ! strings .Contains (string (output ), expectedOutput ) {
151
+ t .Fatal ("Huge Pages not configured for the MarLogic node" )
152
+ }
153
+ return ctx
154
+ })
155
+ }
156
+
96
157
// Using feature.Teardown to clean up
97
158
feature .Teardown (func (ctx context.Context , t * testing.T , c * envconf.Config ) context.Context {
98
159
return ctx
0 commit comments