Skip to content

Commit

Permalink
Restart fleet to avoid sporadic failures in UI tests (#543)
Browse files Browse the repository at this point in the history
  • Loading branch information
juadk authored Nov 30, 2022
1 parent 0e88350 commit 6f323f5
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/master-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ jobs:
id: installation
env:
CA_TYPE: ${{ inputs.ca_type }}
TEST_TYPE: ${{ inputs.test_type }}
run: |
export MY_HOSTNAME=$(hostname -f)
echo "MY_HOSTNAME=$MY_HOSTNAME" >> $GITHUB_OUTPUT
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/ui-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ jobs:
secrets:
credentials: ${{ secrets.GCP_CREDENTIALS }}
with:
ui_account: user
#ui_account: user
cluster_name: cluster-rke2
k8s_version_to_provision: v1.24.8+rke2r1
rancher_channel: latest
rancher_version: devel
runner: elemental-e2e-ci-runner-spot-x86-64-1
test_type: ui

14 changes: 14 additions & 0 deletions cypress/e2e/unit_tests/upgrade.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,21 @@ describe('Upgrade tests', () => {
cy.wait(10000);
cy.get('[data-testid="sortable-cell-0-0"]').contains('Active');

// Workaround to avoid sporadic issue with Upgrade
// https://github.com/rancher/elemental/issues/410
// Restart fleet agent inside downstream cluster
topLevelMenu.openIfClosed();
cy.contains('myelementalcluster').click();
cy.contains('Workload').click();
cy.contains('Pods').click();
cy.get('.header-buttons > :nth-child(2)').click();
cy.wait(40000);
cy.get('.xterm-cursor-layer').type('kubectl scale deployment/fleet-agent -n cattle-fleet-system --replicas=0{enter}');
cy.get('.xterm-cursor-layer').type('kubectl scale deployment/fleet-agent -n cattle-fleet-system --replicas=1{enter}');

// Check if the node reboots to apply the upgrade
topLevelMenu.openIfClosed();
elemental.accessElementalMenu();
cy.clickNavMenu(["Dashboard"]);
cy.clickButton('Manage Elemental Clusters');
cy.get('.title').contains('Clusters');
Expand Down
14 changes: 14 additions & 0 deletions tests/e2e/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,20 @@ var _ = Describe("E2E - Install Rancher Manager", Label("install"), func() {
Expect(err).To(Not(HaveOccurred()))
GinkgoWriter.Printf("Rancher Version:\n%s\n", operatorVersion)
})
if testType == "ui" {
By("Workaround for upgrade test, restart Fleet controller and agent", func() {
// https://github.com/rancher/elemental/issues/410
time.Sleep(misc.SetTimeout(120 * time.Second))
_, err := kubectl.Run("scale", "deployment/fleet-agent", "-n", "cattle-fleet-local-system", "--replicas=0")
Expect(err).To(Not(HaveOccurred()))
_, err = kubectl.Run("scale", "deployment/fleet-controller", "-n", "cattle-fleet-system", "--replicas=0")
Expect(err).To(Not(HaveOccurred()))
_, err = kubectl.Run("scale", "deployment/fleet-controller", "-n", "cattle-fleet-system", "--replicas=1")
Expect(err).To(Not(HaveOccurred()))
_, err = kubectl.Run("scale", "deployment/fleet-agent", "-n", "cattle-fleet-local-system", "--replicas=1")
Expect(err).To(Not(HaveOccurred()))
})
}

By("Installing Elemental Operator", func() {
err := kubectl.RunHelmBinaryWithCustomErr("repo", "add",
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ var (
isoBoot string
k8sVersion string
caType string
testType string
osImage string
rancherChannel string
rancherVersion string
Expand Down Expand Up @@ -73,6 +74,7 @@ var _ = BeforeSuite(func() {
isoBoot = os.Getenv("ISO_BOOT")
k8sVersion = os.Getenv("K8S_VERSION_TO_PROVISION")
caType = os.Getenv("CA_TYPE")
testType = os.Getenv("TEST_TYPE")
osImage = os.Getenv("CONTAINER_IMAGE")
rancherChannel = os.Getenv("RANCHER_CHANNEL")
rancherVersion = os.Getenv("RANCHER_VERSION")
Expand Down

0 comments on commit 6f323f5

Please sign in to comment.