mirror of
https://github.com/hanzoai/deploy.git
synced 2026-10-07 08:44:50 +00:00
go.mod still declared `module github.com/hanzoai/deploy` after the repo was renamed. A Go module path is not cosmetic — it is the resolvable location. So `go get github.com/hanzoai/cd` could not work, and anything importing this module had to spell a name that no longer exists at that address. The build log of v3.6.0 is where it surfaced: the compiler was still emitting github.com/hanzoai/deploy/cmd/cd/commands. 3541 import paths across 690 .go, 19 .proto, 4 .yaml, 3 .sh, 2 .mod, Procfile and Makefile. Plus the 62 ghcr.io/hanzoai/deploy image references, moved to ghcr.io/hanzoai/cd to match hanzo.yml's build target — a distinct string from the module path, replaced separately so neither could clobber the other. go mod tidy clean, CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build ./... clean. Co-authored-by: Hanzo Dev <[email protected]>
697 lines
20 KiB
Go
697 lines
20 KiB
Go
package e2e
|
|
|
|
import (
|
|
"fmt"
|
|
"net"
|
|
"net/http"
|
|
"os"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/hanzoai/cd/gitops-engine/pkg/health"
|
|
. "github.com/hanzoai/cd/gitops-engine/pkg/sync/common"
|
|
"github.com/stretchr/testify/assert"
|
|
corev1 "k8s.io/api/core/v1"
|
|
|
|
. "github.com/hanzoai/cd/pkg/apis/application/v1alpha1"
|
|
"github.com/hanzoai/cd/test/e2e/fixture"
|
|
. "github.com/hanzoai/cd/test/e2e/fixture/app"
|
|
projectFixture "github.com/hanzoai/cd/test/e2e/fixture/project"
|
|
"github.com/hanzoai/cd/util/errors"
|
|
)
|
|
|
|
func TestHelmHooksAreCreated(t *testing.T) {
|
|
ctx := Given(t)
|
|
ctx.Path("hook").
|
|
When().
|
|
PatchFile("hook.yaml", `[{"op": "replace", "path": "/metadata/annotations", "value": {"helm.sh/hook": "pre-install"}}]`).
|
|
CreateApp().
|
|
Sync().
|
|
Then().
|
|
Expect(OperationPhaseIs(OperationSucceeded)).
|
|
Expect(HealthIs(health.HealthStatusHealthy)).
|
|
Expect(SyncStatusIs(SyncStatusCodeSynced)).
|
|
Expect(ResourceResultIs(ResourceResult{Version: "v1", Kind: "Pod", Namespace: ctx.DeploymentNamespace(), Name: "hook", Message: "pod/hook created", Images: []string{"quay.io/argoprojlabs/cd-e2e-container:0.1"}, HookType: HookTypePreSync, Status: ResultCodeSynced, HookPhase: OperationSucceeded, SyncPhase: SyncPhasePreSync}))
|
|
}
|
|
|
|
// make sure we treat Helm weights as a sync wave
|
|
func TestHelmHookWeight(t *testing.T) {
|
|
Given(t).
|
|
Path("hook").
|
|
When().
|
|
// this create a weird hook, that runs during sync - but before the pod, and because it'll fail - the pod will never be created
|
|
PatchFile("hook.yaml", `[
|
|
{"op": "replace", "path": "/metadata/annotations", "value": {"cd.hanzo.ai/hook": "Sync", "helm.sh/hook-weight": "-1"}},
|
|
{"op": "replace", "path": "/spec/containers/0/command/0", "value": "false"}
|
|
]`).
|
|
CreateApp().
|
|
IgnoreErrors().
|
|
Sync().
|
|
Then().
|
|
Expect(OperationPhaseIs(OperationFailed)).
|
|
Expect(ResourceResultNumbering(1))
|
|
}
|
|
|
|
// make sure that execute the delete policy
|
|
func TestHelmHookDeletePolicy(t *testing.T) {
|
|
Given(t).
|
|
Path("hook").
|
|
When().
|
|
PatchFile("hook.yaml", `[{"op": "add", "path": "/metadata/annotations/helm.sh~1hook-delete-policy", "value": "hook-succeeded"}]`).
|
|
CreateApp().
|
|
Sync().
|
|
Then().
|
|
Expect(OperationPhaseIs(OperationSucceeded)).
|
|
Expect(ResourceResultNumbering(2)).
|
|
Expect(NotPod(func(p corev1.Pod) bool { return p.Name == "hook" }))
|
|
}
|
|
|
|
func TestDeclarativeHelm(t *testing.T) {
|
|
Given(t).
|
|
Path("helm").
|
|
When().
|
|
Declarative("declarative-apps/app.yaml").
|
|
Sync().
|
|
Then().
|
|
Expect(OperationPhaseIs(OperationSucceeded)).
|
|
Expect(HealthIs(health.HealthStatusHealthy)).
|
|
Expect(SyncStatusIs(SyncStatusCodeSynced))
|
|
}
|
|
|
|
func TestDeclarativeHelmInvalidValuesFile(t *testing.T) {
|
|
Given(t).
|
|
Path("helm").
|
|
When().
|
|
Declarative("declarative-apps/invalid-helm.yaml").
|
|
Then().
|
|
Expect(HealthIs(health.HealthStatusHealthy)).
|
|
Expect(SyncStatusIs(SyncStatusCodeUnknown)).
|
|
Expect(Condition(ApplicationConditionComparisonError, "does-not-exist-values.yaml: no such file or directory"))
|
|
}
|
|
|
|
func TestHelmRepo(t *testing.T) {
|
|
fixture.SkipOnEnv(t, "HELM")
|
|
Given(t).
|
|
CustomCACertAdded().
|
|
HelmRepoAdded("custom-repo").
|
|
RepoURLType(fixture.RepoURLTypeHelm).
|
|
Chart("helm").
|
|
Revision("1.0.0").
|
|
When().
|
|
CreateApp().
|
|
Then().
|
|
When().
|
|
Sync().
|
|
Then().
|
|
Expect(OperationPhaseIs(OperationSucceeded)).
|
|
Expect(HealthIs(health.HealthStatusHealthy)).
|
|
Expect(SyncStatusIs(SyncStatusCodeSynced))
|
|
}
|
|
|
|
func TestHelmValues(t *testing.T) {
|
|
Given(t).
|
|
Path("helm").
|
|
When().
|
|
AddFile("foo.yml", "").
|
|
CreateApp().
|
|
AppSet("--values", "foo.yml").
|
|
Then().
|
|
And(func(app *Application) {
|
|
assert.Equal(t, []string{"foo.yml"}, app.Spec.GetSource().Helm.ValueFiles)
|
|
})
|
|
}
|
|
|
|
func TestHelmIgnoreMissingValueFiles(t *testing.T) {
|
|
Given(t).
|
|
Path("helm").
|
|
When().
|
|
Declarative("declarative-apps/invalid-helm.yaml").
|
|
Then().
|
|
And(func(app *Application) {
|
|
assert.Equal(t, []string{"does-not-exist-values.yaml"}, app.Spec.GetSource().Helm.ValueFiles)
|
|
assert.False(t, app.Spec.GetSource().Helm.IgnoreMissingValueFiles)
|
|
}).
|
|
When().
|
|
AppSet("--ignore-missing-value-files").
|
|
Then().
|
|
And(func(app *Application) {
|
|
assert.True(t, app.Spec.GetSource().Helm.IgnoreMissingValueFiles)
|
|
}).
|
|
When().
|
|
Sync().
|
|
Then().
|
|
Expect(OperationPhaseIs(OperationSucceeded)).
|
|
Expect(HealthIs(health.HealthStatusHealthy)).
|
|
Expect(SyncStatusIs(SyncStatusCodeSynced)).
|
|
When().
|
|
AppUnSet("--ignore-missing-value-files").
|
|
Then().
|
|
And(func(app *Application) {
|
|
assert.False(t, app.Spec.GetSource().Helm.IgnoreMissingValueFiles)
|
|
}).
|
|
When().
|
|
IgnoreErrors().
|
|
Sync().
|
|
Then().
|
|
Expect(ErrorRegex("Error: open .*does-not-exist-values.yaml: no such file or directory", ""))
|
|
}
|
|
|
|
// TestHelmGlobValueFiles verifies that a glob pattern in valueFiles expands to all matching
|
|
// files and that they are applied in lexical order (last file wins in helm merging).
|
|
// envs/*.yaml expands to envs/a.yaml then envs/b.yaml - b.yaml is last, so foo = "b-value".
|
|
func TestHelmGlobValueFiles(t *testing.T) {
|
|
fixture.SkipOnEnv(t, "HELM")
|
|
ctx := Given(t)
|
|
ctx.Path("helm-glob-values").
|
|
When().
|
|
CreateApp().
|
|
AppSet("--values", "envs/*.yaml").
|
|
Sync().
|
|
Then().
|
|
Expect(OperationPhaseIs(OperationSucceeded)).
|
|
Expect(HealthIs(health.HealthStatusHealthy)).
|
|
Expect(SyncStatusIs(SyncStatusCodeSynced)).
|
|
And(func(_ *Application) {
|
|
val := errors.NewHandler(t).FailOnErr(fixture.Run(".", "kubectl", "-n", ctx.DeploymentNamespace(),
|
|
"get", "cm", "my-map", "-o", "jsonpath={.data.foo}")).(string)
|
|
assert.Equal(t, "b-value", val)
|
|
})
|
|
}
|
|
|
|
// TestHelmRecursiveGlobValueFiles verifies that the ** double-star pattern recursively
|
|
// matches files at any depth. envs/**/*.yaml expands (zero-segments first) to:
|
|
// envs/a.yaml, envs/b.yaml, envs/nested/c.yaml - c.yaml is last, so foo = "c-value".
|
|
func TestHelmRecursiveGlobValueFiles(t *testing.T) {
|
|
fixture.SkipOnEnv(t, "HELM")
|
|
ctx := Given(t)
|
|
ctx.Path("helm-glob-values").
|
|
When().
|
|
CreateApp().
|
|
AppSet("--values", "envs/**/*.yaml").
|
|
Sync().
|
|
Then().
|
|
Expect(OperationPhaseIs(OperationSucceeded)).
|
|
Expect(HealthIs(health.HealthStatusHealthy)).
|
|
Expect(SyncStatusIs(SyncStatusCodeSynced)).
|
|
And(func(_ *Application) {
|
|
val := errors.NewHandler(t).FailOnErr(fixture.Run(".", "kubectl", "-n", ctx.DeploymentNamespace(),
|
|
"get", "cm", "my-map", "-o", "jsonpath={.data.foo}")).(string)
|
|
assert.Equal(t, "c-value", val)
|
|
})
|
|
}
|
|
|
|
// TestHelmGlobValueFilesNoMatch verifies that a glob pattern with no matching files
|
|
// surfaces as a comparison error on the application.
|
|
func TestHelmGlobValueFilesNoMatch(t *testing.T) {
|
|
fixture.SkipOnEnv(t, "HELM")
|
|
Given(t).
|
|
Path("helm-glob-values").
|
|
When().
|
|
CreateApp().
|
|
AppSet("--values", "nonexistent/*.yaml").
|
|
Then().
|
|
Expect(Condition(ApplicationConditionComparisonError, `values file glob "nonexistent/*.yaml" matched no files`))
|
|
}
|
|
|
|
// TestHelmGlobValueFilesIgnoreMissing verifies that a non-matching glob pattern is
|
|
// silently skipped when ignoreMissingValueFiles is set, and the app syncs successfully.
|
|
func TestHelmGlobValueFilesIgnoreMissing(t *testing.T) {
|
|
fixture.SkipOnEnv(t, "HELM")
|
|
Given(t).
|
|
Path("helm-glob-values").
|
|
When().
|
|
CreateApp().
|
|
AppSet("--values", "nonexistent/*.yaml", "--ignore-missing-value-files").
|
|
Sync().
|
|
Then().
|
|
Expect(OperationPhaseIs(OperationSucceeded)).
|
|
Expect(HealthIs(health.HealthStatusHealthy)).
|
|
Expect(SyncStatusIs(SyncStatusCodeSynced))
|
|
}
|
|
|
|
func TestHelmValuesMultipleUnset(t *testing.T) {
|
|
Given(t).
|
|
Path("helm").
|
|
When().
|
|
AddFile("foo.yml", "").
|
|
AddFile("baz.yml", "").
|
|
CreateApp().
|
|
AppSet("--values", "foo.yml", "--values", "baz.yml").
|
|
Then().
|
|
And(func(app *Application) {
|
|
assert.NotNil(t, app.Spec.GetSource().Helm)
|
|
assert.Equal(t, []string{"foo.yml", "baz.yml"}, app.Spec.GetSource().Helm.ValueFiles)
|
|
}).
|
|
When().
|
|
AppUnSet("--values", "foo.yml").
|
|
Then().
|
|
And(func(app *Application) {
|
|
assert.NotNil(t, app.Spec.GetSource().Helm)
|
|
assert.Equal(t, []string{"baz.yml"}, app.Spec.GetSource().Helm.ValueFiles)
|
|
}).
|
|
When().
|
|
AppUnSet("--values", "baz.yml").
|
|
Then().
|
|
And(func(app *Application) {
|
|
assert.Nil(t, app.Spec.GetSource().Helm)
|
|
})
|
|
}
|
|
|
|
func TestHelmValuesLiteralFileLocal(t *testing.T) {
|
|
Given(t).
|
|
Path("helm").
|
|
When().
|
|
CreateApp().
|
|
AppSet("--values-literal-file", "testdata/helm/baz.yaml").
|
|
Then().
|
|
And(func(app *Application) {
|
|
data, err := os.ReadFile("testdata/helm/baz.yaml")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
assert.Equal(t, strings.TrimSuffix(string(data), "\n"), app.Spec.GetSource().Helm.ValuesString())
|
|
}).
|
|
When().
|
|
AppUnSet("--values-literal").
|
|
Then().
|
|
And(func(app *Application) {
|
|
assert.Nil(t, app.Spec.GetSource().Helm)
|
|
})
|
|
}
|
|
|
|
func TestHelmValuesLiteralFileRemote(t *testing.T) {
|
|
sentinel := "a: b"
|
|
lc := &net.ListenConfig{}
|
|
serve := func(c chan<- string) {
|
|
// listen on first available dynamic (unprivileged) port
|
|
listener, err := lc.Listen(t.Context(), "tcp", ":0")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
// send back the address so that it can be used
|
|
c <- listener.Addr().String()
|
|
http.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) {
|
|
// return the sentinel text at root URL
|
|
fmt.Fprint(w, sentinel)
|
|
})
|
|
|
|
panic(http.Serve(listener, nil))
|
|
}
|
|
c := make(chan string, 1)
|
|
|
|
// run a local webserver to test data retrieval
|
|
go serve(c)
|
|
address := <-c
|
|
t.Logf("Listening at address: %s", address)
|
|
|
|
Given(t).
|
|
Path("helm").
|
|
When().
|
|
CreateApp().
|
|
AppSet("--values-literal-file", "http://"+address).
|
|
Then().
|
|
And(func(app *Application) {
|
|
assert.Equal(t, "a: b", app.Spec.GetSource().Helm.ValuesString())
|
|
}).
|
|
When().
|
|
AppUnSet("--values-literal").
|
|
Then().
|
|
And(func(app *Application) {
|
|
assert.Nil(t, app.Spec.GetSource().Helm)
|
|
})
|
|
}
|
|
|
|
func TestHelmCrdHook(t *testing.T) {
|
|
fixture.SkipOnEnv(t, "HELM")
|
|
Given(t).
|
|
Path("helm-crd").
|
|
When().
|
|
CreateApp().
|
|
Sync().
|
|
Then().
|
|
Expect(OperationPhaseIs(OperationSucceeded)).
|
|
Expect(HealthIs(health.HealthStatusHealthy)).
|
|
Expect(SyncStatusIs(SyncStatusCodeSynced)).
|
|
Expect(ResourceResultNumbering(2))
|
|
}
|
|
|
|
func TestHelmReleaseName(t *testing.T) {
|
|
Given(t).
|
|
Path("helm").
|
|
When().
|
|
CreateApp().
|
|
AppSet("--release-name", "foo").
|
|
Then().
|
|
And(func(app *Application) {
|
|
assert.Equal(t, "foo", app.Spec.GetSource().Helm.ReleaseName)
|
|
})
|
|
}
|
|
|
|
func TestHelmSet(t *testing.T) {
|
|
Given(t).
|
|
Path("helm").
|
|
When().
|
|
CreateApp().
|
|
AppSet("--helm-set", "foo=bar", "--helm-set", "foo=baz", "--helm-set", "app=$CD_APP_NAME").
|
|
Then().
|
|
And(func(app *Application) {
|
|
assert.Equal(t, []HelmParameter{{Name: "foo", Value: "baz"}, {Name: "app", Value: "$CD_APP_NAME"}}, app.Spec.GetSource().Helm.Parameters)
|
|
})
|
|
}
|
|
|
|
func TestHelmSetString(t *testing.T) {
|
|
Given(t).
|
|
Path("helm").
|
|
When().
|
|
CreateApp().
|
|
AppSet("--helm-set-string", "foo=bar", "--helm-set-string", "foo=baz", "--helm-set-string", "app=$CD_APP_NAME").
|
|
Then().
|
|
And(func(app *Application) {
|
|
assert.Equal(t, []HelmParameter{{Name: "foo", Value: "baz", ForceString: true}, {Name: "app", Value: "$CD_APP_NAME", ForceString: true}}, app.Spec.GetSource().Helm.Parameters)
|
|
})
|
|
}
|
|
|
|
func TestHelmSetFile(t *testing.T) {
|
|
Given(t).
|
|
Path("helm").
|
|
When().
|
|
CreateApp().
|
|
AppSet("--helm-set-file", "foo=bar.yaml", "--helm-set-file", "foo=baz.yaml").
|
|
Then().
|
|
And(func(app *Application) {
|
|
assert.Equal(t, []HelmFileParameter{{Name: "foo", Path: "baz.yaml"}}, app.Spec.GetSource().Helm.FileParameters)
|
|
})
|
|
}
|
|
|
|
// ensure we can use envsubst in "set" variables
|
|
func TestHelmSetEnv(t *testing.T) {
|
|
ctx := Given(t)
|
|
ctx.Path("helm-values").
|
|
When().
|
|
CreateApp().
|
|
AppSet("--helm-set", "foo=$CD_APP_NAME").
|
|
Sync().
|
|
Then().
|
|
Expect(OperationPhaseIs(OperationSucceeded)).
|
|
Expect(SyncStatusIs(SyncStatusCodeSynced)).
|
|
And(func(_ *Application) {
|
|
assert.Equal(t, ctx.GetName(), errors.NewHandler(t).FailOnErr(fixture.Run(".", "kubectl", "-n", ctx.DeploymentNamespace(), "get", "cm", "my-map", "-o", "jsonpath={.data.foo}")).(string))
|
|
})
|
|
}
|
|
|
|
func TestHelmSetStringEnv(t *testing.T) {
|
|
ctx := Given(t)
|
|
ctx.Path("helm-values").
|
|
When().
|
|
CreateApp().
|
|
AppSet("--helm-set-string", "foo=$CD_APP_NAME").
|
|
Sync().
|
|
Then().
|
|
Expect(OperationPhaseIs(OperationSucceeded)).
|
|
Expect(SyncStatusIs(SyncStatusCodeSynced)).
|
|
And(func(_ *Application) {
|
|
assert.Equal(t, ctx.GetName(), errors.NewHandler(t).FailOnErr(fixture.Run(".", "kubectl", "-n", ctx.DeploymentNamespace(), "get", "cm", "my-map", "-o", "jsonpath={.data.foo}")).(string))
|
|
})
|
|
}
|
|
|
|
// make sure kube-version gets passed down to resources
|
|
func TestKubeVersion(t *testing.T) {
|
|
fixture.SkipOnEnv(t, "HELM")
|
|
ctx := Given(t)
|
|
ctx.Path("helm-kube-version").
|
|
When().
|
|
CreateApp().
|
|
Sync().
|
|
Then().
|
|
Expect(SyncStatusIs(SyncStatusCodeSynced)).
|
|
And(func(_ *Application) {
|
|
kubeVersion := errors.NewHandler(t).FailOnErr(fixture.Run(".", "kubectl", "-n", ctx.DeploymentNamespace(), "get", "cm", "my-map",
|
|
"-o", "jsonpath={.data.kubeVersion}")).(string)
|
|
// Capabilities.KubeVersion defaults to 1.9.0, we assume here you are running a later version
|
|
assert.LessOrEqual(t, fixture.GetVersions(t).ServerVersion.String(), kubeVersion)
|
|
}).
|
|
When().
|
|
// Make sure override works.
|
|
AppSet("--helm-kube-version", "999.999.999").
|
|
Sync().
|
|
Then().
|
|
Expect(SyncStatusIs(SyncStatusCodeSynced)).
|
|
And(func(_ *Application) {
|
|
assert.Equal(t, "v999.999.999", errors.NewHandler(t).FailOnErr(fixture.Run(".", "kubectl", "-n", ctx.DeploymentNamespace(), "get", "cm", "my-map",
|
|
"-o", "jsonpath={.data.kubeVersion}")).(string))
|
|
})
|
|
}
|
|
|
|
// make sure api versions gets passed down to resources
|
|
func TestApiVersions(t *testing.T) {
|
|
fixture.SkipOnEnv(t, "HELM")
|
|
ctx := Given(t)
|
|
ctx.Path("helm-api-versions").
|
|
When().
|
|
CreateApp().
|
|
Sync().
|
|
Then().
|
|
Expect(SyncStatusIs(SyncStatusCodeSynced)).
|
|
And(func(_ *Application) {
|
|
apiVersions := errors.NewHandler(t).FailOnErr(fixture.Run(".", "kubectl", "-n", ctx.DeploymentNamespace(), "get", "cm", "my-map",
|
|
"-o", "jsonpath={.data.apiVersions}")).(string)
|
|
// The v1 API shouldn't be going anywhere.
|
|
assert.Contains(t, apiVersions, "v1")
|
|
}).
|
|
When().
|
|
// Make sure override works.
|
|
AppSet("--helm-api-versions", "v1/MyTestResource").
|
|
Sync().
|
|
Then().
|
|
Expect(SyncStatusIs(SyncStatusCodeSynced)).
|
|
And(func(_ *Application) {
|
|
apiVersions := errors.NewHandler(t).FailOnErr(fixture.Run(".", "kubectl", "-n", ctx.DeploymentNamespace(), "get", "cm", "my-map",
|
|
"-o", "jsonpath={.data.apiVersions}")).(string)
|
|
assert.Contains(t, apiVersions, "v1/MyTestResource")
|
|
})
|
|
}
|
|
|
|
func TestHelmNamespaceOverride(t *testing.T) {
|
|
fixture.SkipOnEnv(t, "HELM")
|
|
Given(t).
|
|
Path("helm-namespace").
|
|
When().
|
|
CreateApp().
|
|
Sync().
|
|
Then().
|
|
Expect(SyncStatusIs(SyncStatusCodeSynced)).
|
|
When().
|
|
AppSet("--helm-namespace", "does-not-exist").
|
|
Then().
|
|
// The app should go out of sync, because the resource's target namespace changed.
|
|
Expect(SyncStatusIs(SyncStatusCodeOutOfSync))
|
|
}
|
|
|
|
func TestHelmValuesHiddenDirectory(t *testing.T) {
|
|
fixture.SkipOnEnv(t, "HELM")
|
|
Given(t).
|
|
Path(".hidden-helm").
|
|
When().
|
|
AddFile("foo.yaml", "").
|
|
CreateApp().
|
|
AppSet("--values", "foo.yaml").
|
|
Sync().
|
|
Then().
|
|
Expect(OperationPhaseIs(OperationSucceeded)).
|
|
Expect(HealthIs(health.HealthStatusHealthy)).
|
|
Expect(SyncStatusIs(SyncStatusCodeSynced))
|
|
}
|
|
|
|
func TestHelmWithDependencies(t *testing.T) {
|
|
fixture.SkipOnEnv(t, "HELM")
|
|
|
|
ctx := Given(t).
|
|
CustomCACertAdded().
|
|
// these are slow tests
|
|
Timeout(30).
|
|
HelmPassCredentials()
|
|
|
|
ctx = ctx.HelmRepoAdded("custom-repo")
|
|
|
|
helmVer := ""
|
|
|
|
ctx.Path("helm-with-dependencies").
|
|
When().
|
|
CreateApp("--helm-version", helmVer).
|
|
Sync().
|
|
Then().
|
|
Expect(SyncStatusIs(SyncStatusCodeSynced))
|
|
}
|
|
|
|
func TestHelmWithMultipleDependencies(t *testing.T) {
|
|
fixture.SkipOnEnv(t, "HELM")
|
|
|
|
Given(t).Path("helm-with-multiple-dependencies").
|
|
CustomCACertAdded().
|
|
// these are slow tests
|
|
Timeout(30).
|
|
HelmHTTPSCredentialsUserPassAdded().
|
|
HelmPassCredentials().
|
|
When().
|
|
CreateApp().
|
|
Sync().
|
|
Then().
|
|
Expect(SyncStatusIs(SyncStatusCodeSynced))
|
|
}
|
|
|
|
func TestHelmDependenciesPermissionDenied(t *testing.T) {
|
|
fixture.SkipOnEnv(t, "HELM")
|
|
|
|
ctx := projectFixture.Given(t)
|
|
ctx.Name("argo-helm-project-denied").
|
|
Destination("*,*").
|
|
When().
|
|
Create().
|
|
AddSource(fixture.RepoURL(fixture.RepoURLTypeFile))
|
|
|
|
expectedErr := fmt.Sprintf("helm repos localhost:5000/myrepo are not permitted in project '%s'", ctx.GetName())
|
|
GivenWithSameState(ctx).
|
|
Project(ctx.GetName()).
|
|
Path("helm-oci-with-dependencies").
|
|
CustomCACertAdded().
|
|
HelmHTTPSCredentialsUserPassAdded().
|
|
HelmPassCredentials().
|
|
When().
|
|
IgnoreErrors().
|
|
CreateApp().
|
|
Then().
|
|
Expect(Error("", expectedErr))
|
|
|
|
expectedErr = fmt.Sprintf("helm repos https://localhost:9443/argo-e2e/testdata.git/helm-repo/local, https://localhost:9443/argo-e2e/testdata.git/helm-repo/local2 are not permitted in project '%s'", ctx.GetName())
|
|
GivenWithSameState(ctx).
|
|
Project(ctx.GetName()).
|
|
Path("helm-with-multiple-dependencies-permission-denied").
|
|
CustomCACertAdded().
|
|
HelmHTTPSCredentialsUserPassAdded().
|
|
HelmPassCredentials().
|
|
When().
|
|
IgnoreErrors().
|
|
CreateApp().
|
|
Then().
|
|
Expect(Error("", expectedErr))
|
|
}
|
|
|
|
func TestHelm3CRD(t *testing.T) {
|
|
fixture.SkipOnEnv(t, "HELM")
|
|
Given(t).
|
|
Path("helm3-crd").
|
|
When().
|
|
CreateApp().
|
|
Sync().
|
|
Then().
|
|
Expect(SyncStatusIs(SyncStatusCodeSynced)).
|
|
Expect(ResourceSyncStatusIs("CustomResourceDefinition", "crontabs.stable.example.com", SyncStatusCodeSynced))
|
|
}
|
|
|
|
func TestHelmOCIRegistry(t *testing.T) {
|
|
Given(t).
|
|
PushChartToOCIRegistry("testdata/helm-values", "helm-values", "1.0.0").
|
|
HelmOCIRepoAdded("myrepo").
|
|
RepoURLType(fixture.RepoURLTypeHelmOCI).
|
|
Chart("helm-values").
|
|
Revision("1.0.0").
|
|
When().
|
|
CreateApp().
|
|
Then().
|
|
When().
|
|
Sync().
|
|
Then().
|
|
Expect(OperationPhaseIs(OperationSucceeded)).
|
|
Expect(HealthIs(health.HealthStatusHealthy)).
|
|
Expect(SyncStatusIs(SyncStatusCodeSynced))
|
|
}
|
|
|
|
func TestGitWithHelmOCIRegistryDependencies(t *testing.T) {
|
|
Given(t).
|
|
PushChartToOCIRegistry("testdata/helm-values", "helm-values", "1.0.0").
|
|
HelmOCIRepoAdded("myrepo").
|
|
Path("helm-oci-with-dependencies").
|
|
When().
|
|
CreateApp().
|
|
Then().
|
|
When().
|
|
Sync().
|
|
Then().
|
|
Expect(OperationPhaseIs(OperationSucceeded)).
|
|
Expect(HealthIs(health.HealthStatusHealthy)).
|
|
Expect(SyncStatusIs(SyncStatusCodeSynced))
|
|
}
|
|
|
|
func TestHelmOCIRegistryWithDependencies(t *testing.T) {
|
|
Given(t).
|
|
PushChartToOCIRegistry("testdata/helm-values", "helm-values", "1.0.0").
|
|
PushChartToOCIRegistry("testdata/helm-oci-with-dependencies", "helm-oci-with-dependencies", "1.0.0").
|
|
HelmOCIRepoAdded("myrepo").
|
|
RepoURLType(fixture.RepoURLTypeHelmOCI).
|
|
Chart("helm-oci-with-dependencies").
|
|
Revision("1.0.0").
|
|
When().
|
|
CreateApp().
|
|
Then().
|
|
When().
|
|
Sync().
|
|
Then().
|
|
Expect(OperationPhaseIs(OperationSucceeded)).
|
|
Expect(HealthIs(health.HealthStatusHealthy)).
|
|
Expect(SyncStatusIs(SyncStatusCodeSynced))
|
|
}
|
|
|
|
func TestTemplatesGitWithHelmOCIDependencies(t *testing.T) {
|
|
Given(t).
|
|
PushChartToOCIRegistry("testdata/helm-values", "helm-values", "1.0.0").
|
|
HelmoOCICredentialsWithoutUserPassAdded().
|
|
Path("helm-oci-with-dependencies").
|
|
When().
|
|
CreateApp().
|
|
Then().
|
|
When().
|
|
Sync().
|
|
Then().
|
|
Expect(OperationPhaseIs(OperationSucceeded)).
|
|
Expect(HealthIs(health.HealthStatusHealthy)).
|
|
Expect(SyncStatusIs(SyncStatusCodeSynced))
|
|
}
|
|
|
|
func TestTemplatesHelmOCIWithDependencies(t *testing.T) {
|
|
Given(t).
|
|
PushChartToOCIRegistry("testdata/helm-values", "helm-values", "1.0.0").
|
|
PushChartToOCIRegistry("testdata/helm-oci-with-dependencies", "helm-oci-with-dependencies", "1.0.0").
|
|
HelmoOCICredentialsWithoutUserPassAdded().
|
|
RepoURLType(fixture.RepoURLTypeHelmOCI).
|
|
Chart("helm-oci-with-dependencies").
|
|
Revision("1.0.0").
|
|
When().
|
|
CreateApp().
|
|
Then().
|
|
When().
|
|
Sync().
|
|
Then().
|
|
Expect(OperationPhaseIs(OperationSucceeded)).
|
|
Expect(HealthIs(health.HealthStatusHealthy)).
|
|
Expect(SyncStatusIs(SyncStatusCodeSynced))
|
|
}
|
|
|
|
func TestHelmOCIRegistryWithConstraintRevision(t *testing.T) {
|
|
Given(t).
|
|
PushChartToOCIRegistry("testdata/helm-values", "helm-values", "1.0.0").
|
|
HelmOCIRepoAdded("myrepo").
|
|
RepoURLType(fixture.RepoURLTypeHelmOCI).
|
|
Chart("helm-values").
|
|
Revision(">=1.0.0").
|
|
When().
|
|
CreateApp().
|
|
Then().
|
|
When().
|
|
Sync().
|
|
Then().
|
|
Expect(OperationPhaseIs(OperationSucceeded)).
|
|
Expect(HealthIs(health.HealthStatusHealthy)).
|
|
Expect(SyncStatusIs(SyncStatusCodeSynced))
|
|
}
|