|
|
@ -104,7 +104,8 @@ func TestInstallReleaseWithValues(t *testing.T) {
|
|
|
|
"simpleKey": "simpleValue",
|
|
|
|
"simpleKey": "simpleValue",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
res, err := instAction.Run(buildChart(withSampleValues()), userVals)
|
|
|
|
|
|
|
|
|
|
|
|
res, err := instAction.RunWithContext(context.Background(), buildChart(withSampleValues()), userVals)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Failed install: %s", err)
|
|
|
|
t.Fatalf("Failed install: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -130,7 +131,7 @@ func TestInstallReleaseClientOnly(t *testing.T) {
|
|
|
|
is := assert.New(t)
|
|
|
|
is := assert.New(t)
|
|
|
|
instAction := installAction(t)
|
|
|
|
instAction := installAction(t)
|
|
|
|
instAction.ClientOnly = true
|
|
|
|
instAction.ClientOnly = true
|
|
|
|
instAction.Run(buildChart(), nil) // disregard output
|
|
|
|
instAction.RunWithContext(context.Background(), buildChart(), nil) // disregard output
|
|
|
|
|
|
|
|
|
|
|
|
is.Equal(instAction.cfg.Capabilities, chartutil.DefaultCapabilities)
|
|
|
|
is.Equal(instAction.cfg.Capabilities, chartutil.DefaultCapabilities)
|
|
|
|
is.Equal(instAction.cfg.KubeClient, &kubefake.PrintingKubeClient{Out: io.Discard})
|
|
|
|
is.Equal(instAction.cfg.KubeClient, &kubefake.PrintingKubeClient{Out: io.Discard})
|
|
|
@ -140,7 +141,7 @@ func TestInstallRelease_NoName(t *testing.T) {
|
|
|
|
instAction := installAction(t)
|
|
|
|
instAction := installAction(t)
|
|
|
|
instAction.ReleaseName = ""
|
|
|
|
instAction.ReleaseName = ""
|
|
|
|
vals := map[string]interface{}{}
|
|
|
|
vals := map[string]interface{}{}
|
|
|
|
_, err := instAction.Run(buildChart(), vals)
|
|
|
|
_, err := instAction.RunWithContext(context.Background(), buildChart(), vals)
|
|
|
|
if err == nil {
|
|
|
|
if err == nil {
|
|
|
|
t.Fatal("expected failure when no name is specified")
|
|
|
|
t.Fatal("expected failure when no name is specified")
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -152,7 +153,8 @@ func TestInstallRelease_WithNotes(t *testing.T) {
|
|
|
|
instAction := installAction(t)
|
|
|
|
instAction := installAction(t)
|
|
|
|
instAction.ReleaseName = "with-notes"
|
|
|
|
instAction.ReleaseName = "with-notes"
|
|
|
|
vals := map[string]interface{}{}
|
|
|
|
vals := map[string]interface{}{}
|
|
|
|
res, err := instAction.Run(buildChart(withNotes("note here")), vals)
|
|
|
|
|
|
|
|
|
|
|
|
res, err := instAction.RunWithContext(context.Background(), buildChart(withNotes("note here")), vals)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Failed install: %s", err)
|
|
|
|
t.Fatalf("Failed install: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -179,7 +181,8 @@ func TestInstallRelease_WithNotesRendered(t *testing.T) {
|
|
|
|
instAction := installAction(t)
|
|
|
|
instAction := installAction(t)
|
|
|
|
instAction.ReleaseName = "with-notes"
|
|
|
|
instAction.ReleaseName = "with-notes"
|
|
|
|
vals := map[string]interface{}{}
|
|
|
|
vals := map[string]interface{}{}
|
|
|
|
res, err := instAction.Run(buildChart(withNotes("got-{{.Release.Name}}")), vals)
|
|
|
|
|
|
|
|
|
|
|
|
res, err := instAction.RunWithContext(context.Background(), buildChart(withNotes("got-{{.Release.Name}}")), vals)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Failed install: %s", err)
|
|
|
|
t.Fatalf("Failed install: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -198,7 +201,8 @@ func TestInstallRelease_WithChartAndDependencyParentNotes(t *testing.T) {
|
|
|
|
instAction := installAction(t)
|
|
|
|
instAction := installAction(t)
|
|
|
|
instAction.ReleaseName = "with-notes"
|
|
|
|
instAction.ReleaseName = "with-notes"
|
|
|
|
vals := map[string]interface{}{}
|
|
|
|
vals := map[string]interface{}{}
|
|
|
|
res, err := instAction.Run(buildChart(withNotes("parent"), withDependency(withNotes("child"))), vals)
|
|
|
|
|
|
|
|
|
|
|
|
res, err := instAction.RunWithContext(context.Background(), buildChart(withNotes("parent"), withDependency(withNotes("child"))), vals)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Failed install: %s", err)
|
|
|
|
t.Fatalf("Failed install: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -216,8 +220,9 @@ func TestInstallRelease_WithChartAndDependencyAllNotes(t *testing.T) {
|
|
|
|
instAction := installAction(t)
|
|
|
|
instAction := installAction(t)
|
|
|
|
instAction.ReleaseName = "with-notes"
|
|
|
|
instAction.ReleaseName = "with-notes"
|
|
|
|
instAction.SubNotes = true
|
|
|
|
instAction.SubNotes = true
|
|
|
|
|
|
|
|
|
|
|
|
vals := map[string]interface{}{}
|
|
|
|
vals := map[string]interface{}{}
|
|
|
|
res, err := instAction.Run(buildChart(withNotes("parent"), withDependency(withNotes("child"))), vals)
|
|
|
|
res, err := instAction.RunWithContext(context.Background(), buildChart(withNotes("parent"), withDependency(withNotes("child"))), vals)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Failed install: %s", err)
|
|
|
|
t.Fatalf("Failed install: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -237,7 +242,7 @@ func TestInstallRelease_DryRun(t *testing.T) {
|
|
|
|
instAction := installAction(t)
|
|
|
|
instAction := installAction(t)
|
|
|
|
instAction.DryRun = true
|
|
|
|
instAction.DryRun = true
|
|
|
|
vals := map[string]interface{}{}
|
|
|
|
vals := map[string]interface{}{}
|
|
|
|
res, err := instAction.Run(buildChart(withSampleTemplates()), vals)
|
|
|
|
res, err := instAction.RunWithContext(context.Background(), buildChart(withSampleTemplates()), vals)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Failed install: %s", err)
|
|
|
|
t.Fatalf("Failed install: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -268,7 +273,7 @@ func TestInstallRelease_DryRun_Lookup(t *testing.T) {
|
|
|
|
Data: []byte(`goodbye: {{ lookup "v1" "Namespace" "" "___" }}`),
|
|
|
|
Data: []byte(`goodbye: {{ lookup "v1" "Namespace" "" "___" }}`),
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
res, err := instAction.Run(mockChart, vals)
|
|
|
|
res, err := instAction.RunWithContext(context.Background(), mockChart, vals)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Failed install: %s", err)
|
|
|
|
t.Fatalf("Failed install: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -281,7 +286,7 @@ func TestInstallReleaseIncorrectTemplate_DryRun(t *testing.T) {
|
|
|
|
instAction := installAction(t)
|
|
|
|
instAction := installAction(t)
|
|
|
|
instAction.DryRun = true
|
|
|
|
instAction.DryRun = true
|
|
|
|
vals := map[string]interface{}{}
|
|
|
|
vals := map[string]interface{}{}
|
|
|
|
_, err := instAction.Run(buildChart(withSampleIncludingIncorrectTemplates()), vals)
|
|
|
|
_, err := instAction.RunWithContext(context.Background(), buildChart(withSampleIncludingIncorrectTemplates()), vals)
|
|
|
|
expectedErr := "\"hello/templates/incorrect\" at <.Values.bad.doh>: nil pointer evaluating interface {}.doh"
|
|
|
|
expectedErr := "\"hello/templates/incorrect\" at <.Values.bad.doh>: nil pointer evaluating interface {}.doh"
|
|
|
|
if err == nil {
|
|
|
|
if err == nil {
|
|
|
|
t.Fatalf("Install should fail containing error: %s", expectedErr)
|
|
|
|
t.Fatalf("Install should fail containing error: %s", expectedErr)
|
|
|
@ -299,7 +304,7 @@ func TestInstallRelease_NoHooks(t *testing.T) {
|
|
|
|
instAction.cfg.Releases.Create(releaseStub())
|
|
|
|
instAction.cfg.Releases.Create(releaseStub())
|
|
|
|
|
|
|
|
|
|
|
|
vals := map[string]interface{}{}
|
|
|
|
vals := map[string]interface{}{}
|
|
|
|
res, err := instAction.Run(buildChart(), vals)
|
|
|
|
res, err := instAction.RunWithContext(context.Background(), buildChart(), vals)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Failed install: %s", err)
|
|
|
|
t.Fatalf("Failed install: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -316,7 +321,7 @@ func TestInstallRelease_FailedHooks(t *testing.T) {
|
|
|
|
instAction.cfg.KubeClient = failer
|
|
|
|
instAction.cfg.KubeClient = failer
|
|
|
|
|
|
|
|
|
|
|
|
vals := map[string]interface{}{}
|
|
|
|
vals := map[string]interface{}{}
|
|
|
|
res, err := instAction.Run(buildChart(), vals)
|
|
|
|
res, err := instAction.RunWithContext(context.Background(), buildChart(), vals)
|
|
|
|
is.Error(err)
|
|
|
|
is.Error(err)
|
|
|
|
is.Contains(res.Info.Description, "failed post-install")
|
|
|
|
is.Contains(res.Info.Description, "failed post-install")
|
|
|
|
is.Equal(release.StatusFailed, res.Info.Status)
|
|
|
|
is.Equal(release.StatusFailed, res.Info.Status)
|
|
|
@ -333,7 +338,8 @@ func TestInstallRelease_ReplaceRelease(t *testing.T) {
|
|
|
|
instAction.ReleaseName = rel.Name
|
|
|
|
instAction.ReleaseName = rel.Name
|
|
|
|
|
|
|
|
|
|
|
|
vals := map[string]interface{}{}
|
|
|
|
vals := map[string]interface{}{}
|
|
|
|
res, err := instAction.Run(buildChart(), vals)
|
|
|
|
|
|
|
|
|
|
|
|
res, err := instAction.RunWithContext(context.Background(), buildChart(), vals)
|
|
|
|
is.NoError(err)
|
|
|
|
is.NoError(err)
|
|
|
|
|
|
|
|
|
|
|
|
// This should have been auto-incremented
|
|
|
|
// This should have been auto-incremented
|
|
|
@ -349,13 +355,15 @@ func TestInstallRelease_KubeVersion(t *testing.T) {
|
|
|
|
is := assert.New(t)
|
|
|
|
is := assert.New(t)
|
|
|
|
instAction := installAction(t)
|
|
|
|
instAction := installAction(t)
|
|
|
|
vals := map[string]interface{}{}
|
|
|
|
vals := map[string]interface{}{}
|
|
|
|
_, err := instAction.Run(buildChart(withKube(">=0.0.0")), vals)
|
|
|
|
|
|
|
|
|
|
|
|
_, err := instAction.RunWithContext(context.Background(), buildChart(withKube(">=0.0.0")), vals)
|
|
|
|
is.NoError(err)
|
|
|
|
is.NoError(err)
|
|
|
|
|
|
|
|
|
|
|
|
// This should fail for a few hundred years
|
|
|
|
// This should fail for a few hundred years
|
|
|
|
instAction.ReleaseName = "should-fail"
|
|
|
|
instAction.ReleaseName = "should-fail"
|
|
|
|
vals = map[string]interface{}{}
|
|
|
|
vals = map[string]interface{}{}
|
|
|
|
_, err = instAction.Run(buildChart(withKube(">=99.0.0")), vals)
|
|
|
|
|
|
|
|
|
|
|
|
_, err = instAction.RunWithContext(context.Background(), buildChart(withKube(">=99.0.0")), vals)
|
|
|
|
is.Error(err)
|
|
|
|
is.Error(err)
|
|
|
|
is.Contains(err.Error(), "chart requires kubeVersion")
|
|
|
|
is.Contains(err.Error(), "chart requires kubeVersion")
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -372,7 +380,7 @@ func TestInstallRelease_Wait(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
|
|
goroutines := runtime.NumGoroutine()
|
|
|
|
goroutines := runtime.NumGoroutine()
|
|
|
|
|
|
|
|
|
|
|
|
res, err := instAction.Run(buildChart(), vals)
|
|
|
|
res, err := instAction.RunWithContext(context.Background(), buildChart(), vals)
|
|
|
|
is.Error(err)
|
|
|
|
is.Error(err)
|
|
|
|
is.Contains(res.Info.Description, "I timed out")
|
|
|
|
is.Contains(res.Info.Description, "I timed out")
|
|
|
|
is.Equal(res.Info.Status, release.StatusFailed)
|
|
|
|
is.Equal(res.Info.Status, release.StatusFailed)
|
|
|
@ -384,25 +392,15 @@ func TestInstallRelease_Wait_Interrupted(t *testing.T) {
|
|
|
|
instAction := installAction(t)
|
|
|
|
instAction := installAction(t)
|
|
|
|
instAction.ReleaseName = "interrupted-release"
|
|
|
|
instAction.ReleaseName = "interrupted-release"
|
|
|
|
failer := instAction.cfg.KubeClient.(*kubefake.FailingKubeClient)
|
|
|
|
failer := instAction.cfg.KubeClient.(*kubefake.FailingKubeClient)
|
|
|
|
failer.WaitDuration = 10 * time.Second
|
|
|
|
failer.WaitError = context.Canceled
|
|
|
|
instAction.cfg.KubeClient = failer
|
|
|
|
instAction.cfg.KubeClient = failer
|
|
|
|
instAction.Wait = true
|
|
|
|
instAction.Wait = true
|
|
|
|
vals := map[string]interface{}{}
|
|
|
|
vals := map[string]interface{}{}
|
|
|
|
|
|
|
|
|
|
|
|
ctx := context.Background()
|
|
|
|
res, err := instAction.RunWithContext(context.Background(), buildChart(), vals)
|
|
|
|
ctx, cancel := context.WithCancel(ctx)
|
|
|
|
|
|
|
|
time.AfterFunc(time.Second, cancel)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
goroutines := runtime.NumGoroutine()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
res, err := instAction.RunWithContext(ctx, buildChart(), vals)
|
|
|
|
|
|
|
|
is.Error(err)
|
|
|
|
is.Error(err)
|
|
|
|
is.Contains(res.Info.Description, "Release \"interrupted-release\" failed: context canceled")
|
|
|
|
is.Contains(res.Info.Description, "Release \"interrupted-release\" failed: context canceled")
|
|
|
|
is.Equal(res.Info.Status, release.StatusFailed)
|
|
|
|
is.Equal(res.Info.Status, release.StatusFailed)
|
|
|
|
|
|
|
|
|
|
|
|
is.Equal(goroutines+1, runtime.NumGoroutine()) // installation goroutine still is in background
|
|
|
|
|
|
|
|
time.Sleep(10 * time.Second) // wait for goroutine to finish
|
|
|
|
|
|
|
|
is.Equal(goroutines, runtime.NumGoroutine())
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func TestInstallRelease_WaitForJobs(t *testing.T) {
|
|
|
|
func TestInstallRelease_WaitForJobs(t *testing.T) {
|
|
|
|
is := assert.New(t)
|
|
|
|
is := assert.New(t)
|
|
|
@ -415,7 +413,7 @@ func TestInstallRelease_WaitForJobs(t *testing.T) {
|
|
|
|
instAction.WaitForJobs = true
|
|
|
|
instAction.WaitForJobs = true
|
|
|
|
vals := map[string]interface{}{}
|
|
|
|
vals := map[string]interface{}{}
|
|
|
|
|
|
|
|
|
|
|
|
res, err := instAction.Run(buildChart(), vals)
|
|
|
|
res, err := instAction.RunWithContext(context.Background(), buildChart(), vals)
|
|
|
|
is.Error(err)
|
|
|
|
is.Error(err)
|
|
|
|
is.Contains(res.Info.Description, "I timed out")
|
|
|
|
is.Contains(res.Info.Description, "I timed out")
|
|
|
|
is.Equal(res.Info.Status, release.StatusFailed)
|
|
|
|
is.Equal(res.Info.Status, release.StatusFailed)
|
|
|
@ -431,9 +429,10 @@ func TestInstallRelease_Atomic(t *testing.T) {
|
|
|
|
failer.WaitError = fmt.Errorf("I timed out")
|
|
|
|
failer.WaitError = fmt.Errorf("I timed out")
|
|
|
|
instAction.cfg.KubeClient = failer
|
|
|
|
instAction.cfg.KubeClient = failer
|
|
|
|
instAction.Atomic = true
|
|
|
|
instAction.Atomic = true
|
|
|
|
|
|
|
|
|
|
|
|
vals := map[string]interface{}{}
|
|
|
|
vals := map[string]interface{}{}
|
|
|
|
|
|
|
|
|
|
|
|
res, err := instAction.Run(buildChart(), vals)
|
|
|
|
res, err := instAction.RunWithContext(context.Background(), buildChart(), vals)
|
|
|
|
is.Error(err)
|
|
|
|
is.Error(err)
|
|
|
|
is.Contains(err.Error(), "I timed out")
|
|
|
|
is.Contains(err.Error(), "I timed out")
|
|
|
|
is.Contains(err.Error(), "atomic")
|
|
|
|
is.Contains(err.Error(), "atomic")
|
|
|
@ -454,7 +453,7 @@ func TestInstallRelease_Atomic(t *testing.T) {
|
|
|
|
instAction.Atomic = true
|
|
|
|
instAction.Atomic = true
|
|
|
|
vals := map[string]interface{}{}
|
|
|
|
vals := map[string]interface{}{}
|
|
|
|
|
|
|
|
|
|
|
|
_, err := instAction.Run(buildChart(), vals)
|
|
|
|
_, err := instAction.RunWithContext(context.Background(), buildChart(), vals)
|
|
|
|
is.Error(err)
|
|
|
|
is.Error(err)
|
|
|
|
is.Contains(err.Error(), "I timed out")
|
|
|
|
is.Contains(err.Error(), "I timed out")
|
|
|
|
is.Contains(err.Error(), "uninstall fail")
|
|
|
|
is.Contains(err.Error(), "uninstall fail")
|
|
|
@ -467,16 +466,12 @@ func TestInstallRelease_Atomic_Interrupted(t *testing.T) {
|
|
|
|
instAction := installAction(t)
|
|
|
|
instAction := installAction(t)
|
|
|
|
instAction.ReleaseName = "interrupted-release"
|
|
|
|
instAction.ReleaseName = "interrupted-release"
|
|
|
|
failer := instAction.cfg.KubeClient.(*kubefake.FailingKubeClient)
|
|
|
|
failer := instAction.cfg.KubeClient.(*kubefake.FailingKubeClient)
|
|
|
|
failer.WaitDuration = 10 * time.Second
|
|
|
|
failer.WaitError = context.Canceled
|
|
|
|
instAction.cfg.KubeClient = failer
|
|
|
|
instAction.cfg.KubeClient = failer
|
|
|
|
instAction.Atomic = true
|
|
|
|
instAction.Atomic = true
|
|
|
|
vals := map[string]interface{}{}
|
|
|
|
vals := map[string]interface{}{}
|
|
|
|
|
|
|
|
|
|
|
|
ctx := context.Background()
|
|
|
|
res, err := instAction.RunWithContext(context.Background(), buildChart(), vals)
|
|
|
|
ctx, cancel := context.WithCancel(ctx)
|
|
|
|
|
|
|
|
time.AfterFunc(time.Second, cancel)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
res, err := instAction.RunWithContext(ctx, buildChart(), vals)
|
|
|
|
|
|
|
|
is.Error(err)
|
|
|
|
is.Error(err)
|
|
|
|
is.Contains(err.Error(), "context canceled")
|
|
|
|
is.Contains(err.Error(), "context canceled")
|
|
|
|
is.Contains(err.Error(), "atomic")
|
|
|
|
is.Contains(err.Error(), "atomic")
|
|
|
@ -566,7 +561,7 @@ func TestInstallReleaseOutputDir(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
|
|
instAction.OutputDir = dir
|
|
|
|
instAction.OutputDir = dir
|
|
|
|
|
|
|
|
|
|
|
|
_, err := instAction.Run(buildChart(withSampleTemplates(), withMultipleManifestTemplate()), vals)
|
|
|
|
_, err := instAction.RunWithContext(context.Background(), buildChart(withSampleTemplates(), withMultipleManifestTemplate()), vals)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Failed install: %s", err)
|
|
|
|
t.Fatalf("Failed install: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -602,7 +597,7 @@ func TestInstallOutputDirWithReleaseName(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
|
|
newDir := filepath.Join(dir, instAction.ReleaseName)
|
|
|
|
newDir := filepath.Join(dir, instAction.ReleaseName)
|
|
|
|
|
|
|
|
|
|
|
|
_, err := instAction.Run(buildChart(withSampleTemplates(), withMultipleManifestTemplate()), vals)
|
|
|
|
_, err := instAction.RunWithContext(context.Background(), buildChart(withSampleTemplates(), withMultipleManifestTemplate()), vals)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Failed install: %s", err)
|
|
|
|
t.Fatalf("Failed install: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|