From b57ede639fe4afce8af22567a6ece7027ee1f5bd Mon Sep 17 00:00:00 2001 From: Dominik Gedon Date: Fri, 2 Aug 2024 11:27:51 +0200 Subject: [PATCH] QE: Update Ruby from 2.5 to 3.3 See https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/ Signed-off-by: Dominik Gedon --- .github/workflows/acceptance_tests_common.yml | 8 +- .github/workflows/build_containers.yml | 2 +- .github/workflows/rubocop.yml | 12 +- testsuite/.rubocop.yml | 2 +- testsuite/.rubocop_todo.yml | 233 +++++++++++++++++- testsuite/Gemfile | 43 ++-- .../dockerfiles/controller-dev/Dockerfile | 50 +++- .../server-all-in-one-dev/Dockerfile | 12 +- testsuite/documentation/api.md | 11 +- .../secondary/min_salt_formulas.feature | 2 +- .../min_salt_formulas_advanced.feature | 4 +- .../features/step_definitions/api_common.rb | 2 +- .../step_definitions/command_steps.rb | 14 +- .../lock_packages_on_client.rb | 6 +- .../step_definitions/navigation_steps.rb | 11 + .../features/step_definitions/retail_steps.rb | 6 +- .../features/step_definitions/salt_steps.rb | 10 +- .../step_definitions/security_steps.rb | 2 +- testsuite/features/support/commonlib.rb | 32 +-- testsuite/features/support/env.rb | 39 ++- .../05_install_gems_in_controller.sh | 10 +- 21 files changed, 386 insertions(+), 125 deletions(-) diff --git a/.github/workflows/acceptance_tests_common.yml b/.github/workflows/acceptance_tests_common.yml index ffb19c1f114c..7d55dc1a0a1d 100644 --- a/.github/workflows/acceptance_tests_common.yml +++ b/.github/workflows/acceptance_tests_common.yml @@ -9,7 +9,7 @@ on: required: true type: string env: - UYUNI_PROJECT: uyuni-project + UYUNI_PROJECT: nodeg UYUNI_VERSION: master CUCUMBER_PUBLISH_TOKEN: ${{ secrets.CUCUMBER_PUBLISH_TOKEN }} jobs: @@ -66,9 +66,9 @@ jobs: - name: create-podman-network run: ./testsuite/podman_runner/02_setup_network.sh - name: start_controller - run: ./testsuite/podman_runner/03_run_controller.sh + run: ./testsuite/podman_runner/03_run_controller.sh - name: create_ssh_conf - run: ./testsuite/podman_runner/04_setup_ssh_controller.sh + run: ./testsuite/podman_runner/04_setup_ssh_controller.sh - name: install_gems_in_controller run: ./testsuite/podman_runner/05_install_gems_in_controller.sh - name: collect_and_tag_flaky_tests_in_controller @@ -110,7 +110,7 @@ jobs: - name: split_secondary run: ./testsuite/podman_runner/19_split_secondary_p_tests.sh - name: run_secondary_tests - run: ./testsuite/podman_runner/${{ inputs.secondary_tests }} + run: ./testsuite/podman_runner/${{ inputs.secondary_tests }} - name: get_server_logs if: ${{ failure() }} run: ./testsuite/podman_runner/20_get_server_logs.sh ${{ inputs.server_id }} diff --git a/.github/workflows/build_containers.yml b/.github/workflows/build_containers.yml index 0d57bf1ce5b3..7d336cb94f0e 100644 --- a/.github/workflows/build_containers.yml +++ b/.github/workflows/build_containers.yml @@ -38,7 +38,7 @@ jobs: labels: ${{ steps.meta.outputs.labels }} build-args: | BASE=registry.opensuse.org/uyuni/server - VERSION=2024.05 + VERSION=2024.07 build-and-push-ubuntu-minion-image: runs-on: ubuntu-latest permissions: diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml index 19daa23d6cf5..c850f098ce6e 100644 --- a/.github/workflows/rubocop.yml +++ b/.github/workflows/rubocop.yml @@ -17,19 +17,11 @@ jobs: - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: - ruby-version: '2.5' + ruby-version: '3.3' - name: Install Rubocop run: | - gem install parallel -v 1.10 - gem install parser -v 3.0.0.0 - gem install rainbow -v 2.2.2 - gem install regexp_parser -v 1.8 - gem install rexml - gem install rubocop-ast -v 1.7.0 - gem install ruby-progressbar -v 1.7 - gem install unicode-display_width -v 1.4.0 - gem install rubocop -v 1.17.0 + gem install rubocop -v 1.65.1 - name: Run RuboCop run: | diff --git a/testsuite/.rubocop.yml b/testsuite/.rubocop.yml index d0eac6904335..255d7165f698 100644 --- a/testsuite/.rubocop.yml +++ b/testsuite/.rubocop.yml @@ -3,7 +3,7 @@ inherit_from: .rubocop_todo.yml AllCops: EnabledByDefault: true SuggestExtensions: false - TargetRubyVersion: 2.5 + TargetRubyVersion: 3.3 Style/MissingElse: Enabled: false diff --git a/testsuite/.rubocop_todo.yml b/testsuite/.rubocop_todo.yml index 169f711877cd..67dc40414bd7 100644 --- a/testsuite/.rubocop_todo.yml +++ b/testsuite/.rubocop_todo.yml @@ -1,25 +1,158 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2023-11-17 13:57:32 UTC using RuboCop version 1.17.0. +# on 2024-08-19 12:51:03 UTC using RuboCop version 1.65.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 31 -# Configuration parameters: RequireForNonPublicMethods. +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Layout/EmptyLineAfterGuardClause: + Exclude: + - 'Rakefile' + +# Offense count: 26 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: leading, trailing +Layout/LineContinuationLeadingSpace: + Exclude: + - 'features/step_definitions/command_steps.rb' + - 'features/step_definitions/vm_steps.rb' + - 'features/support/kubernetes.rb' + +# Offense count: 19 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: space, no_space +Layout/LineContinuationSpacing: + Exclude: + - 'features/support/kubernetes.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: aligned, indented +Layout/LineEndStringConcatenationIndentation: + Exclude: + - 'features/step_definitions/command_steps.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Layout/SpaceAfterComma: + Exclude: + - 'Rakefile' + +# Offense count: 1 +# Configuration parameters: DebuggerMethods, DebuggerRequires. +Lint/Debugger: + Exclude: + - 'features/step_definitions/common_steps.rb' + +# Offense count: 3 +# This cop supports unsafe autocorrection (--autocorrect-all). +Lint/RedundantRequireStatement: + Exclude: + - 'features/step_definitions/command_steps.rb' + - 'features/support/cobbler_test.rb' + - 'features/support/env.rb' + +# Offense count: 1 +# Configuration parameters: LengthThreshold. +Metrics/CollectionLiteralLength: + Exclude: + - 'features/support/constants.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, BlockForwardingName. +# SupportedStyles: anonymous, explicit +Naming/BlockForwarding: + Exclude: + - 'features/support/commonlib.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, conditionals +Style/AndOr: + Exclude: + - 'Rakefile' + +# Offense count: 10 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowOnlyRestArgument, UseAnonymousForwarding, RedundantRestArgumentNames, RedundantKeywordRestArgumentNames, RedundantBlockArgumentNames. +# RedundantRestArgumentNames: args, arguments +# RedundantKeywordRestArgumentNames: kwargs, options, opts +# RedundantBlockArgumentNames: blk, block, proc +Style/ArgumentsForwarding: + Exclude: + - 'features/support/commonlib.rb' + +# Offense count: 48 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/ArrayFirstLast: + Exclude: + - 'ext-tools/collect_and_tag_flaky_tests.rb' + - 'ext-tools/maintenance_crawler.rb' + - 'features/step_definitions/api_common.rb' + - 'features/step_definitions/command_steps.rb' + - 'features/step_definitions/common_steps.rb' + - 'features/step_definitions/docker_steps.rb' + - 'features/step_definitions/salt_steps.rb' + - 'features/step_definitions/setup_steps.rb' + - 'features/step_definitions/smdba_steps.rb' + - 'features/step_definitions/vm_steps.rb' + - 'features/support/commonlib.rb' + - 'features/support/http_client.rb' + - 'features/support/namespaces/api.rb' + - 'features/support/twopence_init.rb' + +# Offense count: 2 +# Configuration parameters: AllowedMethods, RequireForNonPublicMethods. Style/DocumentationMethod: Exclude: - 'spec/**/*' - 'test/**/*' - 'features/support/commonlib.rb' + - 'features/support/twopence_init.rb' + +# Offense count: 5 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedReceivers. +# AllowedReceivers: Thread.current +Style/HashEachMethods: + Exclude: + - 'Rakefile' + - 'features/step_definitions/command_steps.rb' + - 'features/step_definitions/setup_steps.rb' + +# Offense count: 91 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. +# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys +# SupportedShorthandSyntax: always, never, either, consistent, either_consistent +Style/HashSyntax: + Exclude: + - 'ext-tools/collect_and_tag_flaky_tests.rb' + - 'features/step_definitions/command_steps.rb' + - 'features/step_definitions/docker_steps.rb' + - 'features/step_definitions/navigation_steps.rb' + - 'features/step_definitions/setup_steps.rb' + - 'features/support/commonlib.rb' + - 'features/support/lavanda.rb' + - 'features/support/namespaces/actionchain.rb' + - 'features/support/namespaces/activationkey.rb' - 'features/support/namespaces/channel.rb' + - 'features/support/namespaces/configchannel.rb' - 'features/support/namespaces/image.rb' + - 'features/support/namespaces/kickstart.rb' - 'features/support/namespaces/system.rb' - - 'features/support/twopence_init.rb' + - 'features/support/namespaces/user.rb' -# Offense count: 16 -# Cop supports --auto-correct. +# Offense count: 20 +# This cop supports safe autocorrection (--autocorrect). Style/IfUnlessModifier: Exclude: - 'features/step_definitions/cobbler_steps.rb' @@ -32,9 +165,17 @@ Style/IfUnlessModifier: - 'features/step_definitions/vm_steps.rb' - 'features/support/http_client.rb' -Style/InlineComment: +# Offense count: 76 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: InverseMethods. +Style/InvertibleUnlessCondition: + Enabled: false + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/MapIntoArray: Exclude: - - 'features/support/constants.rb' + - 'features/support/cobbler_test.rb' # Offense count: 7 # Configuration parameters: AllowedMethods. @@ -46,9 +187,85 @@ Style/OptionalBooleanParameter: - 'features/support/http_client.rb' - 'features/support/lavanda.rb' +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/RedundantFilterChain: + Exclude: + - 'features/step_definitions/api_common.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantParentheses: + Exclude: + - 'features/step_definitions/retail_steps.rb' + +# Offense count: 4 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantRegexpArgument: + Exclude: + - 'features/step_definitions/command_steps.rb' + - 'features/step_definitions/salt_steps.rb' + - 'features/support/lavanda.rb' + +# Offense count: 25 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantStringEscape: + Exclude: + - 'features/step_definitions/cobbler_steps.rb' + - 'features/step_definitions/command_steps.rb' + - 'features/step_definitions/file_management_steps.rb' + - 'features/step_definitions/smdba_steps.rb' + - 'features/step_definitions/vm_steps.rb' + +# Offense count: 35 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/RequireOrder: + Exclude: + - 'Rakefile' + - 'ext-tools/collect_and_tag_flaky_tests.rb' + - 'ext-tools/maintenance_crawler.rb' + - 'features/step_definitions/command_steps.rb' + - 'features/step_definitions/common_steps.rb' + - 'features/step_definitions/docker_steps.rb' + - 'features/step_definitions/salt_steps.rb' + - 'features/step_definitions/security_steps.rb' + - 'features/support/api_test.rb' + - 'features/support/cobbler_test.rb' + - 'features/support/code_coverage.rb' + - 'features/support/commonlib.rb' + - 'features/support/env.rb' + - 'features/support/lavanda.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/SelectByRegexp: + Exclude: + - 'features/step_definitions/api_common.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/SuperArguments: + Exclude: + - 'features/support/custom_formatter.rb' + # Offense count: 1 # Configuration parameters: EnforcedStyle. # SupportedStyles: forbid_mixed_logical_operators, forbid_logical_operators Style/UnlessLogicalOperators: Exclude: - 'features/step_definitions/vm_steps.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +Style/YAMLFileRead: + Exclude: + - 'Rakefile' + +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: . +# SupportedOperators: *, +, &, |, ^ +Style/YodaExpression: + Exclude: + - 'features/support/commonlib.rb' + - 'features/support/env.rb' diff --git a/testsuite/Gemfile b/testsuite/Gemfile index 0b653207ee17..b9e12b938fe7 100644 --- a/testsuite/Gemfile +++ b/testsuite/Gemfile @@ -3,30 +3,29 @@ source 'https://rubygems.org' -gem 'capybara', '3.35.3' -gem 'cucumber', '7.1.0' -gem 'cucumber-html-formatter', '~> 17.0' -gem 'faraday', '1.10.0' -gem 'ffi', '~> 1.16.0' -gem 'jwt', '~> 2.6' -# mini_mime > 1.1.2, requires ruby 2.6 -gem 'mime-types', '~> 3.4' -gem 'mini_mime', '1.1.2' -gem 'minitest', '~> 5.15.0' +gem 'capybara', '3.40.0' +gem 'cucumber', '9.2.0' +gem 'cucumber-html-formatter', '21.7.0' +gem 'faraday', '~>2.10.1' +gem 'ffi', '~> 1.17' +gem 'jwt', '~> 2.8' +gem 'mime-types', '~> 3.5' +gem 'mini_mime', '1.1.5' +gem 'minitest', '~> 5.25.1' gem 'netrc', '~> 0.11.0' -gem 'nokogiri', '~> 1.12.0' -gem 'parallel_tests', '~> 3.12.0' -gem 'parallel', '~> 1.24.0' -gem 'pg', '~> 1.4' -gem 'public_suffix', '~> 4.0' -gem 'rack', '~> 3.0' -gem 'rack-test', '~> 2.0' -gem 'rake', '~> 13.0' -gem 'redis', '~> 5.0' -gem 'redis-client', '~> 0.19.1' +gem 'nokogiri', '~> 1.16' +gem 'parallel', '~> 1.26' +gem 'parallel_tests', '~> 4.7' +gem 'pg', '~> 1.5' +gem 'public_suffix', '~> 6.0' +gem 'rack', '~> 3.1' +gem 'rack-test', '~> 2.1' +gem 'rake', '~> 13.2' +gem 'redis', '~> 5.2' +gem 'redis-client', '~> 0.22' gem 'require_all', '~> 3.0' -# gem 'rubocop', '1.17.0' -gem 'selenium-webdriver', '~> 3.142' +gem 'rubocop', '1.65.1' +gem 'selenium-webdriver', '4.23.0' gem 'simplecov', '~> 0.22' gem 'syntax', '~> 1.2' # Pre-requisite: diff --git a/testsuite/dockerfiles/controller-dev/Dockerfile b/testsuite/dockerfiles/controller-dev/Dockerfile index 6f37adfe9189..1e415eed9707 100644 --- a/testsuite/dockerfiles/controller-dev/Dockerfile +++ b/testsuite/dockerfiles/controller-dev/Dockerfile @@ -1,12 +1,18 @@ FROM opensuse/leap:15.5 -RUN zypper ref -f && \ + +# Ruby 3 devel repos +RUN zypper -n ar -f --no-gpgcheck http://download.opensuse.org/repositories/devel:/languages:/ruby/15.5/ ruby_devel +RUN zypper -n ar -f --no-gpgcheck http://download.opensuse.org/repositories/devel:/languages:/ruby:/extensions/15.5/ rubey_devel_extensions + +RUN zypper ref -f && \ zypper -n ar --no-gpgcheck http://download.opensuse.org/repositories/systemsmanagement:/sumaform:/tools/openSUSE_Leap_15.5/ tools && \ zypper -n install nmap tar gzip iputils \ gcc \ make \ wget \ - ruby \ - ruby-devel \ + ruby3.3 \ + ruby3.3-devel \ + python-devel \ autoconf \ ca-certificates-mozilla \ automake \ @@ -19,13 +25,6 @@ RUN zypper ref -f && \ libxslt-devel \ mozilla-nss-tools \ postgresql14-devel \ - ruby2.5-rubygem-bundler \ - twopence \ - python-twopence \ - twopence-devel \ - twopence-shell-client \ - twopence-test-server \ - rubygem-twopence \ chromium \ chromedriver \ npm \ @@ -35,7 +34,34 @@ RUN zypper ref -f && \ iproute2 \ && \ zypper -n install --oldpackage libssh4=0.9.6 && \ - zypper clean -a + zypper -n install --oldpackage libssh-devel=0.9.6 && \ + zypper -n clean -a COPY etc_pam.d_sshd /etc/pam.d/sshd CMD ssh-keygen -A && /usr/sbin/sshd -De -RUN curl https://raw.githubusercontent.com/uyuni-project/uyuni/master/testsuite/Gemfile -o Gemfile && bundle.ruby2.5 install && rm Gemfile + +### Ruby 3 changes ### +RUN export GEM_PATH="/usr/lib64/ruby/gems/3.3.0" +RUN echo 'GEM_PATH="/usr/lib64/ruby/gems/3.3.0"' >> ./root/.bashrc +RUN ln -sf /usr/bin/ruby.ruby3.3 /usr/bin/ruby +RUN ln -sf /usr/bin/gem.ruby3.3 /usr/bin/gem +RUN ln -sf /usr/bin/irb.ruby3.3 /usr/bin/irb +RUN update-alternatives --set rake /usr/bin/rake.ruby.ruby3.3 +RUN update-alternatives --set bundle /usr/bin/bundle.ruby.ruby3.3 +RUN update-alternatives --set rdoc /usr/bin/rdoc.ruby.ruby3.3 +RUN update-alternatives --set ri /usr/bin/ri.ruby.ruby3.3 + +# debug +RUN ruby -v +RUN gem env + +# build Twopence from source +RUN git clone https://github.com/nodeg/twopence.git /root/twopence && \ + cd /root/twopence && \ + make && \ + make install +RUN ldconfig +RUN ldconfig -p +RUN ldconfig -p | grep twopence + +RUN curl https://raw.githubusercontent.com/nodeg/uyuni/master/testsuite/Gemfile -o Gemfile && bundle.ruby3.3 install && rm Gemfile +RUN gem list diff --git a/testsuite/dockerfiles/server-all-in-one-dev/Dockerfile b/testsuite/dockerfiles/server-all-in-one-dev/Dockerfile index 9a382abe99bd..d0afca11c693 100644 --- a/testsuite/dockerfiles/server-all-in-one-dev/Dockerfile +++ b/testsuite/dockerfiles/server-all-in-one-dev/Dockerfile @@ -2,22 +2,22 @@ ARG BASE ARG VERSION FROM ${BASE}:${VERSION} -RUN zypper ref && \ - zypper -n install \ +RUN zypper -n --gpg-auto-import-keys ref +RUN zypper -n install \ java-17-openjdk-devel \ openssh \ rsync \ apache-ivy \ ant \ - ant-junit5 \ + ant-junit \ servletapi5 \ cpio \ spacecmd \ expect \ - wget && \ - zypper addrepo --no-gpgcheck obs://systemsmanagement:Uyuni:Utils systemsmanagement:uyuni:utils && \ + wget +RUN zypper -n addrepo --no-gpgcheck obs://systemsmanagement:Uyuni:Utils systemsmanagement:uyuni:utils && \ zypper -n install obs-to-maven yarn && \ - zypper clean -a + zypper -n clean -a COPY minima.yaml /etc/minima.yaml RUN mkdir /tmp/minima && \ cd /tmp/minima && \ diff --git a/testsuite/documentation/api.md b/testsuite/documentation/api.md index 927b86f437e6..0290b66df1a7 100644 --- a/testsuite/documentation/api.md +++ b/testsuite/documentation/api.md @@ -1,4 +1,13 @@ -# Testing the API with a standalone script +# API + +## General + +We use 2 different APIs for testing + +- SUSE Manager: XML-RPC API (HTTPS + XML) +- Uyuni: REST API (HTTPS + JSON), which we internally call HTTP API + +## Testing the API with a standalone script You can use this template: diff --git a/testsuite/features/secondary/min_salt_formulas.feature b/testsuite/features/secondary/min_salt_formulas.feature index d01b45666299..70fb46fa3fd1 100644 --- a/testsuite/features/secondary/min_salt_formulas.feature +++ b/testsuite/features/secondary/min_salt_formulas.feature @@ -80,7 +80,7 @@ Feature: Use salt formulas Scenario: Reset the formula on the minion When I follow "Formulas" in the content area And I follow first "Locale" in the content area - And I click on "Clear values" and confirm + And I click on "Clear values" and confirm alert box And I click on "Save Formula" Then I should see a "Formula saved" text diff --git a/testsuite/features/secondary/min_salt_formulas_advanced.feature b/testsuite/features/secondary/min_salt_formulas_advanced.feature index 9855ced68fa4..b24e3e68804d 100644 --- a/testsuite/features/secondary/min_salt_formulas_advanced.feature +++ b/testsuite/features/secondary/min_salt_formulas_advanced.feature @@ -102,7 +102,7 @@ Feature: Use advanced features of Salt formulas When I follow "test-formula-group" in the content area And I follow "Formulas" in the content area And I follow first "Testform" in the content area - And I click on "Clear values" and confirm + And I click on "Clear values" and confirm alert box And I click on "Save Formula" Then I should see a "Formula saved" text When I wait for "1" seconds @@ -208,7 +208,7 @@ Feature: Use advanced features of Salt formulas Scenario: Clear values in minion formula and verify that the pillar is set to group values When I follow "Formulas" in the content area And I follow first "Testform" in the content area - And I click on "Clear values" and confirm + And I click on "Clear values" and confirm alert box And I click on "Save Formula" Then I should see a "Formula saved" text When I wait for "1" seconds diff --git a/testsuite/features/step_definitions/api_common.rb b/testsuite/features/step_definitions/api_common.rb index ae5f4e71cc14..2336d5e28b12 100644 --- a/testsuite/features/step_definitions/api_common.rb +++ b/testsuite/features/step_definitions/api_common.rb @@ -102,7 +102,7 @@ end Then(/^I should get at least one role that matches "([^"]*)" suffix$/) do |suffix| - refute(@roles.find_all { |el| el =~ /#{suffix}/ }.empty?) + refute(@roles.find_all { |el| el.match?(/#{suffix}/) }.empty?) end Then(/^I should get role "([^"]*)"$/) do |rolename| diff --git a/testsuite/features/step_definitions/command_steps.rb b/testsuite/features/step_definitions/command_steps.rb index e8b25bf3f117..aef9c680b843 100644 --- a/testsuite/features/step_definitions/command_steps.rb +++ b/testsuite/features/step_definitions/command_steps.rb @@ -466,7 +466,7 @@ When(/^I wait until file "([^"]*)" contains "([^"]*)" on server$/) do |file, content| repeat_until_timeout(message: "#{content} not found in file #{file}", report_result: true) do output, _code = get_target('server').run("grep #{content} #{file}", check_errors: false) - break if output =~ /#{content}/ + break if output.match?(/#{content}/) sleep 2 "\n-----\n#{output}\n-----\n" @@ -571,14 +571,16 @@ end When(/^the server starts mocking an IPMI host$/) do + server = get_target('server') + server.run('mkdir -p /etc/ipmi') %w[ipmisim1.emu lan.conf fake_ipmi_host.sh].each do |file| source = "#{File.dirname(__FILE__)}/../upload_files/#{file}" dest = "/etc/ipmi/#{file}" - return_code = file_inject(get_target('server'), source, dest) + return_code = file_inject(server, source, dest) raise ScriptError, 'File injection failed' unless return_code.zero? end - get_target('server').run('chmod +x /etc/ipmi/fake_ipmi_host.sh') - get_target('server').run('ipmi_sim -n < /dev/null > /dev/null &') + server.run('chmod +x /etc/ipmi/fake_ipmi_host.sh', verbose: true, check_errors: true) + server.run('ipmi_sim -n < /dev/null > /dev/null &', verbose: true, check_errors: true) end When(/^the server stops mocking an IPMI host$/) do @@ -1290,8 +1292,8 @@ os_version = node.os_version.gsub('-SP', '.') os_family = node.os_family # TODO: Check why tools_update_repo is not available on the openSUSE minion - repositories = os_family =~ /^opensuse/ ? 'tools_pool_repo' : 'tools_pool_repo tools_update_repo' - if (os_family =~ /^opensuse/ || os_family =~ /^sles/) && (product != 'Uyuni') + repositories = os_family.match?(/^opensuse/) ? 'tools_pool_repo' : 'tools_pool_repo tools_update_repo' + if (os_family.match?(/^opensuse/) || os_family.match?(/^sles/)) && (product != 'Uyuni') repositories.concat(' tools_additional_repo') # Needed because in SLES15SP3 and openSUSE 15.3 and higher, firewalld will replace this package. # But the tools_update_repo's priority doesn't allow to cope with the obsoletes option from firewalld. diff --git a/testsuite/features/step_definitions/lock_packages_on_client.rb b/testsuite/features/step_definitions/lock_packages_on_client.rb index 30756cf4ba36..230e18531afd 100644 --- a/testsuite/features/step_definitions/lock_packages_on_client.rb +++ b/testsuite/features/step_definitions/lock_packages_on_client.rb @@ -17,21 +17,21 @@ find(:xpath, "(//a[text()='#{pkg}'])[1]") locked_pkgs = all(:xpath, '//i[@class=\'fa fa-lock\']/../a') raise ScriptError, 'No packages locked' if locked_pkgs.empty? - raise ScriptError, "Package #{pkg} not found as locked" unless locked_pkgs.find { |a| a.text =~ /^#{pkg}/ } + raise ScriptError, "Package #{pkg} not found as locked" unless locked_pkgs.find { |a| a.text.match?(/^#{pkg}/) } end Then(/^package "(.*?)" is reported as unlocked$/) do |pkg| find(:xpath, "(//a[text()='#{pkg}'])[1]") locked_pkgs = all(:xpath, '//i[@class=\'fa fa-lock\']/../a') - raise ScriptError, "Package #{pkg} found as locked" if locked_pkgs.find { |a| a.text =~ /^#{pkg}/ } + raise ScriptError, "Package #{pkg} found as locked" if locked_pkgs.find { |a| a.text.match?(/^#{pkg}/) } end Then(/^the package scheduled is "(.*?)"$/) do |pkg| match = find(:xpath, '//li[@class=\'list-group-item\']//li') raise ScriptError, 'List of packages not found' unless match - raise ScriptError, "Package #{pkg} not found" unless match.text =~ /^#{pkg}/ + raise ScriptError, "Package #{pkg} not found" unless match.text.match?(/^#{pkg}/) end Then(/^the action status is "(.*?)"$/) do |status| diff --git a/testsuite/features/step_definitions/navigation_steps.rb b/testsuite/features/step_definitions/navigation_steps.rb index c55e445eb01f..07bbcc6c8677 100644 --- a/testsuite/features/step_definitions/navigation_steps.rb +++ b/testsuite/features/step_definitions/navigation_steps.rb @@ -278,6 +278,17 @@ end end +# Click on a button and confirm in alert box +When(/^I click on "([^"]*)" and confirm alert box$/) do |text| + begin + accept_confirm do + click_button(text) + end + rescue Capybara::ModalNotFound + warn 'Modal not found' + end +end + # # Click on a link # diff --git a/testsuite/features/step_definitions/retail_steps.rb b/testsuite/features/step_definitions/retail_steps.rb index 0c07f62103b9..e9c5a9271be4 100644 --- a/testsuite/features/step_definitions/retail_steps.rb +++ b/testsuite/features/step_definitions/retail_steps.rb @@ -13,12 +13,12 @@ repos += 'testing_overlay_devel_repo ' unless $build_validation || $is_containerized_server || product_version_full.include?('-released') # Server Applications, proxy product and modules, proxy devel - if os_family =~ /^sles/ && os_version =~ /^15/ + if os_family.match?(/^sles/) && os_version.match?(/^15/) repos += 'proxy_module_pool_repo proxy_module_update_repo ' \ 'proxy_product_pool_repo proxy_product_update_repo ' \ 'module_server_applications_pool_repo module_server_applications_update_repo ' repos += 'proxy_devel_releasenotes_repo proxy_devel_repo ' unless $build_validation || product_version_full.include?('-released') - elsif os_family =~ /^opensuse/ + elsif os_family.match?(/^opensuse/) repos += 'proxy_pool_repo ' unless $is_containerized_server end @@ -66,7 +66,7 @@ domain, _code = node.run('grep \'^search\' /etc/resolv.conf | sed \'s/^search//\'') conf = "DOMAIN='#{domain.strip}'\\nDEVICE='eth1'\\nSTARTMODE='auto'\\nBOOTPROTO='dhcp'\\nDNS1='#{proxy}'" service = - if node.os_family =~ /^rocky/ + if node.os_family.match?(/^rocky/) 'NetworkManager' else 'network' diff --git a/testsuite/features/step_definitions/salt_steps.rb b/testsuite/features/step_definitions/salt_steps.rb index d4e4b82ccca3..b01c0303bfc5 100644 --- a/testsuite/features/step_definitions/salt_steps.rb +++ b/testsuite/features/step_definitions/salt_steps.rb @@ -35,7 +35,7 @@ pkgname = use_salt_bundle ? 'venv-salt-minion' : 'salt-minion' os_version = node.os_version os_family = node.os_family - if os_family =~ /^sles/ && os_version =~ /^11/ + if os_family.match?(/^sles/) && os_version.match?(/^11/) node.run("rc#{pkgname} stop", check_errors: false) else node.run("systemctl stop #{pkgname}", check_errors: false) @@ -47,7 +47,7 @@ pkgname = use_salt_bundle ? 'venv-salt-minion' : 'salt-minion' os_version = node.os_version os_family = node.os_family - if os_family =~ /^sles/ && os_version =~ /^11/ + if os_family.match?(/^sles/) && os_version.match?(/^11/) node.run("rc#{pkgname} start", check_errors: false) else node.run("systemctl start #{pkgname}", check_errors: false) @@ -59,7 +59,7 @@ pkgname = use_salt_bundle ? 'venv-salt-minion' : 'salt-minion' os_version = node.os_version os_family = node.os_family - if os_family =~ /^sles/ && os_version =~ /^11/ + if os_family.match?(/^sles/) && os_version.match?(/^11/) node.run("rc#{pkgname} restart", check_errors: false) else node.run("systemctl restart #{pkgname}", check_errors: false) @@ -126,7 +126,7 @@ Then(/^it should contain the OS of "([^"]*)"$/) do |host| node = get_target(host) os_family = node.os_family - family = os_family =~ /^opensuse/ ? 'Leap' : 'SLES' + family = os_family.match?(/^opensuse/) ? 'Leap' : 'SLES' assert_match(/#{family}/, $output) end @@ -385,7 +385,7 @@ Tempfile.open(rpm) do |tmpfile| @download_path = tmpfile.path begin - open(url, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE) do |urlfile| + URI.open(url, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE) do |urlfile| tmpfile.write(urlfile.read) end rescue OpenURI::HTTPError => e diff --git a/testsuite/features/step_definitions/security_steps.rb b/testsuite/features/step_definitions/security_steps.rb index 8f4a22ce8739..294a598c9eb3 100644 --- a/testsuite/features/step_definitions/security_steps.rb +++ b/testsuite/features/step_definitions/security_steps.rb @@ -11,7 +11,7 @@ When(/^I retrieve any static resource$/) do resource = %w[/img/action-add.gif /css/susemanager-light.css /fonts/DroidSans.ttf /javascript/actionchain.js].sample @url = Capybara.app_host + resource - open(@url, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE) do |f| + URI.open(@url, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE) do |f| @headers = f.meta end end diff --git a/testsuite/features/support/commonlib.rb b/testsuite/features/support/commonlib.rb index 19066ed1d74d..3246105b84c7 100644 --- a/testsuite/features/support/commonlib.rb +++ b/testsuite/features/support/commonlib.rb @@ -67,7 +67,7 @@ def product_version def product_version_full cmd = 'salt-call --local grains.get product_version | tail -n 1' out, code = get_target('server').run(cmd) - return out.strip if code.zero? && !out.nil? + out.strip if code.zero? && !out.nil? end # Determines whether to use the Salt bundle based on the product and product version. @@ -183,7 +183,7 @@ def refresh_page # @param locator [String] (optional) The locator for the button element. # @param options [Hash] (optional) Additional options for the click_button method. def click_button_and_wait(locator = nil, **options) - click_button(locator, options) + click_button(locator, **options) begin warn 'Timeout: Waiting AJAX transition (click link)' unless has_no_css?('.senna-loading', wait: 20) rescue StandardError => e @@ -197,7 +197,7 @@ def click_button_and_wait(locator = nil, **options) # @param locator [String, nil] The locator for the link to click. # @param options [Hash] Additional options for the click action. def click_link_and_wait(locator = nil, **options) - click_link(locator, options) + click_link(locator, **options) begin warn 'Timeout: Waiting AJAX transition (click link)' unless has_no_css?('.senna-loading', wait: 20) rescue StandardError => e @@ -211,7 +211,7 @@ def click_link_and_wait(locator = nil, **options) # @param locator [String] (optional) The locator for the link or button to click. # @param options [Hash] (optional) Additional options for the click operation. def click_link_or_button_and_wait(locator = nil, **options) - click_link_or_button(locator, options) + click_link_or_button(locator, **options) begin warn 'Timeout: Waiting AJAX transition (click link)' unless has_no_css?('.senna-loading', wait: 20) rescue StandardError => e @@ -253,7 +253,7 @@ def get_client_type(name) # @param optional_filter_block [Block] An optional filter block to be passed to the `find` method. # @return [Capybara::Node::Element] The element after extending it with the CapybaraNodeElementExtension module. def find_and_wait_click(*args, **options, &optional_filter_block) - element = find(*args, options, &optional_filter_block) + element = find(*args, **options, &optional_filter_block) element.extend(CapybaraNodeElementExtension) end @@ -344,7 +344,7 @@ def generate_repository_name(repo_url) def extract_logs_from_node(node, host) begin os_family = node.os_family - if os_family =~ /^opensuse/ && !$is_gh_validation && !transactional_system?(host) + if os_family.match?(/^opensuse/) && !$is_gh_validation && !transactional_system?(host) node.run('zypper --non-interactive install tar') elsif transactional_system?(host) node.run('transactional-update --continue -n pkg install tar') @@ -469,7 +469,7 @@ def get_os_version(node) os_version.delete! '"' # on SLES, we need to replace the dot with '-SP' - os_version.gsub!('.', '-SP') if os_family =~ /^sles/ + os_version.gsub!('.', '-SP') if os_family.match?(/^sles/) $stdout.puts "Node: #{node.hostname}, OS Version: #{os_version}, Family: #{os_family}" [os_version, os_family] end @@ -483,12 +483,16 @@ def get_os_version(node) # @return [Array] An array of GPG keys. def get_gpg_keys(node, target = get_target('server')) os_version, os_family = get_os_version(node) + os_version_str = os_version.to_s case os_family when /^sles/ # HACK: SLE 15 uses SLE 12 GPG key - os_version = 12 if os_version =~ /^15/ - # SLE12 GPG keys don't contain service pack strings - os_version = os_version.split('-')[0] if os_version =~ /^12/ + if os_version_str.start_with?('15') + os_version = 12 + elsif os_version_str.start_with?('12') + # SLE12 GPG keys don't contain service pack strings + os_version = os_version_str.slice(0, 2) + end gpg_keys, _code = target.run("cd /srv/www/htdocs/pub/ && ls -1 sle#{os_version}*", check_errors: false) when /^centos/ gpg_keys, _code = target.run("cd /srv/www/htdocs/pub/ && ls -1 #{os_family}#{os_version}* res*", check_errors: false) @@ -533,21 +537,21 @@ def get_system_name(host) output, _code = get_target('server').run('salt-key') system_name = output.split.find do |word| - word =~ /example.Intel-Genuine-None-/ || word =~ /example.pxeboot-/ || word =~ /example.Intel/ || word =~ /pxeboot-/ + word.match?(/example.Intel-Genuine-None-/) || word.match?(/example.pxeboot-/) || word.match?(/example.Intel/) || word.match?(/pxeboot-/) end system_name = 'pxeboot.example.org' if system_name.nil? when 'sle12sp5_terminal' output, _code = get_target('server').run('salt-key') system_name = output.split.find do |word| - word =~ /example.sle12sp5terminal-/ + word.match?(/example.sle12sp5terminal-/) end system_name = 'sle12sp5terminal.example.org' if system_name.nil? when 'sle15sp4_terminal' output, _code = get_target('server').run('salt-key') system_name = output.split.find do |word| - word =~ /example.sle15sp4terminal-/ + word.match?(/example.sle15sp4terminal-/) end system_name = 'sle15sp4terminal.example.org' if system_name.nil? else @@ -636,7 +640,7 @@ def channel_is_synced(channel) # @return [ApiTestXmlrpc, ApiTestHttp] The created API client. def new_api_client ssl_verify = !$is_gh_validation - if $debug_mode || product == 'SUSE Manager' + if product == 'SUSE Manager' ApiTestXmlrpc.new(get_target('server', refresh: true).full_hostname) else ApiTestHttp.new(get_target('server', refresh: true).full_hostname, ssl_verify) diff --git a/testsuite/features/support/env.rb b/testsuite/features/support/env.rb index 4c8114c7f650..ff204f7d4b77 100644 --- a/testsuite/features/support/env.rb +++ b/testsuite/features/support/env.rb @@ -10,6 +10,7 @@ require 'cucumber' # require 'simplecov' require 'minitest/autorun' +require 'minitest/unit' require 'securerandom' require 'selenium-webdriver' require 'multi_test' @@ -19,6 +20,8 @@ require_relative 'twopence_env' require_relative 'commonlib' +$stdout.puts("Using Ruby version: #{RUBY_VERSION}") + # code coverage analysis # SimpleCov.start @@ -74,38 +77,28 @@ # Fix a problem with minitest and cucumber options passed through rake MultiTest.disable_autorun -# register chromedriver headless mode +# register chromedriver in headless mode def capybara_register_driver - Capybara.register_driver(:headless_chrome) do |app| - client = Selenium::WebDriver::Remote::Http::Default.new + Capybara.register_driver :selenium_chrome_headless do |app| # WORKAROUND failure at Scenario: Test IPMI functions: increase from 60 s to 180 s - client.read_timeout = 240 - # Chrome driver options - chrome_options = %w[no-sandbox disable-dev-shm-usage ignore-certificate-errors disable-gpu window-size=2048,2048 js-flags=--max_old_space_size=2048 remote-debugging-port=9222] - chrome_options << 'headless' unless $debug_mode - capabilities = Selenium::WebDriver::Remote::Capabilities.chrome( - chromeOptions: { - args: chrome_options, - w3c: false, - prefs: { - download: { - prompt_for_download: false, - default_directory: '/tmp/downloads' - } - } - }, - unexpectedAlertBehaviour: 'accept', - unhandledPromptBehavior: 'accept' + client = Selenium::WebDriver::Remote::Http::Default.new(open_timeout: 30, read_timeout: 240) + chrome_options = Selenium::WebDriver::Chrome::Options.new( + args: %w[disable-dev-shm-usage ignore-certificate-errors window-size=2048,2048 js-flags=--max_old_space_size=2048 remote-debugging-port=9222] ) + chrome_options.args << 'headless=new' unless $debug_mode + chrome_options.add_preference('prompt_for_download', false) + chrome_options.add_preference('download.default_directory', '/tmp/downloads') + chrome_options.add_preference('unhandledPromptBehavior', 'accept') + chrome_options.add_preference('unexpectedAlertBehaviour', 'accept') - Capybara::Selenium::Driver.new(app, browser: :chrome, desired_capabilities: capabilities, http_client: client) + Capybara::Selenium::Driver.new(app, browser: :chrome, options: chrome_options, http_client: client) end end $capybara_driver = capybara_register_driver Selenium::WebDriver.logger.level = :error unless $debug_mode -Capybara.default_driver = :headless_chrome -Capybara.javascript_driver = :headless_chrome +Capybara.default_driver = :selenium_chrome_headless +Capybara.javascript_driver = :selenium_chrome_headless Capybara.default_normalize_ws = true Capybara.enable_aria_label = true Capybara.automatic_label_click = true diff --git a/testsuite/podman_runner/05_install_gems_in_controller.sh b/testsuite/podman_runner/05_install_gems_in_controller.sh index 03863316542a..008ddd5d8cfa 100755 --- a/testsuite/podman_runner/05_install_gems_in_controller.sh +++ b/testsuite/podman_runner/05_install_gems_in_controller.sh @@ -1,3 +1,11 @@ #!/bin/bash set -xe -sudo -i podman exec controller bash -c "cd /testsuite && bundle.ruby2.5 install --gemfile Gemfile" +sudo -i podman exec controller bash -c 'export GEM_PATH="/usr/lib64/ruby/gems/3.3.0"' +sudo -i podman exec controller bash -c "cd /testsuite && bundle.ruby3.3 install --gemfile Gemfile --verbose" +sudo -i podman exec controller bash -c "gem env" +sudo -i podman exec controller bash -c "gem list" + +# Necessary due to building Twopence from source +sudo -i podman exec controller bash -c "ln -sf /usr/lib64/ruby/gems/3.3.0/gems/twopence-0.4.2/lib/twopence.so /usr/lib64/ruby/gems/3.3.0/gems/twopence-0.4.2/lib/twopence.so.0" +sudo -i podman exec controller bash -c "ldconfig" +sudo -i podman exec controller bash -c "ldconfig -p" \ No newline at end of file