-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add e2e for cluster import functionality
Signed-off-by: Danil Grigorev <danil.grigorev@suse.com>
- Loading branch information
1 parent
caad847
commit 3cdee05
Showing
7 changed files
with
5,001 additions
and
48 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 was deleted.
Oops, something went wrong.
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,85 @@ | ||
//go:build e2e | ||
// +build e2e | ||
|
||
/* | ||
Copyright 2023 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 ( | ||
"fmt" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
"github.com/rancher-sandbox/rancher-turtles/internal/rancher" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
|
||
apierrors "k8s.io/apimachinery/pkg/api/errors" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" | ||
) | ||
|
||
var _ = Describe("Create and delete CAPI cluster functionality should work", func() { | ||
var ( | ||
bootstrapCluster client.Client | ||
rancherClusterHandler *rancher.ClusterHandler | ||
capiCluster *clusterv1.Cluster | ||
rancherClusterKey client.ObjectKey | ||
) | ||
|
||
BeforeEach(func() { | ||
bootstrapCluster = bootstrapClusterProxy.GetClient() | ||
rancherClusterHandler = rancher.NewClusterHandler(ctx, bootstrapCluster) | ||
capiCluster = &clusterv1.Cluster{ObjectMeta: metav1.ObjectMeta{ | ||
Namespace: capiClusterNamespace, | ||
Name: capiClusterName, | ||
}} | ||
rancherClusterKey = client.ObjectKey{ | ||
Namespace: capiClusterNamespace, | ||
Name: fmt.Sprintf("%s-capi", capiClusterName), | ||
} | ||
}) | ||
|
||
It("should successfully create a rancher cluster from CAPI cluster", func() { | ||
By("Creating a CAPI docker provider cluster setup") | ||
Eventually(func() error { | ||
return bootstrapClusterProxy.Apply(ctx, fleetCapiTestdata) | ||
}, e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...).Should(Succeed()) | ||
|
||
By("Waiting for rancher cluster record to appear") | ||
Eventually(func() error { | ||
_, err := rancherClusterHandler.Get(rancherClusterKey) | ||
return err | ||
}, e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...).Should(Succeed()) | ||
}) | ||
|
||
It("should successfully remove a rancher cluster after CAPI cluster removal and no longer re-import it", func() { | ||
By("Removing CAPI cluster record") | ||
Expect(bootstrapCluster.Delete(ctx, capiCluster)).To(Succeed()) | ||
|
||
By("Waiting for rancher cluster to be removed") | ||
Eventually(func() bool { | ||
_, err := rancherClusterHandler.Get(rancherClusterKey) | ||
return apierrors.IsNotFound(err) | ||
}, e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...).Should(BeTrue()) | ||
|
||
By("Checking if rancher cluster record will not be created again") | ||
Consistently(func() bool { | ||
_, err := rancherClusterHandler.Get(rancherClusterKey) | ||
return apierrors.IsNotFound(err) | ||
}, e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-consistently")...).Should(BeTrue()) | ||
}) | ||
}) |
Oops, something went wrong.