This repository has been archived by the owner on Dec 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Start VM, check network, stop VM, start VM with the same providers and check network. - Start VM, check network, stop vm, start VM with different providers and check network access.
- Loading branch information
Showing
1 changed file
with
133 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
package e2e | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/weaveworks/ignite/e2e/util" | ||
"gotest.tools/assert" | ||
) | ||
|
||
// runVMLifecycle is a helper for testing the VM lifecycle. | ||
// vmName should be unique for each test. | ||
func runVMLifecycle(t *testing.T, vmName, runtime, networkPlugin string) { | ||
assert.Assert(t, e2eHome != "", "IGNITE_E2E_HOME should be set") | ||
|
||
igniteCmd := util.NewCommand(t, igniteBin) | ||
|
||
// Clean-up the following VM. | ||
defer igniteCmd.New(). | ||
With("rm", "-f", vmName). | ||
Run() | ||
|
||
// Run VM. | ||
igniteCmd.New(). | ||
WithRuntime(runtime). | ||
WithNetwork(networkPlugin). | ||
With("run"). | ||
With("--name=" + vmName). | ||
With("--ssh"). | ||
With(util.DefaultVMImage). | ||
Run() | ||
|
||
// Check network access. | ||
igniteCmd.New(). | ||
With("exec", vmName). | ||
With("curl", "google.com"). | ||
Run() | ||
|
||
// Stop VM. | ||
igniteCmd.New(). | ||
With("stop", vmName). | ||
Run() | ||
|
||
// Start VM with explicit runtime and network because these info are | ||
// removed when VM is stopped. Without it, the VM will start with the | ||
// default provider configurations. | ||
igniteCmd.New(). | ||
With("start", vmName). | ||
WithRuntime(runtime). | ||
WithNetwork(networkPlugin). | ||
Run() | ||
|
||
// Check network access after reboot. | ||
igniteCmd.New(). | ||
With("exec", vmName). | ||
With("curl", "google.com"). | ||
Run() | ||
} | ||
|
||
func TestVMLifecycleWithDockerAndDockerBridge(t *testing.T) { | ||
runVMLifecycle( | ||
t, | ||
"e2e_test_vm_lifecycle_docker_and_docker_bridge", | ||
"docker", | ||
"docker-bridge", | ||
) | ||
} | ||
|
||
func TestVMLifecycleWithDockerAndCNI(t *testing.T) { | ||
runVMLifecycle( | ||
t, | ||
"e2e_test_vm_lifecycle_docker_and_cni", | ||
"docker", | ||
"cni", | ||
) | ||
} | ||
|
||
func TestVMLifecycleWithContainerdAndCNI(t *testing.T) { | ||
runVMLifecycle( | ||
t, | ||
"e2e_test_vm_lifecycle_containerd_and_cni", | ||
"containerd", | ||
"cni", | ||
) | ||
} | ||
|
||
// TestVMProviderSwitch tests that a VM's runtime and network-plugin can be | ||
// changed. | ||
func TestVMProviderSwitch(t *testing.T) { | ||
assert.Assert(t, e2eHome != "", "IGNITE_E2E_HOME should be set") | ||
|
||
vmName := "e2e_test_vm_providers_switch" | ||
|
||
igniteCmd := util.NewCommand(t, igniteBin) | ||
|
||
// Clean-up the following VM. | ||
defer igniteCmd.New(). | ||
With("rm", "-f", vmName). | ||
Run() | ||
|
||
// Run VM. | ||
igniteCmd.New(). | ||
WithRuntime("containerd"). | ||
WithNetwork("cni"). | ||
With("run"). | ||
With("--name=" + vmName). | ||
With("--ssh"). | ||
With(util.DefaultVMImage). | ||
Run() | ||
|
||
// Check network access. | ||
igniteCmd.New(). | ||
With("exec", vmName). | ||
With("curl", "google.com"). | ||
Run() | ||
|
||
// Stop VM. | ||
igniteCmd.New(). | ||
With("stop", vmName). | ||
Run() | ||
|
||
// Start VM with different providers. | ||
igniteCmd.New(). | ||
With("start", vmName). | ||
WithRuntime("docker"). | ||
WithNetwork("docker-bridge"). | ||
Run() | ||
|
||
// Check network access. | ||
igniteCmd.New(). | ||
With("exec", vmName). | ||
With("curl", "google.com"). | ||
Run() | ||
} |