Skip to content

Commit 6da1c00

Browse files
author
Roman Sysoev
committed
chore(test): fix some problems
- increase context timeout in the ipam test - run complex-test in a single process - run log streamer in a single instance - ignore not found when deleting kustomized resources - fix some typos Signed-off-by: Roman Sysoev <[email protected]>
1 parent 9760455 commit 6da1c00

10 files changed

+26
-22
lines changed

tests/e2e/affinity_toleration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ var _ = Describe("Virtual machine affinity and toleration", ginkgoutil.CommonE2E
463463

464464
Context("When test is completed", func() {
465465
It("deletes test case resources", func() {
466-
DeleteTestCaseResources(ResourcesToDelete{KustomizationDir: conf.TestData.AffinityToleration})
466+
DeleteTestCaseResources(ns, ResourcesToDelete{KustomizationDir: conf.TestData.AffinityToleration})
467467
})
468468
})
469469
})

tests/e2e/complex_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
kc "github.com/deckhouse/virtualization/tests/e2e/kubectl"
3131
)
3232

33-
var _ = Describe("Complex test", ginkgoutil.CommonE2ETestDecorators(), func() {
33+
var _ = Describe("ComplexTest", Serial, ginkgoutil.CommonE2ETestDecorators(), func() {
3434
var (
3535
testCaseLabel = map[string]string{"testcase": "complex-test"}
3636
hasNoConsumerLabel = map[string]string{"hasNoConsumer": "complex-test"}

tests/e2e/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ require (
99
github.com/kubernetes-csi/external-snapshotter/client/v8 v8.0.0
1010
github.com/onsi/ginkgo/v2 v2.21.0
1111
github.com/onsi/gomega v1.35.1
12+
golang.org/x/sync v0.8.0
1213
gopkg.in/yaml.v3 v3.0.1
1314
k8s.io/api v0.32.3
1415
k8s.io/apimachinery v0.32.3
@@ -64,7 +65,6 @@ require (
6465
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
6566
golang.org/x/net v0.30.0 // indirect
6667
golang.org/x/oauth2 v0.23.0 // indirect
67-
golang.org/x/sync v0.8.0 // indirect
6868
golang.org/x/sys v0.26.0 // indirect
6969
golang.org/x/term v0.25.0 // indirect
7070
golang.org/x/text v0.19.0 // indirect

tests/e2e/ipam_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ var _ = Describe("IPAM", ginkgoutil.CommonE2ETestDecorators(), func() {
5959
})
6060

6161
BeforeEach(func() {
62-
ctx, cancel = context.WithTimeout(context.Background(), 30*time.Second)
62+
ctx, cancel = context.WithTimeout(context.Background(), 50*time.Second)
6363

6464
vmip = &virtv2.VirtualMachineIPAddress{
6565
ObjectMeta: metav1.ObjectMeta{

tests/e2e/tests_suite_test.go

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -171,20 +171,15 @@ func TestTests(t *testing.T) {
171171
RegisterFailHandler(Fail)
172172
fmt.Fprintf(GinkgoWriter, "Starting test suite\n")
173173
RunSpecs(t, "Tests")
174-
175-
if (ginkgoutil.FailureBehaviourEnvSwitcher{}).IsStopOnFailure() || !config.IsCleanUpNeeded() {
176-
return
177-
}
178174
}
179175

180176
var _ = SynchronizedBeforeSuite(func() {
181-
// TODO: get kustomization files from testdata directory when all tests will be refactored
182177
var kustomizationFiles []string
183178
v := reflect.ValueOf(conf.TestData)
184179
t := reflect.TypeOf(conf.TestData)
185180

186181
if v.Kind() == reflect.Struct {
187-
for i := 0; i < v.NumField(); i++ {
182+
for i := range v.NumField() {
188183
field := v.Field(i)
189184
fieldType := t.Field(i)
190185

@@ -216,11 +211,11 @@ var _ = SynchronizedBeforeSuite(func() {
216211
} else {
217212
log.Println("Run test in REUSABLE mode")
218213
}
219-
}, func() {
220-
// StartV12nControllerLogStream(logStreamByV12nControllerPod)
221-
})
222214

223-
var _ = SynchronizedAfterSuite(func() {
215+
StartV12nControllerLogStream(logStreamByV12nControllerPod)
216+
}, func() {})
217+
218+
var _ = SynchronizedAfterSuite(func() {}, func() {
224219
errs := make([]error, 0)
225220
checkErrs := CheckV12nControllerRestarts(logStreamByV12nControllerPod)
226221
if len(checkErrs) != 0 {
@@ -231,7 +226,11 @@ var _ = SynchronizedAfterSuite(func() {
231226
errs = append(errs, stopErrs...)
232227
}
233228
Expect(errs).Should(BeEmpty())
234-
}, func() {
229+
230+
if (ginkgoutil.FailureBehaviourEnvSwitcher{}).IsStopOnFailure() || !config.IsCleanUpNeeded() {
231+
return
232+
}
233+
235234
err := Cleanup()
236235
if err != nil {
237236
log.Fatal(err)
@@ -241,7 +240,11 @@ var _ = SynchronizedAfterSuite(func() {
241240
func Cleanup() error {
242241
var eg errgroup.Group
243242

244-
eg.Go(deleteProject)
243+
err := deleteProject()
244+
if err != nil {
245+
return err
246+
}
247+
245248
eg.Go(deleteNamespaces)
246249
eg.Go(deleteResources)
247250

tests/e2e/util_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,7 @@ func DeleteTestCaseResources(ns string, resources ResourcesToDelete) {
551551
res := kubectl.Delete(kc.DeleteOptions{
552552
Filename: []string{resources.KustomizationDir},
553553
FilenameOption: kc.Kustomize,
554+
IgnoreNotFound: true,
554555
})
555556
Expect(res.Error()).NotTo(HaveOccurred(), fmt.Sprintf("%s\nkustomizationDir: %s\ncmd: %s\nstderr: %s", errMessage, resources.KustomizationDir, res.GetCmd(), res.StdErr()))
556557
}

tests/e2e/vd_snapshots_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const (
4646
var _ = Describe("VirtualDiskSnapshots", ginkgoutil.CommonE2ETestDecorators(), func() {
4747
var (
4848
defaultVolumeSnapshotClassName string
49-
testCaseLabel = map[string]string{"testcase": "vd-snapshots"}
49+
testCaseLabel = map[string]string{"testcase": "vd-snapshots", "id": namePrefix}
5050
attachedVirtualDiskLabel = map[string]string{"attachedVirtualDisk": ""}
5151
hasNoConsumerLabel = map[string]string{"hasNoConsumer": "vd-snapshots"}
5252
vmAutomaticWithHotplug = map[string]string{"vm": "automatic-with-hotplug"}

tests/e2e/vm_configuration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ func CheckCPUCoresNumber(approvalMode, stage string, requiredValue int, vmNamesp
315315
}
316316
}
317317

318-
func CheckCPUCoresNumberFromVirtualMachine(requiredValue string, vmNamespace string, vmNames ...string) {
318+
func CheckCPUCoresNumberFromVirtualMachine(requiredValue, vmNamespace string, vmNames ...string) {
319319
By("Checking the number of processor cores after changing from virtual machine")
320320
for _, vmName := range vmNames {
321321
cmd := "nproc --all"

tests/e2e/vm_connectivity_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const (
4141
nginxActiveStatus = "active"
4242
)
4343

44-
var _ = Describe(fmt.Sprintf("VirtualMachineConnectivity %d", GinkgoParallelProcess()), ginkgoutil.CommonE2ETestDecorators(), func() {
44+
var _ = Describe("VirtualMachineConnectivity", ginkgoutil.CommonE2ETestDecorators(), func() {
4545
var (
4646
testCaseLabel = map[string]string{"testcase": "vm-connectivity"}
4747
aObjName = fmt.Sprintf("%s-vm-connectivity-a", namePrefix)
@@ -314,7 +314,7 @@ func CheckCiliumAgents(kubectl kc.Kubectl, namespace string, vms ...string) {
314314
}
315315
}
316316

317-
func CheckExternalConnection(host, httpCode string, vmNamespace string, vmNames ...string) {
317+
func CheckExternalConnection(host, httpCode, vmNamespace string, vmNames ...string) {
318318
GinkgoHelper()
319319
for _, vmName := range vmNames {
320320
By(fmt.Sprintf("Response code from %q should be %q for %q", host, httpCode, vmName))

tests/e2e/vm_version_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ var _ = Describe("VirtualMachineVersions", ginkgoutil.CommonE2ETestDecorators(),
9494
})
9595
Expect(err).NotTo(HaveOccurred())
9696

97-
It("has qemu version is status", func() {
97+
It("has qemu version in the status", func() {
9898
for _, vm := range vms.Items {
9999
Expect(vm.Status.Versions.Qemu).NotTo(BeEmpty())
100100
}
101101
})
102102

103-
It("has libvirt version is status", func() {
103+
It("has libvirt version in the status", func() {
104104
for _, vm := range vms.Items {
105105
Expect(vm.Status.Versions.Libvirt).NotTo(BeEmpty())
106106
}

0 commit comments

Comments
 (0)