Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,24 @@ void runTests() {
sh "make test"
}

void runE2eTests() {
void runMinikubeSetup() {
sh '''
make e2e-setup-minikube
'''
}

void runE2eTests() {
sh '''
make e2e-test
'''
}

void runMinikubeCleanup() {
sh '''
make e2e-cleanup-minikube
'''
}

pipeline {
agent {
label {
Expand Down Expand Up @@ -167,11 +178,23 @@ pipeline {
}
}

stage('Run-e2e-tests') {
stage('Run-Minikube-Setup') {
steps {
runMinikubeSetup()
}
}

stage('Run-e2e-Tests') {
steps {
runE2eTests()
}
}

stage('Cleanup Environment') {
steps {
runMinikubeCleanup()
}
}

}

Expand Down
24 changes: 22 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,34 @@ test: manifests generate fmt vet envtest ## Run tests.
# Utilize minikube or modify the e2e tests to load the image locally, enabling compatibility with other vendors.
.PHONY: e2e-test # Run the e2e tests against a minikube k8s instance that is spun up.
e2e-test:
go test -v -count=1 ./test/e2e
minikube delete || true
@echo "=====Setting hugepages value to 1280 for hugepages-e2e test"
sudo sysctl -w vm.nr_hugepages=1280

@echo "=====Restart minikube cluster to apply hugepages value"
minikube stop
minikube start

@echo "=====Running e2e test including hugepages test"
go test -v -count=1 ./test/e2e -verifyHugePages

@echo "=====Resetting hugepages value to 0"
sudo sysctl -w vm.nr_hugepages=0

@echo "=====Restart minikube cluster"
minikube stop
minikube start

.PHONY: e2e-setup-minikube
e2e-setup-minikube: kustomize controller-gen build docker-build
minikube delete || true
minikube start --driver=docker --kubernetes-version=$(E2E_KUBERNETES_VERSION) --memory=8192 --cpus=2
minikube addons enable ingress
minikube image load $(IMG)

.PHONY: e2e-cleanup-minikube
e2e-cleanup-minikube:
@echo "=====Delete minikube cluster"
minikube delete

GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint
GOLANGCI_LINT_VERSION ?= v1.54.2
Expand Down
63 changes: 62 additions & 1 deletion test/e2e/2_marklogic_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@ package e2e

import (
"context"
"flag"
"fmt"
"strings"
"testing"
"time"

databasev1alpha1 "github.com/marklogic/marklogic-kubernetes-operator/api/v1alpha1"
coreV1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/marklogic/marklogic-kubernetes-operator/test/utils"
Expand All @@ -16,14 +21,17 @@ import (
"sigs.k8s.io/e2e-framework/pkg/features"
)

var replicas = int32(1)
var verifyHugePages = flag.Bool("verifyHugePages", false, "Test hugePages configuration")

const (
groupName = "node"
mlNamespace = "default"
)

var (
replicas = int32(1)
adminUsername = "admin"
adminPassword = "Admin@8001"
marklogiccluster = &databasev1alpha1.MarklogicCluster{
TypeMeta: metav1.TypeMeta{
APIVersion: "marklogic.com/v1alpha1",
Expand All @@ -35,6 +43,10 @@ var (
},
Spec: databasev1alpha1.MarklogicClusterSpec{
Image: marklogicImage,
Auth: &databasev1alpha1.AdminAuth{
AdminUsername: &adminUsername,
AdminPassword: &adminPassword,
},
MarkLogicGroups: []*databasev1alpha1.MarklogicGroups{
{
Name: groupName,
Expand Down Expand Up @@ -93,6 +105,55 @@ func TestMarklogicCluster(t *testing.T) {

})

// Run hugepages verification tests if verifyHugePages flag is set
if *verifyHugePages {
t.Log("Running HugePages verification tests")

// Update the MarkLogic group resources
feature.Setup(func(ctx context.Context, t *testing.T, c *envconf.Config) context.Context {
t.Log("Updating MarkLogic group resources")
client := c.Client()
var mlcluster databasev1alpha1.MarklogicCluster
var resources = coreV1.ResourceRequirements{
Requests: coreV1.ResourceList{
"memory": resource.MustParse("8Gi"),
},
Limits: coreV1.ResourceList{
"memory": resource.MustParse("8Gi"),
"hugepages-2Mi": resource.MustParse("1Gi"),
},
}
if err := client.Resources().Get(ctx, "marklogicclusters", mlNamespace, &mlcluster); err != nil {
t.Fatal(err)
}

mlcluster.Spec.MarkLogicGroups[0].Resources = &resources
if err := client.Resources().Update(ctx, &mlcluster); err != nil {
t.Log("Failed to update MarkLogic group resources")
t.Fatal(err)
}
return ctx
})

// Assessment to verify the hugepages is configured
feature.Assess("Verify Huge pages", func(ctx context.Context, t *testing.T, c *envconf.Config) context.Context {
podName := "node-0"
containerName := "marklogic-server"
cmd := fmt.Sprintf("cat /var/opt/MarkLogic/Logs/ErrorLog.txt")

output, err := utils.ExecCmdInPod(podName, mlNamespace, containerName, cmd)
if err != nil {
t.Fatalf("Failed to execute kubectl command in pod: %v", err)
}
expectedOutput := "Linux Huge Pages: detected 1280"

if !strings.Contains(string(output), expectedOutput) {
t.Fatal("Huge Pages not configured for the MarLogic node")
}
return ctx
})
}

// Using feature.Teardown to clean up
feature.Teardown(func(ctx context.Context, t *testing.T, c *envconf.Config) context.Context {
return ctx
Expand Down
2 changes: 0 additions & 2 deletions test/e2e/3_ml_cluster_ednode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ var (
home = homedir.HomeDir()
initialPodCount int
incrReplica = int32(2)
adminUsername = "admin"
adminPassword = "Admin@8001"
marklogicgroups = []*databasev1alpha1.MarklogicGroups{
{
Name: dnodeGrpName,
Expand Down