Skip to content

Commit

Permalink
chore: integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
ericzzzzzzz committed Sep 27, 2023
1 parent 02d4f89 commit 3a8d6d9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
17 changes: 17 additions & 0 deletions integration/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"testing"

"github.com/GoogleContainerTools/skaffold/v2/integration/skaffold"
"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/util"
"github.com/GoogleContainerTools/skaffold/v2/testutil"
)

Expand All @@ -41,6 +42,22 @@ func TestHelmDeploy(t *testing.T) {
skaffold.Delete().InDir("testdata/helm").InNs(ns.Name).WithEnv(env).RunOrFail(t)
}

func TestHelmDeployWithHook(t *testing.T) {
MarkIntegrationTest(t, CanRunWithoutGcp)

ns, client := SetupNamespace(t)

// To fix #1823, we make use of env variable templating for release name
replicas := 5
env := []string{fmt.Sprintf("REPLICAS=%d", replicas), fmt.Sprintf("TEST_NS=%s", ns.Name)}
skaffold.Deploy("--images", "us-central1-docker.pkg.dev/k8s-skaffold/testing/skaffold-helm", "-p", "helm-hook").InDir("testdata/helm").InNs(ns.Name).WithEnv(env).RunOrFail(t)

dep := client.GetDeployment("skaffold-helm-" + ns.Name)
testutil.CheckDeepEqual(t, dep.Spec.Replicas, util.Ptr(int32(replicas)))

skaffold.Delete().InDir("testdata/helm").InNs(ns.Name).WithEnv(env).RunOrFail(t)
}

func TestRunHelmMultiConfig(t *testing.T) {
var tests = []struct {
description string
Expand Down
7 changes: 7 additions & 0 deletions integration/testdata/helm/change_replicas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env python3
import sys
import os
stdin_data = sys.stdin.read()
count = os.getenv("REPLICAS")

print(stdin_data.replace("replicas: 1", "replicas: {}".format(count)))
2 changes: 1 addition & 1 deletion integration/testdata/helm/skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ profiles:
chartPath: skaffold-helm
flags:
install:
- "--post-renderer=./update_replica.sh"
- "--post-renderer=./change_replicas.py"
3 changes: 0 additions & 3 deletions integration/testdata/helm/update_replica.sh

This file was deleted.

0 comments on commit 3a8d6d9

Please sign in to comment.