ref(pkg/releasetesting): simplify test setup

pull/3945/head
Adam Reese 7 years ago
parent c5151fb7b3
commit 1e2e65ce54
No known key found for this signature in database
GPG Key ID: 06F35E60A7A18DD6

@ -17,81 +17,50 @@ limitations under the License.
package releasetesting
import (
"bytes"
"errors"
"io"
"io/ioutil"
"testing"
"k8s.io/helm/pkg/hapi"
"k8s.io/helm/pkg/hapi/release"
tillerEnv "k8s.io/helm/pkg/tiller/environment"
)
func TestCreateTestPodSuccess(t *testing.T) {
env := testEnvFixture()
test := testFixture()
err := env.createTestPod(test)
if err != nil {
if err := env.createTestPod(test); err != nil {
t.Errorf("Expected no error, got an error: %s", err)
}
}
func TestCreateTestPodFailure(t *testing.T) {
env := testEnvFixture()
env.KubeClient = newCreateFailingKubeClient()
env.KubeClient = &mockKubeClient{
err: errors.New("We ran out of budget and couldn't create finding-nemo"),
}
test := testFixture()
err := env.createTestPod(test)
if err == nil {
if err := env.createTestPod(test); err == nil {
t.Errorf("Expected error, got no error")
}
if test.result.Info == "" {
t.Errorf("Expected error to be saved in test result info but found empty string")
}
if test.result.Status != release.TestRun_FAILURE {
t.Errorf("Expected test result status to be failure but got: %v", test.result.Status)
}
}
func TestDeleteTestPods(t *testing.T) {
mockTestSuite := testSuiteFixture([]string{manifestWithTestSuccessHook})
mockTestEnv := newMockTestingEnvironment()
mockTestEnv.KubeClient = newGetFailingKubeClient()
mockTestEnv.DeleteTestPods(mockTestSuite.TestManifests)
for _, testManifest := range mockTestSuite.TestManifests {
if _, err := mockTestEnv.KubeClient.Get(mockTestEnv.Namespace, bytes.NewBufferString(testManifest)); err == nil {
t.Error("Expected error, got nil")
}
}
}
func TestStreamMessage(t *testing.T) {
tEnv := mockTillerEnvironment()
ch := make(chan *hapi.TestReleaseResponse, 1)
defer close(ch)
mockTestEnv := &Environment{
Namespace: "default",
KubeClient: tEnv.KubeClient,
Timeout: 1,
Mesages: ch,
}
env := testEnvFixture()
defer close(env.Mesages)
expectedMessage := "testing streamMessage"
expectedStatus := release.TestRun_SUCCESS
err := mockTestEnv.streamMessage(expectedMessage, expectedStatus)
if err != nil {
if err := env.streamMessage(expectedMessage, expectedStatus); err != nil {
t.Errorf("Expected no errors, got: %s", err)
}
got := <-mockTestEnv.Mesages
got := <-env.Mesages
if got.Msg != expectedMessage {
t.Errorf("Expected message: %s, got: %s", expectedMessage, got.Msg)
}
@ -99,39 +68,3 @@ func TestStreamMessage(t *testing.T) {
t.Errorf("Expected status: %v, got: %v", expectedStatus, got.Status)
}
}
func newMockTestingEnvironment() *Environment {
return &Environment{
Namespace: "default",
KubeClient: mockTillerEnvironment().KubeClient,
Timeout: 1,
}
}
type getFailingKubeClient struct {
tillerEnv.PrintingKubeClient
}
func newGetFailingKubeClient() *getFailingKubeClient {
return &getFailingKubeClient{
PrintingKubeClient: tillerEnv.PrintingKubeClient{Out: ioutil.Discard},
}
}
func (p *getFailingKubeClient) Get(ns string, r io.Reader) (string, error) {
return "", errors.New("in the end, they did not find Nemo")
}
type createFailingKubeClient struct {
tillerEnv.PrintingKubeClient
}
func newCreateFailingKubeClient() *createFailingKubeClient {
return &createFailingKubeClient{
PrintingKubeClient: tillerEnv.PrintingKubeClient{Out: ioutil.Discard},
}
}
func (p *createFailingKubeClient) Create(ns string, r io.Reader, t int64, shouldWait bool) error {
return errors.New("We ran out of budget and couldn't create finding-nemo")
}

@ -18,18 +18,14 @@ package releasetesting
import (
"io"
"io/ioutil"
"testing"
"time"
"k8s.io/kubernetes/pkg/apis/core"
"k8s.io/helm/pkg/hapi"
"k8s.io/helm/pkg/hapi/chart"
"k8s.io/helm/pkg/hapi/release"
"k8s.io/helm/pkg/storage"
"k8s.io/helm/pkg/storage/driver"
tillerEnv "k8s.io/helm/pkg/tiller/environment"
"k8s.io/helm/pkg/tiller/environment"
)
const manifestWithTestSuccessHook = `
@ -70,22 +66,22 @@ data:
`
func TestRun(t *testing.T) {
testManifests := []string{manifestWithTestSuccessHook, manifestWithTestFailureHook}
ts := testSuiteFixture(testManifests)
ch := make(chan *hapi.TestReleaseResponse, 1)
env := testEnvFixture()
env.Mesages = ch
go func() {
defer close(ch)
defer close(env.Mesages)
if err := ts.Run(env); err != nil {
t.Error(err)
}
}()
for range ch { // drain
for i := 0; i <= 4; i++ {
<-env.Mesages
}
if _, ok := <-env.Mesages; ok {
t.Errorf("Expected 4 messages streamed")
}
if ts.StartedAt.IsZero() {
@ -128,19 +124,16 @@ func TestRun(t *testing.T) {
func TestRunEmptyTestSuite(t *testing.T) {
ts := testSuiteFixture([]string{})
ch := make(chan *hapi.TestReleaseResponse, 1)
env := testEnvFixture()
env.Mesages = ch
go func() {
defer close(ch)
defer close(env.Mesages)
if err := ts.Run(env); err != nil {
t.Error(err)
}
}()
msg := <-ch
msg := <-env.Mesages
if msg.Msg != "No Tests Found" {
t.Errorf("Expected message 'No Tests Found', Got: %v", msg.Msg)
}
@ -157,30 +150,29 @@ func TestRunEmptyTestSuite(t *testing.T) {
func TestRunSuccessWithTestFailureHook(t *testing.T) {
ts := testSuiteFixture([]string{manifestWithTestFailureHook})
ch := make(chan *hapi.TestReleaseResponse, 1)
env := testEnvFixture()
env.KubeClient = newPodFailedKubeClient()
env.Mesages = ch
env.KubeClient = &mockKubeClient{podFail: true}
go func() {
defer close(ch)
defer close(env.Mesages)
if err := ts.Run(env); err != nil {
t.Error(err)
}
}()
for range ch { // drain
for i := 0; i <= 4; i++ {
<-env.Mesages
}
if _, ok := <-env.Mesages; ok {
t.Errorf("Expected 4 messages streamed")
}
if ts.StartedAt.IsZero() {
t.Errorf("Expected StartedAt to not be nil. Got: %v", ts.StartedAt)
}
if ts.CompletedAt.IsZero() {
t.Errorf("Expected CompletedAt to not be nil. Got: %v", ts.CompletedAt)
}
if len(ts.Results) != 1 {
t.Errorf("Expected 1 test result. Got %v", len(ts.Results))
}
@ -189,75 +181,38 @@ func TestRunSuccessWithTestFailureHook(t *testing.T) {
if result.StartedAt.IsZero() {
t.Errorf("Expected test StartedAt to not be nil. Got: %v", result.StartedAt)
}
if result.CompletedAt.IsZero() {
t.Errorf("Expected test CompletedAt to not be nil. Got: %v", result.CompletedAt)
}
if result.Name != "gold-rush" {
t.Errorf("Expected test name to be gold-rush, Got: %v", result.Name)
}
if result.Status != release.TestRun_SUCCESS {
t.Errorf("Expected test result to be successful, got: %v", result.Status)
}
}
func TestExtractTestManifestsFromHooks(t *testing.T) {
rel := releaseStub()
testManifests := extractTestManifestsFromHooks(rel.Hooks)
testManifests := extractTestManifestsFromHooks(hooksStub)
if len(testManifests) != 1 {
t.Errorf("Expected 1 test manifest, Got: %v", len(testManifests))
}
}
func chartStub() *chart.Chart {
return &chart.Chart{
Metadata: &chart.Metadata{
Name: "nemo",
},
Templates: []*chart.File{
{Name: "templates/hello", Data: []byte("hello: world")},
{Name: "templates/hooks", Data: []byte(manifestWithTestSuccessHook)},
},
}
}
func releaseStub() *release.Release {
return &release.Release{
Name: "lost-fish",
Info: &release.Info{
FirstDeployed: time.Now(),
LastDeployed: time.Now(),
Status: &release.Status{Code: release.Status_DEPLOYED},
Description: "a release stub",
var hooksStub = []*release.Hook{
{
Manifest: manifestWithTestSuccessHook,
Events: []release.HookEvent{
release.Hook_RELEASE_TEST_SUCCESS,
},
Chart: chartStub(),
Config: &chart.Config{Raw: `name: value`},
Version: 1,
Hooks: []*release.Hook{
{
Name: "finding-nemo",
Kind: "Pod",
Path: "finding-nemo",
Manifest: manifestWithTestSuccessHook,
Events: []release.HookEvent{
release.Hook_RELEASE_TEST_SUCCESS,
},
},
{
Name: "test-cm",
Kind: "ConfigMap",
Path: "test-cm",
Manifest: manifestWithInstallHooks,
Events: []release.HookEvent{
release.Hook_POST_INSTALL,
release.Hook_PRE_DELETE,
},
},
},
{
Manifest: manifestWithInstallHooks,
Events: []release.HookEvent{
release.Hook_POST_INSTALL,
},
}
},
}
func testFixture() *test {
@ -273,49 +228,36 @@ func testSuiteFixture(testManifests []string) *TestSuite {
TestManifests: testManifests,
Results: testResults,
}
return ts
}
func testEnvFixture() *Environment {
return &Environment{
Namespace: "default",
KubeClient: mockTillerEnvironment().KubeClient,
KubeClient: &mockKubeClient{},
Timeout: 1,
Mesages: make(chan *hapi.TestReleaseResponse, 1),
}
}
func mockTillerEnvironment() *tillerEnv.Environment {
e := tillerEnv.New()
e.Releases = storage.Init(driver.NewMemory())
e.KubeClient = newPodSucceededKubeClient()
return e
}
type podSucceededKubeClient struct {
tillerEnv.PrintingKubeClient
type mockKubeClient struct {
environment.KubeClient
podFail bool
err error
}
func newPodSucceededKubeClient() *podSucceededKubeClient {
return &podSucceededKubeClient{
PrintingKubeClient: tillerEnv.PrintingKubeClient{Out: ioutil.Discard},
func (c *mockKubeClient) WaitAndGetCompletedPodPhase(_ string, _ io.Reader, _ time.Duration) (core.PodPhase, error) {
if c.podFail {
return core.PodFailed, nil
}
}
func (p *podSucceededKubeClient) WaitAndGetCompletedPodPhase(ns string, r io.Reader, timeout time.Duration) (core.PodPhase, error) {
return core.PodSucceeded, nil
}
type podFailedKubeClient struct {
tillerEnv.PrintingKubeClient
func (c *mockKubeClient) Get(_ string, _ io.Reader) (string, error) {
return "", nil
}
func newPodFailedKubeClient() *podFailedKubeClient {
return &podFailedKubeClient{
PrintingKubeClient: tillerEnv.PrintingKubeClient{Out: ioutil.Discard},
}
func (c *mockKubeClient) Create(_ string, _ io.Reader, _ int64, _ bool) error {
return c.err
}
func (p *podFailedKubeClient) WaitAndGetCompletedPodPhase(ns string, r io.Reader, timeout time.Duration) (core.PodPhase, error) {
return core.PodFailed, nil
func (c *mockKubeClient) Delete(_ string, _ io.Reader) error {
return nil
}

@ -36,8 +36,6 @@ import (
"k8s.io/helm/pkg/hapi/release"
"k8s.io/helm/pkg/hooks"
"k8s.io/helm/pkg/kube"
"k8s.io/helm/pkg/storage"
"k8s.io/helm/pkg/storage/driver"
"k8s.io/helm/pkg/tiller/environment"
)
@ -379,7 +377,6 @@ func releaseWithKeepStub(rlsName string) *release.Release {
func MockEnvironment() *environment.Environment {
e := environment.New()
e.Releases = storage.Init(driver.NewMemory())
e.KubeClient = &environment.PrintingKubeClient{Out: ioutil.Discard}
return e
}
@ -432,8 +429,7 @@ func (kc *mockHooksKubeClient) makeManifest(r io.Reader) (*mockHooksManifest, er
}
manifest := &mockHooksManifest{}
err = yaml.Unmarshal(b, manifest)
if err != nil {
if err = yaml.Unmarshal(b, manifest); err != nil {
return nil, err
}
@ -498,7 +494,6 @@ func (kc *mockHooksKubeClient) WaitAndGetCompletedPodPhase(namespace string, rea
func deletePolicyStub(kubeClient *mockHooksKubeClient) *ReleaseServer {
e := environment.New()
e.Releases = storage.Init(driver.NewMemory())
e.KubeClient = kubeClient
dc := fake.NewSimpleClientset().Discovery()
@ -535,24 +530,21 @@ name: value`, hookName, extraAnnotationsStr),
}
func execHookShouldSucceed(rs *ReleaseServer, hook *release.Hook, releaseName string, namespace string, hookType string) error {
err := rs.execHook([]*release.Hook{hook}, releaseName, namespace, hookType, 600)
if err != nil {
if err := rs.execHook([]*release.Hook{hook}, releaseName, namespace, hookType, 600); err != nil {
return fmt.Errorf("expected hook %s to be successful: %s", hook.Name, err)
}
return nil
}
func execHookShouldFail(rs *ReleaseServer, hook *release.Hook, releaseName string, namespace string, hookType string) error {
err := rs.execHook([]*release.Hook{hook}, releaseName, namespace, hookType, 600)
if err == nil {
if err := rs.execHook([]*release.Hook{hook}, releaseName, namespace, hookType, 600); err == nil {
return fmt.Errorf("expected hook %s to be failed", hook.Name)
}
return nil
}
func execHookShouldFailWithError(rs *ReleaseServer, hook *release.Hook, releaseName string, namespace string, hookType string, expectedError error) error {
err := rs.execHook([]*release.Hook{hook}, releaseName, namespace, hookType, 600)
if err != expectedError {
if err := rs.execHook([]*release.Hook{hook}, releaseName, namespace, hookType, 600); err != expectedError {
return fmt.Errorf("expected hook %s to fail with error %v, got %v", hook.Name, expectedError, err)
}
return nil
@ -584,8 +576,7 @@ func TestSuccessfulHookWithoutDeletePolicy(t *testing.T) {
ctx := newDeletePolicyContext()
hook := deletePolicyHookStub(ctx.HookName, nil, nil)
err := execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall)
if err != nil {
if err := execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall); err != nil {
t.Error(err)
}
if _, hasResource := ctx.KubeClient.Resources[hook.Name]; !hasResource {
@ -600,8 +591,7 @@ func TestFailedHookWithoutDeletePolicy(t *testing.T) {
nil,
)
err := execHookShouldFail(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall)
if err != nil {
if err := execHookShouldFail(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall); err != nil {
t.Error(err)
}
if _, hasResource := ctx.KubeClient.Resources[hook.Name]; !hasResource {
@ -616,8 +606,7 @@ func TestSuccessfulHookWithSucceededDeletePolicy(t *testing.T) {
[]release.HookDeletePolicy{release.Hook_SUCCEEDED},
)
err := execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall)
if err != nil {
if err := execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall); err != nil {
t.Error(err)
}
if _, hasResource := ctx.KubeClient.Resources[hook.Name]; hasResource {
@ -632,8 +621,7 @@ func TestSuccessfulHookWithFailedDeletePolicy(t *testing.T) {
[]release.HookDeletePolicy{release.Hook_FAILED},
)
err := execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall)
if err != nil {
if err := execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall); err != nil {
t.Error(err)
}
if _, hasResource := ctx.KubeClient.Resources[hook.Name]; !hasResource {
@ -652,8 +640,7 @@ func TestFailedHookWithSucceededDeletePolicy(t *testing.T) {
[]release.HookDeletePolicy{release.Hook_SUCCEEDED},
)
err := execHookShouldFail(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall)
if err != nil {
if err := execHookShouldFail(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall); err != nil {
t.Error(err)
}
if _, hasResource := ctx.KubeClient.Resources[hook.Name]; !hasResource {
@ -672,8 +659,7 @@ func TestFailedHookWithFailedDeletePolicy(t *testing.T) {
[]release.HookDeletePolicy{release.Hook_FAILED},
)
err := execHookShouldFail(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall)
if err != nil {
if err := execHookShouldFail(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall); err != nil {
t.Error(err)
}
if _, hasResource := ctx.KubeClient.Resources[hook.Name]; hasResource {
@ -691,8 +677,7 @@ func TestSuccessfulHookWithSuccededOrFailedDeletePolicy(t *testing.T) {
[]release.HookDeletePolicy{release.Hook_SUCCEEDED, release.Hook_FAILED},
)
err := execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall)
if err != nil {
if err := execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall); err != nil {
t.Error(err)
}
if _, hasResource := ctx.KubeClient.Resources[hook.Name]; hasResource {
@ -711,8 +696,7 @@ func TestFailedHookWithSuccededOrFailedDeletePolicy(t *testing.T) {
[]release.HookDeletePolicy{release.Hook_SUCCEEDED, release.Hook_FAILED},
)
err := execHookShouldFail(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall)
if err != nil {
if err := execHookShouldFail(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall); err != nil {
t.Error(err)
}
if _, hasResource := ctx.KubeClient.Resources[hook.Name]; hasResource {
@ -725,20 +709,15 @@ func TestHookAlreadyExists(t *testing.T) {
hook := deletePolicyHookStub(ctx.HookName, nil, nil)
err := execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall)
if err != nil {
if err := execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall); err != nil {
t.Error(err)
}
if _, hasResource := ctx.KubeClient.Resources[hook.Name]; !hasResource {
t.Errorf("expected resource %s to be existing after hook succeeded", hook.Name)
}
err = execHookShouldFailWithError(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreUpgrade, errResourceExists)
if err != nil {
if err := execHookShouldFailWithError(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreUpgrade, errResourceExists); err != nil {
t.Error(err)
}
if _, hasResource := ctx.KubeClient.Resources[hook.Name]; !hasResource {
t.Errorf("expected resource %s to be existing after already exists error", hook.Name)
}
@ -752,20 +731,15 @@ func TestHookDeletingWithBeforeHookCreationDeletePolicy(t *testing.T) {
[]release.HookDeletePolicy{release.Hook_BEFORE_HOOK_CREATION},
)
err := execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall)
if err != nil {
if err := execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall); err != nil {
t.Error(err)
}
if _, hasResource := ctx.KubeClient.Resources[hook.Name]; !hasResource {
t.Errorf("expected resource %s to be existing after hook succeeded", hook.Name)
}
err = execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreUpgrade)
if err != nil {
if err := execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreUpgrade); err != nil {
t.Error(err)
}
if _, hasResource := ctx.KubeClient.Resources[hook.Name]; !hasResource {
t.Errorf("expected resource %s to be existing after hook succeeded", hook.Name)
}
@ -781,20 +755,15 @@ func TestSuccessfulHookWithMixedDeletePolicies(t *testing.T) {
[]release.HookDeletePolicy{release.Hook_SUCCEEDED, release.Hook_BEFORE_HOOK_CREATION},
)
err := execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall)
if err != nil {
if err := execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall); err != nil {
t.Error(err)
}
if _, hasResource := ctx.KubeClient.Resources[hook.Name]; hasResource {
t.Errorf("expected resource %s to be unexisting after hook succeeded", hook.Name)
}
err = execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreUpgrade)
if err != nil {
if err := execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreUpgrade); err != nil {
t.Error(err)
}
if _, hasResource := ctx.KubeClient.Resources[hook.Name]; hasResource {
t.Errorf("expected resource %s to be unexisting after hook succeeded", hook.Name)
}
@ -811,20 +780,15 @@ func TestFailedHookWithMixedDeletePolicies(t *testing.T) {
[]release.HookDeletePolicy{release.Hook_SUCCEEDED, release.Hook_BEFORE_HOOK_CREATION},
)
err := execHookShouldFail(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall)
if err != nil {
if err := execHookShouldFail(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall); err != nil {
t.Error(err)
}
if _, hasResource := ctx.KubeClient.Resources[hook.Name]; !hasResource {
t.Errorf("expected resource %s to be existing after hook failed", hook.Name)
}
err = execHookShouldFail(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreUpgrade)
if err != nil {
if err := execHookShouldFail(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreUpgrade); err != nil {
t.Error(err)
}
if _, hasResource := ctx.KubeClient.Resources[hook.Name]; !hasResource {
t.Errorf("expected resource %s to be existing after hook failed", hook.Name)
}
@ -841,11 +805,9 @@ func TestFailedThenSuccessfulHookWithMixedDeletePolicies(t *testing.T) {
[]release.HookDeletePolicy{release.Hook_SUCCEEDED, release.Hook_BEFORE_HOOK_CREATION},
)
err := execHookShouldFail(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall)
if err != nil {
if err := execHookShouldFail(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall); err != nil {
t.Error(err)
}
if _, hasResource := ctx.KubeClient.Resources[hook.Name]; !hasResource {
t.Errorf("expected resource %s to be existing after hook failed", hook.Name)
}
@ -857,11 +819,9 @@ func TestFailedThenSuccessfulHookWithMixedDeletePolicies(t *testing.T) {
[]release.HookDeletePolicy{release.Hook_SUCCEEDED, release.Hook_BEFORE_HOOK_CREATION},
)
err = execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreUpgrade)
if err != nil {
if err := execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreUpgrade); err != nil {
t.Error(err)
}
if _, hasResource := ctx.KubeClient.Resources[hook.Name]; hasResource {
t.Errorf("expected resource %s to be unexisting after hook succeeded", hook.Name)
}

Loading…
Cancel
Save