Skip to content

Commit

Permalink
Refactor main
Browse files Browse the repository at this point in the history
Signed-off-by: Chandan Pinjani <[email protected]>
  • Loading branch information
cpinjani committed Feb 3, 2025
1 parent 50af065 commit 9bccf34
Show file tree
Hide file tree
Showing 29 changed files with 183 additions and 77 deletions.
34 changes: 14 additions & 20 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ jobs:
env:
# For some reason the go doesn't link by default against system libresolv library
CGO_LDFLAGS: -O2 -g -lresolv
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
INSTALL_K3S_VERSION: ${{ inputs.k3s_version }}
RANCHER_VERSION: ${{ inputs.rancher_version }}
outputs:
PUBLIC_IP: ${{ steps.runner-ip.outputs.PUBLIC_IP }}
steps:
Expand Down Expand Up @@ -207,9 +210,6 @@ jobs:
id: prepare-rancher
if: ${{ inputs.rancher_installed == 'hostname/password' }}
env:
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
INSTALL_K3S_VERSION: ${{ inputs.k3s_version }}
RANCHER_VERSION: ${{ inputs.rancher_version }}
RANCHER_HOSTNAME: ${{ env.RANCHER_HOSTNAME }}
RANCHER_PASSWORD: ${{ env.RANCHER_PASSWORD }}
PROXY_HOST: ${{ env.PROXY_HOST }}
Expand Down Expand Up @@ -249,7 +249,7 @@ jobs:
rm -rf awscliv2.zip aws/
- name: Provisioning cluster tests
if: ${{ !cancelled() && steps.prepare-rancher.outcome != 'failure' && contains(inputs.tests_to_run, 'p0_provisioning') }}
if: ${{ !cancelled() && steps.prepare-rancher.outcome == 'success' && contains(inputs.tests_to_run, 'p0_provisioning') }}
env:
RANCHER_HOSTNAME: ${{ env.RANCHER_HOSTNAME }}
RANCHER_PASSWORD: ${{ env.RANCHER_PASSWORD }}
Expand All @@ -259,7 +259,7 @@ jobs:
make e2e-provisioning-tests
- name: Import cluster tests
if: ${{ !cancelled() && steps.prepare-rancher.outcome != 'failure' && contains(inputs.tests_to_run, 'p0_import') }}
if: ${{ !cancelled() && steps.prepare-rancher.outcome == 'success' && contains(inputs.tests_to_run, 'p0_import') }}
env:
RANCHER_HOSTNAME: ${{ env.RANCHER_HOSTNAME }}
RANCHER_PASSWORD: ${{ env.RANCHER_PASSWORD }}
Expand All @@ -269,7 +269,7 @@ jobs:
make e2e-import-tests
- name: Provisioning cluster P1 tests
if: ${{ !cancelled() && steps.prepare-rancher.outcome != 'failure' && contains(inputs.tests_to_run, 'p1_provisioning') }}
if: ${{ !cancelled() && steps.prepare-rancher.outcome == 'success' && contains(inputs.tests_to_run, 'p1_provisioning') }}
env:
RANCHER_HOSTNAME: ${{ env.RANCHER_HOSTNAME }}
RANCHER_PASSWORD: ${{ env.RANCHER_PASSWORD }}
Expand All @@ -279,7 +279,7 @@ jobs:
make e2e-p1-provisioning-tests
- name: Import cluster P1 tests
if: ${{ !cancelled() && steps.prepare-rancher.outcome != 'failure' && contains(inputs.tests_to_run, 'p1_import') }}
if: ${{ !cancelled() && steps.prepare-rancher.outcome == 'success' && contains(inputs.tests_to_run, 'p1_import') }}
env:
RANCHER_HOSTNAME: ${{ env.RANCHER_HOSTNAME }}
RANCHER_PASSWORD: ${{ env.RANCHER_PASSWORD }}
Expand All @@ -289,7 +289,7 @@ jobs:
make e2e-p1-import-tests
- name: Support matrix provisioning tests
if: ${{ !cancelled() && steps.prepare-rancher.outcome != 'failure' && contains(inputs.tests_to_run, 'support_matrix_provisioning') }}
if: ${{ !cancelled() && steps.prepare-rancher.outcome == 'success' && contains(inputs.tests_to_run, 'support_matrix_provisioning') }}
env:
RANCHER_HOSTNAME: ${{ env.RANCHER_HOSTNAME }}
RANCHER_PASSWORD: ${{ env.RANCHER_PASSWORD }}
Expand All @@ -299,7 +299,7 @@ jobs:
make e2e-support-matrix-provisioning-tests
- name: Support matrix import tests
if: ${{ !cancelled() && steps.prepare-rancher.outcome != 'failure' && contains(inputs.tests_to_run, 'support_matrix_import') }}
if: ${{ !cancelled() && steps.prepare-rancher.outcome == 'success' && contains(inputs.tests_to_run, 'support_matrix_import') }}
env:
RANCHER_HOSTNAME: ${{ env.RANCHER_HOSTNAME }}
RANCHER_PASSWORD: ${{ env.RANCHER_PASSWORD }}
Expand All @@ -309,7 +309,7 @@ jobs:
make e2e-support-matrix-import-tests
- name: K8s Chart Support provisioning tests
if: ${{ !cancelled() && steps.prepare-rancher.outcome != 'failure' && contains(inputs.tests_to_run, 'k8s_chart_support_provisioning') }}
if: ${{ !cancelled() && steps.prepare-rancher.outcome == 'success' && contains(inputs.tests_to_run, 'k8s_chart_support_provisioning') }}
env:
RANCHER_HOSTNAME: ${{ env.RANCHER_HOSTNAME }}
RANCHER_PASSWORD: ${{ env.RANCHER_PASSWORD }}
Expand All @@ -320,7 +320,7 @@ jobs:
make e2e-k8s-chart-support-provisioning-tests
- name: K8s Chart Support import tests
if: ${{ !cancelled() && steps.prepare-rancher.outcome != 'failure' && contains(inputs.tests_to_run, 'k8s_chart_support_import') }}
if: ${{ !cancelled() && steps.prepare-rancher.outcome == 'success' && contains(inputs.tests_to_run, 'k8s_chart_support_import') }}
env:
RANCHER_HOSTNAME: ${{ env.RANCHER_HOSTNAME }}
RANCHER_PASSWORD: ${{ env.RANCHER_PASSWORD }}
Expand All @@ -331,7 +331,7 @@ jobs:
make e2e-k8s-chart-support-import-tests
- name: Sync provisioning tests
if: ${{ !cancelled() && steps.prepare-rancher.outcome != 'failure' && contains(inputs.tests_to_run, 'sync_provisioning') }}
if: ${{ !cancelled() && steps.prepare-rancher.outcome == 'success' && contains(inputs.tests_to_run, 'sync_provisioning') }}
env:
RANCHER_HOSTNAME: ${{ env.RANCHER_HOSTNAME }}
RANCHER_PASSWORD: ${{ env.RANCHER_PASSWORD }}
Expand All @@ -341,7 +341,7 @@ jobs:
make e2e-sync-provisioning-tests
- name: Sync import tests
if: ${{ !cancelled() && steps.prepare-rancher.outcome != 'failure' && contains(inputs.tests_to_run, 'sync_import') }}
if: ${{ !cancelled() && steps.prepare-rancher.outcome == 'success' && contains(inputs.tests_to_run, 'sync_import') }}
env:
RANCHER_HOSTNAME: ${{ env.RANCHER_HOSTNAME }}
RANCHER_PASSWORD: ${{ env.RANCHER_PASSWORD }}
Expand All @@ -355,11 +355,9 @@ jobs:
env:
RANCHER_HOSTNAME: ${{ env.RANCHER_HOSTNAME }}
RANCHER_PASSWORD: ${{ env.RANCHER_PASSWORD }}
RANCHER_VERSION: ${{ inputs.rancher_version }}
BACKUP_OPERATOR_VERSION: ${{ inputs.backup_operator_version }}
CATTLE_TEST_CONFIG: ${{ github.workspace }}/cattle-config-provisioning.yaml
QASE_RUN_ID: ${{ steps.qase.outputs.qase_run_id }}
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
run: |
make e2e-backup-restore-provisioning-tests
Expand All @@ -368,11 +366,9 @@ jobs:
env:
RANCHER_HOSTNAME: ${{ env.RANCHER_HOSTNAME }}
RANCHER_PASSWORD: ${{ env.RANCHER_PASSWORD }}
RANCHER_VERSION: ${{ inputs.rancher_version }}
BACKUP_OPERATOR_VERSION: ${{ inputs.backup_operator_version }}
CATTLE_TEST_CONFIG: ${{ github.workspace }}/cattle-config-import.yaml
QASE_RUN_ID: ${{ steps.qase.outputs.qase_run_id }}
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
run: |
make e2e-backup-restore-import-tests
Expand Down Expand Up @@ -416,8 +412,6 @@ jobs:
if-no-files-found: ignore

- name: Add summary
env:
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
if: ${{ always() && steps.prepare-rancher.outcome == 'success' }}
run: |
# Add summary
Expand All @@ -427,7 +421,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
2 changes: 1 addition & 1 deletion hosted/aks/helper/helper_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ func UpdateAutoScaling(cluster *management.Cluster, client *rancher.Client, enab
}
}
return true
}, tools.SetTimeout(7*time.Minute), 5*time.Second).Should(BeTrue())
}, tools.SetTimeout(10*time.Minute), 15*time.Second).Should(BeTrue())
}
return cluster, nil
}
Expand Down
5 changes: 3 additions & 2 deletions hosted/aks/p0/p0_import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ var _ = Describe("P0Import", func() {
} {
testData := testData
When("a cluster is imported", func() {
var cluster *management.Cluster

BeforeEach(func() {
if testData.isUpgrade && helpers.SkipUpgradeTests {
Skip("Skipping upgrade tests ...")
}
k8sVersion, err := helper.GetK8sVersion(ctx.RancherAdminClient, ctx.CloudCredID, location, testData.isUpgrade)
Expect(err).NotTo(HaveOccurred())
GinkgoLogr.Info(fmt.Sprintf("Using K8s version %s for cluster %s", k8sVersion, clusterName))
Expand Down
5 changes: 3 additions & 2 deletions hosted/aks/p0/p0_provisioning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ var _ = Describe("P0Provisioning", func() {
} {
testData := testData
When("a cluster is created", func() {
var cluster *management.Cluster

BeforeEach(func() {
if testData.isUpgrade && helpers.SkipUpgradeTests {
Skip("Skipping upgrade tests ...")
}
k8sVersion, err := helper.GetK8sVersion(ctx.RancherAdminClient, ctx.CloudCredID, location, testData.isUpgrade)
Expect(err).NotTo(HaveOccurred())
GinkgoLogr.Info(fmt.Sprintf("Using K8s version %s for cluster %s", k8sVersion, clusterName))
Expand Down
2 changes: 2 additions & 0 deletions hosted/aks/p0/p0_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const (

var (
ctx helpers.RancherContext
cluster *management.Cluster
clusterName string
testCaseID int64
location = helpers.GetAKSLocation()
Expand All @@ -53,6 +54,7 @@ var _ = SynchronizedBeforeSuite(func() []byte {
})

var _ = BeforeEach(func() {
cluster = nil
clusterName = namegen.AppendRandomString(helpers.ClusterNamePrefix)
})

Expand Down
28 changes: 22 additions & 6 deletions hosted/aks/p1/p1_import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
management "github.com/rancher/shepherd/clients/rancher/generated/management/v3"

"github.com/rancher/hosted-providers-e2e/hosted/aks/helper"
"github.com/rancher/hosted-providers-e2e/hosted/helpers"
)

var _ = Describe("P1Import", func() {
var (
cluster *management.Cluster
k8sVersion string
)
var k8sVersion string
BeforeEach(func() {
GinkgoLogr.Info(fmt.Sprintf("Running on process: %d", GinkgoParallelProcess()))

Expand Down Expand Up @@ -78,6 +74,9 @@ var _ = Describe("P1Import", func() {
})

It("should be able to update cluster monitoring", func() {
if helpers.SkipUpgradeTests {
Skip("Skipping test for v2.8 ...")
}
testCaseID = 271
updateMonitoringCheck(cluster, ctx.RancherAdminClient)
})
Expand All @@ -99,7 +98,7 @@ var _ = Describe("P1Import", func() {
// Wait until the cluster no longer exists
_, err := ctx.RancherAdminClient.Management.Cluster.ByID(clusterID)
return err
}, "10s", "1s").ShouldNot(BeNil())
}, "30s", "3s").ShouldNot(BeNil())
cluster, err = helper.ImportAKSHostedCluster(ctx.RancherAdminClient, clusterName, ctx.CloudCredID, location, helpers.GetCommonMetadataLabels())
Expect(err).To(BeNil())
cluster, err = helpers.WaitUntilClusterIsReady(cluster, ctx.RancherAdminClient)
Expand All @@ -108,6 +107,9 @@ var _ = Describe("P1Import", func() {
})

It("should successfully Import a cluster in Region without AZ", func() {
if helpers.SkipUpgradeTests {
Skip("Skipping test for v2.8 ...")
}
location = "ukwest"
testCaseID = 276

Expand Down Expand Up @@ -142,6 +144,10 @@ var _ = Describe("P1Import", func() {
When("a cluster with custom kubelet and os config is created and imported for upgrade", func() {
var upgradeToVersion string
BeforeEach(func() {
if helpers.SkipUpgradeTests {
Skip("Skipping test for v2.8 ...")
}

kubeletConfigJsonData := `{"cpuManagerPolicy": "static", "cpuCfsQuota": true, "cpuCfsQuotaPeriod": "200ms", "imageGcHighThreshold": 90, "imageGcLowThreshold": 70, "topologyManagerPolicy": "best-effort", "allowedUnsafeSysctls": ["kernel.msg*","net.*"], "failSwapOn": false}`
kubeletConfigDotJson, err := os.CreateTemp("", "custom-kubelet-*.json")
Expect(err).ToNot(HaveOccurred())
Expand Down Expand Up @@ -201,6 +207,9 @@ var _ = Describe("P1Import", func() {
})

It("should not be able to remove system nodepool", func() {
if helpers.SkipTest {
Skip("Skipping test for v2.8, v2.9 ...")
}
testCaseID = 267
removeSystemNpCheck(cluster, ctx.RancherAdminClient)
})
Expand All @@ -226,6 +235,10 @@ var _ = Describe("P1Import", func() {
When("a cluster is created and imported for upgrade", func() {
var upgradeK8sVersion string
BeforeEach(func() {
if helpers.SkipUpgradeTests {
Skip("Skipping test for v2.8 ...")
}

var err error
k8sVersion, err = helper.GetK8sVersion(ctx.RancherAdminClient, ctx.CloudCredID, location, true)
Expect(err).NotTo(HaveOccurred())
Expand All @@ -244,6 +257,9 @@ var _ = Describe("P1Import", func() {
})

It("NP cannot be upgraded to k8s version greater than CP k8s version", func() {
if helpers.SkipUpgradeTests {
Skip("Skipping test for v2.8 ...")
}
testCaseID = 269
npUpgradeToVersionGTCPCheck(cluster, ctx.RancherAdminClient, upgradeK8sVersion)
})
Expand Down
26 changes: 24 additions & 2 deletions hosted/aks/p1/p1_provisioning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
)

var _ = Describe("P1Provisioning", func() {
var cluster *management.Cluster
var k8sVersion string

BeforeEach(func() {
Expand All @@ -45,6 +44,9 @@ var _ = Describe("P1Provisioning", func() {
})

It("should successfully Create a cluster in Region without AZ", func() {
if helpers.SkipUpgradeTests {
Skip("Skipping test for v2.8 ...")
}
location = "ukwest"
testCaseID = 275

Expand Down Expand Up @@ -362,6 +364,10 @@ var _ = Describe("P1Provisioning", func() {
})

It("should not be able to edit availability zone of a nodepool", func() {
if helpers.SkipTest {
Skip("Skipping test for v2.8, v2.9 ...")
}

// Refer: https://github.com/rancher/aks-operator/issues/669
testCaseID = 195
originalNPMap := make(map[string][]string)
Expand Down Expand Up @@ -430,6 +436,9 @@ var _ = Describe("P1Provisioning", func() {
})

It("should be able to update cluster monitoring", func() {
if helpers.SkipUpgradeTests {
Skip("Skipping test for v2.8 ...")
}
testCaseID = 200
updateMonitoringCheck(cluster, ctx.RancherAdminClient)
})
Expand Down Expand Up @@ -510,6 +519,10 @@ var _ = Describe("P1Provisioning", func() {
When("a cluster is created for upgrade", func() {
var upgradeK8sVersion string
BeforeEach(func() {
if helpers.SkipUpgradeTests {
Skip("Skipping test for v2.8 ...")
}

var err error
k8sVersion, err = helper.GetK8sVersion(ctx.RancherAdminClient, ctx.CloudCredID, location, true)
Expect(err).NotTo(HaveOccurred())
Expand All @@ -525,6 +538,9 @@ var _ = Describe("P1Provisioning", func() {
})

It("NP cannot be upgraded to k8s version greater than CP k8s version", func() {
if helpers.SkipUpgradeTests {
Skip("Skipping test for v2.8 ...")
}
testCaseID = 183
npUpgradeToVersionGTCPCheck(cluster, ctx.RancherAdminClient, upgradeK8sVersion)
})
Expand Down Expand Up @@ -579,8 +595,11 @@ var _ = Describe("P1Provisioning", func() {
})

It("should not be able to select NP K8s version; CP K8s version should take precedence", func() {
testCaseID = 182
if helpers.SkipUpgradeTests {
Skip("Skipping test for v2.8 ...")
}

testCaseID = 182
k8sVersions, err := helper.ListSingleVariantAKSAllVersions(ctx.RancherAdminClient, ctx.CloudCredID, location)
Expect(err).To(BeNil())
Expect(len(k8sVersions)).To(BeNumerically(">=", 2))
Expand Down Expand Up @@ -695,6 +714,9 @@ var _ = Describe("P1Provisioning", func() {
})

It("should not be able to remove system nodepool", func() {
if helpers.SkipTest {
Skip("Skipping test for v2.8, v2.9 ...")
}
testCaseID = 191
removeSystemNpCheck(cluster, ctx.RancherAdminClient)
})
Expand Down
Loading

0 comments on commit 9bccf34

Please sign in to comment.