update tests
parent
03600d9afc
commit
d185d765a1
|
@ -1193,9 +1193,9 @@ func validateCNI(cmd *cobra.Command, runtime string) {
|
|||
}
|
||||
if cmd.Flags().Changed(cniFlag) && strings.ToLower(viper.GetString(cniFlag)) == "false" {
|
||||
if viper.GetBool(force) {
|
||||
out.WarnReason(reason.Usage, "The {{.name}} container runtime requires CNI", out.V{"name": runtime})
|
||||
out.WarnReason(reason.Usage, "You have chosen to disable the CNI but the \"{{.name}}\" container runtime requires CNI", out.V{"name": runtime})
|
||||
} else {
|
||||
exit.Message(reason.Usage, "The {{.name}} container runtime requires CNI", out.V{"name": runtime})
|
||||
exit.Message(reason.Usage, "The \"{{.name}}\" container runtime requires CNI", out.V{"name": runtime})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,23 +38,51 @@ import (
|
|||
func TestCNIFalse(t *testing.T) {
|
||||
|
||||
for _, cr := range []string{"containerd", "cri-o"} {
|
||||
t.Run("TestCNIFalse-"+cr, func(t *testing.T) {
|
||||
profile := UniqueProfileName("no-cni-" + cr)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), Minutes(1))
|
||||
defer CleanupWithLogs(t, profile, cancel)
|
||||
|
||||
profile := UniqueProfileName("no-cni-" + cr)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), Minutes(1))
|
||||
defer CleanupWithLogs(t, profile, cancel)
|
||||
startArgs := []string{"start", "-p", profile, "--memory=2048", "--alsologtostderr", "--cni=false", "--container-runtime=" + cr}
|
||||
startArgs = append(startArgs, StartArgs()...)
|
||||
mkCmd := exec.CommandContext(ctx, Target(), startArgs...)
|
||||
rr, err := Run(t, mkCmd)
|
||||
if err == nil {
|
||||
t.Errorf("%s expected to fail", mkCmd)
|
||||
continue
|
||||
}
|
||||
expectedMsg := fmt.Sprintf("The %q container runtime requires CNI", cr)
|
||||
if !strings.Contains(rr.Output(), expectedMsg) {
|
||||
t.Errorf("Expected %q line not found in ouput %s", expectedMsg, rr.Output())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
startArgs := []string{"start", "-p", profile, "--memory=2048", "--alsologtostderr", "--cni=false", "--container-runtime=" + cr}
|
||||
startArgs = append(startArgs, StartArgs()...)
|
||||
mkCmd := exec.CommandContext(ctx, Target(), startArgs...)
|
||||
rr, err := Run(t, mkCmd)
|
||||
if err == nil {
|
||||
t.Errorf("%s expected to fail", mkCmd)
|
||||
continue
|
||||
}
|
||||
expectedMsg := fmt.Sprintf("The %s container runtime requires CNI", cr)
|
||||
if !strings.Contains(rr.Output(), expectedMsg) {
|
||||
t.Errorf("Expected %q line not found in ouput %s", expectedMsg, rr.Output())
|
||||
}
|
||||
// TestCNIFalseForce checks that minikube returns not error
|
||||
// if container runtime is "containerd" or "crio"
|
||||
// and --cni=false, but --force=true
|
||||
func TestCNIFalseForce(t *testing.T) {
|
||||
|
||||
for _, cr := range []string{"containerd", "cri-o"} {
|
||||
t.Run("TestCNIFalseForce-"+cr, func(t *testing.T) {
|
||||
profile := UniqueProfileName("no-cni-" + cr)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), Minutes(1))
|
||||
defer CleanupWithLogs(t, profile, cancel)
|
||||
|
||||
startArgs := []string{"start", "-p", profile, "--memory=2048", "--alsologtostderr", "--cni=false", "--container-runtime=" + cr}
|
||||
startArgs = append(startArgs, StartArgs()...)
|
||||
mkCmd := exec.CommandContext(ctx, Target(), startArgs...)
|
||||
rr, err := Run(t, mkCmd)
|
||||
if err == nil {
|
||||
t.Errorf("%s expected to fail", mkCmd)
|
||||
continue
|
||||
}
|
||||
expectedMsg := fmt.Sprintf("You have chosen to disable the CNI but the %q container runtime requires CNI", cr)
|
||||
if !strings.Contains(rr.Output(), expectedMsg) {
|
||||
t.Errorf("Expected %q line not found in ouput %s", expectedMsg, rr.Output())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue