Skip to content

Commit

Permalink
BackupRestore common function
Browse files Browse the repository at this point in the history
Signed-off-by: Chandan Pinjani <chandan.pinjani@suse.com>
  • Loading branch information
cpinjani committed Jan 29, 2025
1 parent 422dbe4 commit 8bb6a59
Show file tree
Hide file tree
Showing 10 changed files with 142 additions and 256 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ jobs:
echo "Tests run: ${{ inputs.tests_to_run }}" >> ${GITHUB_STEP_SUMMARY}
OPERATOR_HELM_VERSION=$(helm get metadata rancher-${{ inputs.hosted_provider }}-operator -n cattle-system -o json | jq -r .version)
echo "Installed rancher-${{ inputs.hosted_provider }}-operator chart version: $OPERATOR_HELM_VERSION" >> ${GITHUB_STEP_SUMMARY}
if [ ${{ inputs.tests_to_run }} == "backup_restore" ]; then
if [ ${{ inputs.tests_to_run }} == "backup_restore*" ]; then
BR_OPERATOR_HELM_VERSION=$(helm get metadata rancher-backup -n cattle-resources-system -o json | jq -r .version)
echo "Installed backup-restore operator chart version: $BR_OPERATOR_HELM_VERSION" >> ${GITHUB_STEP_SUMMARY}
fi
Expand Down
44 changes: 2 additions & 42 deletions hosted/aks/backup_restore/backup_restore_import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,14 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package backup_test
package backup_restore_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"
)

var _ = Describe("BackupRestoreImport", func() {
Expand All @@ -37,42 +33,6 @@ var _ = Describe("BackupRestoreImport", func() {

It("Do a full backup/restore test", func() {
testCaseID = 315 // Report to Qase
By("Checking hosted cluster is ready", func() {
helpers.ClusterIsReadyChecks(cluster, ctx.RancherAdminClient, clusterName)
})

By("Performing a backup", func() {
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)
})
BackupRestoreChecks(k)
})
})
44 changes: 2 additions & 42 deletions hosted/aks/backup_restore/backup_restore_provisioning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,14 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package backup_test
package backup_restore_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"
)

var _ = Describe("BackupRestoreProvisioning", func() {
Expand All @@ -37,42 +33,6 @@ var _ = Describe("BackupRestoreProvisioning", func() {

It("Do a full backup/restore test", func() {
testCaseID = 246 // Report to Qase
By("Checking hosted cluster is ready", func() {
helpers.ClusterIsReadyChecks(cluster, ctx.RancherAdminClient, clusterName)
})

By("Performing a backup", func() {
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)
})
BackupRestoreChecks(k)
})
})
44 changes: 43 additions & 1 deletion hosted/aks/backup_restore/backup_restore_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package backup_test
package backup_restore_test

import (
"fmt"
"os"
"os/exec"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/rancher-sandbox/ele-testhelpers/kubectl"
. "github.com/rancher-sandbox/qase-ginkgo"

"testing"
Expand Down Expand Up @@ -111,3 +113,43 @@ func restoreNodesChecks(cluster *management.Cluster, client *rancher.Client, clu
Expect(err).To(BeNil())
})
}

func BackupRestoreChecks(k *kubectl.Kubectl) {
By("Checking hosted cluster is ready", func() {
helpers.ClusterIsReadyChecks(cluster, ctx.RancherAdminClient, clusterName)
})

By("Performing a backup", func() {
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)
})
}
44 changes: 2 additions & 42 deletions hosted/eks/backup_restore/backup_restore_import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,14 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package backup_test
package backup_restore_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"
)

var _ = Describe("BackupRestoreImport", func() {
Expand All @@ -37,42 +33,6 @@ var _ = Describe("BackupRestoreImport", func() {

It("Do a full backup/restore test", func() {
testCaseID = 314 // Report to Qase
By("Checking hosted cluster is ready", func() {
helpers.ClusterIsReadyChecks(cluster, ctx.RancherAdminClient, clusterName)
})

By("Performing a backup", func() {
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)
})
BackupRestoreChecks(k)
})
})
44 changes: 2 additions & 42 deletions hosted/eks/backup_restore/backup_restore_provisioning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,14 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package backup_test
package backup_restore_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"
)

var _ = Describe("BackupRestoreProvisioning", func() {
Expand All @@ -37,42 +33,6 @@ var _ = Describe("BackupRestoreProvisioning", func() {

It("Do a full backup/restore test", func() {
testCaseID = 164 // Report to Qase
By("Checking hosted cluster is ready", func() {
helpers.ClusterIsReadyChecks(cluster, ctx.RancherAdminClient, clusterName)
})

By("Performing a backup", func() {
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)
})
BackupRestoreChecks(k)
})
})
44 changes: 43 additions & 1 deletion hosted/eks/backup_restore/backup_restore_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package backup_test
package backup_restore_test

import (
"fmt"
"os"
"os/exec"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/rancher-sandbox/ele-testhelpers/kubectl"
. "github.com/rancher-sandbox/qase-ginkgo"

"testing"
Expand Down Expand Up @@ -113,3 +115,43 @@ func restoreNodesChecks(cluster *management.Cluster, client *rancher.Client, clu
Expect(err).To(BeNil())
})
}

func BackupRestoreChecks(k *kubectl.Kubectl) {
By("Checking hosted cluster is ready", func() {
helpers.ClusterIsReadyChecks(cluster, ctx.RancherAdminClient, clusterName)
})

By("Performing a backup", func() {
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)
})
}
Loading

0 comments on commit 8bb6a59

Please sign in to comment.