Browse Source

chore: fix the argocd e2e test case (#5688)

Gergely Brautigam 5 months ago
parent
commit
85bebde019
3 changed files with 32 additions and 18 deletions
  1. 3 0
      e2e/framework/addon/addon.go
  2. 24 18
      e2e/framework/addon/chart.go
  3. 5 0
      e2e/run.sh

+ 3 - 0
e2e/framework/addon/addon.go

@@ -64,6 +64,9 @@ func InstallGlobalAddon(addon Addon) {
 	gomega.Expect(err).NotTo(gomega.HaveOccurred())
 
 	err = addon.Install()
+	if err != nil {
+		addon.Logs() // Print logs in case installation fails
+	}
 	gomega.Expect(err).NotTo(gomega.HaveOccurred())
 }
 

+ 24 - 18
e2e/framework/addon/chart.go

@@ -20,6 +20,7 @@ import (
 	"bytes"
 	"fmt"
 	"os/exec"
+	"path/filepath"
 
 	. "github.com/onsi/ginkgo/v2"
 	corev1 "k8s.io/api/core/v1"
@@ -61,12 +62,22 @@ func (c *HelmChart) Setup(cfg *Config) error {
 
 // Install adds the chart repo and installs the helm chart.
 func (c *HelmChart) Install() error {
-	err := c.addRepo()
+	args := []string{
+		"dependency", "update", filepath.Join(AssetDir(), "deploy/charts/external-secrets"),
+	}
+	log.Logf("updating chart dependencies with args: %+q", args)
+	cmd := exec.Command("helm", args...)
+	output, err := cmd.CombinedOutput()
+	if err != nil {
+		return fmt.Errorf("unable to run update cmd: %w: %s", err, string(output))
+	}
+
+	err = c.addRepo()
 	if err != nil {
 		return err
 	}
 
-	args := []string{"install", c.ReleaseName, c.Chart,
+	args = []string{"install", c.ReleaseName, c.Chart,
 		"--dependency-update",
 		"--debug",
 		"--wait",
@@ -89,28 +100,25 @@ func (c *HelmChart) Install() error {
 
 	args = append(args, c.Args...)
 
-	var sout, serr bytes.Buffer
 	log.Logf("installing chart with args: %+q", args)
-	cmd := exec.Command("helm", args...)
-	cmd.Stdout = &sout
-	cmd.Stderr = &serr
-	err = cmd.Run()
+	cmd = exec.Command("helm", args...)
+	output, err = cmd.CombinedOutput()
 	if err != nil {
-		return fmt.Errorf("unable to run cmd: %w: %s %s", err, sout.String(), serr.String())
+		return fmt.Errorf("unable to run cmd: %w: %s", err, string(output))
 	}
+
+	log.Logf("finished running chart install")
+
 	return nil
 }
 
 // Uninstall removes the chart aswell as the repo.
 func (c *HelmChart) Uninstall() error {
-	var sout, serr bytes.Buffer
 	args := []string{"uninstall", "--namespace", c.Namespace, c.ReleaseName, "--wait"}
 	cmd := exec.Command("helm", args...)
-	cmd.Stdout = &sout
-	cmd.Stderr = &serr
-	err := cmd.Run()
+	output, err := cmd.CombinedOutput()
 	if err != nil {
-		return fmt.Errorf("unable to uninstall helm release: %w: %s, %s", err, sout.String(), serr.String())
+		return fmt.Errorf("unable to uninstall helm release: %w: %s", err, string(output))
 	}
 	return c.removeRepo()
 }
@@ -135,14 +143,12 @@ func (c *HelmChart) removeRepo() error {
 	if c.Repo.Name == "" || c.Repo.URL == "" {
 		return nil
 	}
-	var sout, serr bytes.Buffer
+
 	args := []string{"repo", "remove", c.Repo.Name}
 	cmd := exec.Command("helm", args...)
-	cmd.Stdout = &sout
-	cmd.Stderr = &serr
-	err := cmd.Run()
+	output, err := cmd.CombinedOutput()
 	if err != nil {
-		return fmt.Errorf("unable to remove repo: %w: %s, %s", err, sout.String(), serr.String())
+		return fmt.Errorf("unable to remove repo: %w: %s", err, string(output))
 	}
 	return nil
 }

+ 5 - 0
e2e/run.sh

@@ -39,6 +39,11 @@ kubectl create clusterrolebinding service-account-issuer-discovery-binding \
   --clusterrole=system:service-account-issuer-discovery \
   --group=system:unauthenticated || true
 
+echo -e "Cleaning cache before running tests"
+docker system prune --force
+go clean -cache
+go clean -modcache
+
 echo -e "Starting the e2e test pod ${E2E_IMAGE_NAME}:${VERSION}"
 kubectl run --rm \
   --attach \