|
|
@ -103,7 +103,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)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -129,7 +130,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})
|
|
|
@ -139,7 +140,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")
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -151,7 +152,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)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -178,7 +180,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)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -197,7 +200,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)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -215,8 +219,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)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -236,7 +241,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)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -267,7 +272,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)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -280,7 +285,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)
|
|
|
@ -298,7 +303,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)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -315,7 +320,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)
|
|
|
@ -332,7 +337,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
|
|
|
@ -348,13 +354,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")
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -369,7 +377,7 @@ func TestInstallRelease_Wait(t *testing.T) {
|
|
|
|
instAction.Wait = true
|
|
|
|
instAction.Wait = 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)
|
|
|
@ -379,15 +387,13 @@ 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
|
|
|
|
|
|
|
|
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()
|
|
|
|
ctx := context.Background()
|
|
|
|
ctx, cancel := context.WithCancel(ctx)
|
|
|
|
ctx, cancel := context.WithCancel(ctx)
|
|
|
|
time.AfterFunc(time.Second, cancel)
|
|
|
|
cancel()
|
|
|
|
//cancel()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
res, err := instAction.RunWithContext(ctx, buildChart(), vals)
|
|
|
|
res, err := instAction.RunWithContext(ctx, buildChart(), vals)
|
|
|
|
is.Error(err)
|
|
|
|
is.Error(err)
|
|
|
@ -405,7 +411,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)
|
|
|
@ -421,9 +427,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")
|
|
|
@ -444,7 +451,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")
|
|
|
@ -457,14 +464,13 @@ 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
|
|
|
|
|
|
|
|
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()
|
|
|
|
ctx := context.Background()
|
|
|
|
ctx, cancel := context.WithCancel(ctx)
|
|
|
|
ctx, cancel := context.WithCancel(ctx)
|
|
|
|
time.AfterFunc(time.Second, cancel)
|
|
|
|
cancel()
|
|
|
|
|
|
|
|
|
|
|
|
res, err := instAction.RunWithContext(ctx, buildChart(), vals)
|
|
|
|
res, err := instAction.RunWithContext(ctx, buildChart(), vals)
|
|
|
|
is.Error(err)
|
|
|
|
is.Error(err)
|
|
|
@ -556,7 +562,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)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -592,7 +598,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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|