-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
150 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package e2e | ||
|
||
import ( | ||
"path/filepath" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
v1 "k8s.io/api/apps/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"sigs.k8s.io/cluster-api/test/framework" | ||
"sigs.k8s.io/cluster-api/test/framework/bootstrap" | ||
"sigs.k8s.io/cluster-api/test/framework/clusterctl" | ||
) | ||
|
||
var _ = Describe("BMO Upgrade", func() { | ||
var ( | ||
bmoNamespace string | ||
bmoDeployName string | ||
upgradeClusterProvider bootstrap.ClusterProvider | ||
upgradeClusterProxy framework.ClusterProxy | ||
) | ||
BeforeEach(func() { | ||
if e2eConfig.GetVariable("RUN_UPGRADE_TESTS") != "true" { | ||
Skip("Upgrade tests are skipped") | ||
} | ||
bmoNamespace = "baremetal-operator-system" | ||
bmoDeployName = "baremetal-operator-controller-manager" | ||
bmoUpgradeFromImageName := e2eConfig.GetVariable("BMO_UPGRADE_FROM_IMAGE") | ||
bmoUpgradeFromImage := clusterctl.ContainerImage{ | ||
Name: bmoUpgradeFromImageName, | ||
LoadBehavior: clusterctl.MustLoadImage, | ||
} | ||
|
||
By("Creating a separate cluster for upgrade tests") | ||
upgradeClusterProvider = bootstrap.CreateKindBootstrapClusterAndLoadImages(ctx, bootstrap.CreateKindBootstrapClusterAndLoadImagesInput{ | ||
Name: "bmo-e2e-upgrade", | ||
Images: append(e2eConfig.Images, bmoUpgradeFromImage), | ||
}) | ||
Expect(upgradeClusterProvider).ToNot(BeNil(), "Failed to create a cluster") | ||
kubeconfigPath := upgradeClusterProvider.GetKubeconfigPath() | ||
scheme := runtime.NewScheme() | ||
framework.TryAddDefaultSchemes(scheme) | ||
upgradeClusterProxy = framework.NewClusterProxy("bmo-e2e-upgrade", kubeconfigPath, scheme) | ||
By("Installing cert-manager on the upgrade cluster") | ||
cmVersion := e2eConfig.GetVariable("CERT_MANAGER_VERSION") | ||
err := installCertManager(ctx, upgradeClusterProxy, cmVersion) | ||
Expect(err).NotTo(HaveOccurred()) | ||
By("Waiting for cert-manager webhook") | ||
Eventually(func() error { | ||
return checkCertManagerWebhook(ctx, upgradeClusterProxy) | ||
}, e2eConfig.GetIntervals("default", "wait-available")...).Should(Succeed()) | ||
err = checkCertManagerAPI(upgradeClusterProxy) | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
By("Installing BMO on the upgrade cluster") | ||
kustomization := e2eConfig.GetVariable("BMO_UPGRADE_FROM_KUSTOMIZATION") | ||
manifest, err := buildKustomizeManifest(kustomization) | ||
Expect(err).NotTo(HaveOccurred()) | ||
err = upgradeClusterProxy.Apply(ctx, manifest) | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
bmoDeployment := &v1.Deployment{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "baremetal-operator-controller-manager", | ||
Namespace: "baremetal-operator-system", | ||
}, | ||
} | ||
// Wait for it to become available | ||
framework.WaitForDeploymentsAvailable(ctx, framework.WaitForDeploymentsAvailableInput{ | ||
Getter: upgradeClusterProxy.GetClient(), | ||
Deployment: bmoDeployment, | ||
}, e2eConfig.GetIntervals("default", "wait-deployment")...) | ||
// Set up log watcher | ||
framework.WatchDeploymentLogsByName(ctx, framework.WatchDeploymentLogsByNameInput{ | ||
GetLister: upgradeClusterProxy.GetClient(), | ||
Cache: upgradeClusterProxy.GetCache(ctx), | ||
ClientSet: upgradeClusterProxy.GetClientSet(), | ||
Deployment: bmoDeployment, | ||
LogPath: filepath.Join(artifactFolder, "logs", bmoDeployment.GetNamespace()), | ||
}) | ||
}) | ||
|
||
It("Should upgrade BMO to latest version", func() { | ||
By("Upgrading BMO deployment") | ||
bmoKustomization := e2eConfig.GetVariable("BMO_KUSTOMIZATION") | ||
clientSet := upgradeClusterProxy.GetClientSet() | ||
deploy, err := clientSet.AppsV1().Deployments(bmoNamespace).Get(ctx, bmoDeployName, metav1.GetOptions{}) | ||
Expect(err).NotTo(HaveOccurred()) | ||
manifest, err := buildKustomizeManifest(bmoKustomization) | ||
Expect(err).NotTo(HaveOccurred()) | ||
err = upgradeClusterProxy.Apply(ctx, manifest) | ||
Expect(err).NotTo(HaveOccurred()) | ||
By("Waiting for BMO update to rollout") | ||
Eventually(func() bool { | ||
return DeploymentRolledOut(ctx, upgradeClusterProxy, bmoDeployName, bmoNamespace, deploy.Status.ObservedGeneration+1) | ||
}, | ||
e2eConfig.GetIntervals("default", "wait-deployment")..., | ||
).Should(BeTrue()) | ||
}) | ||
|
||
AfterEach(func() { | ||
upgradeClusterProxy.Dispose(ctx) | ||
upgradeClusterProvider.Dispose(ctx) | ||
}) | ||
|
||
}) |