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
14 changes: 12 additions & 2 deletions internal/integration_tests/gcloud/commands.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
package gcloud

import (
. "github.com/neo4j/helm-charts/internal/helpers"
"github.com/neo4j/helm-charts/internal/model"
"sync"

"os/exec"
"strings"
"testing"
"time"

. "github.com/neo4j/helm-charts/internal/helpers"
"github.com/neo4j/helm-charts/internal/model"
)

var (
credentialMutex sync.Mutex
)

func InstallGcloud(t *testing.T, zone Zone, project Project, releaseName model.ReleaseName) (Closeable, *model.PersistentDiskName, error) {

// Synchronize credential fetching to prevent race conditions
credentialMutex.Lock()
err := run(t, "gcloud", "container", "clusters", "get-credentials", string(CurrentCluster()))
credentialMutex.Unlock()
if err != nil {
return nil, nil, err
}
Expand Down
44 changes: 41 additions & 3 deletions internal/integration_tests/persistent_data.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,53 @@
package integration_tests

import (
"github.com/neo4j/helm-charts/internal/model"
"fmt"
"time"

"testing"

"github.com/neo4j/helm-charts/internal/model"
)

func ResourcesCleanup(t *testing.T, releaseName model.ReleaseName) error {
return run(t, "helm", "uninstall", releaseName.String(), "--namespace", string(releaseName.Namespace()), "--wait", "--timeout=3m")
namespace := string(releaseName.Namespace())

// First, do the helm uninstall
err := run(t, "helm", "uninstall", releaseName.String(), "--namespace", namespace, "--wait", "--timeout=3m")
if err != nil {
return err
}

// Clean up the load balancer service and endpoint that might be left behind
// due to helm.sh/resource-policy: keep annotation when clustering is enabled
loadBalancerServiceName := fmt.Sprintf("%s-lb-neo4j", model.DefaultNeo4jName)

// Delete the service if it exists (it might have resource-policy: keep)
_ = run(t, "kubectl", "delete", "service", loadBalancerServiceName, "--namespace", namespace, "--ignore-not-found=true")

// Delete the endpoint if it exists
_ = run(t, "kubectl", "delete", "endpoints", loadBalancerServiceName, "--namespace", namespace, "--ignore-not-found=true")

// Wait a moment for resources to be fully deleted
time.Sleep(2 * time.Second)

return nil
}

func ResourcesReinstall(t *testing.T, releaseName model.ReleaseName, chart model.Neo4jHelmChartBuilder) error {
namespace := string(releaseName.Namespace())
// Clean up the load balancer service and endpoint that might be left behind
// due to helm.sh/resource-policy: keep annotation when clustering is enabled
loadBalancerServiceName := fmt.Sprintf("%s-lb-neo4j", model.DefaultNeo4jName)

// Delete the service if it exists (it might have resource-policy: keep)
_ = run(t, "kubectl", "delete", "service", loadBalancerServiceName, "--namespace", namespace, "--ignore-not-found=true")

// Delete the endpoint if it exists (Kubernetes creates this automatically for services)
_ = run(t, "kubectl", "delete", "endpoints", loadBalancerServiceName, "--namespace", namespace, "--ignore-not-found=true")

// Wait a moment for resources to be fully deleted
time.Sleep(2 * time.Second)

defaultHelmArgs := []string{}
defaultHelmArgs = append(defaultHelmArgs, model.DefaultNeo4jNameArg...)
Expand All @@ -20,7 +58,7 @@ func ResourcesReinstall(t *testing.T, releaseName model.ReleaseName, chart model
_ = run(t, "kubectl", "get", "events")
return err
}
err = run(t, "kubectl", "--namespace", string(releaseName.Namespace()), "rollout", "status", "--watch", "--timeout=120s", "statefulset/"+releaseName.String())
err = run(t, "kubectl", "--namespace", namespace, "rollout", "status", "--watch", "--timeout=120s", "statefulset/"+releaseName.String())
if err != nil {
t.Log("Helm Install failed:", err)
return err
Expand Down