Skip to content

Commit

Permalink
uninstall: adapt to installer changes (kyma-project#152)
Browse files Browse the repository at this point in the history
* uninstall: adapt to installer changes

- Now uninstallation has infinite retries, thus a timeout is mandatory.
- Added first unit tests
  • Loading branch information
clebs authored Jul 5, 2019
1 parent c4d6848 commit f1eb60c
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/kyma/cmd/uninstall/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ This command:
Aliases: []string{"i"},
}

cobraCmd.Flags().DurationVarP(&o.Timeout, "timeout", "", 0, "Timeout after which Kyma CLI stops watching the installation progress")
cobraCmd.Flags().DurationVarP(&o.Timeout, "timeout", "", 30*time.Minute, "Timeout after which Kyma CLI stops watching the uninstallation progress")

return cobraCmd
}
Expand Down Expand Up @@ -276,8 +276,8 @@ func (cmd *command) waitForInstallerToUninstall() error {
case "Error":
if !errorOccured {
errorOccured = true
cmd.CurrentStep.Failuref("Failed to uninstall Kyma: %s", desc)
cmd.CurrentStep.LogInfof("To fetch the logs from the Installer, run: 'kubectl logs -n kyma-installer -l name=kyma-installer'")
cmd.CurrentStep.LogInfof("There was an error uninstalling Kyma, which might be OK. Will retry later...\n%s", desc)
cmd.CurrentStep.LogInfof("For more information, run: 'kubectl logs -n kyma-installer -l name=kyma-installer'")
}

case "InProgress":
Expand Down
37 changes: 37 additions & 0 deletions pkg/kyma/cmd/uninstall/cmd_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package uninstall

import (
"io/ioutil"
"testing"
"time"

"github.com/kyma-project/cli/pkg/kyma/core"
"github.com/stretchr/testify/require"
)

// TestUninstallFlags ensures that the provided command flags are stored in the options.
func TestUninstallFlags(t *testing.T) {
o := NewOptions(&core.Options{})
c := NewCmd(o)
c.SetOutput(ioutil.Discard) // not interested in the command's output

// test default flag values
require.Error(t, c.Execute(), "Command execution should fail") // command fails becuase there is no kyma to uninstall, but it is ok.
require.Equal(t, 30*time.Minute, o.Timeout, "Default uninstall timeout not correct")

// test passing flags
c.SetArgs([]string{"--timeout=60m0s"})

require.Error(t, c.Execute(), "Command execution should fail")
require.Equal(t, 60*time.Minute, o.Timeout, "Default uninstall timeout not correct")
}

func TestUninstallSubcommands(t *testing.T) {
o := NewOptions(&core.Options{})
c := NewCmd(o)
c.SetOutput(ioutil.Discard) // not interested in the command's output

sub := c.Commands()

require.Equal(t, 0, len(sub), "Number of uninstall subcommands not as expected")
}

0 comments on commit f1eb60c

Please sign in to comment.