feat(helm): add cleanup flag to test command

pull/1935/head
Vaughn Dice 8 years ago
parent eadd830d01
commit 4a57b01a47
No known key found for this signature in database
GPG Key ID: 4B4330BDC5C5B095

@ -317,6 +317,8 @@ message TestReleaseRequest {
string name = 1;
// timeout specifies the max amount of time any kubernetes client command can run.
int64 timeout = 2;
// cleanup specifies whether or not to attempt pod deletion after test completes
bool cleanup = 3;
}
// TestReleaseResponse represents a message from executing a test

@ -37,6 +37,7 @@ type releaseTestCmd struct {
out io.Writer
client helm.Interface
timeout int64
cleanup bool
}
func newReleaseTestCmd(c helm.Interface, out io.Writer) *cobra.Command {
@ -63,12 +64,17 @@ func newReleaseTestCmd(c helm.Interface, out io.Writer) *cobra.Command {
f := cmd.Flags()
f.Int64Var(&rlsTest.timeout, "timeout", 300, "time in seconds to wait for any individual kubernetes operation (like Jobs for hooks)")
f.BoolVar(&rlsTest.cleanup, "cleanup", false, "delete test pods upon completion")
return cmd
}
func (t *releaseTestCmd) run() (err error) {
c, errc := t.client.RunReleaseTest(t.name, helm.ReleaseTestTimeout(t.timeout))
c, errc := t.client.RunReleaseTest(
t.name,
helm.ReleaseTestTimeout(t.timeout),
helm.ReleaseTestCleanup(t.cleanup),
)
for {
select {

@ -190,6 +190,13 @@ func ReleaseTestTimeout(timeout int64) ReleaseTestOption {
}
}
// ReleaseTestCleanup is a boolean value representing whether to cleanup test pods
func ReleaseTestCleanup(cleanup bool) ReleaseTestOption {
return func(opts *options) {
opts.testReq.Cleanup = cleanup
}
}
// RollbackTimeout specifies the number of seconds before kubernetes calls timeout
func RollbackTimeout(timeout int64) RollbackOption {
return func(opts *options) {

@ -498,6 +498,8 @@ type TestReleaseRequest struct {
Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
// timeout specifies the max amount of time any kubernetes client command can run.
Timeout int64 `protobuf:"varint,2,opt,name=timeout" json:"timeout,omitempty"`
// cleanup specifies whether or not to attempt pod deletion after test completes
Cleanup bool `protobuf:"varint,3,opt,name=cleanup" json:"cleanup,omitempty"`
}
func (m *TestReleaseRequest) Reset() { *m = TestReleaseRequest{} }
@ -994,77 +996,78 @@ var _ReleaseService_serviceDesc = grpc.ServiceDesc{
func init() { proto.RegisterFile("hapi/services/tiller.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{
// 1141 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x9c, 0x57, 0xdd, 0x6e, 0xe3, 0x44,
0x14, 0xae, 0xf3, 0x9f, 0xd3, 0x1f, 0xd2, 0xe9, 0x9f, 0x6b, 0x01, 0x2a, 0x46, 0xd0, 0xec, 0xc2,
0xa6, 0x10, 0xae, 0x90, 0x10, 0x52, 0xdb, 0x8d, 0xda, 0x42, 0xe9, 0x4a, 0xce, 0x76, 0x91, 0xb8,
0x20, 0x72, 0x93, 0x49, 0x6b, 0xd6, 0xf1, 0x04, 0xcf, 0xa4, 0x6c, 0x6f, 0xb9, 0xe3, 0x35, 0xb8,
0x83, 0x87, 0xe1, 0x05, 0x78, 0x19, 0x34, 0x7f, 0xae, 0x27, 0xb5, 0x5b, 0x93, 0x9b, 0x78, 0x66,
0xce, 0x99, 0xef, 0x9c, 0xf3, 0x9d, 0x33, 0x67, 0x26, 0xe0, 0xdc, 0xf8, 0xd3, 0xe0, 0x80, 0xe2,
0xf8, 0x36, 0x18, 0x62, 0x7a, 0xc0, 0x82, 0x30, 0xc4, 0x71, 0x67, 0x1a, 0x13, 0x46, 0xd0, 0x26,
0x97, 0x75, 0xb4, 0xac, 0x23, 0x65, 0xce, 0xb6, 0xd8, 0x31, 0xbc, 0xf1, 0x63, 0x26, 0x7f, 0xa5,
0xb6, 0xb3, 0x93, 0x5e, 0x27, 0xd1, 0x38, 0xb8, 0x56, 0x02, 0x69, 0x22, 0xc6, 0x21, 0xf6, 0x29,
0xd6, 0x5f, 0x63, 0x93, 0x96, 0x05, 0xd1, 0x98, 0x28, 0xc1, 0xae, 0x21, 0x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, 0xea, 0x22, 0x8f, 0x04, 0x65, 0xb6, 0xa8,
0x47, 0x82, 0x9a, 0x6b, 0x48, 0xee, 0x12, 0x0a, 0x60, 0xcd, 0x9b, 0x45, 0xca, 0x34, 0xef, 0x12,
0x28, 0x67, 0xf7, 0xc3, 0x2e, 0xe4, 0x3c, 0x2b, 0xa0, 0x79, 0x7f, 0xbe, 0x8f, 0xe0, 0xa7, 0x86,
0x56, 0xbd, 0xaa, 0x89, 0xbf, 0x85, 0x5f, 0xfd, 0x17, 0x00, 0x00, 0xff, 0xff, 0x70, 0xcd, 0xbe,
0x36, 0xe7, 0x0e, 0x00, 0x00,
// 1162 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x9c, 0x57, 0xdd, 0x6e, 0xe3, 0xc4,
0x17, 0xaf, 0xe3, 0x7c, 0x9e, 0x76, 0xfb, 0x4f, 0xa7, 0x5f, 0xae, 0xf5, 0x07, 0x15, 0x23, 0x68,
0x76, 0x61, 0x53, 0x08, 0x57, 0x48, 0x08, 0xa9, 0xdb, 0x8d, 0xda, 0x42, 0xe9, 0x4a, 0xce, 0x76,
0x91, 0x10, 0x22, 0x72, 0x93, 0x49, 0x6b, 0xd6, 0xf1, 0x04, 0xcf, 0xb8, 0x6c, 0x6f, 0xb9, 0xe3,
0x51, 0xe0, 0x29, 0x78, 0x02, 0x5e, 0x80, 0x97, 0x41, 0x9e, 0x0f, 0xd7, 0xe3, 0xda, 0xad, 0xe9,
0x4d, 0x3c, 0x33, 0xe7, 0xcc, 0xf9, 0xf8, 0x9d, 0x33, 0xbf, 0x99, 0x80, 0x7d, 0xe5, 0x2d, 0xfc,
0x7d, 0x8a, 0xa3, 0x6b, 0x7f, 0x82, 0xe9, 0x3e, 0xf3, 0x83, 0x00, 0x47, 0xfd, 0x45, 0x44, 0x18,
0x41, 0x1b, 0x89, 0xac, 0xaf, 0x64, 0x7d, 0x21, 0xb3, 0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4, 0x40, 0x21, 0x7f, 0xdb, 0x9f, 0x56, 0x53, 0x4e, 0xdd, 0x51, 0xe8, 0xe6, 0xd9,
0xa0, 0xac, 0x8e, 0x25, 0xcc, 0x55, 0x56, 0xc7, 0x32, 0x92, 0x71, 0x96, 0x90, 0x07, 0x70, 0x4b,
0x06, 0x68, 0xaf, 0xb4, 0x20, 0x3a, 0x87, 0xd8, 0xbd, 0x87, 0x15, 0x53, 0x17, 0x0b, 0xf8, 0x5f,
0xee, 0xb6, 0x44, 0x25, 0xd0, 0x14, 0x3f, 0x12, 0xec, 0xe7, 0x15, 0xb5, 0x73, 0x49, 0x49, 0x7e,
0xb9, 0x27, 0x29, 0x9d, 0xbc, 0xee, 0x49, 0x2a, 0x47, 0x55, 0xce, 0x12, 0xf2, 0x61, 0xd5, 0x8d,
0x43, 0xe9, 0x3a, 0x61, 0x09, 0x54, 0xb2, 0xfb, 0x2e, 0x3f, 0xd9, 0x4f, 0x2b, 0x68, 0xde, 0x9e,
0xef, 0x17, 0xf0, 0x43, 0x5b, 0xa9, 0x5e, 0x34, 0xf9, 0xdf, 0xc9, 0x2f, 0xfe, 0x0d, 0x00, 0x00,
0xff, 0xff, 0xf9, 0x32, 0x44, 0xf7, 0x1f, 0x0f, 0x00, 0x00,
}

@ -17,6 +17,7 @@ limitations under the License.
package releasetesting
import (
"bytes"
"fmt"
"k8s.io/helm/pkg/proto/hapi/services"
@ -31,38 +32,42 @@ type Environment struct {
Timeout int64
}
func streamRunning(name string, stream services.ReleaseService_RunReleaseTestServer) error {
func (env *Environment) streamRunning(name string) error {
msg := "RUNNING: " + name
err := streamMessage(msg, stream)
return err
return env.streamMessage(msg)
}
func streamError(info string, stream services.ReleaseService_RunReleaseTestServer) error {
func (env *Environment) streamError(info string) error {
msg := "ERROR: " + info
err := streamMessage(msg, stream)
return err
return env.streamMessage(msg)
}
func streamFailed(name, namespace string, stream services.ReleaseService_RunReleaseTestServer) error {
msg := fmt.Sprintf("FAILED: %s, run `kubectl logs %s --namespace %s` for more info", name, name, namespace)
err := streamMessage(msg, stream)
return err
func (env *Environment) streamFailed(name string) error {
msg := fmt.Sprintf("FAILED: %s, run `kubectl logs %s --namespace %s` for more info", name, name, env.Namespace)
return env.streamMessage(msg)
}
func streamSuccess(name string, stream services.ReleaseService_RunReleaseTestServer) error {
func (env *Environment) streamSuccess(name string) error {
msg := fmt.Sprintf("PASSED: %s", name)
err := streamMessage(msg, stream)
return err
return env.streamMessage(msg)
}
func streamUnknown(name, info string, stream services.ReleaseService_RunReleaseTestServer) error {
func (env *Environment) streamUnknown(name, info string) error {
msg := fmt.Sprintf("UNKNOWN: %s: %s", name, info)
err := streamMessage(msg, stream)
return err
return env.streamMessage(msg)
}
func streamMessage(msg string, stream services.ReleaseService_RunReleaseTestServer) error {
func (env *Environment) streamMessage(msg string) error {
resp := &services.TestReleaseResponse{Msg: msg}
err := stream.Send(resp)
return err
return env.Stream.Send(resp)
}
// DeleteTestPods deletes resources given in testManifests
func (env *Environment) DeleteTestPods(testManifests []string) {
for _, testManifest := range testManifests {
err := env.KubeClient.Delete(env.Namespace, bytes.NewBufferString(testManifest))
if err != nil {
env.streamError(err.Error())
}
}
}

@ -0,0 +1,111 @@
/*
Copyright 2017 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package releasetesting
import (
"bytes"
"errors"
"io"
"os"
"testing"
tillerEnv "k8s.io/helm/pkg/tiller/environment"
)
func TestDeleteTestPods(t *testing.T) {
mockTestSuite := testSuiteFixture()
mockTestEnv := newMockTestingEnvironment()
mockTestEnv.KubeClient = newGetFailingKubeClient()
mockTestEnv.DeleteTestPods(mockTestSuite.TestManifests)
stream := mockTestEnv.Stream.(mockStream)
if len(stream.messages) != 0 {
t.Errorf("Expected 0 errors, got at least one: %v", stream.messages)
}
for _, testManifest := range mockTestSuite.TestManifests {
if _, err := mockTestEnv.KubeClient.Get(mockTestEnv.Namespace, bytes.NewBufferString(testManifest)); err == nil {
t.Error("Expected error, got nil")
}
}
}
func TestDeleteTestPodsFailingDelete(t *testing.T) {
mockTestSuite := testSuiteFixture()
mockTestEnv := newMockTestingEnvironment()
mockTestEnv.KubeClient = newDeleteFailingKubeClient()
mockTestEnv.DeleteTestPods(mockTestSuite.TestManifests)
stream := mockTestEnv.Stream.(mockStream)
if len(stream.messages) == 1 {
t.Errorf("Expected 1 error, got none: %v", stream.messages)
}
}
type MockTestingEnvironment struct {
*Environment
}
func newMockTestingEnvironment() *MockTestingEnvironment {
tEnv := mockTillerEnvironment()
return &MockTestingEnvironment{
Environment: &Environment{
Namespace: "default",
KubeClient: tEnv.KubeClient,
Timeout: 5,
Stream: mockStream{},
},
}
}
func (mte MockTestingEnvironment) streamRunning(name string) error { return nil }
func (mte MockTestingEnvironment) streamError(info string) error { return nil }
func (mte MockTestingEnvironment) streamFailed(name string) error { return nil }
func (mte MockTestingEnvironment) streamSuccess(name string) error { return nil }
func (mte MockTestingEnvironment) streamUnknown(name, info string) error { return nil }
func (mte MockTestingEnvironment) streamMessage(msg string) error { return nil }
func newGetFailingKubeClient() *getFailingKubeClient {
return &getFailingKubeClient{
PrintingKubeClient: tillerEnv.PrintingKubeClient{Out: os.Stdout},
}
}
type getFailingKubeClient struct {
tillerEnv.PrintingKubeClient
}
func (p *getFailingKubeClient) Get(ns string, r io.Reader) (string, error) {
return "", errors.New("Get failed")
}
func newDeleteFailingKubeClient() *deleteFailingKubeClient {
return &deleteFailingKubeClient{
PrintingKubeClient: tillerEnv.PrintingKubeClient{Out: os.Stdout},
}
}
type deleteFailingKubeClient struct {
tillerEnv.PrintingKubeClient
}
func (p *deleteFailingKubeClient) Delete(ns string, r io.Reader) error {
return errors.New("In the end, they did not find Nemo.")
}

@ -72,14 +72,14 @@ func (t *TestSuite) Run(env *Environment) error {
}
test.result.StartedAt = timeconv.Now()
if err := streamRunning(test.result.Name, env.Stream); err != nil {
if err := env.streamRunning(test.result.Name); err != nil {
return err
}
resourceCreated := true
if err := t.createTestPod(test, env); err != nil {
resourceCreated = false
if streamErr := streamError(test.result.Info, env.Stream); streamErr != nil {
if streamErr := env.streamError(test.result.Info); streamErr != nil {
return err
}
}
@ -90,7 +90,7 @@ func (t *TestSuite) Run(env *Environment) error {
status, err = t.getTestPodStatus(test, env)
if err != nil {
resourceCleanExit = false
if streamErr := streamUnknown(test.result.Name, test.result.Info, env.Stream); streamErr != nil {
if streamErr := env.streamUnknown(test.result.Name, test.result.Info); streamErr != nil {
return streamErr
}
}
@ -98,12 +98,12 @@ func (t *TestSuite) Run(env *Environment) error {
if resourceCreated && resourceCleanExit && status == api.PodSucceeded {
test.result.Status = release.TestRun_SUCCESS
if streamErr := streamSuccess(test.result.Name, env.Stream); streamErr != nil {
if streamErr := env.streamSuccess(test.result.Name); streamErr != nil {
return streamErr
}
} else if resourceCreated && resourceCleanExit && status == api.PodFailed {
test.result.Status = release.TestRun_FAILURE
if streamErr := streamFailed(test.result.Name, env.Namespace, env.Stream); streamErr != nil {
if streamErr := env.streamFailed(test.result.Name); streamErr != nil {
return err
}
}

@ -201,14 +201,7 @@ func testSuiteFixture() *TestSuite {
}
func testEnvFixture() *Environment {
tillerEnv := mockTillerEnvironment()
return &Environment{
Namespace: "default",
KubeClient: tillerEnv.KubeClient,
Timeout: 5,
Stream: mockStream{},
}
return newMockTestingEnvironment().Environment
}
func mockTillerEnvironment() *tillerEnv.Environment {
@ -219,10 +212,12 @@ func mockTillerEnvironment() *tillerEnv.Environment {
}
type mockStream struct {
stream grpc.ServerStream
stream grpc.ServerStream
messages []*services.TestReleaseResponse
}
func (rs mockStream) Send(m *services.TestReleaseResponse) error {
rs.messages = append(rs.messages, m)
return nil
}
func (rs mockStream) SetHeader(m metadata.MD) error { return nil }

@ -1103,5 +1103,9 @@ func (s *ReleaseServer) RunReleaseTest(req *services.TestReleaseRequest, stream
Results: tSuite.Results,
}
if req.Cleanup {
testEnv.DeleteTestPods(tSuite.TestManifests)
}
return s.env.Releases.Update(rel)
}

Loading…
Cancel
Save