Skip to content

Commit

Permalink
Revert "test(vm): run reusable tests in different namespaces"
Browse files Browse the repository at this point in the history
This reverts commit 08e1ad3.
  • Loading branch information
Isteb4k committed Jan 17, 2025
1 parent 08e1ad3 commit 723d77a
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 125 deletions.
51 changes: 21 additions & 30 deletions tests/e2e/complex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ import (
kc "github.com/deckhouse/virtualization/tests/e2e/kubectl"
)

func GetComplexNamespace() string {
return conf.Namespace + "-complex"
}

func AssignIPToVMIP(name, namespace string) error {
func AssignIPToVMIP(name string) error {
assignErr := fmt.Sprintf("cannot patch VMIP %q with unnassigned IP address", name)
unassignedIP, err := FindUnassignedIP(mc.Spec.Settings.VirtualMachineCIDRs)
if err != nil {
Expand All @@ -46,14 +42,14 @@ func AssignIPToVMIP(name, namespace string) error {
}
vmip := virtv2.VirtualMachineIPAddress{}
err = GetObject(kc.ResourceVMIP, name, &vmip, kc.GetOptions{
Namespace: namespace,
Namespace: conf.Namespace,
})
if err != nil {
return fmt.Errorf("%s\n%s", assignErr, err)
}
jsonPath := fmt.Sprintf("'jsonpath={.status.phase}=%s'", PhaseAttached)
waitOpts := kc.WaitOptions{
Namespace: namespace,
Namespace: conf.Namespace,
For: jsonPath,
Timeout: ShortWaitDuration,
}
Expand All @@ -68,19 +64,14 @@ var _ = Describe("Complex test", ginkgoutil.CommonE2ETestDecorators(), func() {
var (
testCaseLabel = map[string]string{"testcase": "complex-test"}
hasNoConsumerLabel = map[string]string{"hasNoConsumer": "complex-test"}
namespace = conf.Namespace
)

if config.IsReusable() {
namespace = GetComplexNamespace()
}

Context("When virtualization resources are applied", func() {
It("result should be succeeded", func() {
if config.IsReusable() {
res := kubectl.List(kc.ResourceVM, kc.GetOptions{
Labels: testCaseLabel,
Namespace: namespace,
Namespace: conf.Namespace,
Output: "jsonpath='{.items[*].metadata.name}'",
})
Expect(res.Error()).NotTo(HaveOccurred(), res.StdErr())
Expand All @@ -103,7 +94,7 @@ var _ = Describe("Complex test", ginkgoutil.CommonE2ETestDecorators(), func() {
By(fmt.Sprintf("VIs should be in %s phases", PhaseReady))
WaitPhaseByLabel(kc.ResourceVI, PhaseReady, kc.WaitOptions{
Labels: testCaseLabel,
Namespace: namespace,
Namespace: conf.Namespace,
Timeout: MaxWaitTimeout,
})
})
Expand All @@ -114,7 +105,7 @@ var _ = Describe("Complex test", ginkgoutil.CommonE2ETestDecorators(), func() {
By(fmt.Sprintf("CVIs should be in %s phases", PhaseReady))
WaitPhaseByLabel(kc.ResourceCVI, PhaseReady, kc.WaitOptions{
Labels: testCaseLabel,
Namespace: namespace,
Namespace: conf.Namespace,
Timeout: MaxWaitTimeout,
})
})
Expand All @@ -125,7 +116,7 @@ var _ = Describe("Complex test", ginkgoutil.CommonE2ETestDecorators(), func() {
By(fmt.Sprintf("VMClasses should be in %s phases", PhaseReady))
WaitPhaseByLabel(kc.ResourceVMClass, PhaseReady, kc.WaitOptions{
Labels: testCaseLabel,
Namespace: namespace,
Namespace: conf.Namespace,
Timeout: MaxWaitTimeout,
})
})
Expand All @@ -135,15 +126,15 @@ var _ = Describe("Complex test", ginkgoutil.CommonE2ETestDecorators(), func() {
It("patches custom VMIP with unassigned address", func() {
vmipName := fmt.Sprintf("%s-%s", namePrefix, "vm-custom-ip")
Eventually(func() error {
return AssignIPToVMIP(vmipName, namespace)
return AssignIPToVMIP(vmipName)
}).Should(Succeed())
})

It("checks VMIPs phases", func() {
By(fmt.Sprintf("VMIPs should be in %s phases", PhaseAttached))
WaitPhaseByLabel(kc.ResourceVMIP, PhaseAttached, kc.WaitOptions{
Labels: testCaseLabel,
Namespace: namespace,
Namespace: conf.Namespace,
Timeout: MaxWaitTimeout,
})
})
Expand All @@ -155,7 +146,7 @@ var _ = Describe("Complex test", ginkgoutil.CommonE2ETestDecorators(), func() {
WaitPhaseByLabel(kc.ResourceVD, PhaseReady, kc.WaitOptions{
ExcludedLabels: []string{"hasNoConsumer"},
Labels: testCaseLabel,
Namespace: namespace,
Namespace: conf.Namespace,
Timeout: MaxWaitTimeout,
})
})
Expand All @@ -164,7 +155,7 @@ var _ = Describe("Complex test", ginkgoutil.CommonE2ETestDecorators(), func() {
By(fmt.Sprintf("VDs should be in %s phases", phaseByVolumeBindingMode))
WaitPhaseByLabel(kc.ResourceVD, phaseByVolumeBindingMode, kc.WaitOptions{
Labels: hasNoConsumerLabel,
Namespace: namespace,
Namespace: conf.Namespace,
Timeout: MaxWaitTimeout,
})
})
Expand All @@ -175,7 +166,7 @@ var _ = Describe("Complex test", ginkgoutil.CommonE2ETestDecorators(), func() {
By(fmt.Sprintf("VMs should be in %s phases", PhaseRunning))
WaitPhaseByLabel(kc.ResourceVM, PhaseRunning, kc.WaitOptions{
Labels: testCaseLabel,
Namespace: namespace,
Namespace: conf.Namespace,
Timeout: MaxWaitTimeout,
})
})
Expand All @@ -186,7 +177,7 @@ var _ = Describe("Complex test", ginkgoutil.CommonE2ETestDecorators(), func() {
By(fmt.Sprintf("VMBDAs should be in %s phases", PhaseAttached))
WaitPhaseByLabel(kc.ResourceVMBDA, PhaseAttached, kc.WaitOptions{
Labels: testCaseLabel,
Namespace: namespace,
Namespace: conf.Namespace,
Timeout: MaxWaitTimeout,
})
})
Expand All @@ -197,13 +188,13 @@ var _ = Describe("Complex test", ginkgoutil.CommonE2ETestDecorators(), func() {
It("checks VMs external connectivity", func() {
res := kubectl.List(kc.ResourceVM, kc.GetOptions{
Labels: testCaseLabel,
Namespace: namespace,
Namespace: conf.Namespace,
Output: "jsonpath='{.items[*].metadata.name}'",
})
Expect(res.Error()).NotTo(HaveOccurred(), res.StdErr())

vms := strings.Split(res.StdOut(), " ")
CheckExternalConnection(externalHost, httpStatusOk, namespace, vms...)
CheckExternalConnection(externalHost, httpStatusOk, vms...)
})
})
})
Expand All @@ -213,13 +204,13 @@ var _ = Describe("Complex test", ginkgoutil.CommonE2ETestDecorators(), func() {
It("starts migrations", func() {
res := kubectl.List(kc.ResourceVM, kc.GetOptions{
Labels: testCaseLabel,
Namespace: namespace,
Namespace: conf.Namespace,
Output: "jsonpath='{.items[*].metadata.name}'",
})
Expect(res.Error()).NotTo(HaveOccurred(), res.StdErr())

vms := strings.Split(res.StdOut(), " ")
MigrateVirtualMachines(testCaseLabel, conf.TestData.ComplexTest, namespace, vms...)
MigrateVirtualMachines(testCaseLabel, conf.TestData.ComplexTest, vms...)
})
})

Expand All @@ -228,27 +219,27 @@ var _ = Describe("Complex test", ginkgoutil.CommonE2ETestDecorators(), func() {
By(fmt.Sprintf("KubevirtVMIMs should be in %s phases", PhaseSucceeded))
WaitPhaseByLabel(kc.ResourceKubevirtVMIM, PhaseSucceeded, kc.WaitOptions{
Labels: testCaseLabel,
Namespace: namespace,
Namespace: conf.Namespace,
Timeout: MaxWaitTimeout,
})
By(fmt.Sprintf("VMs should be in %s phase", PhaseRunning))
WaitPhaseByLabel(kc.ResourceVM, PhaseRunning, kc.WaitOptions{
Labels: testCaseLabel,
Namespace: namespace,
Namespace: conf.Namespace,
Timeout: MaxWaitTimeout,
})
})

It("checks VMs external connection after migrations", func() {
res := kubectl.List(kc.ResourceVM, kc.GetOptions{
Labels: testCaseLabel,
Namespace: namespace,
Namespace: conf.Namespace,
Output: "jsonpath='{.items[*].metadata.name}'",
})
Expect(res.Error()).NotTo(HaveOccurred(), res.StdErr())

vms := strings.Split(res.StdOut(), " ")
CheckExternalConnection(externalHost, httpStatusOk, namespace, vms...)
CheckExternalConnection(externalHost, httpStatusOk, vms...)
})
})

Expand Down
10 changes: 2 additions & 8 deletions tests/e2e/tests_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func init() {
log.Fatal(err)
}
} else {
log.Println("Run test in REUSABLE mode")
log.Printf("Run test in REUSABLE mode\n")
}

res := kubectl.CreateResource(kc.ResourceNamespace, conf.Namespace, kc.CreateOptions{})
Expand All @@ -147,13 +147,7 @@ func TestTests(t *testing.T) {

func Cleanup() error {
res := kubectl.Delete(kc.DeleteOptions{
Filename: []string{
conf.Namespace,
GetVirtualMachineConfigurationNamespace(),
GetVirtualMachineConnectivityNamespace(),
GetVirtualMachineMigrationNamespace(),
GetComplexNamespace(),
},
Filename: []string{conf.Namespace},
IgnoreNotFound: true,
Resource: kc.ResourceNamespace,
})
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/vd_snapshots_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"

sdsrepvolv1 "github.com/deckhouse/sds-replicated-volume/api/v1alpha1"

virtv2 "github.com/deckhouse/virtualization/api/core/v1alpha2"
"github.com/deckhouse/virtualization/tests/e2e/config"
"github.com/deckhouse/virtualization/tests/e2e/ginkgoutil"
Expand Down
Loading

0 comments on commit 723d77a

Please sign in to comment.