From 783badf2949e3980e7c19f825da9523e81e3e0ad Mon Sep 17 00:00:00 2001 From: "Yuriy Georgiev (jeux)" Date: Thu, 7 Apr 2022 08:04:51 +0300 Subject: [PATCH] Installer: e2e tests against unsupported minor & major versions of K8s (#451) * Implemented K8s patch version masking via registry filter similar to the OS one * Revert "Implemented K8s patch version masking via registry filter similar to the OS one" This reverts commit fdbfbb293cd76eb16889fefff416e7c9c1a459c8. * Implemented K8s patch version masking via registry filter similar to the OS one * Updated the registry e2e test * Resolved hardcoded k8s version requirement from the Installer * Resolved issue causing the installer to panic when no k8s version is specified when calling the addBundleInstaller - it now defaults to v1.22.3 if no k8s ver is specified * Default K8s version set to v1.22 if no such is provided; Any patch subversion is accepted if supported Major and Minor versions are present. * Added filters for K8s versions v1.21.*, v1.22.*, v1.23.* * Revert "Added filters for K8s versions v1.21.*, v1.22.*, v1.23.*" This reverts commit eb3a0338c991553686b5cfc4b29b9ed178728868. * Revert "Added filters for K8s versions v1.21.*, v1.22.*, v1.23.*" This reverts commit eb3a0338c991553686b5cfc4b29b9ed178728868. There is a separate issue for this task. * Updated K8s against algo mapping to require specific hardcoded mask versions * Added empty lines between couple of comments * Refactored the filter container from plain array to struct for consistency reasons; Updated the registry e2e tests * Removed unused registry test variable * Renamed the supported OS container structure to better represent it purpose. * Added support and filters for K8s minor versions v1.21.* & v1.23.* to the installer. * Implemented tests for unsupported K8s versions * Resolved go lint missing space issue * Consolidated Installer Ginkgo test Contexts to a single one as they are seving the same purpose * Resolved golangc-lint err in an Installer Test * Updated Installer Test to conform the updated signature of the newUnchecked() method that requires the Bundle Type --- agent/installer/installer_test.go | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/agent/installer/installer_test.go b/agent/installer/installer_test.go index 85ea1118a..25c7186cb 100644 --- a/agent/installer/installer_test.go +++ b/agent/installer/installer_test.go @@ -16,18 +16,23 @@ var _ = Describe("Byohost Installer Tests", func() { Context("When installer is created for unsupported OS", func() { It("Should return error", func() { - _, err := newUnchecked("Ubuntu_99.04.3_x86-64", BundleTypeK8s, "", logr.Discard(), nil) + _, err := newUnchecked("Ubuntu_99.04.3_x86-64", "k8s", "", logr.Discard(), nil) Expect(err).Should(HaveOccurred()) }) }) Context("When installer is created with empty download path", func() { It("Should return error", func() { - _, err := New("", BundleTypeK8s, logr.Discard()) + _, err := New("", "k8s", logr.Discard()) Expect(err).Should(HaveOccurred()) }) }) Context("When installer is created", func() { It("Install/uninstall should return error for unsupported k8s", func() { + + // Currently supported versions: v1.21.*, v1.22.*, v1.23.* + unsupportedMinorVer := "v1.20.1" + unsupportedMajorVer := "v0.21.1" + _, osList := ListSupportedOS() for _, os := range osList { i := NewPreviewInstaller(os, nil) @@ -37,6 +42,18 @@ var _ = Describe("Byohost Installer Tests", func() { err = i.Uninstall("", "unsupported-k8s", testTag) Expect(err).Should(HaveOccurred()) + + err = i.Install("", unsupportedMinorVer, testTag) + Expect(err).Should(HaveOccurred()) + + err = i.Uninstall("", unsupportedMinorVer, testTag) + Expect(err).Should(HaveOccurred()) + + err = i.Install("", unsupportedMajorVer, testTag) + Expect(err).Should(HaveOccurred()) + + err = i.Uninstall("", unsupportedMajorVer, testTag) + Expect(err).Should(HaveOccurred()) } }) }) @@ -125,7 +142,7 @@ var _ = Describe("Byohost Installer Tests", func() { }) func NewPreviewInstaller(os string, ob algo.OutputBuilder) *installer { - i, err := newUnchecked(os, BundleTypeK8s, "", logr.Discard(), ob) + i, err := newUnchecked(os, "k8s", "", logr.Discard(), ob) if err != nil { panic(err) }