-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add E2E tests for MachineDeployment orchestrated in-place upgrades (#74)
- Loading branch information
1 parent
183bfa9
commit 1012cfc
Showing
2 changed files
with
191 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
//go:build e2e | ||
// +build e2e | ||
|
||
/* | ||
Copyright 2021 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package e2e | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"path/filepath" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
corev1 "k8s.io/api/core/v1" | ||
"k8s.io/utils/ptr" | ||
"sigs.k8s.io/cluster-api/test/framework/clusterctl" | ||
"sigs.k8s.io/cluster-api/util" | ||
) | ||
|
||
var _ = Describe("Machine Deployment Orchestrated In place upgrades", func() { | ||
var ( | ||
ctx = context.TODO() | ||
specName = "workload-cluster-md-inplace" | ||
namespace *corev1.Namespace | ||
cancelWatches context.CancelFunc | ||
result *ApplyClusterTemplateAndWaitResult | ||
clusterName string | ||
clusterctlLogFolder string | ||
infrastructureProvider string | ||
) | ||
|
||
BeforeEach(func() { | ||
Expect(e2eConfig.Variables).To(HaveKey(KubernetesVersion)) | ||
|
||
clusterName = fmt.Sprintf("capick8s-md-in-place-%s", util.RandomString(6)) | ||
infrastructureProvider = clusterctl.DefaultInfrastructureProvider | ||
|
||
// Setup a Namespace where to host objects for this spec and create a watcher for the namespace events. | ||
namespace, cancelWatches = setupSpecNamespace(ctx, specName, bootstrapClusterProxy, artifactFolder) | ||
|
||
result = new(ApplyClusterTemplateAndWaitResult) | ||
|
||
clusterctlLogFolder = filepath.Join(artifactFolder, "clusters", bootstrapClusterProxy.GetName()) | ||
}) | ||
|
||
AfterEach(func() { | ||
cleanInput := cleanupInput{ | ||
SpecName: specName, | ||
Cluster: result.Cluster, | ||
ClusterProxy: bootstrapClusterProxy, | ||
Namespace: namespace, | ||
CancelWatches: cancelWatches, | ||
IntervalsGetter: e2eConfig.GetIntervals, | ||
SkipCleanup: skipCleanup, | ||
ArtifactFolder: artifactFolder, | ||
} | ||
|
||
dumpSpecResourcesAndCleanup(ctx, cleanInput) | ||
}) | ||
|
||
Context("Performing Machine Deployment Orchestrated in-place upgrades", func() { | ||
It("Creating a workload cluster and applying in-place upgrade to Machine Deployment [MD-InPlace] [PR-Blocking]", func() { | ||
By("Creating a workload cluster of 1 control plane and 3 worker nodes") | ||
ApplyClusterTemplateAndWait(ctx, ApplyClusterTemplateAndWaitInput{ | ||
ClusterProxy: bootstrapClusterProxy, | ||
ConfigCluster: clusterctl.ConfigClusterInput{ | ||
LogFolder: clusterctlLogFolder, | ||
ClusterctlConfigPath: clusterctlConfigPath, | ||
KubeconfigPath: bootstrapClusterProxy.GetKubeconfigPath(), | ||
InfrastructureProvider: infrastructureProvider, | ||
Namespace: namespace.Name, | ||
ClusterName: clusterName, | ||
KubernetesVersion: e2eConfig.GetVariable(KubernetesVersion), | ||
ControlPlaneMachineCount: ptr.To(int64(1)), | ||
WorkerMachineCount: ptr.To(int64(3)), | ||
}, | ||
WaitForClusterIntervals: e2eConfig.GetIntervals(specName, "wait-cluster"), | ||
WaitForControlPlaneIntervals: e2eConfig.GetIntervals(specName, "wait-control-plane"), | ||
WaitForMachineDeployments: e2eConfig.GetIntervals(specName, "wait-worker-nodes"), | ||
}, result) | ||
|
||
bootstrapProxyClient := bootstrapClusterProxy.GetClient() | ||
|
||
By("Applying in place upgrade with local path for worker nodes") | ||
ApplyInPlaceUpgradeForMachineDeployment(ctx, ApplyInPlaceUpgradeForMachineDeploymentInput{ | ||
Lister: bootstrapProxyClient, | ||
Getter: bootstrapProxyClient, | ||
ClusterProxy: bootstrapClusterProxy, | ||
Cluster: result.Cluster, | ||
WaitForUpgradeIntervals: e2eConfig.GetIntervals(specName, "wait-machine-upgrade"), | ||
UpgradeOption: e2eConfig.GetVariable(InPlaceUpgradeOption), | ||
MachineDeployments: result.MachineDeployments, | ||
}) | ||
}) | ||
}) | ||
|
||
}) |