generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 37
Added e2e test for multiple network support #455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
k8s-ci-robot
merged 1 commit into
kubernetes-sigs:main
from
shapeblue:testsForMultiNicSupport
Jul 15, 2025
+270
−0
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
6 changes: 6 additions & 0 deletions
6
...a/infrastructure-cloudstack/v1beta3/cluster-template-multiple-networks/kustomization.yaml
This file contains hidden or 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,6 @@ | ||
| bases: | ||
| - ../bases/cluster-with-kcp.yaml | ||
| - ../bases/md.yaml | ||
|
|
||
| patchesStrategicMerge: | ||
| - ./multiple-networks.yaml |
33 changes: 33 additions & 0 deletions
33
...frastructure-cloudstack/v1beta3/cluster-template-multiple-networks/multiple-networks.yaml
This file contains hidden or 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,33 @@ | ||
| --- | ||
| apiVersion: infrastructure.cluster.x-k8s.io/v1beta3 | ||
| kind: CloudStackMachineTemplate | ||
| metadata: | ||
| name: ${CLUSTER_NAME}-control-plane | ||
| spec: | ||
| template: | ||
| spec: | ||
| offering: | ||
| name: ${CLOUDSTACK_CONTROL_PLANE_MACHINE_OFFERING} | ||
| template: | ||
| name: ${CLOUDSTACK_TEMPLATE_NAME} | ||
| sshKey: ${CLOUDSTACK_SSH_KEY_NAME} | ||
| affinity: pro | ||
harikrishna-patnala marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| networks: | ||
| - name: ${CLOUDSTACK_NETWORK_NAME} | ||
| - name: ${CLOUDSTACK_NEW_NETWORK_NAME} | ||
| --- | ||
| apiVersion: infrastructure.cluster.x-k8s.io/v1beta3 | ||
| kind: CloudStackMachineTemplate | ||
| metadata: | ||
| name: ${CLUSTER_NAME}-md-0 | ||
| spec: | ||
| template: | ||
| spec: | ||
| offering: | ||
| name: ${CLOUDSTACK_WORKER_MACHINE_OFFERING} | ||
| template: | ||
| name: ${CLOUDSTACK_TEMPLATE_NAME} | ||
| sshKey: ${CLOUDSTACK_SSH_KEY_NAME} | ||
| networks: | ||
| - name: ${CLOUDSTACK_NETWORK_NAME} | ||
| - name: ${CLOUDSTACK_NEW_NETWORK_NAME} | ||
This file contains hidden or 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,100 @@ | ||
| /* | ||
| Copyright 2020 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" | ||
| "os" | ||
| "path/filepath" | ||
|
|
||
| . "github.com/onsi/ginkgo/v2" | ||
| . "github.com/onsi/gomega" | ||
| corev1 "k8s.io/api/core/v1" | ||
| "k8s.io/utils/pointer" | ||
|
|
||
| "sigs.k8s.io/cluster-api/test/framework/clusterctl" | ||
| "sigs.k8s.io/cluster-api/util" | ||
| ) | ||
|
|
||
| // MultipleNetworksSpec implements a spec that creates a cluster with nodes having multiple NICs. | ||
| func MultipleNetworksSpec(ctx context.Context, inputGetter func() CommonSpecInput) { | ||
| var ( | ||
| specName = "multiple-networks" | ||
| input CommonSpecInput | ||
| namespace *corev1.Namespace | ||
| cancelWatches context.CancelFunc | ||
| clusterResources *clusterctl.ApplyClusterTemplateAndWaitResult | ||
| ) | ||
|
|
||
| BeforeEach(func() { | ||
| Expect(ctx).NotTo(BeNil(), "ctx is required for %s spec", specName) | ||
| input = inputGetter() | ||
|
|
||
| Expect(input.E2EConfig).ToNot(BeNil(), "Invalid argument. input.E2EConfig can't be nil when calling %s spec", specName) | ||
| Expect(input.ClusterctlConfigPath).To(BeAnExistingFile(), "Invalid argument. input.ClusterctlConfigPath must be an existing file when calling %s spec", specName) | ||
| Expect(input.BootstrapClusterProxy).ToNot(BeNil(), "Invalid argument. input.BootstrapClusterProxy can't be nil when calling %s spec", specName) | ||
| Expect(os.MkdirAll(input.ArtifactFolder, 0750)).To(Succeed(), "Invalid argument. input.ArtifactFolder can't be created for %s spec", specName) | ||
|
|
||
| Expect(input.E2EConfig.Variables).To(HaveKey(KubernetesVersion)) | ||
|
|
||
| // Setup a Namespace where to host objects for this spec and create a watcher for the namespace events. | ||
| namespace, cancelWatches = setupSpecNamespace(ctx, specName, input.BootstrapClusterProxy, input.ArtifactFolder) | ||
| clusterResources = new(clusterctl.ApplyClusterTemplateAndWaitResult) | ||
| }) | ||
|
|
||
| It("Should create a workload cluster", func() { | ||
| By("Creating a workload cluster") | ||
|
|
||
| clusterName := fmt.Sprintf("%s-%s", specName, util.RandomString(6)) | ||
|
|
||
| // Get details from ACS and ensure secondary network exists | ||
| csClient := CreateCloudStackClient(ctx, input.BootstrapClusterProxy.GetKubeconfigPath()) | ||
| _, err := EnsureSecondaryNetworkExists(csClient, input) | ||
| Expect(err).ToNot(HaveOccurred(), "Failed to ensure secondary network exists") | ||
|
|
||
| clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{ | ||
| ClusterProxy: input.BootstrapClusterProxy, | ||
| CNIManifestPath: input.E2EConfig.GetVariable(CNIPath), | ||
| ConfigCluster: clusterctl.ConfigClusterInput{ | ||
| LogFolder: filepath.Join(input.ArtifactFolder, "clusters", input.BootstrapClusterProxy.GetName()), | ||
| ClusterctlConfigPath: input.ClusterctlConfigPath, | ||
| KubeconfigPath: input.BootstrapClusterProxy.GetKubeconfigPath(), | ||
| InfrastructureProvider: clusterctl.DefaultInfrastructureProvider, | ||
| Flavor: specName, | ||
| Namespace: namespace.Name, | ||
| ClusterName: clusterName, | ||
| KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersion), | ||
| ControlPlaneMachineCount: pointer.Int64Ptr(1), | ||
| WorkerMachineCount: pointer.Int64Ptr(1), | ||
| }, | ||
| WaitForClusterIntervals: input.E2EConfig.GetIntervals(specName, "wait-cluster"), | ||
| WaitForControlPlaneIntervals: input.E2EConfig.GetIntervals(specName, "wait-control-plane"), | ||
| WaitForMachineDeployments: input.E2EConfig.GetIntervals(specName, "wait-worker-nodes"), | ||
| }, clusterResources) | ||
|
|
||
| By("Verifying that each VM has two NICs") | ||
| CheckIfNodesHaveTwoNICs(csClient, clusterName, input) | ||
|
|
||
| By("PASSED!") | ||
| }) | ||
|
|
||
| AfterEach(func() { | ||
| // Dumps all the resources in the spec namespace, then cleanups the cluster object and the spec namespace itself. | ||
| dumpSpecResourcesAndCleanup(ctx, specName, input.BootstrapClusterProxy, input.ArtifactFolder, namespace, cancelWatches, clusterResources.Cluster, input.E2EConfig.GetIntervals, input.SkipCleanup) | ||
| }) | ||
| } |
This file contains hidden or 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,40 @@ | ||
| //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" | ||
|
|
||
| . "github.com/onsi/ginkgo/v2" | ||
| ) | ||
|
|
||
| var _ = Describe("Test with multiple networks for nodes", func() { | ||
|
|
||
| MultipleNetworksSpec(context.TODO(), func() CommonSpecInput { | ||
| return CommonSpecInput{ | ||
| E2EConfig: e2eConfig, | ||
| ClusterctlConfigPath: clusterctlConfigPath, | ||
| BootstrapClusterProxy: bootstrapClusterProxy, | ||
| ArtifactFolder: artifactFolder, | ||
| SkipCleanup: skipCleanup, | ||
| } | ||
| }) | ||
|
|
||
| }) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.