fix(tiller): add test for failed hooks

pull/1139/head
Matt Butcher 8 years ago
parent 53b01949a8
commit 663f2b0f1d

@ -588,7 +588,7 @@ func (s *releaseServer) execHook(hs []*release.Hook, name, namespace, hook strin
b := bytes.NewBufferString(h.Manifest) b := bytes.NewBufferString(h.Manifest)
if err := kubeCli.Create(namespace, b); err != nil { if err := kubeCli.Create(namespace, b); err != nil {
log.Printf("wrning: Release %q pre-install %s failed: %s", name, h.Path, err) log.Printf("warning: Release %q pre-install %s failed: %s", name, h.Path, err)
return err return err
} }
// No way to rewind a bytes.Buffer()? // No way to rewind a bytes.Buffer()?

@ -17,7 +17,9 @@ limitations under the License.
package main package main
import ( import (
"errors"
"fmt" "fmt"
"io"
"os" "os"
"regexp" "regexp"
"strings" "strings"
@ -431,6 +433,25 @@ func TestInstallReleaseNoHooks(t *testing.T) {
} }
} }
func TestInstallReleaseFailedHooks(t *testing.T) {
c := context.Background()
rs := rsFixture()
rs.env.Releases.Create(releaseStub())
rs.env.KubeClient = newHookFailingKubeClient()
req := &services.InstallReleaseRequest{
Chart: chartStub(),
}
res, err := rs.InstallRelease(c, req)
if err == nil {
t.Error("Expected failed install")
}
if hl := res.Release.Info.Status.Code; hl != release.Status_FAILED {
t.Errorf("Expected FAILED release. Got %d", hl)
}
}
func TestInstallReleaseReuseName(t *testing.T) { func TestInstallReleaseReuseName(t *testing.T) {
c := context.Background() c := context.Background()
rs := rsFixture() rs := rsFixture()
@ -912,6 +933,20 @@ func mockEnvironment() *environment.Environment {
return e return e
} }
func newHookFailingKubeClient() *hookFailingKubeClient {
return &hookFailingKubeClient{
PrintingKubeClient: environment.PrintingKubeClient{Out: os.Stdout},
}
}
type hookFailingKubeClient struct {
environment.PrintingKubeClient
}
func (h *hookFailingKubeClient) WatchUntilReady(ns string, r io.Reader) error {
return errors.New("Failed watch")
}
type mockListServer struct { type mockListServer struct {
val *services.ListReleasesResponse val *services.ListReleasesResponse
} }

Loading…
Cancel
Save