diff --git a/tests/e2e/.golangci.yaml b/tests/e2e/.golangci.yaml new file mode 100644 index 0000000000..6a3506df90 --- /dev/null +++ b/tests/e2e/.golangci.yaml @@ -0,0 +1,84 @@ +run: + concurrency: 4 + timeout: 10m +issues: + # Show all errors. + max-issues-per-linter: 0 + max-same-issues: 0 + exclude: + - "don't use an underscore in package name" +output: + sort-results: true + +exclude-files: + - "^zz_generated.*" + +linters-settings: + gofumpt: + extra-rules: true + gci: + sections: + - standard + - default + - prefix(github.com/deckhouse/) + goimports: + local-prefixes: github.com/deckhouse/ + errcheck: + exclude-functions: fmt:.*,[rR]ead|[wW]rite|[cC]lose,io:Copy + revive: + rules: + - name: dot-imports + disabled: true + stylecheck: + dot-import-whitelist: + - github.com/onsi/gomega + - github.com/onsi/ginkgo/v2 + - github.com/deckhouse/virtualization/tests/e2e/helper + nolintlint: + # Exclude following linters from requiring an explanation. + # Default: [] + allow-no-explanation: [funlen, gocognit, lll] + # Enable to require an explanation of nonzero length after each nolint directive. + # Default: false + require-explanation: true + # Enable to require nolint directives to mention the specific linter being suppressed. + # Default: false + require-specific: true + +linters: + disable-all: true + enable: + - asciicheck # checks that your code does not contain non-ASCII identifiers + - bidichk # checks for dangerous unicode character sequences + - bodyclose # checks whether HTTP response body is closed successfully + - contextcheck # [maby too many false positives] checks the function whether use a non-inherited context + - dogsled # checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()) + - errcheck # checking for unchecked errors, these unchecked errors can be critical bugs in some cases + - errname # checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error + - errorlint # finds code that will cause problems with the error wrapping scheme introduced in Go 1.13 + - copyloopvar # detects places where loop variables are copied (Go 1.22+) + - gci # controls golang package import order and makes it always deterministic + - gocritic # provides diagnostics that check for bugs, performance and style issues + - gofmt # [replaced by goimports] checks whether code was gofmt-ed + - gofumpt # [replaced by goimports, gofumports is not available yet] checks whether code was gofumpt-ed + - goimports # in addition to fixing imports, goimports also formats your code in the same style as gofmt + - gosimple # specializes in simplifying a code + - govet # reports suspicious constructs, such as Printf calls whose arguments do not align with the format string + - ineffassign # detects when assignments to existing variables are not used + - misspell # finds commonly misspelled English words in comments + - nolintlint # reports ill-formed or insufficient nolint directives + - reassign # Checks that package variables are not reassigned. + - revive # fast, configurable, extensible, flexible, and beautiful linter for Go, drop-in replacement of golint + - stylecheck # is a replacement for golint + - staticcheck # is a go vet on steroids, applying a ton of static analysis checks + - typecheck # like the front-end of a Go compiler, parses and type-checks Go code + - testifylint # checks usage of github.com/stretchr/testify + - unconvert # removes unnecessary type conversions + - unparam # reports unused function parameters + - unused # checks for unused constants, variables, functions and types + - usetesting # reports uses of functions with replacement inside the testing package + - testableexamples # checks if examples are testable (have an expected output) + - thelper # detects golang test helpers without t.Helper() call and checks the consistency of test helpers + - tparallel # detects inappropriate usage of t.Parallel() method in your Go test codes + - whitespace # detects leading and trailing whitespace + - wastedassign # Finds wasted assignment statements. diff --git a/tests/e2e/Taskfile.yaml b/tests/e2e/Taskfile.yaml index 38cdbc85d6..4ec3de1daa 100644 --- a/tests/e2e/Taskfile.yaml +++ b/tests/e2e/Taskfile.yaml @@ -159,12 +159,12 @@ tasks: echo "Error: Deckhouse is not ready." exit 1 fi - d8 k patch mpo virtualization --type merge -p "{\"spec\":{\"imageTag\":\"$v12n_tag\"}}" + d8 k patch mpo virtualization --type merge -p "{\"spec\":{\"imageTag\":\"$v12n_tag\"}}" images_hash=$(crane export "dev-registry.deckhouse.io/sys/deckhouse-oss/modules/virtualization:$v12n_tag" - | tar -Oxf - images_digests.json) v12n_pods=$(kubectl -n d8-virtualization get pods -o json | jq -c) retry_count=0 max_retries=120 - sleep_interval=5 + sleep_interval=5 while true; do all_hashes_found=true @@ -193,7 +193,7 @@ tasks: if [ "$all_hashes_found" = true ]; then echo "All image hashes found in pods." break - fi + fi retry_count=$((retry_count + 1)) echo "Some hashes are missing, rechecking... Attempt: $retry_count" @@ -206,3 +206,22 @@ tasks: # Wait for the specified interval before retrying sleep "$sleep_interval" done + + _ensure:golangci-lint: + desc: "Ensure golangci-lint is available" + internal: true + cmds: + - | + echo -e >&2 "Please install golangci-lint https://golangci-lint.run/usage/install/" + exit 1 + status: + - | + [ -f ./golangci-lint ] || which golangci-lint + + lint:go: + desc: "Run golangci-lint" + deps: + - _ensure:golangci-lint + cmds: + - | + golangci-lint run --sort-results diff --git a/tests/e2e/affinity_toleration_test.go b/tests/e2e/affinity_toleration_test.go index 3586b6a443..e69b3dbe01 100644 --- a/tests/e2e/affinity_toleration_test.go +++ b/tests/e2e/affinity_toleration_test.go @@ -228,7 +228,7 @@ var _ = Describe("Virtual machine affinity and toleration", ginkgoutil.CommonE2E }) }) By("`VirtualMachines` agents should be ready", func() { - WaitVmAgentReady(kc.WaitOptions{ + WaitVMAgentReady(kc.WaitOptions{ Labels: testCaseLabel, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, @@ -274,12 +274,12 @@ var _ = Describe("Virtual machine affinity and toleration", ginkgoutil.CommonE2E ExpectVirtualMachineIsMigratable(vmObjC) p, err := GenerateVirtualMachineAndPodAntiAffinityPatch(vmKey, nodeLabelKey, metav1.LabelSelectorOpIn, []string{vmA[vmKey]}) Expect(err).NotTo(HaveOccurred(), "failed to generate the `VirtualMachineAndPodAntiAffinity` patch") - jsonPatchAdd := &kc.JsonPatch{ + jsonPatchAdd := &kc.JSONPatch{ Op: "add", Path: "/spec/affinity/virtualMachineAndPodAntiAffinity", Value: string(p), } - jsonPatchRemove := &kc.JsonPatch{ + jsonPatchRemove := &kc.JSONPatch{ Op: "remove", Path: "/spec/affinity/virtualMachineAndPodAffinity", } @@ -288,21 +288,21 @@ var _ = Describe("Virtual machine affinity and toleration", ginkgoutil.CommonE2E defer GinkgoRecover() defer wg.Done() Eventually(func() error { - updatedVmObjC := &virtv2.VirtualMachine{} - err := GetObject(virtv2.VirtualMachineResource, vmObjC.Name, updatedVmObjC, kc.GetOptions{ + updatedVMObjC := &virtv2.VirtualMachine{} + err := GetObject(virtv2.VirtualMachineResource, vmObjC.Name, updatedVMObjC, kc.GetOptions{ Namespace: conf.Namespace, }) if err != nil { return err } - if updatedVmObjC.Status.Phase != virtv2.MachineMigrating { + if updatedVMObjC.Status.Phase != virtv2.MachineMigrating { return fmt.Errorf("the `VirtualMachine` should be %s", virtv2.MachineMigrating) } return nil }).WithTimeout(Timeout).WithPolling(migratingStatusPollingInterval).Should(Succeed()) }() res := kubectl.PatchResource(kc.ResourceVM, vmObjC.Name, kc.PatchOptions{ - JsonPatch: []*kc.JsonPatch{ + JSONPatch: []*kc.JSONPatch{ jsonPatchAdd, jsonPatchRemove, }, @@ -311,44 +311,44 @@ var _ = Describe("Virtual machine affinity and toleration", ginkgoutil.CommonE2E Expect(res.Error()).NotTo(HaveOccurred(), "failed to patch the %q `VirtualMachine`", vmC) wg.Wait() - WaitVmAgentReady(kc.WaitOptions{ + WaitVMAgentReady(kc.WaitOptions{ Labels: vmC, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, }) - updatedVmObjC := &virtv2.VirtualMachine{} - err = GetObject(virtv2.VirtualMachineResource, vmObjC.Name, updatedVmObjC, kc.GetOptions{ + updatedVMObjC := &virtv2.VirtualMachine{} + err = GetObject(virtv2.VirtualMachineResource, vmObjC.Name, updatedVMObjC, kc.GetOptions{ Namespace: conf.Namespace, }) Expect(err).NotTo(HaveOccurred(), "failed to obtain the %q `VirtualMachine` object", vmC) - Expect(updatedVmObjC.Status.MigrationState.Source.Node).Should(Equal(vmObjC.Status.Node)) - Expect(updatedVmObjC.Status.MigrationState.Target.Node).ShouldNot(Equal(vmObjA.Status.Node)) - Expect(updatedVmObjC.Status.Node).ShouldNot(Equal(vmObjA.Status.Node)) + Expect(updatedVMObjC.Status.MigrationState.Source.Node).Should(Equal(vmObjC.Status.Node)) + Expect(updatedVMObjC.Status.MigrationState.Target.Node).ShouldNot(Equal(vmObjA.Status.Node)) + Expect(updatedVMObjC.Status.Node).ShouldNot(Equal(vmObjA.Status.Node)) }) By("Change anti-affinity to affinity when the `VirtualMachines` are runnning: `vm-a` and `vm-c` should be running on the same node", func() { wg := &sync.WaitGroup{} - updatedVmObjC := &virtv2.VirtualMachine{} - err = GetObject(virtv2.VirtualMachineResource, vmObjC.Name, updatedVmObjC, kc.GetOptions{ + updatedVMObjC := &virtv2.VirtualMachine{} + err = GetObject(virtv2.VirtualMachineResource, vmObjC.Name, updatedVMObjC, kc.GetOptions{ Namespace: conf.Namespace, }) - ExpectVirtualMachineIsMigratable(updatedVmObjC) + ExpectVirtualMachineIsMigratable(updatedVMObjC) p, err := GenerateVirtualMachineAndPodAffinityPatch(vmKey, nodeLabelKey, metav1.LabelSelectorOpIn, []string{vmA[vmKey]}) Expect(err).NotTo(HaveOccurred(), "failed to generate the `VirtualMachineAndPodAffinity` patch") - jsonPatchAdd := &kc.JsonPatch{ + jsonPatchAdd := &kc.JSONPatch{ Op: "add", Path: "/spec/affinity/virtualMachineAndPodAffinity", Value: string(p), } - jsonPatchRemove := &kc.JsonPatch{ + jsonPatchRemove := &kc.JSONPatch{ Op: "remove", Path: "/spec/affinity/virtualMachineAndPodAntiAffinity", } migrationInitiatedAt := time.Now().UTC() res := kubectl.PatchResource(kc.ResourceVM, vmObjC.Name, kc.PatchOptions{ - JsonPatch: []*kc.JsonPatch{ + JSONPatch: []*kc.JSONPatch{ jsonPatchAdd, jsonPatchRemove, }, @@ -361,27 +361,27 @@ var _ = Describe("Virtual machine affinity and toleration", ginkgoutil.CommonE2E defer GinkgoRecover() defer wg.Done() Eventually(func() error { - updatedVmObjC = &virtv2.VirtualMachine{} - err = GetObject(virtv2.VirtualMachineResource, vmObjC.Name, updatedVmObjC, kc.GetOptions{ + updatedVMObjC = &virtv2.VirtualMachine{} + err = GetObject(virtv2.VirtualMachineResource, vmObjC.Name, updatedVMObjC, kc.GetOptions{ Namespace: conf.Namespace, }) if err != nil { return err } - if updatedVmObjC.Status.MigrationState == nil || updatedVmObjC.Status.MigrationState.StartTimestamp == nil || updatedVmObjC.Status.MigrationState.StartTimestamp.UTC().Before(migrationInitiatedAt) { + if updatedVMObjC.Status.MigrationState == nil || updatedVMObjC.Status.MigrationState.StartTimestamp == nil || updatedVMObjC.Status.MigrationState.StartTimestamp.UTC().Before(migrationInitiatedAt) { return errors.New("couldn't wait for the migration to start") } - if updatedVmObjC.Status.MigrationState.Source.Node == vmObjA.Status.Node { + if updatedVMObjC.Status.MigrationState.Source.Node == vmObjA.Status.Node { return errors.New("migration should start from a different node") } - if updatedVmObjC.Status.MigrationState.Target.Node != vmObjA.Status.Node { + if updatedVMObjC.Status.MigrationState.Target.Node != vmObjA.Status.Node { return errors.New("migration should end at the same node") } - if updatedVmObjC.Status.Node != vmObjA.Status.Node { + if updatedVMObjC.Status.Node != vmObjA.Status.Node { return errors.New("migration should end at the same node") } @@ -391,7 +391,7 @@ var _ = Describe("Virtual machine affinity and toleration", ginkgoutil.CommonE2E wg.Wait() - WaitVmAgentReady(kc.WaitOptions{ + WaitVMAgentReady(kc.WaitOptions{ Labels: vmC, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, @@ -420,30 +420,30 @@ var _ = Describe("Virtual machine affinity and toleration", ginkgoutil.CommonE2E }) By("The `VirtualMachine` should not be migrated", func() { time.Sleep(20 * time.Second) - updatedVmObj := &virtv2.VirtualMachine{} - err := GetObject(virtv2.VirtualMachineResource, vmObj.Name, updatedVmObj, kc.GetOptions{ + updatedVMObj := &virtv2.VirtualMachine{} + err := GetObject(virtv2.VirtualMachineResource, vmObj.Name, updatedVMObj, kc.GetOptions{ Namespace: conf.Namespace, }) Expect(err).NotTo(HaveOccurred(), "failed to obtain the %q `VirtualMachine` object", vmNodeSelector) - for _, c := range updatedVmObj.Status.Conditions { + for _, c := range updatedVMObj.Status.Conditions { if c.Type == string(vmcondition.TypeMigrating) { Expect(c.Status).Should(Equal(metav1.ConditionFalse)) } } - Expect(updatedVmObj.Status.MigrationState).Should(BeNil()) - Expect(updatedVmObj.Status.Node).Should(Equal(sourceNode)) + Expect(updatedVMObj.Status.MigrationState).Should(BeNil()) + Expect(updatedVMObj.Status.Node).Should(Equal(sourceNode)) }) By("Sets the `spec.nodeSelector` with `another node` value", func() { wg := &sync.WaitGroup{} - updatedVmObj := &virtv2.VirtualMachine{} - err := GetObject(virtv2.VirtualMachineResource, vmObj.Name, updatedVmObj, kc.GetOptions{ + updatedVMObj := &virtv2.VirtualMachine{} + err := GetObject(virtv2.VirtualMachineResource, vmObj.Name, updatedVMObj, kc.GetOptions{ Namespace: conf.Namespace, }) Expect(err).NotTo(HaveOccurred(), "failed to obtain the %q `VirtualMachine` object", vmNodeSelector) - Expect(updatedVmObj.Status.MigrationState).Should(BeNil()) + Expect(updatedVMObj.Status.MigrationState).Should(BeNil()) - sourceNode := updatedVmObj.Status.Node + sourceNode := updatedVMObj.Status.Node Expect(sourceNode).ShouldNot(BeEmpty(), "the `vm.status.nodeName` should have a value") targetNode, err = DefineTargetNode(sourceNode, workerNodeLabel) @@ -453,14 +453,14 @@ var _ = Describe("Virtual machine affinity and toleration", ginkgoutil.CommonE2E defer GinkgoRecover() defer wg.Done() Eventually(func() error { - updatedVmObj := &virtv2.VirtualMachine{} - err := GetObject(virtv2.VirtualMachineResource, vmObj.Name, updatedVmObj, kc.GetOptions{ + updatedVMObj := &virtv2.VirtualMachine{} + err := GetObject(virtv2.VirtualMachineResource, vmObj.Name, updatedVMObj, kc.GetOptions{ Namespace: conf.Namespace, }) if err != nil { return err } - if updatedVmObj.Status.Phase != virtv2.MachineMigrating { + if updatedVMObj.Status.Phase != virtv2.MachineMigrating { return fmt.Errorf("the `VirtualMachine` should be %s", virtv2.MachineMigrating) } return nil @@ -472,19 +472,19 @@ var _ = Describe("Virtual machine affinity and toleration", ginkgoutil.CommonE2E wg.Wait() }) By("The `VirtualMachine` should be migrated", func() { - WaitVmAgentReady(kc.WaitOptions{ + WaitVMAgentReady(kc.WaitOptions{ Labels: vmNodeSelector, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, }) - updatedVmObj := &virtv2.VirtualMachine{} - err := GetObject(virtv2.VirtualMachineResource, vmObj.Name, updatedVmObj, kc.GetOptions{ + updatedVMObj := &virtv2.VirtualMachine{} + err := GetObject(virtv2.VirtualMachineResource, vmObj.Name, updatedVMObj, kc.GetOptions{ Namespace: conf.Namespace, }) Expect(err).NotTo(HaveOccurred(), "failed to obtain the %q `VirtualMachine` object", vmNodeSelector) - Expect(updatedVmObj.Status.MigrationState.Source.Node).Should(Equal(sourceNode)) - Expect(updatedVmObj.Status.MigrationState.Target.Node).Should(Equal(targetNode)) - Expect(updatedVmObj.Status.Node).Should(Equal(targetNode)) + Expect(updatedVMObj.Status.MigrationState.Source.Node).Should(Equal(sourceNode)) + Expect(updatedVMObj.Status.MigrationState.Target.Node).Should(Equal(targetNode)) + Expect(updatedVMObj.Status.Node).Should(Equal(targetNode)) }) }) }) @@ -512,30 +512,30 @@ var _ = Describe("Virtual machine affinity and toleration", ginkgoutil.CommonE2E }) By("The `VirtualMachine` should not be migrated", func() { time.Sleep(20 * time.Second) - updatedVmObj := &virtv2.VirtualMachine{} - err := GetObject(virtv2.VirtualMachineResource, vmObj.Name, updatedVmObj, kc.GetOptions{ + updatedVMObj := &virtv2.VirtualMachine{} + err := GetObject(virtv2.VirtualMachineResource, vmObj.Name, updatedVMObj, kc.GetOptions{ Namespace: conf.Namespace, }) Expect(err).NotTo(HaveOccurred(), "failed to obtain the %q `VirtualMachine` object", vmNodeAffinity) - for _, c := range updatedVmObj.Status.Conditions { + for _, c := range updatedVMObj.Status.Conditions { if c.Type == string(vmcondition.TypeMigrating) { Expect(c.Status).Should(Equal(metav1.ConditionFalse)) } } - Expect(updatedVmObj.Status.MigrationState).Should(BeNil()) - Expect(updatedVmObj.Status.Node).Should(Equal(sourceNode)) + Expect(updatedVMObj.Status.MigrationState).Should(BeNil()) + Expect(updatedVMObj.Status.Node).Should(Equal(sourceNode)) }) By("Sets the `spec.affinity.nodeAffinity` with `another node` value", func() { wg := &sync.WaitGroup{} - updatedVmObj := &virtv2.VirtualMachine{} - err := GetObject(virtv2.VirtualMachineResource, vmObj.Name, updatedVmObj, kc.GetOptions{ + updatedVMObj := &virtv2.VirtualMachine{} + err := GetObject(virtv2.VirtualMachineResource, vmObj.Name, updatedVMObj, kc.GetOptions{ Namespace: conf.Namespace, }) Expect(err).NotTo(HaveOccurred(), "failed to obtain the %q `VirtualMachine` object", vmNodeAffinity) - Expect(updatedVmObj.Status.MigrationState).Should(BeNil()) + Expect(updatedVMObj.Status.MigrationState).Should(BeNil()) - sourceNode = updatedVmObj.Status.Node + sourceNode = updatedVMObj.Status.Node Expect(sourceNode).ShouldNot(BeEmpty(), "the `vm.status.nodeName` should have a value") targetNode, err = DefineTargetNode(sourceNode, workerNodeLabel) @@ -548,14 +548,14 @@ var _ = Describe("Virtual machine affinity and toleration", ginkgoutil.CommonE2E defer GinkgoRecover() defer wg.Done() Eventually(func() error { - updatedVmObj := &virtv2.VirtualMachine{} - err := GetObject(virtv2.VirtualMachineResource, vmObj.Name, updatedVmObj, kc.GetOptions{ + updatedVMObj := &virtv2.VirtualMachine{} + err := GetObject(virtv2.VirtualMachineResource, vmObj.Name, updatedVMObj, kc.GetOptions{ Namespace: conf.Namespace, }) if err != nil { return err } - if updatedVmObj.Status.Phase != virtv2.MachineMigrating { + if updatedVMObj.Status.Phase != virtv2.MachineMigrating { return fmt.Errorf("the `VirtualMachine` should be %s", virtv2.MachineMigrating) } return nil @@ -567,19 +567,19 @@ var _ = Describe("Virtual machine affinity and toleration", ginkgoutil.CommonE2E wg.Wait() }) By("The `VirtualMachine` should be migrated", func() { - WaitVmAgentReady(kc.WaitOptions{ + WaitVMAgentReady(kc.WaitOptions{ Labels: vmNodeAffinity, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, }) - updatedVmObj := &virtv2.VirtualMachine{} - err := GetObject(virtv2.VirtualMachineResource, vmObj.Name, updatedVmObj, kc.GetOptions{ + updatedVMObj := &virtv2.VirtualMachine{} + err := GetObject(virtv2.VirtualMachineResource, vmObj.Name, updatedVMObj, kc.GetOptions{ Namespace: conf.Namespace, }) Expect(err).NotTo(HaveOccurred(), "failed to obtain the %q `VirtualMachine` object", vmNodeAffinity) - Expect(updatedVmObj.Status.MigrationState.Source.Node).Should(Equal(sourceNode)) - Expect(updatedVmObj.Status.MigrationState.Target.Node).Should(Equal(targetNode)) - Expect(updatedVmObj.Status.Node).Should(Equal(targetNode)) + Expect(updatedVMObj.Status.MigrationState.Source.Node).Should(Equal(sourceNode)) + Expect(updatedVMObj.Status.MigrationState.Target.Node).Should(Equal(targetNode)) + Expect(updatedVMObj.Status.Node).Should(Equal(targetNode)) }) }) }) diff --git a/tests/e2e/complex_test.go b/tests/e2e/complex_test.go index 7cc0626b90..274915f25e 100644 --- a/tests/e2e/complex_test.go +++ b/tests/e2e/complex_test.go @@ -34,19 +34,19 @@ 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 { - return fmt.Errorf("%s\n%s", assignErr, err) + return fmt.Errorf("%s\n%w", assignErr, err) } patch := fmt.Sprintf("{\"spec\":{\"staticIP\":%q}}", unassignedIP) err = MergePatchResource(kc.ResourceVMIP, name, patch) if err != nil { - return fmt.Errorf("%s\n%s", assignErr, err) + return fmt.Errorf("%s\n%w", assignErr, err) } vmip := virtv2.VirtualMachineIPAddress{} err = GetObject(kc.ResourceVMIP, name, &vmip, kc.GetOptions{ Namespace: conf.Namespace, }) if err != nil { - return fmt.Errorf("%s\n%s", assignErr, err) + return fmt.Errorf("%s\n%w", assignErr, err) } jsonPath := fmt.Sprintf("'jsonpath={.status.phase}=%s'", PhaseAttached) waitOpts := kc.WaitOptions{ @@ -182,7 +182,7 @@ var _ = Describe("Complex test", ginkgoutil.CommonE2ETestDecorators(), func() { Context("When virtual machines are applied", func() { It("checks VMs phases", func() { By("Virtual machine agents should be ready") - WaitVmAgentReady(kc.WaitOptions{ + WaitVMAgentReady(kc.WaitOptions{ Labels: testCaseLabel, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, @@ -312,7 +312,7 @@ var _ = Describe("Complex test", ginkgoutil.CommonE2ETestDecorators(), func() { Timeout: MaxWaitTimeout, }) By("Virtual machine agents should be ready") - WaitVmAgentReady(kc.WaitOptions{ + WaitVMAgentReady(kc.WaitOptions{ Labels: testCaseLabel, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, @@ -370,7 +370,7 @@ var _ = Describe("Complex test", ginkgoutil.CommonE2ETestDecorators(), func() { Timeout: MaxWaitTimeout, }) By("Virtual machine agents should be ready") - WaitVmAgentReady(kc.WaitOptions{ + WaitVMAgentReady(kc.WaitOptions{ Labels: testCaseLabel, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, @@ -400,7 +400,7 @@ var _ = Describe("Complex test", ginkgoutil.CommonE2ETestDecorators(), func() { Timeout: MaxWaitTimeout, }) By("Virtual machine agents should be ready") - WaitVmAgentReady(kc.WaitOptions{ + WaitVMAgentReady(kc.WaitOptions{ Labels: testCaseLabel, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, @@ -437,7 +437,7 @@ var _ = Describe("Complex test", ginkgoutil.CommonE2ETestDecorators(), func() { RebootVirtualMachinesBySSH(vms...) By("Virtual machines agent should be ready", func() { - WaitVmAgentReady(kc.WaitOptions{ + WaitVMAgentReady(kc.WaitOptions{ Labels: testCaseLabel, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, @@ -473,7 +473,7 @@ var _ = Describe("Complex test", ginkgoutil.CommonE2ETestDecorators(), func() { Expect(res.Error()).NotTo(HaveOccurred()) By("Virtual machines agent should be ready", func() { - WaitVmAgentReady(kc.WaitOptions{ + WaitVMAgentReady(kc.WaitOptions{ Labels: testCaseLabel, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, diff --git a/tests/e2e/config/clustertransport/kube_connection_settings.go b/tests/e2e/config/clustertransport/kube_connection_settings.go index 0f963588d8..5c4da236d0 100644 --- a/tests/e2e/config/clustertransport/kube_connection_settings.go +++ b/tests/e2e/config/clustertransport/kube_connection_settings.go @@ -25,7 +25,7 @@ type ClusterTransport struct { Token string `yaml:"token"` Endpoint string `yaml:"endpoint"` CertificateAuthority string `yaml:"certificateAuthority"` - InsecureTls bool `yaml:"insecureTls"` + InsecureTLS bool `yaml:"insecureTls"` } // KubeConnectionCmdSettings returns environment variables and arguments for kubectl command @@ -52,7 +52,7 @@ func KubeConnectionCmdSettings(conf ClusterTransport) (env, args []string, err e if conf.CertificateAuthority != "" { args = append(args, fmt.Sprintf("--certificate-authority=%s", conf.CertificateAuthority)) } - if conf.InsecureTls { + if conf.InsecureTLS { args = append(args, "--insecure-skip-tls-verify=true") } diff --git a/tests/e2e/config/config.go b/tests/e2e/config/config.go index e25795203e..d6f9cf4c56 100644 --- a/tests/e2e/config/config.go +++ b/tests/e2e/config/config.go @@ -75,7 +75,7 @@ func GetConfig() (*Config, error) { } type ModuleConfig struct { - ApiVersion string `yaml:"apiVersion"` + APIVersion string `yaml:"apiVersion"` Kind string `yaml:"kind"` Metadata Metadata `yaml:"metadata"` Spec Spec `yaml:"spec"` @@ -108,7 +108,7 @@ type Storage struct { } type Kustomize struct { - ApiVersion string `yaml:"apiVersion"` + APIVersion string `yaml:"apiVersion"` Labels []KustomizeLabel `yaml:"labels"` Configurations []string `yaml:"configurations"` Kind string `yaml:"kind"` @@ -125,7 +125,7 @@ type KustomizeLabel struct { type Config struct { ClusterTransport ClusterTransport `yaml:"clusterTransport"` Disks DisksConf `yaml:"disks"` - VM VmConf `yaml:"vm"` + VM VMConf `yaml:"vm"` Ipam IpamConf `yaml:"ipam"` HelperImages HelperImages `yaml:"helperImages"` Namespace string `yaml:"namespaceSuffix"` @@ -145,16 +145,16 @@ type TestData struct { ImporterNetworkPolicy string `yaml:"importerNetworkPolicy"` ImageHotplug string `yaml:"imageHotplug"` ImagesCreation string `yaml:"imagesCreation"` - VmConfiguration string `yaml:"vmConfiguration"` - VmLabelAnnotation string `yaml:"vmLabelAnnotation"` - VmMigration string `yaml:"vmMigration"` - VmMigrationCancel string `yaml:"vmMigrationCancel"` - VmEvacuation string `yaml:"vmEvacuation"` - VmDiskAttachment string `yaml:"vmDiskAttachment"` - VmVersions string `yaml:"vmVersions"` + VMConfiguration string `yaml:"vmConfiguration"` + VMLabelAnnotation string `yaml:"vmLabelAnnotation"` + VMMigration string `yaml:"vmMigration"` + VMMigrationCancel string `yaml:"vmMigrationCancel"` + VMEvacuation string `yaml:"vmEvacuation"` + VMDiskAttachment string `yaml:"vmDiskAttachment"` + VMVersions string `yaml:"vmVersions"` VdSnapshots string `yaml:"vdSnapshots"` Sshkey string `yaml:"sshKey"` - SshUser string `yaml:"sshUser"` + SSHUser string `yaml:"sshUser"` IPAM string `yaml:"ipam"` } @@ -168,7 +168,7 @@ type ClusterTransport struct { Token string `yaml:"token"` Endpoint string `yaml:"endpoint"` CertificateAuthority string `yaml:"certificateAuthority"` - InsecureTls bool `yaml:"insecureTls"` + InsecureTLS bool `yaml:"insecureTls"` } type DisksConf struct { @@ -178,7 +178,7 @@ type DisksConf struct { VdTestDataDir string `yaml:"vdTestDataDir"` } -type VmConf struct { +type VMConf struct { TestDataDir string `yaml:"testDataDir"` } @@ -212,7 +212,7 @@ func (c *Config) setEnvs() error { if err != nil { return err } - c.ClusterTransport.InsecureTls = v + c.ClusterTransport.InsecureTLS = v } // DisksConf if e, ok := os.LookupEnv("E2E_DISKS_UPLOADHELPERIMAGE"); ok { @@ -241,7 +241,7 @@ func (c *Config) setEnvs() error { func (c *Config) GetTestCases() ([]string, error) { testDataValue := reflect.ValueOf(c.TestData) testDataType := reflect.TypeOf(c.TestData) - excludedData := []string{"Sshkey", "SshUser"} + excludedData := []string{"Sshkey", "SSHUser"} testCases := make([]string, 0, testDataType.NumField()-len(excludedData)) if testDataType.Kind() == reflect.Struct { diff --git a/tests/e2e/config/project.go b/tests/e2e/config/project.go index 7f353256ac..33afd5eda0 100644 --- a/tests/e2e/config/project.go +++ b/tests/e2e/config/project.go @@ -31,6 +31,7 @@ var kustomize *Kustomize func PrepareProject(testData string) { kustomization := fmt.Sprintf("%s/%s", testData, "kustomization.yaml") ns, err := kustomize.GetNamespace(kustomization) + Expect(err).NotTo(HaveOccurred(), err) project := Project{} projectFilePath := fmt.Sprintf("%s/project/project.yaml", testData) @@ -38,8 +39,7 @@ func PrepareProject(testData string) { Expect(err).NotTo(HaveOccurred(), "cannot get project from file: %s\nstderr: %s", projectFilePath, err) namePrefix, err := GetNamePrefix() - if err != nil { - } + Expect(err).NotTo(HaveOccurred(), "cannot get name prefix\nstderr: %s", err) project.Name = ns diff --git a/tests/e2e/d8/d8.go b/tests/e2e/d8/d8.go index f7e7cc8098..233967f67d 100644 --- a/tests/e2e/d8/d8.go +++ b/tests/e2e/d8/d8.go @@ -39,7 +39,7 @@ type d8VirtualizationCMD struct { cmd string } -type SshOptions struct { +type SSHOptions struct { Namespace string Username string IdenityFile string @@ -52,14 +52,14 @@ type D8VirtualizationConf struct { Token string Endpoint string CertificateAuthority string - InsecureTls bool + InsecureTLS bool } type D8Virtualization interface { - SshCommand(vmName, command string, opts SshOptions) *executor.CMDResult - StopVM(vmName string, opts SshOptions) *executor.CMDResult - StartVM(vmName string, opts SshOptions) *executor.CMDResult - RestartVM(vmName string, opts SshOptions) *executor.CMDResult + SSHCommand(vmName, command string, opts SSHOptions) *executor.CMDResult + StopVM(vmName string, opts SSHOptions) *executor.CMDResult + StartVM(vmName string, opts SSHOptions) *executor.CMDResult + RestartVM(vmName string, opts SSHOptions) *executor.CMDResult } func NewD8Virtualization(conf D8VirtualizationConf) (*d8VirtualizationCMD, error) { @@ -82,16 +82,16 @@ func NewD8Virtualization(conf D8VirtualizationConf) (*d8VirtualizationCMD, error }, nil } -func (v d8VirtualizationCMD) SshCommand(vmName, command string, opts SshOptions) *executor.CMDResult { +func (v d8VirtualizationCMD) SSHCommand(vmName, command string, opts SSHOptions) *executor.CMDResult { timeout := ShortTimeout if opts.Timeout != 0 { timeout = opts.Timeout } - localSshOpts := "--local-ssh-opts='-o StrictHostKeyChecking=no' --local-ssh-opts='-o UserKnownHostsFile=/dev/null' --local-ssh-opts='-o LogLevel=ERROR'" - localSshOpts = fmt.Sprintf("%s --local-ssh-opts='-o ConnectTimeout=%s'", localSshOpts, timeout.String()) + localSSHOpts := "--local-ssh-opts='-o StrictHostKeyChecking=no' --local-ssh-opts='-o UserKnownHostsFile=/dev/null' --local-ssh-opts='-o LogLevel=ERROR'" + localSSHOpts = fmt.Sprintf("%s --local-ssh-opts='-o ConnectTimeout=%s'", localSSHOpts, timeout.String()) - cmd := fmt.Sprintf("%s ssh %s -c '%s' --local-ssh=true %s", v.cmd, vmName, command, localSshOpts) + cmd := fmt.Sprintf("%s ssh %s -c '%s' --local-ssh=true %s", v.cmd, vmName, command, localSSHOpts) cmd = v.addNamespace(cmd, opts.Namespace) if opts.Username != "" { @@ -112,7 +112,7 @@ func (v d8VirtualizationCMD) SshCommand(vmName, command string, opts SshOptions) return v.ExecContext(ctx, cmd) } -func (v d8VirtualizationCMD) StartVM(vmName string, opts SshOptions) *executor.CMDResult { +func (v d8VirtualizationCMD) StartVM(vmName string, opts SSHOptions) *executor.CMDResult { timeout := ShortTimeout if opts.Timeout != 0 { timeout = opts.Timeout @@ -127,7 +127,7 @@ func (v d8VirtualizationCMD) StartVM(vmName string, opts SshOptions) *executor.C return v.ExecContext(ctx, cmd) } -func (v d8VirtualizationCMD) StopVM(vmName string, opts SshOptions) *executor.CMDResult { +func (v d8VirtualizationCMD) StopVM(vmName string, opts SSHOptions) *executor.CMDResult { timeout := ShortTimeout if opts.Timeout != 0 { timeout = opts.Timeout @@ -142,7 +142,7 @@ func (v d8VirtualizationCMD) StopVM(vmName string, opts SshOptions) *executor.CM return v.ExecContext(ctx, cmd) } -func (v d8VirtualizationCMD) RestartVM(vmName string, opts SshOptions) *executor.CMDResult { +func (v d8VirtualizationCMD) RestartVM(vmName string, opts SSHOptions) *executor.CMDResult { timeout := ShortTimeout if opts.Timeout != 0 { timeout = opts.Timeout diff --git a/tests/e2e/errlogger/errlogger.go b/tests/e2e/errlogger/errlogger.go index a54be7a9e4..eb2b58965a 100644 --- a/tests/e2e/errlogger/errlogger.go +++ b/tests/e2e/errlogger/errlogger.go @@ -145,7 +145,7 @@ func (l *LogStream) WaitCmd() (warning, error) { return warning(msg), nil } } - return "", fmt.Errorf("the command %q has been finished with the error: %v", l.LogStreamCmd.String(), err) + return "", fmt.Errorf("the command %q has been finished with the error: %w", l.LogStreamCmd.String(), err) } return "", nil } diff --git a/tests/e2e/helper/helper.go b/tests/e2e/helper/helper.go index a788087596..f1529d6686 100644 --- a/tests/e2e/helper/helper.go +++ b/tests/e2e/helper/helper.go @@ -61,7 +61,7 @@ func ParseYaml(filepath string) ([]*unstructured.Unstructured, error) { return out, nil } -func GetFullApiResourceName(u *unstructured.Unstructured) kubectl.Resource { +func GetFullAPIResourceName(u *unstructured.Unstructured) kubectl.Resource { return kubectl.Resource(strings.ToLower(u.GetKind() + "." + strings.Split(u.GetAPIVersion(), "/")[0])) } diff --git a/tests/e2e/image_hotplug_test.go b/tests/e2e/image_hotplug_test.go index b90b8f742a..0c7e8f0a52 100644 --- a/tests/e2e/image_hotplug_test.go +++ b/tests/e2e/image_hotplug_test.go @@ -40,11 +40,11 @@ type Image struct { func IsBlockDeviceCdRom(vmName, blockDeviceName string) (bool, error) { var blockDevices *BlockDevices - bdIdPath := fmt.Sprintf("/dev/disk/by-id/%s-%s", CdRomIdPrefix, blockDeviceName) - cmd := fmt.Sprintf("lsblk --json --nodeps --output name,type %s", bdIdPath) - res := d8Virtualization.SshCommand(vmName, cmd, d8.SshOptions{ + bdIDPath := fmt.Sprintf("/dev/disk/by-id/%s-%s", CdRomIDPrefix, blockDeviceName) + cmd := fmt.Sprintf("lsblk --json --nodeps --output name,type %s", bdIDPath) + res := d8Virtualization.SSHCommand(vmName, cmd, d8.SSHOptions{ Namespace: conf.Namespace, - Username: conf.TestData.SshUser, + Username: conf.TestData.SSHUser, IdenityFile: conf.TestData.Sshkey, }) if res.Error() != nil { @@ -61,12 +61,12 @@ func IsBlockDeviceCdRom(vmName, blockDeviceName string) (bool, error) { return blockDevice.Type == "rom", nil } -func MountBlockDevice(vmName, blockDeviceId string) error { - bdIdPath := fmt.Sprintf("/dev/disk/by-id/%s", blockDeviceId) - cmd := fmt.Sprintf("sudo mount --read-only %s /mnt", bdIdPath) - res := d8Virtualization.SshCommand(vmName, cmd, d8.SshOptions{ +func MountBlockDevice(vmName, blockDeviceID string) error { + bdIDPath := fmt.Sprintf("/dev/disk/by-id/%s", blockDeviceID) + cmd := fmt.Sprintf("sudo mount --read-only %s /mnt", bdIDPath) + res := d8Virtualization.SSHCommand(vmName, cmd, d8.SSHOptions{ Namespace: conf.Namespace, - Username: conf.TestData.SshUser, + Username: conf.TestData.SSHUser, IdenityFile: conf.TestData.Sshkey, }) if res.Error() != nil { @@ -75,12 +75,12 @@ func MountBlockDevice(vmName, blockDeviceId string) error { return nil } -func IsBlockDeviceReadOnly(vmName, blockDeviceId string) (bool, error) { - bdIdPath := fmt.Sprintf("/dev/disk/by-id/%s", blockDeviceId) - cmd := fmt.Sprintf("findmnt --noheadings --output options %s", bdIdPath) - res := d8Virtualization.SshCommand(vmName, cmd, d8.SshOptions{ +func IsBlockDeviceReadOnly(vmName, blockDeviceID string) (bool, error) { + bdIDPath := fmt.Sprintf("/dev/disk/by-id/%s", blockDeviceID) + cmd := fmt.Sprintf("findmnt --noheadings --output options %s", bdIDPath) + res := d8Virtualization.SSHCommand(vmName, cmd, d8.SSHOptions{ Namespace: conf.Namespace, - Username: conf.TestData.SshUser, + Username: conf.TestData.SSHUser, IdenityFile: conf.TestData.Sshkey, }) if res.Error() != nil { @@ -219,7 +219,7 @@ var _ = Describe("Image hotplug", ginkgoutil.CommonE2ETestDecorators(), func() { }) }) By("`VirtualMachine` agent should be ready", func() { - WaitVmAgentReady(kc.WaitOptions{ + WaitVMAgentReady(kc.WaitOptions{ Labels: testCaseLabel, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, @@ -297,7 +297,7 @@ var _ = Describe("Image hotplug", ginkgoutil.CommonE2ETestDecorators(), func() { }) }) By("`VirtualMachine` should be ready", func() { - WaitVmAgentReady(kc.WaitOptions{ + WaitVMAgentReady(kc.WaitOptions{ Labels: testCaseLabel, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, @@ -352,17 +352,17 @@ var _ = Describe("Image hotplug", ginkgoutil.CommonE2ETestDecorators(), func() { for _, disk := range intVirtVmi.Spec.Domain.Devices.Disks { switch { case strings.HasSuffix(disk.Name, "iso"): - imgs[disk.Name] = fmt.Sprintf("%s-%s", CdRomIdPrefix, disk.Name) + imgs[disk.Name] = fmt.Sprintf("%s-%s", CdRomIDPrefix, disk.Name) case strings.HasPrefix(disk.Name, "cvi-") || strings.HasPrefix(disk.Name, "vi-"): - imgs[disk.Name] = fmt.Sprintf("%s_%s", DiskIdPrefix, disk.Serial) + imgs[disk.Name] = fmt.Sprintf("%s_%s", DiskIDPrefix, disk.Serial) } } Expect(len(imgs)).To(Equal(imgCount), "there are only %d `blockDevices` in this case", imgCount) - for img, diskId := range imgs { - err := MountBlockDevice(vmObj.Name, diskId) + for img, diskID := range imgs { + err := MountBlockDevice(vmObj.Name, diskID) Expect(err).NotTo(HaveOccurred(), "failed to mount %q into the `VirtualMachine`: %s", img, err) - isReadOnly, err := IsBlockDeviceReadOnly(vmObj.Name, diskId) + isReadOnly, err := IsBlockDeviceReadOnly(vmObj.Name, diskID) Expect(err).NotTo(HaveOccurred(), "failed to check the `ReadOnly` status: %s", img) Expect(isReadOnly).Should(BeTrue(), "the mounted disk should be `ReadOnly`") } diff --git a/tests/e2e/images_creation_test.go b/tests/e2e/images_creation_test.go index 65fe69f9e4..0fa0d13158 100644 --- a/tests/e2e/images_creation_test.go +++ b/tests/e2e/images_creation_test.go @@ -30,9 +30,7 @@ import ( ) var _ = Describe("VirtualImagesCreation", ginkgoutil.CommonE2ETestDecorators(), func() { - var ( - testCaseLabel = map[string]string{"testcase": "images-creation"} - ) + testCaseLabel := map[string]string{"testcase": "images-creation"} BeforeAll(func() { if config.IsReusable() { diff --git a/tests/e2e/kubectl/kubectl.go b/tests/e2e/kubectl/kubectl.go index 26b138a526..c515ce6c65 100644 --- a/tests/e2e/kubectl/kubectl.go +++ b/tests/e2e/kubectl/kubectl.go @@ -120,16 +120,16 @@ type PatchOptions struct { Type string PatchFile string MergePatch string - JsonPatch []*JsonPatch + JSONPatch []*JSONPatch } -type JsonPatch struct { +type JSONPatch struct { Op string Path string Value string } -func (p JsonPatch) String() string { +func (p JSONPatch) String() string { var value string if _, err := strconv.Atoi(p.Value); err == nil || strings.HasPrefix(p.Value, "[") || @@ -146,7 +146,7 @@ type KubectlConf struct { Token string Endpoint string CertificateAuthority string - InsecureTls bool + InsecureTLS bool } func NewKubectl(conf KubectlConf) (*KubectlCMD, error) { @@ -413,9 +413,9 @@ func (k KubectlCMD) patchOptions(cmd string, opts PatchOptions) string { if opts.PatchFile != "" { cmd = fmt.Sprintf("%s --patch-file=%s", cmd, opts.PatchFile) } - if opts.JsonPatch != nil { - patches := make([]string, len(opts.JsonPatch)) - for i, p := range opts.JsonPatch { + if opts.JSONPatch != nil { + patches := make([]string, len(opts.JSONPatch)) + for i, p := range opts.JSONPatch { patches[i] = p.String() } rawPatches := strings.Join(patches, ",") diff --git a/tests/e2e/network/cilium_agents.go b/tests/e2e/network/cilium_agents.go index 7809416f1d..60ed468bc9 100644 --- a/tests/e2e/network/cilium_agents.go +++ b/tests/e2e/network/cilium_agents.go @@ -22,9 +22,10 @@ import ( "fmt" "strings" + corev1 "k8s.io/api/core/v1" + virtv2 "github.com/deckhouse/virtualization/api/core/v1alpha2" kc "github.com/deckhouse/virtualization/tests/e2e/kubectl" - corev1 "k8s.io/api/core/v1" ) const ( @@ -36,19 +37,19 @@ func CheckCilliumAgents(ctx context.Context, kubectl kc.Kubectl, vmName, vmNames // Get VM information using kubectl vmIP, nodeName, err := getVMInfo(kubectl, vmName, vmNamespace) if err != nil { - return fmt.Errorf("failed to get VM info: %v", err) + return fmt.Errorf("failed to get VM info: %w", err) } // Get node internal IP using kubectl nodeInternalIP, err := getNodeInternalIP(kubectl, nodeName) if err != nil { - return fmt.Errorf("failed to get node internal IP: %v", err) + return fmt.Errorf("failed to get node internal IP: %w", err) } // Get Cilium agent pods using kubectl pods, err := getCiliumAgentPods(kubectl) if err != nil { - return fmt.Errorf("failed to get Cilium agent pods: %v", err) + return fmt.Errorf("failed to get Cilium agent pods: %w", err) } // Check each Cilium agent pod @@ -82,12 +83,12 @@ func CheckCilliumAgents(ctx context.Context, kubectl kc.Kubectl, vmName, vmNames func getVMInfo(kubectl kc.Kubectl, vmName, vmNamespace string) (string, string, error) { result := kubectl.GetResource(kc.ResourceVM, vmName, kc.GetOptions{Namespace: vmNamespace, Output: "json"}) if result.Error() != nil { - return "", "", fmt.Errorf("failed to get VM: %v", result.Error()) + return "", "", fmt.Errorf("failed to get VM: %w", result.Error()) } var vm virtv2.VirtualMachine if err := json.Unmarshal([]byte(result.StdOut()), &vm); err != nil { - return "", "", fmt.Errorf("failed to parse VM JSON: %v", err) + return "", "", fmt.Errorf("failed to parse VM JSON: %w", err) } if vm.Status.IPAddress == "" { @@ -104,12 +105,12 @@ func getVMInfo(kubectl kc.Kubectl, vmName, vmNamespace string) (string, string, func getNodeInternalIP(kubectl kc.Kubectl, nodeName string) (string, error) { result := kubectl.GetResource(kc.ResourceNode, nodeName, kc.GetOptions{Output: "json"}) if result.Error() != nil { - return "", fmt.Errorf("failed to get node: %v", result.Error()) + return "", fmt.Errorf("failed to get node: %w", result.Error()) } var node corev1.Node if err := json.Unmarshal([]byte(result.StdOut()), &node); err != nil { - return "", fmt.Errorf("failed to parse node JSON: %v", err) + return "", fmt.Errorf("failed to parse node JSON: %w", err) } for _, addr := range node.Status.Addresses { @@ -128,12 +129,12 @@ func getCiliumAgentPods(kubectl kc.Kubectl) ([]corev1.Pod, error) { Output: "json", }) if result.Error() != nil { - return nil, fmt.Errorf("failed to get Cilium agent pods: %v", result.Error()) + return nil, fmt.Errorf("failed to get Cilium agent pods: %w", result.Error()) } var podList corev1.PodList if err := json.Unmarshal([]byte(result.StdOut()), &podList); err != nil { - return nil, fmt.Errorf("failed to parse pod list JSON: %v", err) + return nil, fmt.Errorf("failed to parse pod list JSON: %w", err) } return podList.Items, nil @@ -143,7 +144,7 @@ func searchIPFromCiliumIPCache(kubectl kc.Kubectl, pod corev1.Pod, vmIP, nodeIP cmd := fmt.Sprintf("-n %s exec %s -c cilium-agent -- cilium map get cilium_ipcache", pod.Namespace, pod.Name) result := kubectl.RawCommand(cmd, kc.MediumTimeout) if result.Error() != nil { - return false, fmt.Errorf("failed to execute command: %v", result.Error()) + return false, fmt.Errorf("failed to execute command: %w", result.Error()) } output := result.StdOut() diff --git a/tests/e2e/sizing_policy_test.go b/tests/e2e/sizing_policy_test.go index 6987b8da99..dae993c5d0 100644 --- a/tests/e2e/sizing_policy_test.go +++ b/tests/e2e/sizing_policy_test.go @@ -76,10 +76,10 @@ var _ = Describe("Sizing policy", ginkgoutil.CommonE2ETestDecorators(), func() { vmNotValidSizingPolicyCreating string vmClassDiscovery string vmClassDiscoveryCopy string - newVmClassFilePath string - notExistingVmClassChanging = map[string]string{"vm": "not-existing-vmclass-with-changing"} - notExistingVmClassCreating = map[string]string{"vm": "not-existing-vmclass-with-creating"} - existingVmClass = map[string]string{"vm": "existing-vmclass"} + newVMClassFilePath string + notExistingVMClassChanging = map[string]string{"vm": "not-existing-vmclass-with-changing"} + notExistingVMClassCreating = map[string]string{"vm": "not-existing-vmclass-with-creating"} + existingVMClass = map[string]string{"vm": "existing-vmclass"} testCaseLabel = map[string]string{"testcase": "sizing-policy"} ) @@ -90,11 +90,11 @@ var _ = Describe("Sizing policy", ginkgoutil.CommonE2ETestDecorators(), func() { }) Context("Preparing the environment", func() { - vmNotValidSizingPolicyChanging = fmt.Sprintf("%s-vm-%s", namePrefix, notExistingVmClassChanging["vm"]) - vmNotValidSizingPolicyCreating = fmt.Sprintf("%s-vm-%s", namePrefix, notExistingVmClassCreating["vm"]) + vmNotValidSizingPolicyChanging = fmt.Sprintf("%s-vm-%s", namePrefix, notExistingVMClassChanging["vm"]) + vmNotValidSizingPolicyCreating = fmt.Sprintf("%s-vm-%s", namePrefix, notExistingVMClassCreating["vm"]) vmClassDiscovery = fmt.Sprintf("%s-discovery", namePrefix) vmClassDiscoveryCopy = fmt.Sprintf("%s-discovery-copy", namePrefix) - newVmClassFilePath = fmt.Sprintf("%s/vmc-copy.yaml", conf.TestData.SizingPolicy) + newVMClassFilePath = fmt.Sprintf("%s/vmc-copy.yaml", conf.TestData.SizingPolicy) It("sets the namespace", func() { kustomization := fmt.Sprintf("%s/%s", conf.TestData.SizingPolicy, "kustomization.yaml") @@ -126,24 +126,24 @@ var _ = Describe("Sizing policy", ginkgoutil.CommonE2ETestDecorators(), func() { }) Context("When virtual disks are applied", func() { - It(fmt.Sprintf("checks VDs phases with %s and %s label", notExistingVmClassChanging, notExistingVmClassCreating), func() { + It(fmt.Sprintf("checks VDs phases with %s and %s label", notExistingVMClassChanging, notExistingVMClassCreating), func() { By(fmt.Sprintf("VDs should be in %s phases", phaseByVolumeBindingMode)) WaitPhaseByLabel(kc.ResourceVD, phaseByVolumeBindingMode, kc.WaitOptions{ - Labels: notExistingVmClassChanging, + Labels: notExistingVMClassChanging, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, }) WaitPhaseByLabel(kc.ResourceVD, phaseByVolumeBindingMode, kc.WaitOptions{ - Labels: notExistingVmClassCreating, + Labels: notExistingVMClassCreating, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, }) }) - It(fmt.Sprintf("checks VDs phases with %s label", existingVmClass), func() { + It(fmt.Sprintf("checks VDs phases with %s label", existingVMClass), func() { By(fmt.Sprintf("VDs should be in %s phases", PhaseReady)) WaitPhaseByLabel(kc.ResourceVD, PhaseReady, kc.WaitOptions{ - Labels: existingVmClass, + Labels: existingVMClass, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, }) @@ -151,24 +151,24 @@ var _ = Describe("Sizing policy", ginkgoutil.CommonE2ETestDecorators(), func() { }) Context("When virtual machines are applied", func() { - It(fmt.Sprintf("checks VMs phases with %s and %s label", notExistingVmClassChanging, notExistingVmClassCreating), func() { + It(fmt.Sprintf("checks VMs phases with %s and %s label", notExistingVMClassChanging, notExistingVMClassCreating), func() { By(fmt.Sprintf("VMs should be in %s phases", PhasePending)) WaitPhaseByLabel(kc.ResourceVM, PhasePending, kc.WaitOptions{ - Labels: notExistingVmClassChanging, + Labels: notExistingVMClassChanging, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, }) WaitPhaseByLabel(kc.ResourceVM, PhasePending, kc.WaitOptions{ - Labels: notExistingVmClassCreating, + Labels: notExistingVMClassCreating, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, }) }) - It(fmt.Sprintf("checks VMs phases with %s label", existingVmClass), func() { + It(fmt.Sprintf("checks VMs phases with %s label", existingVMClass), func() { By("Virtual machine agents should be ready") - WaitVmAgentReady(kc.WaitOptions{ - Labels: existingVmClass, + WaitVMAgentReady(kc.WaitOptions{ + Labels: existingVMClass, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, }) @@ -176,7 +176,7 @@ var _ = Describe("Sizing policy", ginkgoutil.CommonE2ETestDecorators(), func() { }) Describe("Not existing virtual machine class", func() { - Context(fmt.Sprintf("When virtual machine with label %s in phase %s", notExistingVmClassChanging, PhasePending), func() { + Context(fmt.Sprintf("When virtual machine with label %s in phase %s", notExistingVMClassChanging, PhasePending), func() { It("checks condition status before changing 'virtulaMachineCLass` field with existing class", func() { By(fmt.Sprintf("VirtualMachineClassReady status should be '%s' before changing", metav1.ConditionFalse)) CompareVirtualMachineClassReadyStatus(vmNotValidSizingPolicyChanging, metav1.ConditionFalse) @@ -190,8 +190,8 @@ var _ = Describe("Sizing policy", ginkgoutil.CommonE2ETestDecorators(), func() { It("checks VM phase and condition status after changing", func() { By("VM should be ready") - WaitVmAgentReady(kc.WaitOptions{ - Labels: notExistingVmClassChanging, + WaitVMAgentReady(kc.WaitOptions{ + Labels: notExistingVMClassChanging, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, }) @@ -200,7 +200,7 @@ var _ = Describe("Sizing policy", ginkgoutil.CommonE2ETestDecorators(), func() { }) }) - Context(fmt.Sprintf("When virtual machine with label %s in phase %s", notExistingVmClassCreating, PhasePending), func() { + Context(fmt.Sprintf("When virtual machine with label %s in phase %s", notExistingVMClassCreating, PhasePending), func() { It("checks condition status before creating `VirtualMachineClass`", func() { By(fmt.Sprintf("VirtualMachineClassReady status should be '%s' before creating", metav1.ConditionFalse)) CompareVirtualMachineClassReadyStatus(vmNotValidSizingPolicyCreating, metav1.ConditionFalse) @@ -218,10 +218,10 @@ var _ = Describe("Sizing policy", ginkgoutil.CommonE2ETestDecorators(), func() { Expect(err).NotTo(HaveOccurred()) vmClass.Name = vmClassDiscoveryCopy vmClass.Labels = map[string]string{"id": namePrefix} - writeErr := WriteYamlObject(newVmClassFilePath, &vmClass) + writeErr := WriteYamlObject(newVMClassFilePath, &vmClass) Expect(writeErr).NotTo(HaveOccurred(), writeErr) res := kubectl.Apply(kc.ApplyOptions{ - Filename: []string{newVmClassFilePath}, + Filename: []string{newVMClassFilePath}, FilenameOption: kc.Filename, }) Expect(res.Error()).NotTo(HaveOccurred(), res.StdErr()) @@ -229,8 +229,8 @@ var _ = Describe("Sizing policy", ginkgoutil.CommonE2ETestDecorators(), func() { It("checks VM phase and condition after creating", func() { By("VM should be ready") - WaitVmAgentReady(kc.WaitOptions{ - Labels: notExistingVmClassCreating, + WaitVMAgentReady(kc.WaitOptions{ + Labels: notExistingVMClassCreating, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, }) @@ -268,7 +268,7 @@ var _ = Describe("Sizing policy", ginkgoutil.CommonE2ETestDecorators(), func() { It("deletes test case resources", func() { DeleteTestCaseResources(ResourcesToDelete{ KustomizationDir: conf.TestData.SizingPolicy, - Files: []string{newVmClassFilePath}, + Files: []string{newVMClassFilePath}, }) }) }) diff --git a/tests/e2e/tests_suite_test.go b/tests/e2e/tests_suite_test.go index 6c91431e00..a267306d8e 100644 --- a/tests/e2e/tests_suite_test.go +++ b/tests/e2e/tests_suite_test.go @@ -155,7 +155,7 @@ func init() { fieldType := t.Field(i) // Ignore - if fieldType.Name == "Sshkey" || fieldType.Name == "SshUser" { + if fieldType.Name == "Sshkey" || fieldType.Name == "SSHUser" { continue } @@ -189,8 +189,8 @@ func newRestConfig(transport config.ClusterTransport) (*rest.Config, error) { if transport.Token != "" { configFlags.BearerToken = &transport.Token } - if transport.InsecureTls { - configFlags.Insecure = &transport.InsecureTls + if transport.InsecureTLS { + configFlags.Insecure = &transport.InsecureTLS } if transport.CertificateAuthority != "" { configFlags.CAFile = &transport.CertificateAuthority diff --git a/tests/e2e/util_test.go b/tests/e2e/util_test.go index 983da91043..81fd0394cf 100644 --- a/tests/e2e/util_test.go +++ b/tests/e2e/util_test.go @@ -117,7 +117,7 @@ func ItCheckStatusFromFile(filepath, output, compareField string) { for _, u := range unstructs { It("Get recourse status "+u.GetName(), func() { - fullName := helper.GetFullApiResourceName(u) + fullName := helper.GetFullAPIResourceName(u) var res *executor.CMDResult if u.GetNamespace() == "" { res = kubectl.GetResource(fullName, u.GetName(), kc.GetOptions{Output: output}) @@ -150,11 +150,11 @@ func WaitResource(resource kc.Resource, name, waitFor string, timeout time.Durat Expect(res.Error()).NotTo(HaveOccurred(), "wait failed %s %s/%s.\n%s", resource, conf.Namespace, name, res.StdErr()) } -func PatchResource(resource kc.Resource, name string, patch []*kc.JsonPatch) { +func PatchResource(resource kc.Resource, name string, patch []*kc.JSONPatch) { GinkgoHelper() res := kubectl.PatchResource(resource, name, kc.PatchOptions{ Namespace: conf.Namespace, - JsonPatch: patch, + JSONPatch: patch, }) Expect(res.Error()).NotTo(HaveOccurred(), "patch failed %s %s/%s.\n%s", resource, conf.Namespace, name, res.StdErr()) @@ -189,7 +189,7 @@ func GetVMFromManifest(manifest string) (*virtv2.VirtualMachine, error) { } var unstruct *unstructured.Unstructured for _, u := range unstructs { - if helper.GetFullApiResourceName(u) == kc.ResourceVM { + if helper.GetFullAPIResourceName(u) == kc.ResourceVM { unstruct = u break } @@ -267,7 +267,7 @@ func ChmodFile(pathFile string, permission os.FileMode) { } } -func WaitVmAgentReady(opts kc.WaitOptions) { +func WaitVMAgentReady(opts kc.WaitOptions) { GinkgoHelper() WaitPhaseByLabel(kc.ResourceVM, PhaseRunning, opts) WaitConditionIsTrueByLabel(kc.ResourceVM, vmcondition.TypeAgentReady.String(), opts) @@ -636,7 +636,7 @@ func StopVirtualMachinesBySSH(virtualMachines ...string) { cmd := "sudo nohup poweroff -f > /dev/null 2>&1 &" for _, vm := range virtualMachines { - ExecSshCommand(vm, cmd) + ExecSSHCommand(vm, cmd) } } @@ -646,7 +646,7 @@ func RebootVirtualMachinesBySSH(virtualMachines ...string) { cmd := "sudo nohup reboot -f > /dev/null 2>&1 &" for _, vm := range virtualMachines { - ExecSshCommand(vm, cmd) + ExecSSHCommand(vm, cmd) } } @@ -707,7 +707,7 @@ func SaveTestResources(labels map[string]string, additional string) { cmdr := kubectl.Get("virtualization -A", kc.GetOptions{Output: "yaml", Labels: labels}) Expect(cmdr.Error()).NotTo(HaveOccurred(), "cmd: %s\nstderr: %s", cmdr.GetCmd(), cmdr.StdErr()) - err := os.WriteFile(str, cmdr.StdOutBytes(), 0644) + err := os.WriteFile(str, cmdr.StdOutBytes(), 0o644) Expect(err).NotTo(HaveOccurred(), "cmd: %s\nstderr: %s", cmdr.GetCmd(), cmdr.StdErr()) } diff --git a/tests/e2e/vd_snapshots_test.go b/tests/e2e/vd_snapshots_test.go index 2c884ac3fc..434e183e72 100644 --- a/tests/e2e/vd_snapshots_test.go +++ b/tests/e2e/vd_snapshots_test.go @@ -66,7 +66,7 @@ func CreateVirtualDiskSnapshot(vdName, snapshotName, volumeSnapshotClassName str filePath := fmt.Sprintf("%s/snapshots/%s-%s.yaml", conf.TestData.VdSnapshots, vdSnapshotName, volumeSnapshotClassName) err := WriteYamlObject(filePath, &vdSnapshot) if err != nil { - return fmt.Errorf("cannot write file with virtual disk snapshot: %s\nstderr: %s", vdSnapshotName, err) + return fmt.Errorf("cannot write file with virtual disk snapshot: %s\nstderr: %w", vdSnapshotName, err) } res := kubectl.Apply(kc.ApplyOptions{ @@ -83,7 +83,7 @@ func GetVolumeSnapshotClassName(storageClass *storagev1.StorageClass) (string, e vscObjects := snapshotvolv1.VolumeSnapshotClassList{} err := GetObjects(kc.ResourceVolumeSnapshotClass, &vscObjects, kc.GetOptions{}) if err != nil { - return "", fmt.Errorf("cannot get `VolumeSnapshotClasses` by provisioner %q\nstderr: %s", storageClass.Provisioner, err) + return "", fmt.Errorf("cannot get `VolumeSnapshotClasses` by provisioner %q\nstderr: %w", storageClass.Provisioner, err) } for _, vsc := range vscObjects.Items { @@ -99,7 +99,7 @@ func CheckFileSystemFrozen(vmName string) (bool, error) { vmObj := virtv2.VirtualMachine{} err := GetObject(kc.ResourceVM, vmName, &vmObj, kc.GetOptions{Namespace: conf.Namespace}) if err != nil { - return false, fmt.Errorf("cannot get `VirtualMachine`: %q\nstderr: %s", vmName, err) + return false, fmt.Errorf("cannot get `VirtualMachine`: %q\nstderr: %w", vmName, err) } for _, condition := range vmObj.Status.Conditions { @@ -177,7 +177,7 @@ var _ = Describe("VirtualDiskSnapshots", ginkgoutil.CommonE2ETestDecorators(), f Context("When virtual machines are applied:", func() { It("checks VMs phases", func() { By("Virtual machine agents should be ready") - WaitVmAgentReady(kc.WaitOptions{ + WaitVMAgentReady(kc.WaitOptions{ Labels: testCaseLabel, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, diff --git a/tests/e2e/vm_configuration_test.go b/tests/e2e/vm_configuration_test.go index 9febbd8ed3..d9529ce540 100644 --- a/tests/e2e/vm_configuration_test.go +++ b/tests/e2e/vm_configuration_test.go @@ -38,13 +38,13 @@ const ( StageAfter = "after" ) -func ExecSshCommand(vmName, cmd string) { +func ExecSSHCommand(vmName, cmd string) { GinkgoHelper() Eventually(func() error { - res := d8Virtualization.SshCommand(vmName, cmd, d8.SshOptions{ + res := d8Virtualization.SSHCommand(vmName, cmd, d8.SSHOptions{ Namespace: conf.Namespace, - Username: conf.TestData.SshUser, + Username: conf.TestData.SSHUser, IdenityFile: conf.TestData.Sshkey, }) if res.Error() != nil { @@ -57,7 +57,7 @@ func ExecSshCommand(vmName, cmd string) { func ExecStartCommand(vmName string) { GinkgoHelper() Eventually(func() error { - res := d8Virtualization.StartVM(vmName, d8.SshOptions{Namespace: conf.Namespace}) + res := d8Virtualization.StartVM(vmName, d8.SSHOptions{Namespace: conf.Namespace}) if res.Error() != nil { return fmt.Errorf("cmd: %s\nstderr: %s", res.GetCmd(), res.StdErr()) } @@ -68,7 +68,7 @@ func ExecStartCommand(vmName string) { func ExecStopCommand(vmName string) { GinkgoHelper() Eventually(func() error { - res := d8Virtualization.StopVM(vmName, d8.SshOptions{Namespace: conf.Namespace}) + res := d8Virtualization.StopVM(vmName, d8.SSHOptions{Namespace: conf.Namespace}) if res.Error() != nil { return fmt.Errorf("cmd: %s\nstderr: %s", res.GetCmd(), res.StdErr()) } @@ -79,7 +79,7 @@ func ExecStopCommand(vmName string) { func ExecRestartCommand(vmName string) { GinkgoHelper() Eventually(func() error { - res := d8Virtualization.RestartVM(vmName, d8.SshOptions{Namespace: conf.Namespace}) + res := d8Virtualization.RestartVM(vmName, d8.SSHOptions{Namespace: conf.Namespace}) if res.Error() != nil { return fmt.Errorf("cmd: %s\nstderr: %s", res.GetCmd(), res.StdErr()) } @@ -115,7 +115,7 @@ func CheckCPUCoresNumberFromVirtualMachine(requiredValue string, virtualMachines By("Checking the number of processor cores after changing from virtual machine") for _, vm := range virtualMachines { cmd := "nproc --all" - CheckResultSshCommand(vm, cmd, requiredValue) + CheckResultSSHCommand(vm, cmd, requiredValue) } } @@ -134,7 +134,7 @@ var _ = Describe("Virtual machine configuration", ginkgoutil.CommonE2ETestDecora Context("Preparing the environment", func() { It("sets the namespace", func() { - kustomization := fmt.Sprintf("%s/%s", conf.TestData.VmConfiguration, "kustomization.yaml") + kustomization := fmt.Sprintf("%s/%s", conf.TestData.VMConfiguration, "kustomization.yaml") ns, err := kustomize.GetNamespace(kustomization) Expect(err).NotTo(HaveOccurred(), "%w", err) conf.SetNamespace(ns) @@ -157,7 +157,7 @@ var _ = Describe("Virtual machine configuration", ginkgoutil.CommonE2ETestDecora } res := kubectl.Apply(kc.ApplyOptions{ - Filename: []string{conf.TestData.VmConfiguration}, + Filename: []string{conf.TestData.VMConfiguration}, FilenameOption: kc.Kustomize, }) Expect(res.WasSuccess()).To(Equal(true), res.StdErr()) @@ -187,7 +187,7 @@ var _ = Describe("Virtual machine configuration", ginkgoutil.CommonE2ETestDecora Context("When virtual machines are applied", func() { It("should be ready", func() { - WaitVmAgentReady(kc.WaitOptions{ + WaitVMAgentReady(kc.WaitOptions{ Labels: testCaseLabel, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, @@ -196,7 +196,7 @@ var _ = Describe("Virtual machine configuration", ginkgoutil.CommonE2ETestDecora }) Describe("Manual restart approval mode", func() { - var oldCpuCores int + var oldCPUCores int var newCPUCores int Context("When virtual machine agents are ready", func() { @@ -215,10 +215,10 @@ var _ = Describe("Virtual machine configuration", ginkgoutil.CommonE2ETestDecora err := GetObject(kc.ResourceVM, vms[0], &vmResource, kc.GetOptions{Namespace: conf.Namespace}) Expect(err).NotTo(HaveOccurred()) - oldCpuCores = vmResource.Spec.CPU.Cores + oldCPUCores = vmResource.Spec.CPU.Cores newCPUCores = 1 + (vmResource.Spec.CPU.Cores & 1) - CheckCPUCoresNumber(ManualMode, StageBefore, oldCpuCores, vms...) + CheckCPUCoresNumber(ManualMode, StageBefore, oldCPUCores, vms...) ChangeCPUCoresNumber(newCPUCores, vms...) }) }) @@ -249,9 +249,9 @@ var _ = Describe("Virtual machine configuration", ginkgoutil.CommonE2ETestDecora vms := strings.Split(res.StdOut(), " ") for _, vm := range vms { cmd := "sudo nohup reboot -f > /dev/null 2>&1 &" - ExecSshCommand(vm, cmd) + ExecSSHCommand(vm, cmd) } - WaitVmAgentReady(kc.WaitOptions{ + WaitVMAgentReady(kc.WaitOptions{ Labels: manualLabel, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, @@ -275,7 +275,7 @@ var _ = Describe("Virtual machine configuration", ginkgoutil.CommonE2ETestDecora }) Describe("Automatic restart approval mode", func() { - var oldCpuCores int + var oldCPUCores int var newCPUCores int Context(fmt.Sprintf("When virtual machine is in %s phase", PhaseRunning), func() { @@ -294,10 +294,10 @@ var _ = Describe("Virtual machine configuration", ginkgoutil.CommonE2ETestDecora err := GetObject(kc.ResourceVM, vms[0], &vmResource, kc.GetOptions{Namespace: conf.Namespace}) Expect(err).NotTo(HaveOccurred(), "%v", err) - oldCpuCores = vmResource.Spec.CPU.Cores + oldCPUCores = vmResource.Spec.CPU.Cores newCPUCores = 1 + (vmResource.Spec.CPU.Cores & 1) - CheckCPUCoresNumber(AutomaticMode, StageBefore, oldCpuCores, vms...) + CheckCPUCoresNumber(AutomaticMode, StageBefore, oldCPUCores, vms...) ChangeCPUCoresNumber(newCPUCores, vms...) }) }) @@ -318,7 +318,7 @@ var _ = Describe("Virtual machine configuration", ginkgoutil.CommonE2ETestDecora Context("When virtual machine is restarted", func() { It("should be ready", func() { - WaitVmAgentReady(kc.WaitOptions{ + WaitVMAgentReady(kc.WaitOptions{ Labels: automaticLabel, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, @@ -346,7 +346,7 @@ var _ = Describe("Virtual machine configuration", ginkgoutil.CommonE2ETestDecora var resourcesToDelete ResourcesToDelete if config.IsCleanUpNeeded() { - resourcesToDelete.KustomizationDir = conf.TestData.VmConfiguration + resourcesToDelete.KustomizationDir = conf.TestData.VMConfiguration } DeleteTestCaseResources(resourcesToDelete) diff --git a/tests/e2e/vm_connectivity_test.go b/tests/e2e/vm_connectivity_test.go index 89497f8436..0c10b4fbc5 100644 --- a/tests/e2e/vm_connectivity_test.go +++ b/tests/e2e/vm_connectivity_test.go @@ -61,7 +61,7 @@ func RunPod(podName, namespace, image string, entrypoint PodEntrypoint) *executo return kubectl.RawCommand(cmd, ShortWaitDuration) } -func GenerateServiceUrl(svc *corev1.Service, namespace string) string { +func GenerateServiceURL(svc *corev1.Service, namespace string) string { service := fmt.Sprintf("%s.%s.svc:%d", svc.Name, namespace, svc.Spec.Ports[0].Port) return service } @@ -85,16 +85,16 @@ func CheckExternalConnection(host, httpCode string, vms ...string) { for _, vm := range vms { By(fmt.Sprintf("Response code from %q should be %q for %q", host, httpCode, vm)) cmd := fmt.Sprintf("curl -o /dev/null -s -w \"%%{http_code}\\n\" %s", host) - CheckResultSshCommand(vm, cmd, httpCode) + CheckResultSSHCommand(vm, cmd, httpCode) } } -func CheckResultSshCommand(vmName, cmd, equal string) { +func CheckResultSSHCommand(vmName, cmd, equal string) { GinkgoHelper() Eventually(func() (string, error) { - res := d8Virtualization.SshCommand(vmName, cmd, d8.SshOptions{ + res := d8Virtualization.SSHCommand(vmName, cmd, d8.SSHOptions{ Namespace: conf.Namespace, - Username: conf.TestData.SshUser, + Username: conf.TestData.SSHUser, IdenityFile: conf.TestData.Sshkey, }) if res.Error() != nil { @@ -180,7 +180,7 @@ var _ = Describe("VM connectivity", ginkgoutil.CommonE2ETestDecorators(), func() Context("When virtual machines are applied", func() { It("checks VMs phases", func() { By("Virtual machine agents should be ready") - WaitVmAgentReady(kc.WaitOptions{ + WaitVMAgentReady(kc.WaitOptions{ Labels: testCaseLabel, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, @@ -230,7 +230,7 @@ var _ = Describe("VM connectivity", ginkgoutil.CommonE2ETestDecorators(), func() cmd := "hostname" for _, vmName := range []string{vmA.Name, vmB.Name} { By(fmt.Sprintf("VirtualMachine %q", vmName)) - CheckResultSshCommand(vmName, cmd, vmName) + CheckResultSSHCommand(vmName, cmd, vmName) } }) @@ -243,12 +243,12 @@ var _ = Describe("VM connectivity", ginkgoutil.CommonE2ETestDecorators(), func() cmd := "systemctl is-active nginx.service" for _, vmName := range []string{vmA.Name, vmB.Name} { By(fmt.Sprintf("VirtualMachine %q", vmName)) - CheckResultSshCommand(vmName, cmd, nginxActiveStatus) + CheckResultSSHCommand(vmName, cmd, nginxActiveStatus) } }) It(fmt.Sprintf("gets page from service %s", aObjName), func() { - service := GenerateServiceUrl(&svcA, conf.Namespace) + service := GenerateServiceURL(&svcA, conf.Namespace) Eventually(func() (string, error) { res := GetResponseViaPodWithCurl(CurlPod, conf.Namespace, service) if res.Error() != nil { @@ -259,7 +259,7 @@ var _ = Describe("VM connectivity", ginkgoutil.CommonE2ETestDecorators(), func() }) It(fmt.Sprintf("gets page from service %s", bObjName), func() { - service := GenerateServiceUrl(&svcB, conf.Namespace) + service := GenerateServiceURL(&svcB, conf.Namespace) Eventually(func() (string, error) { res := GetResponseViaPodWithCurl(CurlPod, conf.Namespace, service) if res.Error() != nil { @@ -273,7 +273,7 @@ var _ = Describe("VM connectivity", ginkgoutil.CommonE2ETestDecorators(), func() selectorA = svcA.Spec.Selector["service"] selectorB = svcB.Spec.Selector["service"] - PatchResource(kc.ResourceService, svcA.Name, []*kc.JsonPatch{ + PatchResource(kc.ResourceService, svcA.Name, []*kc.JSONPatch{ { Op: "replace", Path: "/spec/selector/service", @@ -290,7 +290,7 @@ var _ = Describe("VM connectivity", ginkgoutil.CommonE2ETestDecorators(), func() It(fmt.Sprintf("gets page from service %s", aObjName), func() { By(fmt.Sprintf("Response should be from virtual machine %q", vmB.Name)) - service := GenerateServiceUrl(&svcA, conf.Namespace) + service := GenerateServiceURL(&svcA, conf.Namespace) Eventually(func() (string, error) { res := GetResponseViaPodWithCurl(CurlPod, conf.Namespace, service) if res.Error() != nil { @@ -301,7 +301,7 @@ var _ = Describe("VM connectivity", ginkgoutil.CommonE2ETestDecorators(), func() }) It(fmt.Sprintf("changes back selector in service %s", aObjName), func() { - PatchResource(kc.ResourceService, svcA.Name, []*kc.JsonPatch{ + PatchResource(kc.ResourceService, svcA.Name, []*kc.JSONPatch{ { Op: "replace", Path: "/spec/selector/service", diff --git a/tests/e2e/vm_disk_attachment_test.go b/tests/e2e/vm_disk_attachment_test.go index 05bf968dd1..877c9c9424 100644 --- a/tests/e2e/vm_disk_attachment_test.go +++ b/tests/e2e/vm_disk_attachment_test.go @@ -94,9 +94,9 @@ func CreateVMBDAManifest(filePath, vmName, blockDeviceName string, blockDeviceTy func GetDisksMetadata(vmName string, disks *Disks) error { GinkgoHelper() cmd := "lsblk --nodeps --json" - res := d8Virtualization.SshCommand(vmName, cmd, d8.SshOptions{ + res := d8Virtualization.SSHCommand(vmName, cmd, d8.SSHOptions{ Namespace: conf.Namespace, - Username: conf.TestData.SshUser, + Username: conf.TestData.SSHUser, IdenityFile: conf.TestData.Sshkey, }) if res.Error() != nil { @@ -137,7 +137,7 @@ var _ = Describe("Virtual disk attachment", ginkgoutil.CommonE2ETestDecorators() vmName = fmt.Sprintf("%s-vm-%s", namePrefix, nameSuffix) It("sets the namespace", func() { - kustomization := fmt.Sprintf("%s/%s", conf.TestData.VmDiskAttachment, "kustomization.yaml") + kustomization := fmt.Sprintf("%s/%s", conf.TestData.VMDiskAttachment, "kustomization.yaml") ns, err := kustomize.GetNamespace(kustomization) Expect(err).NotTo(HaveOccurred(), "%w", err) conf.SetNamespace(ns) @@ -147,7 +147,7 @@ var _ = Describe("Virtual disk attachment", ginkgoutil.CommonE2ETestDecorators() Context("When resources are applied", func() { It("result should be succeeded", func() { res := kubectl.Apply(kc.ApplyOptions{ - Filename: []string{conf.TestData.VmDiskAttachment}, + Filename: []string{conf.TestData.VMDiskAttachment}, FilenameOption: kc.Kustomize, }) Expect(res.WasSuccess()).To(Equal(true), res.StdErr()) @@ -186,7 +186,7 @@ var _ = Describe("Virtual disk attachment", ginkgoutil.CommonE2ETestDecorators() Context("When virtual machines are applied", func() { It("checks VMs phases", func() { By("Virtual machine agents should be ready") - WaitVmAgentReady(kc.WaitOptions{ + WaitVMAgentReady(kc.WaitOptions{ Labels: testCaseLabel, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, @@ -202,7 +202,7 @@ var _ = Describe("Virtual disk attachment", ginkgoutil.CommonE2ETestDecorators() }).WithTimeout(Timeout).WithPolling(Interval).ShouldNot(HaveOccurred(), "virtualMachine: %s", vmName) }) It("attaches virtual disk", func() { - AttachBlockDevice(vmName, vdAttach, virtv2.VMBDAObjectRefKindVirtualDisk, testCaseLabel, conf.TestData.VmDiskAttachment) + AttachBlockDevice(vmName, vdAttach, virtv2.VMBDAObjectRefKindVirtualDisk, testCaseLabel, conf.TestData.VMDiskAttachment) }) It("checks VM and VMBDA phases", func() { By(fmt.Sprintf("VMBDA should be in %s phases", PhaseAttached)) @@ -212,7 +212,7 @@ var _ = Describe("Virtual disk attachment", ginkgoutil.CommonE2ETestDecorators() Timeout: MaxWaitTimeout, }) By("Virtual machines should be ready") - WaitVmAgentReady(kc.WaitOptions{ + WaitVMAgentReady(kc.WaitOptions{ Labels: testCaseLabel, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, @@ -241,7 +241,7 @@ var _ = Describe("Virtual disk attachment", ginkgoutil.CommonE2ETestDecorators() }) It("detaches virtual disk", func() { res := kubectl.Delete(kc.DeleteOptions{ - Filename: []string{fmt.Sprintf("%s/vmbda", conf.TestData.VmDiskAttachment)}, + Filename: []string{fmt.Sprintf("%s/vmbda", conf.TestData.VMDiskAttachment)}, FilenameOption: kc.Filename, Namespace: conf.Namespace, }) @@ -249,7 +249,7 @@ var _ = Describe("Virtual disk attachment", ginkgoutil.CommonE2ETestDecorators() }) It("checks VM phase", func() { By("Virtual machines should be ready") - WaitVmAgentReady(kc.WaitOptions{ + WaitVMAgentReady(kc.WaitOptions{ Labels: testCaseLabel, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, @@ -271,7 +271,7 @@ var _ = Describe("Virtual disk attachment", ginkgoutil.CommonE2ETestDecorators() Context("When test is completed", func() { It("deletes test case resources", func() { DeleteTestCaseResources(ResourcesToDelete{ - KustomizationDir: conf.TestData.VmDiskAttachment, + KustomizationDir: conf.TestData.VMDiskAttachment, AdditionalResources: []AdditionalResource{ { Resource: kc.ResourceVMBDA, diff --git a/tests/e2e/vm_disk_resizing_test.go b/tests/e2e/vm_disk_resizing_test.go index 1227f51db2..49cb641283 100644 --- a/tests/e2e/vm_disk_resizing_test.go +++ b/tests/e2e/vm_disk_resizing_test.go @@ -38,14 +38,14 @@ import ( type VirtualMachineDisks map[string]DiskMetaData type DiskMetaData struct { - Id string + ID string SizeByLsblk *resource.Quantity SizeFromObject *resource.Quantity } const ( - DiskIdPrefix = "scsi-0QEMU_QEMU_HARDDISK" - CdRomIdPrefix = "scsi-0QEMU_QEMU_CD-ROM_drive-ua" + DiskIDPrefix = "scsi-0QEMU_QEMU_HARDDISK" + CdRomIDPrefix = "scsi-0QEMU_QEMU_CD-ROM_drive-ua" ) func WaitBlockDeviceRefsAttached(namespace string, vms ...string) { @@ -55,7 +55,7 @@ func WaitBlockDeviceRefsAttached(namespace string, vms ...string) { vm := virtv2.VirtualMachine{} err := GetObject(virtv2.VirtualMachineResource, vmName, &vm, kc.GetOptions{Namespace: namespace}) if err != nil { - return fmt.Errorf("virtualMachine: %s\nstderr: %s", vmName, err) + return fmt.Errorf("virtualMachine: %s\nstderr: %w", vmName, err) } for _, bd := range vm.Status.BlockDeviceRefs { if !bd.Attached { @@ -97,16 +97,16 @@ func GetSizeFromObject(vdName, namespace string) (*resource.Quantity, error) { return vd.Spec.PersistentVolumeClaim.Size, nil } -func GetSizeByLsblk(vmName, diskIdPath string) (*resource.Quantity, error) { +func GetSizeByLsblk(vmName, diskIDPath string) (*resource.Quantity, error) { GinkgoHelper() var ( blockDevices *BlockDevices quantity resource.Quantity ) - cmd := fmt.Sprintf("lsblk --json --nodeps --output size %s", diskIdPath) - res := d8Virtualization.SshCommand(vmName, cmd, d8.SshOptions{ + cmd := fmt.Sprintf("lsblk --json --nodeps --output size %s", diskIDPath) + res := d8Virtualization.SSHCommand(vmName, cmd, d8.SSHOptions{ Namespace: conf.Namespace, - Username: conf.TestData.SshUser, + Username: conf.TestData.SSHUser, IdenityFile: conf.TestData.Sshkey, }) if res.Error() != nil { @@ -124,15 +124,15 @@ func GetSizeByLsblk(vmName, diskIdPath string) (*resource.Quantity, error) { return &quantity, nil } -func GetDiskSize(vmName, vdName, diskIdPath string, config *cfg.Config, disk *DiskMetaData) { +func GetDiskSize(vmName, vdName, diskIDPath string, config *cfg.Config, disk *DiskMetaData) { GinkgoHelper() sizeFromObject, err := GetSizeFromObject(vdName, config.Namespace) Expect(err).NotTo(HaveOccurred(), "%v", err) var sizeByLsblk *resource.Quantity Eventually(func() error { - sizeByLsblk, err = GetSizeByLsblk(vmName, diskIdPath) + sizeByLsblk, err = GetSizeByLsblk(vmName, diskIDPath) if err != nil { - return fmt.Errorf("virtualMachine: %s\nstderr: %s", vmName, err) + return fmt.Errorf("virtualMachine: %s\nstderr: %w", vmName, err) } return nil }).WithTimeout(Timeout).WithPolling(Interval).Should(Succeed()) @@ -142,11 +142,11 @@ func GetDiskSize(vmName, vdName, diskIdPath string, config *cfg.Config, disk *Di disk.SizeByLsblk = sizeByLsblk } -func GetDiskIdPath(vdName string, vmi *virtv1.VirtualMachineInstance) string { +func GetDiskIDPath(vdName string, vmi *virtv1.VirtualMachineInstance) string { diskName := fmt.Sprintf("vd-%s", vdName) for _, disk := range vmi.Spec.Domain.Devices.Disks { if disk.Name == diskName { - return fmt.Sprintf("/dev/disk/by-id/%s_%s", DiskIdPrefix, disk.Serial) + return fmt.Sprintf("/dev/disk/by-id/%s_%s", DiskIDPrefix, disk.Serial) } } return "" @@ -177,8 +177,8 @@ func GetVirtualMachineDisks(vmName string, config *cfg.Config) (VirtualMachineDi if device.Kind != virtv2.DiskDevice { continue } - diskIdPath := GetDiskIdPath(device.Name, intVirtVmi) - GetDiskSize(vmName, device.Name, diskIdPath, config, &disk) + diskIDPath := GetDiskIDPath(device.Name, intVirtVmi) + GetDiskSize(vmName, device.Name, diskIDPath, config, &disk) disks[device.Name] = disk } return disks, nil @@ -246,7 +246,7 @@ var _ = Describe("Virtual disk resizing", ginkgoutil.CommonE2ETestDecorators(), Context("When the virtual machine are applied", func() { It("checks `VirtualMachine` phase", func() { By("`VirtualMachine` agent should be ready", func() { - WaitVmAgentReady(kc.WaitOptions{ + WaitVMAgentReady(kc.WaitOptions{ Labels: testCaseLabel, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, @@ -336,7 +336,7 @@ var _ = Describe("Virtual disk resizing", ginkgoutil.CommonE2ETestDecorators(), }) }) By("`VirtualMachine` should be ready", func() { - WaitVmAgentReady(kc.WaitOptions{ + WaitVMAgentReady(kc.WaitOptions{ Labels: testCaseLabel, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, @@ -358,7 +358,7 @@ var _ = Describe("Virtual disk resizing", ginkgoutil.CommonE2ETestDecorators(), Eventually(func() error { vmDisksAfter, err = GetVirtualMachineDisks(vmObj.Name, conf) if err != nil { - return fmt.Errorf("failed to obtain disks metadata after resizing: %s", err) + return fmt.Errorf("failed to obtain disks metadata after resizing: %w", err) } if len(vmDisksAfter) != diskCount { return fmt.Errorf("quantity of the disk should be %d", diskCount) diff --git a/tests/e2e/vm_evacuation_test.go b/tests/e2e/vm_evacuation_test.go index d08bf75708..5d625c919b 100644 --- a/tests/e2e/vm_evacuation_test.go +++ b/tests/e2e/vm_evacuation_test.go @@ -38,13 +38,13 @@ var _ = Describe("Virtual machine evacuation", SIGMigration(), ginkgoutil.Common testCaseLabel := map[string]string{"testcase": "vm-evacuation"} BeforeEach(func() { - kustomization := fmt.Sprintf("%s/%s", conf.TestData.VmEvacuation, "kustomization.yaml") + kustomization := fmt.Sprintf("%s/%s", conf.TestData.VMEvacuation, "kustomization.yaml") ns, err := kustomize.GetNamespace(kustomization) Expect(err).NotTo(HaveOccurred(), "%w", err) conf.SetNamespace(ns) res := kubectl.Apply(kc.ApplyOptions{ - Filename: []string{conf.TestData.VmEvacuation}, + Filename: []string{conf.TestData.VMEvacuation}, FilenameOption: kc.Kustomize, }) Expect(res.WasSuccess()).To(Equal(true), res.StdErr()) @@ -64,7 +64,7 @@ var _ = Describe("Virtual machine evacuation", SIGMigration(), ginkgoutil.Common } if config.IsCleanUpNeeded() { - resourcesToDelete.KustomizationDir = conf.TestData.VmEvacuation + resourcesToDelete.KustomizationDir = conf.TestData.VMEvacuation } DeleteTestCaseResources(resourcesToDelete) }) @@ -89,7 +89,7 @@ var _ = Describe("Virtual machine evacuation", SIGMigration(), ginkgoutil.Common It("Evacuation", func() { By("Virtual machine agents should be ready") - WaitVmAgentReady(kc.WaitOptions{ + WaitVMAgentReady(kc.WaitOptions{ Labels: testCaseLabel, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, @@ -134,7 +134,6 @@ var _ = Describe("Virtual machine evacuation", SIGMigration(), ginkgoutil.Common return fmt.Errorf("expected %d finished VMOPs, got %d", len(vmNames), finishedVMOPs) } return nil - }).WithTimeout(MaxWaitTimeout).WithPolling(time.Second).ShouldNot(HaveOccurred()) }) }) diff --git a/tests/e2e/vm_label_annotation_test.go b/tests/e2e/vm_label_annotation_test.go index 4c8ad93375..d10c7b2a92 100644 --- a/tests/e2e/vm_label_annotation_test.go +++ b/tests/e2e/vm_label_annotation_test.go @@ -121,7 +121,7 @@ var _ = Describe("Virtual machine label and annotation", ginkgoutil.CommonE2ETes Context("Preparing the environment", func() { It("sets the namespace", func() { - kustomization := fmt.Sprintf("%s/%s", conf.TestData.VmLabelAnnotation, "kustomization.yaml") + kustomization := fmt.Sprintf("%s/%s", conf.TestData.VMLabelAnnotation, "kustomization.yaml") ns, err := kustomize.GetNamespace(kustomization) Expect(err).NotTo(HaveOccurred(), "%w", err) conf.SetNamespace(ns) @@ -131,7 +131,7 @@ var _ = Describe("Virtual machine label and annotation", ginkgoutil.CommonE2ETes Context("When resources are applied", func() { It("result should be succeeded", func() { res := kubectl.Apply(kc.ApplyOptions{ - Filename: []string{conf.TestData.VmLabelAnnotation}, + Filename: []string{conf.TestData.VMLabelAnnotation}, FilenameOption: kc.Kustomize, }) Expect(res.Error()).NotTo(HaveOccurred(), "cmd: %s\nstderr: %s", res.GetCmd(), res.StdErr()) @@ -163,7 +163,7 @@ var _ = Describe("Virtual machine label and annotation", ginkgoutil.CommonE2ETes Context("When virtual machines are applied", func() { It("checks VMs phases", func() { By("Virtual machine agents should be ready") - WaitVmAgentReady(kc.WaitOptions{ + WaitVMAgentReady(kc.WaitOptions{ Labels: testCaseLabel, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, @@ -358,7 +358,7 @@ var _ = Describe("Virtual machine label and annotation", ginkgoutil.CommonE2ETes Context("When test is completed", func() { It("deletes test case resources", func() { DeleteTestCaseResources(ResourcesToDelete{ - KustomizationDir: conf.TestData.VmLabelAnnotation, + KustomizationDir: conf.TestData.VMLabelAnnotation, }) }) }) diff --git a/tests/e2e/vm_migration_cancel_test.go b/tests/e2e/vm_migration_cancel_test.go index 73e1e0a66e..d5261c4aee 100644 --- a/tests/e2e/vm_migration_cancel_test.go +++ b/tests/e2e/vm_migration_cancel_test.go @@ -23,7 +23,6 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - virtv1 "kubevirt.io/api/core/v1" virtv2 "github.com/deckhouse/virtualization/api/core/v1alpha2" @@ -37,13 +36,13 @@ var _ = Describe("Virtual machine cancel migration", SIGMigration(), ginkgoutil. testCaseLabel := map[string]string{"testcase": "vm-migration-cancel"} BeforeEach(func() { - kustomization := fmt.Sprintf("%s/%s", conf.TestData.VmMigrationCancel, "kustomization.yaml") + kustomization := fmt.Sprintf("%s/%s", conf.TestData.VMMigrationCancel, "kustomization.yaml") ns, err := kustomize.GetNamespace(kustomization) Expect(err).NotTo(HaveOccurred(), "%w", err) conf.SetNamespace(ns) res := kubectl.Apply(kc.ApplyOptions{ - Filename: []string{conf.TestData.VmMigrationCancel}, + Filename: []string{conf.TestData.VMMigrationCancel}, FilenameOption: kc.Kustomize, }) Expect(res.WasSuccess()).To(Equal(true), res.StdErr()) @@ -63,14 +62,14 @@ var _ = Describe("Virtual machine cancel migration", SIGMigration(), ginkgoutil. } if config.IsCleanUpNeeded() { - resourcesToDelete.KustomizationDir = conf.TestData.VmMigrationCancel + resourcesToDelete.KustomizationDir = conf.TestData.VMMigrationCancel } DeleteTestCaseResources(resourcesToDelete) }) It("Cancel migrate", func() { By("Virtual machine agents should be ready") - WaitVmAgentReady(kc.WaitOptions{ + WaitVMAgentReady(kc.WaitOptions{ Labels: testCaseLabel, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, @@ -87,9 +86,9 @@ var _ = Describe("Virtual machine cancel migration", SIGMigration(), ginkgoutil. for _, name := range vmNames { By(fmt.Sprintf("Exec SSHCommand for virtualmachine %s/%s", conf.Namespace, name)) - res := d8Virtualization.SshCommand(name, "sudo nohup stress-ng --vm 1 --vm-bytes 100% --timeout 300s &>/dev/null &", d8.SshOptions{ + res := d8Virtualization.SSHCommand(name, "sudo nohup stress-ng --vm 1 --vm-bytes 100% --timeout 300s &>/dev/null &", d8.SSHOptions{ Namespace: conf.Namespace, - Username: conf.TestData.SshUser, + Username: conf.TestData.SSHUser, IdenityFile: conf.TestData.Sshkey, Timeout: ShortTimeout, }) @@ -156,7 +155,6 @@ var _ = Describe("Virtual machine cancel migration", SIGMigration(), ginkgoutil. } } return fmt.Errorf("retry because not all vmops canceled") - }).WithTimeout(MaxWaitTimeout).WithPolling(time.Second).ShouldNot(HaveOccurred()) Expect(someCompleted).Should(BeFalse()) diff --git a/tests/e2e/vm_migration_test.go b/tests/e2e/vm_migration_test.go index 251aab8176..65ff8f3d43 100644 --- a/tests/e2e/vm_migration_test.go +++ b/tests/e2e/vm_migration_test.go @@ -45,7 +45,7 @@ var _ = Describe("Virtual machine migration", SIGMigration(), ginkgoutil.CommonE Context("Preparing the environment", func() { It("sets the namespace", func() { - kustomization := fmt.Sprintf("%s/%s", conf.TestData.VmMigration, "kustomization.yaml") + kustomization := fmt.Sprintf("%s/%s", conf.TestData.VMMigration, "kustomization.yaml") ns, err := kustomize.GetNamespace(kustomization) Expect(err).NotTo(HaveOccurred(), "%w", err) conf.SetNamespace(ns) @@ -68,7 +68,7 @@ var _ = Describe("Virtual machine migration", SIGMigration(), ginkgoutil.CommonE } res := kubectl.Apply(kc.ApplyOptions{ - Filename: []string{conf.TestData.VmMigration}, + Filename: []string{conf.TestData.VMMigration}, FilenameOption: kc.Kustomize, }) Expect(res.WasSuccess()).To(Equal(true), res.StdErr()) @@ -78,7 +78,7 @@ var _ = Describe("Virtual machine migration", SIGMigration(), ginkgoutil.CommonE Context("When virtual machines are applied", func() { It("checks VMs phases", func() { By("Virtual machine agents should be ready") - WaitVmAgentReady(kc.WaitOptions{ + WaitVMAgentReady(kc.WaitOptions{ Labels: testCaseLabel, Namespace: conf.Namespace, Timeout: MaxWaitTimeout, @@ -143,7 +143,7 @@ var _ = Describe("Virtual machine migration", SIGMigration(), ginkgoutil.CommonE } if config.IsCleanUpNeeded() { - resourcesToDelete.KustomizationDir = conf.TestData.VmMigration + resourcesToDelete.KustomizationDir = conf.TestData.VMMigration } DeleteTestCaseResources(resourcesToDelete) diff --git a/tests/e2e/vm_version_test.go b/tests/e2e/vm_version_test.go index affb6fd0b9..9e8207fb7f 100644 --- a/tests/e2e/vm_version_test.go +++ b/tests/e2e/vm_version_test.go @@ -22,10 +22,9 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + virtv2 "github.com/deckhouse/virtualization/api/core/v1alpha2" "github.com/deckhouse/virtualization/tests/e2e/config" "github.com/deckhouse/virtualization/tests/e2e/ginkgoutil" - - virtv2 "github.com/deckhouse/virtualization/api/core/v1alpha2" kc "github.com/deckhouse/virtualization/tests/e2e/kubectl" ) @@ -46,7 +45,7 @@ var _ = Describe("Virtual machine versions", ginkgoutil.CommonE2ETestDecorators( Context("Preparing the environment", func() { It("sets the namespace", func() { - kustomization := fmt.Sprintf("%s/%s", conf.TestData.VmVersions, "kustomization.yaml") + kustomization := fmt.Sprintf("%s/%s", conf.TestData.VMVersions, "kustomization.yaml") ns, err := kustomize.GetNamespace(kustomization) Expect(err).NotTo(HaveOccurred(), "%w", err) conf.SetNamespace(ns) @@ -56,7 +55,7 @@ var _ = Describe("Virtual machine versions", ginkgoutil.CommonE2ETestDecorators( Context("When virtualization resources are applied:", func() { It("result should be succeeded", func() { res := kubectl.Apply(kc.ApplyOptions{ - Filename: []string{conf.TestData.VmVersions}, + Filename: []string{conf.TestData.VMVersions}, FilenameOption: kc.Kustomize, }) Expect(res.Error()).NotTo(HaveOccurred(), "cmd: %s\nstderr: %s", res.GetCmd(), res.StdErr()) @@ -113,7 +112,7 @@ var _ = Describe("Virtual machine versions", ginkgoutil.CommonE2ETestDecorators( Context("When test is completed", func() { It("deletes test case resources", func() { DeleteTestCaseResources(ResourcesToDelete{ - KustomizationDir: conf.TestData.VmVersions, + KustomizationDir: conf.TestData.VMVersions, }) }) })