Update tests

pull/11394/head
Ilya Zuyev 2021-05-20 10:58:38 -07:00
parent 6454527a1e
commit 5a0f955970
1 changed files with 28 additions and 36 deletions

View File

@ -36,25 +36,21 @@ import (
// if container runtime is "containerd" or "crio"
// and --cni=false
func TestCNIFalse(t *testing.T) {
cr := ContainerRuntime()
profile := UniqueProfileName("no-cni-" + cr)
ctx, cancel := context.WithTimeout(context.Background(), Minutes(1))
defer CleanupWithLogs(t, profile, cancel)
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)
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)
}
expectedMsg := fmt.Sprintf("The %q container runtime requires CNI", cr)
if !strings.Contains(rr.Output(), expectedMsg) {
t.Errorf("Expected %q line not found in output %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)
}
expectedMsg := fmt.Sprintf("The %q container runtime requires CNI", cr)
if !strings.Contains(rr.Output(), expectedMsg) {
t.Errorf("Expected %q line not found in output %s", expectedMsg, rr.Output())
}
}
@ -62,25 +58,21 @@ func TestCNIFalse(t *testing.T) {
// if container runtime is "containerd" or "crio"
// and --cni=false, but --force=true
func TestCNIFalseForce(t *testing.T) {
cr := ContainerRuntime()
profile := UniqueProfileName("no-cni-" + cr)
ctx, cancel := context.WithTimeout(context.Background(), Minutes(1))
defer CleanupWithLogs(t, profile, cancel)
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)
}
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 output %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)
}
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 output %s", expectedMsg, rr.Output())
}
}