Skip to content

Commit b47da98

Browse files
fix release tests
Signed-off-by: Nikita Korolev <nikita.korolev@flant.com>
1 parent 10e5c6a commit b47da98

3 files changed

Lines changed: 18 additions & 34 deletions

File tree

test/e2e/release/current_release_smoke.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,32 +89,34 @@ func runPostUpgradeReleaseSmoke() {
8989
}
9090

9191
func (t *currentReleaseSmokeTest) createResources() {
92+
ctx := context.Background()
93+
9294
By("Creating root and hotplug virtual disks")
93-
Expect(t.framework.CreateWithDeferredDeletion(context.Background(), t.diskObjects()...)).To(Succeed())
95+
Expect(t.framework.CreateWithDeferredDeletion(ctx, t.diskObjects()...)).To(Succeed())
9496

9597
By("Creating virtual machines")
96-
Expect(t.framework.CreateWithDeferredDeletion(context.Background(), t.vmObjects()...)).To(Succeed())
98+
Expect(t.framework.CreateWithDeferredDeletion(ctx, t.vmObjects()...)).To(Succeed())
9799
if runningVMs := t.initialRunningVMObjects(); len(runningVMs) > 0 {
98-
util.UntilObjectPhase(string(v1alpha2.MachineRunning), framework.LongTimeout, runningVMs...)
100+
util.UntilObjectPhase(ctx, string(v1alpha2.MachineRunning), framework.LongTimeout, runningVMs...)
99101
}
100102
if stoppedVMs := t.initialStoppedVMObjects(); len(stoppedVMs) > 0 {
101-
util.UntilObjectPhase(string(v1alpha2.MachineStopped), framework.MiddleTimeout, stoppedVMs...)
103+
util.UntilObjectPhase(ctx, string(v1alpha2.MachineStopped), framework.MiddleTimeout, stoppedVMs...)
102104
}
103105

104106
By("Starting manual-policy virtual machines")
105107
for _, vmScenario := range t.manualStartVMs() {
106-
util.StartVirtualMachine(t.framework, vmScenario.vm)
108+
util.StartVirtualMachine(ctx, t.framework, vmScenario.vm)
107109
}
108110
if startedVMs := t.manualStartVMObjects(); len(startedVMs) > 0 {
109-
util.UntilObjectPhase(string(v1alpha2.MachineRunning), framework.LongTimeout, startedVMs...)
111+
util.UntilObjectPhase(ctx, string(v1alpha2.MachineRunning), framework.LongTimeout, startedVMs...)
110112
}
111113

112114
By("Attaching hotplug disks")
113-
Expect(t.framework.CreateWithDeferredDeletion(context.Background(), t.attachmentObjects()...)).To(Succeed())
114-
util.UntilObjectPhase(string(v1alpha2.BlockDeviceAttachmentPhaseAttached), framework.MaxTimeout, t.attachmentObjects()...)
115+
Expect(t.framework.CreateWithDeferredDeletion(ctx, t.attachmentObjects()...)).To(Succeed())
116+
util.UntilObjectPhase(ctx, string(v1alpha2.BlockDeviceAttachmentPhaseAttached), framework.MaxTimeout, t.attachmentObjects()...)
115117

116118
By("Waiting for all disks to become ready after consumers appear")
117-
util.UntilObjectPhase(string(v1alpha2.DiskReady), framework.LongTimeout, t.diskObjects()...)
119+
util.UntilObjectPhase(ctx, string(v1alpha2.DiskReady), framework.LongTimeout, t.diskObjects()...)
118120
}
119121

120122
func (t *currentReleaseSmokeTest) verifyVMsReady() {
@@ -132,7 +134,7 @@ func (t *currentReleaseSmokeTest) verifyVMsReady() {
132134

133135
func (t *currentReleaseSmokeTest) verifyVMsSurvivedUpgrade() {
134136
By("Waiting for upgraded virtual machines to be running")
135-
util.UntilObjectPhase(string(v1alpha2.MachineRunning), framework.LongTimeout, t.vmObjects()...)
137+
util.UntilObjectPhase(context.Background(), string(v1alpha2.MachineRunning), framework.LongTimeout, t.vmObjects()...)
136138

137139
By("Checking guest access after module upgrade")
138140
for _, vmScenario := range t.vms {

test/e2e/release/guest.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ import (
3333
)
3434

3535
const (
36-
lsblkJSONCommand = "sudo lsblk --bytes --json --nodeps --output NAME,SIZE,TYPE,MOUNTPOINTS"
37-
rootDiskNameCommand = `root_source=$(findmnt -no SOURCE /); root_disk=$(lsblk -ndo PKNAME "$root_source" 2>/dev/null | head -n1); if [ -n "$root_disk" ]; then echo "$root_disk"; else lsblk -ndo NAME "$root_source" | head -n1; fi`
36+
lsblkJSONCommand = "sudo lsblk --bytes --json --nodeps --output NAME,SIZE,TYPE,MOUNTPOINTS"
37+
rootDiskNameCommand = `root_source=$(findmnt -no SOURCE /); root_disk=$(lsblk -ndo PKNAME "$root_source" 2>/dev/null | head -n1); if [ -n "$root_disk" ]; then echo "$root_disk"; else lsblk -ndo NAME "$root_source" | head -n1; fi`
3838
maxCloudInitDiskSize = int64(4 * 1024 * 1024)
3939
)
4040

@@ -61,7 +61,7 @@ func (t *currentReleaseSmokeTest) expectGuestReady(vmScenario *vmScenario) {
6161
}
6262

6363
By(fmt.Sprintf("Waiting for guest agent on %s", vm.Name))
64-
util.UntilVMAgentReady(crclient.ObjectKeyFromObject(vm), framework.LongTimeout)
64+
util.UntilVMAgentReady(context.Background(), crclient.ObjectKeyFromObject(vm), framework.LongTimeout)
6565
}
6666

6767
func (t *currentReleaseSmokeTest) expectAdditionalDiskCount(vm *v1alpha2.VirtualMachine, expectedCount int) {

test/e2e/release/release_suite_test.go

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,18 @@ package release
1818

1919
import (
2020
"context"
21-
"fmt"
2221
"testing"
2322

2423
. "github.com/onsi/ginkgo/v2"
2524
. "github.com/onsi/gomega"
2625
"sigs.k8s.io/controller-runtime/pkg/log"
2726
"sigs.k8s.io/controller-runtime/pkg/log/zap"
2827

29-
"github.com/deckhouse/virtualization/api/core/v1alpha2"
3028
"github.com/deckhouse/virtualization/test/e2e/controller"
31-
"github.com/deckhouse/virtualization/test/e2e/internal/config"
3229
"github.com/deckhouse/virtualization/test/e2e/internal/framework"
33-
"github.com/deckhouse/virtualization/test/e2e/internal/precreatedcvi"
34-
"github.com/deckhouse/virtualization/test/e2e/internal/util"
30+
"github.com/deckhouse/virtualization/test/e2e/internal/precheck"
3531
)
3632

37-
var cviManager = precreatedcvi.NewManager()
38-
3933
func TestRelease(t *testing.T) {
4034
log.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true)))
4135
RegisterFailHandler(Fail)
@@ -45,23 +39,11 @@ func TestRelease(t *testing.T) {
4539
var _ = SynchronizedBeforeSuite(func() {
4640
controller.NewBeforeProcess1Body()
4741

48-
By("Creating or reusing precreated CVIs")
49-
err := cviManager.Bootstrap(context.Background())
50-
Expect(err).NotTo(HaveOccurred())
51-
52-
cvis := cviManager.CVIsAsObjects()
53-
By(fmt.Sprintf("Waiting for all %d precreated CVIs to be ready", len(cvis)))
54-
util.UntilObjectPhase(string(v1alpha2.ImageReady), framework.LongTimeout, cvis...)
42+
precheck.Run(framework.NewFramework(""), GinkgoLabelFilter())
5543
}, func() {})
5644

5745
var _ = SynchronizedAfterSuite(func() {
58-
if !config.IsCleanUpNeeded() || !config.IsPrecreatedCVICleanupNeeded() {
59-
return
60-
}
61-
62-
By("Cleaning up precreated CVIs")
63-
err := cviManager.Cleanup(context.Background())
64-
Expect(err).NotTo(HaveOccurred(), "Failed to delete precreated CVIs")
46+
precheck.CleanupPrecreatedCVIs(context.Background(), framework.NewFramework(""))
6547
}, func() {
6648
controller.NewAfterAllProcessBody()
6749
})

0 commit comments

Comments
 (0)