github.com/rancher/elemental/tests@v0.0.0-20240517125144-ae048c615b3f/cypress/latest/e2e/unit_tests/upgrade.spec.ts (about)

     1  /*
     2  Copyright © 2022 - 2024 SUSE LLC
     3  Licensed under the Apache License, Version 2.0 (the "License");
     4  you may not use this file except in compliance with the License.
     5  You may obtain a copy of the License at
     6      http://www.apache.org/licenses/LICENSE-2.0
     7  Unless required by applicable law or agreed to in writing, software
     8  distributed under the License is distributed on an "AS IS" BASIS,
     9  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    10  See the License for the specific language governing permissions and
    11  limitations under the License.
    12  */
    13  
    14  import '~/support/commands';
    15  import 'cypress-file-upload';
    16  import filterTests from '~/support/filterTests.js';
    17  import * as utils from "~/support/utils";
    18  import * as cypressLib from '@rancher-ecp-qa/cypress-library';
    19  import { qase } from 'cypress-qase-reporter/dist/mocha';
    20  import { slowCypressDown } from 'cypress-slow-down'
    21  
    22  // slow down each command by 500ms
    23  slowCypressDown(500)
    24  
    25  
    26  Cypress.config();
    27  describe('Upgrade tests', () => {
    28    const channelName      = "mychannel"
    29    const clusterName      = "mycluster"
    30    const elementalUser    = "elemental-user"
    31    const uiAccount        = Cypress.env('ui_account');
    32    const uiPassword       = "rancherpassword"
    33    const upgradeImage     = Cypress.env('upgrade_image')
    34  
    35    beforeEach(() => {
    36      (uiAccount == "user") ? cy.login(elementalUser, uiPassword) : cy.login();
    37      cy.visit('/');
    38      cy.viewport(1920, 1080);
    39  
    40      // Open the navigation menu
    41      cypressLib.burgerMenuToggle();
    42  
    43      // Click on the Elemental's icon
    44      cypressLib.accesMenu('OS Management');
    45    });
    46  
    47    filterTests(['upgrade'], () => {
    48      // Add dev OS Version Channel if stable operator is installed
    49      // because we do not update the operator in RKE2 UI test so far
    50      // Only RKE2 tests use os version channel
    51      if (utils.isK8sVersion("rke2") && !utils.isRancherManagerVersion('2.7')) {
    52        // With operator 1.4.2, dev and stable cannot live together
    53        // Let's delete the stable channel first
    54        it('Delete stable channel for RKE2 upgrade', () => {
    55          cy.clickNavMenu(["Advanced", "OS Version Channels"]);
    56          cy.deleteAllResources();
    57        })
    58  
    59        it('Add dev channel for RKE2 upgrade', () => {
    60          cy.addOsVersionChannel('dev');
    61        })
    62      }
    63  
    64      if (utils.isK8sVersion("rke2")) {
    65        qase(33,
    66          it('Check OS Versions', () => {
    67            cy.clickNavMenu(["Advanced", "OS Versions"]);
    68            cy.contains(new RegExp('Active.*-iso-unstable'), {timeout: 120000})
    69          })
    70        );
    71      };
    72  
    73      qase(34,
    74        it('Upgrade one node (different methods if rke2 or k3s)', () => {
    75          cypressLib.burgerMenuToggle();
    76          cypressLib.checkClusterStatus(clusterName, 'Active', 600000);
    77          cypressLib.burgerMenuToggle();
    78          cypressLib.accesMenu('OS Management');
    79          /////////////////////////////////////////
    80          // K3s cluster upgraded with OS Image
    81          // RKE2 cluster upgraded with OS version channel
    82          // Marketplace test uses OS version channel
    83          cy.clickNavMenu(["Advanced", "Update Groups"]);
    84          cy.getBySel('masthead-create')
    85          .contains('Create')
    86            .click();
    87          cy.get('.primaryheader')
    88            .contains('Update Group: Create');
    89          cy.getBySel('name-ns-description-name')
    90            .type(channelName);
    91          cy.contains('Target Cluster')
    92          cy.getBySel('cluster-target')
    93            .click();
    94          cy.get('.vs__dropdown-menu')
    95            .contains(clusterName)
    96            .click();
    97          if (utils.isK8sVersion("k3s") && !utils.isOperatorVersion('marketplace')) {
    98            cy.getBySel('upgrade-choice-selector')
    99              .parent()
   100              .contains('Use image from registry')
   101              .click();
   102            cy.getBySel('os-image-box')
   103              .type(upgradeImage)
   104          } else {
   105            cy.getBySel('upgrade-choice-selector')
   106              .parent()
   107              .contains('Use Managed OS Version')
   108              .click();
   109            cy.getBySel('os-version-box')
   110              .click()
   111            if (utils.isOperatorVersion('marketplace')) {
   112              cy.getBySel('os-version-box')
   113                .parents()
   114                .contains(Cypress.env('os_version_target'))
   115                .click();
   116            } else {
   117              cy.getBySel('os-version-box')
   118                .parents()
   119                .contains('unstable')
   120                .click();
   121            }
   122          } 
   123  
   124          cy.getBySel('form-save')
   125          .contains('Create')
   126            .click();
   127          // Status changes a lot right after the creation so let's wait 10 secondes
   128          // before checking
   129          // eslint-disable-next-line cypress/no-unnecessary-waiting
   130          cy.wait(10000);
   131          cy.getBySel('sortable-cell-0-0')
   132            .contains('Active');
   133          // Check if the node reboots to apply the upgrade
   134          cypressLib.burgerMenuToggle();
   135          cypressLib.accesMenu('OS Management');
   136          cy.clickNavMenu(["Dashboard"]);
   137          cy.getBySel('card-clusters')
   138            .contains('Manage Elemental Clusters')
   139            .click()
   140          cy.get('.title')
   141            .contains('Clusters');
   142          cy.get('.outlet')
   143            .contains(clusterName)
   144            .click();
   145          cy.get('.primaryheader')
   146            .contains('Updating', {timeout: 420000});
   147          cy.get('.primaryheader')
   148            .contains('Active', {timeout: 720000});
   149        })
   150      );
   151  
   152      qase(35,
   153        it('Cannot create two upgrade groups targeting the same cluster', () => {
   154          cy.clickNavMenu(["Advanced", "Update Groups"]);
   155          cy.getBySel('masthead-create')
   156          .contains('Create')
   157            .click();
   158          cy.get('.primaryheader')
   159            .contains('Update Group: Create');
   160          cy.getBySel('cluster-target')
   161            .click();
   162          cy.contains('Sorry, no matching options');
   163        })
   164      );
   165  
   166      qase(37,
   167        it('Delete OS Versions Channels', () => {
   168          cy.clickNavMenu(["Advanced", "OS Version Channels"]);
   169          cy.deleteAllResources();
   170          cy.clickNavMenu(["Advanced", "OS Versions"]);
   171          cy.contains('There are no rows to show');
   172        })
   173      );
   174    })
   175  })