|
|
@ -44,6 +44,16 @@ data:
|
|
|
|
name: value
|
|
|
|
name: value
|
|
|
|
`
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var manifestWithUpgradeHooks = `apiVersion: v1
|
|
|
|
|
|
|
|
kind: ConfigMap
|
|
|
|
|
|
|
|
metadata:
|
|
|
|
|
|
|
|
name: test-cm
|
|
|
|
|
|
|
|
annotations:
|
|
|
|
|
|
|
|
"helm.sh/hook": post-upgrade,pre-upgrade
|
|
|
|
|
|
|
|
data:
|
|
|
|
|
|
|
|
name: value
|
|
|
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
|
|
func rsFixture() *releaseServer {
|
|
|
|
func rsFixture() *releaseServer {
|
|
|
|
return &releaseServer{
|
|
|
|
return &releaseServer{
|
|
|
|
env: mockEnvironment(),
|
|
|
|
env: mockEnvironment(),
|
|
|
@ -302,6 +312,7 @@ func TestUpdateRelease(t *testing.T) {
|
|
|
|
Metadata: &chart.Metadata{Name: "hello"},
|
|
|
|
Metadata: &chart.Metadata{Name: "hello"},
|
|
|
|
Templates: []*chart.Template{
|
|
|
|
Templates: []*chart.Template{
|
|
|
|
{Name: "hello", Data: []byte("hello: world")},
|
|
|
|
{Name: "hello", Data: []byte("hello: world")},
|
|
|
|
|
|
|
|
{Name: "hooks", Data: []byte(manifestWithUpgradeHooks)},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -309,6 +320,7 @@ func TestUpdateRelease(t *testing.T) {
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("Failed updated: %s", err)
|
|
|
|
t.Errorf("Failed updated: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if res.Release.Name == "" {
|
|
|
|
if res.Release.Name == "" {
|
|
|
|
t.Errorf("Expected release name.")
|
|
|
|
t.Errorf("Expected release name.")
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -326,6 +338,21 @@ func TestUpdateRelease(t *testing.T) {
|
|
|
|
t.Errorf("Expected release for %s (%v).", res.Release.Name, rs.env.Releases)
|
|
|
|
t.Errorf("Expected release for %s (%v).", res.Release.Name, rs.env.Releases)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(updated.Hooks) != 1 {
|
|
|
|
|
|
|
|
t.Fatalf("Expected 1 hook, got %d", len(updated.Hooks))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if updated.Hooks[0].Manifest != manifestWithUpgradeHooks {
|
|
|
|
|
|
|
|
t.Errorf("Unexpected manifest: %v", updated.Hooks[0].Manifest)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if updated.Hooks[0].Events[0] != release.Hook_POST_UPGRADE {
|
|
|
|
|
|
|
|
t.Errorf("Expected event 0 to be post upgrade")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if updated.Hooks[0].Events[1] != release.Hook_PRE_UPGRADE {
|
|
|
|
|
|
|
|
t.Errorf("Expected event 0 to be pre upgrade")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if len(res.Release.Manifest) == 0 {
|
|
|
|
if len(res.Release.Manifest) == 0 {
|
|
|
|
t.Errorf("No manifest returned: %v", res.Release)
|
|
|
|
t.Errorf("No manifest returned: %v", res.Release)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -343,6 +370,35 @@ func TestUpdateRelease(t *testing.T) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func TestUpdateReleaseNoHooks(t *testing.T) {
|
|
|
|
|
|
|
|
c := context.Background()
|
|
|
|
|
|
|
|
rs := rsFixture()
|
|
|
|
|
|
|
|
rel := releaseStub()
|
|
|
|
|
|
|
|
rs.env.Releases.Create(rel)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
req := &services.UpdateReleaseRequest{
|
|
|
|
|
|
|
|
Name: rel.Name,
|
|
|
|
|
|
|
|
DisableHooks: true,
|
|
|
|
|
|
|
|
Chart: &chart.Chart{
|
|
|
|
|
|
|
|
Metadata: &chart.Metadata{Name: "hello"},
|
|
|
|
|
|
|
|
Templates: []*chart.Template{
|
|
|
|
|
|
|
|
{Name: "hello", Data: []byte("hello: world")},
|
|
|
|
|
|
|
|
{Name: "hooks", Data: []byte(manifestWithUpgradeHooks)},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
res, err := rs.UpdateRelease(c, req)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
t.Errorf("Failed updated: %s", err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if hl := res.Release.Hooks[0].LastRun; hl != nil {
|
|
|
|
|
|
|
|
t.Errorf("Expected that no hooks were run. Got %d", hl)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestUninstallRelease(t *testing.T) {
|
|
|
|
func TestUninstallRelease(t *testing.T) {
|
|
|
|
c := context.Background()
|
|
|
|
c := context.Background()
|
|
|
|
rs := rsFixture()
|
|
|
|
rs := rsFixture()
|
|
|
|