-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Chandan Pinjani <[email protected]>
- Loading branch information
Showing
30 changed files
with
1,080 additions
and
202 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
Copyright © 2023 - 2024 SUSE LLC | ||
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 backup_test | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
. "github.com/rancher-sandbox/qase-ginkgo" | ||
|
||
"testing" | ||
|
||
"github.com/rancher/hosted-providers-e2e/hosted/aks/helper" | ||
"github.com/rancher/hosted-providers-e2e/hosted/helpers" | ||
"github.com/rancher/shepherd/clients/rancher" | ||
management "github.com/rancher/shepherd/clients/rancher/generated/management/v3" | ||
namegen "github.com/rancher/shepherd/pkg/namegenerator" | ||
) | ||
|
||
const ( | ||
increaseBy = 1 | ||
) | ||
|
||
var ( | ||
testCaseID int64 | ||
clusterName, backupFile string | ||
ctx helpers.RancherContext | ||
cluster *management.Cluster | ||
location = helpers.GetAKSLocation() | ||
k3sVersion = os.Getenv("INSTALL_K3S_VERSION") | ||
) | ||
|
||
func TestBackupRestore(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
helpers.CommonSynchronizedBeforeSuite() | ||
ctx = helpers.CommonBeforeSuite() | ||
RunSpecs(t, "BackupRestore Suite") | ||
} | ||
|
||
var _ = ReportBeforeEach(func(report SpecReport) { | ||
// Reset case ID | ||
testCaseID = -1 | ||
}) | ||
|
||
var _ = ReportAfterEach(func(report SpecReport) { | ||
// Add result in Qase if asked | ||
Qase(testCaseID, report) | ||
}) | ||
|
||
var _ = BeforeEach(func() { | ||
clusterName = namegen.AppendRandomString(helpers.ClusterNamePrefix) | ||
k8sVersion, err := helper.GetK8sVersion(ctx.RancherAdminClient, ctx.CloudCredID, location, false) | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
GinkgoLogr.Info(fmt.Sprintf("Using K8s version %s for cluster %s", k8sVersion, clusterName)) | ||
cluster, err = helper.CreateAKSHostedCluster(ctx.RancherAdminClient, clusterName, ctx.CloudCredID, k8sVersion, location, nil) | ||
Expect(err).To(BeNil()) | ||
cluster, err = helpers.WaitUntilClusterIsReady(cluster, ctx.RancherAdminClient) | ||
Expect(err).To(BeNil()) | ||
}) | ||
|
||
var _ = AfterEach(func() { | ||
if ctx.ClusterCleanup && cluster != nil { | ||
err := helper.DeleteAKSHostCluster(cluster, ctx.RancherAdminClient) | ||
Expect(err).To(BeNil()) | ||
} else { | ||
fmt.Println("Skipping downstream cluster deletion: ", clusterName) | ||
} | ||
}) | ||
|
||
func restoreNodesChecks(cluster *management.Cluster, client *rancher.Client, clusterName string) { | ||
helpers.ClusterIsReadyChecks(cluster, client, clusterName) | ||
initialNodeCount := *cluster.AKSConfig.NodePools[0].Count | ||
|
||
By("scaling up the nodepool", func() { | ||
var err error | ||
cluster, err = helper.ScaleNodePool(cluster, client, initialNodeCount+1, true, true) | ||
Expect(err).To(BeNil()) | ||
}) | ||
|
||
By("adding a nodepool", func() { | ||
var err error | ||
cluster, err = helper.AddNodePool(cluster, increaseBy, client, true, true) | ||
Expect(err).To(BeNil()) | ||
}) | ||
} |
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,84 @@ | ||
/* | ||
Copyright © 2022 - 2025 SUSE LLC | ||
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 backup_test | ||
|
||
import ( | ||
"os" | ||
"os/exec" | ||
"time" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
"github.com/rancher-sandbox/ele-testhelpers/kubectl" | ||
"github.com/rancher-sandbox/ele-testhelpers/tools" | ||
"github.com/rancher/hosted-providers-e2e/hosted/helpers" | ||
) | ||
|
||
const ( | ||
backupResourceName = "hp-backup" | ||
restoreResourceName = "hp-restore" | ||
) | ||
|
||
var _ = Describe("BackupRestore", func() { | ||
// Create kubectl context | ||
// Default timeout is too small, so New() cannot be used | ||
k := &kubectl.Kubectl{ | ||
Namespace: "", | ||
PollTimeout: tools.SetTimeout(300 * time.Second), | ||
PollInterval: 500 * time.Millisecond, | ||
} | ||
|
||
It("Do a full backup/restore test", func() { | ||
By("Checking hosted cluster is ready", func() { | ||
helpers.ClusterIsReadyChecks(cluster, ctx.RancherAdminClient, clusterName) | ||
}) | ||
|
||
By("Performing a backup", func() { | ||
// Report to Qase | ||
// testCaseID = 65 | ||
backupFile = helpers.ExecuteBackup(k, backupResourceName) | ||
}) | ||
|
||
By("Perform restore pre-requisites: Uninstalling k3s", func() { | ||
out, err := exec.Command("k3s-uninstall.sh").CombinedOutput() | ||
Expect(err).To(Not(HaveOccurred()), out) | ||
}) | ||
|
||
By("Perform restore pre-requisites: Getting k3s ready", func() { | ||
helpers.InstallK3S(k, k3sVersion, "none", "none") | ||
}) | ||
|
||
By("Performing a restore", func() { | ||
helpers.ExecuteRestore(k, restoreResourceName, backupFile) | ||
}) | ||
|
||
By("Performing post migration installations: Installing CertManager", func() { | ||
helpers.InstallCertManager(k, "none", "none") | ||
}) | ||
|
||
By("Performing post migration installations: Installing Rancher Manager", func() { | ||
rancherChannel, rancherVersion, rancherHeadVersion := helpers.GetRancherVersions() | ||
helpers.InstallRancherManager(k, os.Getenv("RANCHER_HOSTNAME"), rancherChannel, rancherVersion, rancherHeadVersion, "none", "none") | ||
}) | ||
|
||
By("Performing post migration installations: Checking Rancher Deployments", func() { | ||
helpers.CheckRancherDeployments(k) | ||
}) | ||
|
||
By("Checking hosted cluster is able to be modified", func() { | ||
restoreNodesChecks(cluster, ctx.RancherAdminClient, clusterName) | ||
}) | ||
}) | ||
}) |
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
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,100 @@ | ||
/* | ||
Copyright © 2023 - 2024 SUSE LLC | ||
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 backup_test | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
. "github.com/rancher-sandbox/qase-ginkgo" | ||
|
||
"testing" | ||
|
||
"github.com/rancher/hosted-providers-e2e/hosted/eks/helper" | ||
"github.com/rancher/hosted-providers-e2e/hosted/helpers" | ||
"github.com/rancher/shepherd/clients/rancher" | ||
management "github.com/rancher/shepherd/clients/rancher/generated/management/v3" | ||
namegen "github.com/rancher/shepherd/pkg/namegenerator" | ||
) | ||
|
||
const ( | ||
increaseBy = 1 | ||
) | ||
|
||
var ( | ||
testCaseID int64 | ||
clusterName, backupFile string | ||
ctx helpers.RancherContext | ||
cluster *management.Cluster | ||
region = helpers.GetEKSRegion() | ||
k3sVersion = os.Getenv("INSTALL_K3S_VERSION") | ||
) | ||
|
||
func TestBackupRestore(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
helpers.CommonSynchronizedBeforeSuite() | ||
ctx = helpers.CommonBeforeSuite() | ||
RunSpecs(t, "BackupRestore Suite") | ||
} | ||
|
||
var _ = ReportBeforeEach(func(report SpecReport) { | ||
// Reset case ID | ||
testCaseID = -1 | ||
}) | ||
|
||
var _ = ReportAfterEach(func(report SpecReport) { | ||
// Add result in Qase if asked | ||
Qase(testCaseID, report) | ||
}) | ||
|
||
var _ = BeforeEach(func() { | ||
clusterName = namegen.AppendRandomString(helpers.ClusterNamePrefix) | ||
k8sVersion, err := helper.GetK8sVersion(ctx.RancherAdminClient, false) | ||
Expect(err).To(BeNil()) | ||
|
||
GinkgoLogr.Info(fmt.Sprintf("Using K8s version %s for cluster %s", k8sVersion, clusterName)) | ||
cluster, err = helper.CreateEKSHostedCluster(ctx.RancherAdminClient, clusterName, ctx.CloudCredID, k8sVersion, region, nil) | ||
Expect(err).To(BeNil()) | ||
cluster, err = helpers.WaitUntilClusterIsReady(cluster, ctx.RancherAdminClient) | ||
Expect(err).To(BeNil()) | ||
}) | ||
|
||
var _ = AfterEach(func() { | ||
if ctx.ClusterCleanup && cluster != nil { | ||
err := helper.DeleteEKSHostCluster(cluster, ctx.RancherAdminClient) | ||
Expect(err).To(BeNil()) | ||
} else { | ||
fmt.Println("Skipping downstream cluster deletion: ", clusterName) | ||
} | ||
}) | ||
|
||
func restoreNodesChecks(cluster *management.Cluster, client *rancher.Client, clusterName string) { | ||
helpers.ClusterIsReadyChecks(cluster, client, clusterName) | ||
initialNodeCount := *cluster.EKSConfig.NodeGroups[0].DesiredSize | ||
|
||
By("scaling up the NodeGroup", func() { | ||
var err error | ||
cluster, err = helper.ScaleNodeGroup(cluster, client, initialNodeCount+increaseBy, true, true) | ||
Expect(err).To(BeNil()) | ||
}) | ||
|
||
By("adding a NodeGroup", func() { | ||
var err error | ||
cluster, err = helper.AddNodeGroup(cluster, increaseBy, client, true, true) | ||
Expect(err).To(BeNil()) | ||
}) | ||
} |
Oops, something went wrong.