uyuni icon indicating copy to clipboard operation
uyuni copied to clipboard

QE: Update test suite to Ruby 3.1

Open nodeg opened this issue 2 years ago • 7 comments

What does this PR change?

See https://github.com/SUSE/spacewalk/issues/17431

TODO

  • [x] Positional arguments
  • [ ] Deprecated object #=~

GUI diff

No difference.

  • [x] DONE

Documentation

  • No documentation needed: only internal and user invisible changes

  • [x] DONE

Test coverage

  • Cucumber tests were added

  • [x] DONE

Links

  • [x] DONE

Changelogs

Make sure the changelogs entries you are adding are compliant with https://github.com/uyuni-project/uyuni/wiki/Contributing#changelogs and https://github.com/uyuni-project/uyuni/wiki/Contributing#uyuni-projectuyuni-repository

If you don't need a changelog check, please mark this checkbox:

  • [x] No changelog needed

If you uncheck the checkbox after the PR is created, you will need to re-run changelog_test (see below)

Re-run a test

If you need to re-run a test, please mark the related checkbox, it will be unchecked automatically once it has re-run:

  • [ ] Re-run test "changelog_test"
  • [ ] Re-run test "backend_unittests_pgsql"
  • [ ] Re-run test "java_pgsql_tests"
  • [ ] Re-run test "schema_migration_test_pgsql"
  • [ ] Re-run test "susemanager_unittests"
  • [ ] Re-run test "javascript_lint"
  • [ ] Re-run test "spacecmd_unittests"

nodeg avatar Jan 31 '23 14:01 nodeg

Core stage

Scenario: Create admin user and first organization

  Scenario: Create admin user and first organization # features/core/srv_first_settings.feature:9
      This scenario ran at: 2022-08-29 13:28:50 +0200
    Given I access the host the first time           # features/step_definitions/navigation_steps.rb:390
    And I run "rm -Rf /srv/salt/*" on "server"       # features/step_definitions/command_steps.rb:716
    When I go to the home page                       # features/step_definitions/navigation_steps.rb:386
    And I enter "SUSE Test" as "orgName"             # features/step_definitions/navigation_steps.rb:226
    And I enter "admin" as "login"                   # features/step_definitions/navigation_steps.rb:226
    And I enter "admin" as "desiredpassword"         # features/step_definitions/navigation_steps.rb:226
    And I enter "admin" as "desiredpasswordConfirm"  # features/step_definitions/navigation_steps.rb:226
    And I select "Mr." from "prefix"                 # features/step_definitions/navigation_steps.rb:174
    And I enter "Admin" as "firstNames"              # features/step_definitions/navigation_steps.rb:226
    And I enter "Admin" as "lastName"                # features/step_definitions/navigation_steps.rb:226
    And I enter "[email protected]" as "email"    # features/step_definitions/navigation_steps.rb:226
    And I click on "Create Organization"             # features/step_definitions/navigation_steps.rb:256
      wrong number of arguments (given 2, expected 0..1) (ArgumentError)
      ./features/support/commonlib.rb:128:in `click_button_and_wait'
      ./features/step_definitions/navigation_steps.rb:257:in `/^I click on "([^"]*)"$/'
      features/core/srv_first_settings.feature:21:in `I click on "Create Organization"'                 
    Then I am logged in                              # features/step_definitions/navigation_steps.rb:540

With Ruby 2.7 we only get a deprecation warning:

  Scenario: Create admin user and first organization # features/core/srv_first_settings.feature:9
      This scenario ran at: 2023-01-31 13:33:05 +0100
    Given I access the host the first time           # features/step_definitions/navigation_steps.rb:391
    And I run "rm -Rf /srv/salt/*" on "server"       # features/step_definitions/command_steps.rb:715
    When I go to the home page                       # features/step_definitions/navigation_steps.rb:387
    And I enter "SUSE Test" as "orgName"             # features/step_definitions/navigation_steps.rb:232
    And I enter "admin" as "login"                   # features/step_definitions/navigation_steps.rb:232
    And I enter "admin" as "desiredpassword"         # features/step_definitions/navigation_steps.rb:232
    And I enter "admin" as "desiredpasswordConfirm"  # features/step_definitions/navigation_steps.rb:232
    And I select "Mr." from "prefix"                 # features/step_definitions/navigation_steps.rb:182
    And I enter "Admin" as "firstNames"              # features/step_definitions/navigation_steps.rb:232
    And I enter "Admin" as "lastName"                # features/step_definitions/navigation_steps.rb:232
    And I enter "[email protected]" as "email"    # features/step_definitions/navigation_steps.rb:232
/usr/lib64/ruby/gems/2.7.0/gems/capybara-3.38.0/lib/capybara/session.rb:773: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/usr/lib64/ruby/gems/2.7.0/gems/capybara-3.38.0/lib/capybara/node/actions.rb:57: warning: The called method `click_button' is defined here
    And I click on "Create Organization"             # features/step_definitions/navigation_steps.rb:262
    Then I am logged in                              # features/step_definitions/navigation_steps.rb:548
      This scenario took: 4 seconds
When(/^I click on "([^"]*)"$/) do |text|
  click_button_and_wait(text, match: :first)
end
def click_button_and_wait(locator = nil, **options)
  click_button(locator, options)
  begin
    raise 'Timeout: Waiting AJAX transition (click link)' unless has_no_css?('.senna-loading', wait: 5)
  rescue StandardError, Capybara::ExpectationNotMet => e
    STDOUT.puts e.message # Skip errors related to .senna-loading element
  end
end

:heavy_check_mark: Positional arguments

This error is a result of Ruby 3.0. See https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/

In Ruby 3, a method delegating all arguments must explicitly delegate keyword arguments in addition to positional arguments. If you want to keep the delegation behavior found in Ruby 2.7 and earlier, use ruby2_keywords.

# Before:
def foo(*args, &block)
  target(*args, &block)
end

# Now: You need to explicitly delegate keyword arguments.
def foo(*args, **kwargs, &block)
  target(*args, **kwargs, &block)
end

nodeg avatar Mar 15 '23 08:03 nodeg

Core did pass with the new adjustments to the positional arguments:

ruby31-ctl:~/spacewalk/testsuite # rake cucumber:core                                                                                                                         
/usr/bin/ruby.ruby3.1 -S bundle exec cucumber --profile default -f html -o output_20230202115333-core.html -f json -o output_20230202115333-core.json -f junit -o results_juni
t -f pretty -r features features/core/srv_first_settings.feature features/core/srv_disable_local_repos_off.feature features/core/srv_organization_credentials.feature features
/core/srv_user_preferences.feature features/core/srv_channels_add.feature features/core/srv_create_repository.feature features/core/srv_create_activationkey.feature features/
core/srv_osimage.feature features/core/srv_docker.feature features/core/proxy_register_as_minion_with_script.feature features/core/proxy_branch_network.feature               
Capybara APP Host: https://ruby31-srv.tf.local:8888                                                                                                                           
Client IP address or domain name variable empty                                                                                                                               
Host 'ruby31-ctl' is alive with determined hostname ruby31-ctl and FQDN ruby31-ctl.tf.local                                                                                   
Node: ruby31-ctl, OS Version: 15.4, Family: opensuse-leap                                                                                                                     
Host 'ruby31-srv.tf.local' is alive with determined hostname ruby31-srv and FQDN ruby31-srv.tf.local                                                                          
Node: ruby31-srv, OS Version: 15.4, Family: opensuse-leap                                                                                                                     
Host 'ruby31-pxy.tf.local' is alive with determined hostname ruby31-pxy and FQDN ruby31-pxy.tf.local                                                                          
Node: ruby31-pxy, OS Version: 15.4, Family: opensuse-leap
Host 'ruby31-min-kvm.tf.local' is alive with determined hostname ruby31-min-kvm and FQDN ruby31-min-kvm.tf.local
Node: ruby31-min-kvm, OS Version: 15-SP4, Family: sles
Host 'ruby31-min-sles15.tf.local' is alive with determined hostname ruby31-min-sles15 and FQDN ruby31-min-sles15.tf.local
Node: ruby31-min-sles15, OS Version: 15-SP4, Family: sles
Host 'ruby31-minssh-sles15.tf.local' is alive with determined hostname ruby31-minssh-sles15 and FQDN ruby31-minssh-sles15.tf.local
Node: ruby31-minssh-sles15, OS Version: 15-SP4, Family: sles
Host 'ruby31-min-rocky8.tf.local' is alive with determined hostname ruby31-min-rocky8 and FQDN ruby31-min-rocky8.tf.local
Node: ruby31-min-rocky8, OS Version: 8.7, Family: rocky
Host 'ruby31-min-ubuntu2204.tf.local' is alive with determined hostname ruby31-min-ubuntu2204 and FQDN ruby31-min-ubuntu2204.tf.local
Node: ruby31-min-ubuntu2204, OS Version: 22.04, Family: ubuntu
Host 'ruby31-min-build.tf.local' is alive with determined hostname ruby31-min-build and FQDN ruby31-min-build.tf.local
Node: ruby31-min-build, OS Version: 15-SP4, Family: sles
Activating HTTP API
Using the default profile...
# Copyright (c) 2017-2021 SUSE LLC
(...)
80 scenarios (5 skipped, 75 passed)
514 steps (28 skipped, 486 passed)
24m42.915s

ruby31-ctl:~/spacewalk/testsuite # /usr/bin/ruby.ruby3.1 --version
ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) [x86_64-linux-gnu]

nodeg avatar Mar 15 '23 08:03 nodeg

A full test suite run passed with minimal issues: https://ci.suse.de/view/Manager/view/Uyuni-PRs/job/uyuni-prs-ci-tests-qe/45 image

The failures were also seen in the normal test suite, so not specific to my Ruby changes. But when reviewing the logs manually, I found e.g. the following which did fail but did not show up in the results:

03:22:02  Scenario: Bootstrap via API a non-existing system                           # features/secondary/min_bootstrap_api.feature:64
03:22:02  This scenario ran at: 2023-03-14 03:21:43 +0100
03:22:04  #<Thread:0x00007f8fe6324470 /root/spacewalk/testsuite/features/support/api_test.rb:64 run> terminated with exception (report_on_exception is true):
03:22:04  /root/spacewalk/testsuite/features/support/http_client.rb:99:in `call': API failure: [An error has occurred during salt execution: unable to establish ssh connection.] (RuntimeError)
03:22:04  from /root/spacewalk/testsuite/features/support/api_test.rb:68:in `block (2 levels) in call'
03:22:04  from /root/spacewalk/testsuite/features/support/api_test.rb:65:in `synchronize'
03:22:04  from /root/spacewalk/testsuite/features/support/api_test.rb:65:in `block in call'
03:22:04  When I call system.bootstrap() on unknown host, I should get an API fault # features/step_definitions/api_common.rb:31
03:22:04  This scenario took: 6 seconds
03:22:04  
03:22:04  Scenario: Bootstrap a salt-ssh system with activation key and default contact method                                                                  # features/secondary/min_bootstrap_api.feature:67
03:22:04  This scenario ran at: 2023-03-14 03:21:49 +0100
03:22:04  #<Thread:0x00007f8fe6213608 /root/spacewalk/testsuite/features/support/api_test.rb:64 run> terminated with exception (report_on_exception is true):
03:22:04  /root/spacewalk/testsuite/features/support/http_client.rb:99:in `call': API failure: [Selected activation key cannot be used as its contact method is not compatible with the salt-ssh systems.] (RuntimeError)
03:22:04  from /root/spacewalk/testsuite/features/support/api_test.rb:68:in `block (2 levels) in call'
03:22:04  from /root/spacewalk/testsuite/features/support/api_test.rb:65:in `synchronize'
03:22:04  from /root/spacewalk/testsuite/features/support/api_test.rb:65:in `block in call'
03:22:04  When I call system.bootstrap() on a Salt minion with saltSSH = true, but with activation key with default contact method, I should get an API fault # features/step_definitions/api_common.rb:42
03:22:04  This scenario took: 0 seconds

(...)
01:36:47  
01:36:47  Scenario: One search result for Country                                                 # features/secondary/srv_advanced_search.feature:41
01:36:47  This scenario ran at: 2023-03-14 01:36:28 +0100
01:36:47  #<Thread:0x00007f8fe9967aa0 /root/spacewalk/testsuite/features/support/api_test.rb:64 run> terminated with exception (report_on_exception is true):
01:36:47  /root/spacewalk/testsuite/features/support/http_client.rb:99:in `call': API failure: Error communicating with search server (RuntimeError)
01:36:47  from /root/spacewalk/testsuite/features/support/api_test.rb:68:in `block (2 levels) in call'
01:36:47  from /root/spacewalk/testsuite/features/support/api_test.rb:65:in `synchronize'
01:36:47  from /root/spacewalk/testsuite/features/support/api_test.rb:65:in `block in call'
01:36:47  Given I have a combobox property "Country" with value "Portugal (PT)" on "sle_minion" # features/step_definitions/navigation_steps.rb:1085
01:36:47  Search by hostname: suma-pr8-min-sles15
01:36:47  rhn-search still not responding.
01:36:47  Error message: API failure: Error communicating with search server
01:36:47  Search by hostname: suma-pr8-min-sles15
01:36:47  []
01:36:47  rhn-search still not responding.
01:36:47  Error message: undefined method `[]' for nil:NilClass
01:36:47  
01:36:47        break if $minion.full_hostname.include? result.first['hostname']
01:36:47                                                            ^^^^^^^^^^^^
01:36:47  Search by hostname: suma-pr8-min-sles15
01:36:47  [{"hostname"=>"suma-pr8-min-sles15.mgr.prv.suse.net", "ip"=>"10.84.222.116", "name"=>"suma-pr8-min-sles15.mgr.prv.suse.net", "id"=>1000010029, "last_checkin"=>"Mar 14, 2023, 1:34:35 AM"}]
01:36:47  When I follow the left menu "Systems > Advanced Search"                               # features/step_definitions/navigation_steps.rb:348
(...)

22:01:48  
22:01:48  Scenario: Cleanup: register a Salt minion after SSH tunnel tests                                                  # features/secondary/min_ssh_tunnel.feature:82
22:01:48  This scenario ran at: 2023-03-13 22:01:37 +0100
22:01:48  Node: suma-pr8-minssh-sles15, OS Version: 15-SP4, Family: sles
22:01:48  /root/spacewalk/testsuite/features/support/commonlib.rb:309: warning: deprecated Object#=~ is called on Integer; it always returns nil
(...)
22:01:48  
22:01:48  Scenario: Cleanup: register a Salt minion after SSH tunnel tests                                                  # features/secondary/min_ssh_tunnel.feature:82
22:01:48  This scenario ran at: 2023-03-13 22:01:37 +0100
22:01:48  Node: suma-pr8-minssh-sles15, OS Version: 15-SP4, Family: sles
22:01:48  /root/spacewalk/testsuite/features/support/commonlib.rb:309: warning: deprecated Object#=~ is called on Integer; it always returns nil
(...)
20:09:34  
20:09:34  Scenario: Cleanup: cancel all scheduled actions # features/secondary/srv_maintenance_windows.feature:122
20:09:34  This scenario ran at: 2023-03-13 20:09:21 +0100
20:09:34  #<Thread:0x00007f7f027cb4f0 /root/spacewalk/testsuite/features/support/api_test.rb:64 run> terminated with exception (report_on_exception is true):
20:09:34  /root/spacewalk/testsuite/features/support/http_client.rb:99:in `call': API failure: Cannot cancel an action in PICKED UP state. (RuntimeError)
20:09:34  from /root/spacewalk/testsuite/features/support/api_test.rb:68:in `block (2 levels) in call'
20:09:34  from /root/spacewalk/testsuite/features/support/api_test.rb:65:in `synchronize'
20:09:34  from /root/spacewalk/testsuite/features/support/api_test.rb:65:in `block in call'
20:09:34  When I cancel all scheduled actions           # features/step_definitions/api_common.rb:405
20:09:34  	- Try to cancel "Package Install/Upgrade scheduled by admin" action
20:09:34  	- Removed "Package Install/Upgrade scheduled by admin" action
20:09:34  	- Try to cancel "Subscribe channels scheduled by admin" action
20:09:34  	- Removed "Subscribe channels scheduled by admin" action
20:09:34  This scenario took: 1 seconds
20:09:34 
(...)
[2023-03-15T23:26:09.132Z] Scenario: Bootstrap via API a non-existing system                           # features/secondary/min_bootstrap_api.feature:64
[2023-03-15T23:26:09.132Z] This scenario ran at: 2023-03-16 00:25:57 +0100
[2023-03-15T23:26:09.132Z] #<Thread:0x00007fa9c5746168 /root/spacewalk/testsuite/features/support/api_test.rb:64 run> terminated with exception (report_on_exception is true):
[2023-03-15T23:26:09.132Z] /root/spacewalk/testsuite/features/support/http_client.rb:99:in `call': API failure: [An error has occurred during salt execution: unable to establish ssh connection.] (RuntimeError)
[2023-03-15T23:26:09.132Z] from /root/spacewalk/testsuite/features/support/api_test.rb:68:in `block (2 levels) in call'
[2023-03-15T23:26:09.132Z] from /root/spacewalk/testsuite/features/support/api_test.rb:65:in `synchronize'
[2023-03-15T23:26:09.132Z] from /root/spacewalk/testsuite/features/support/api_test.rb:65:in `block in call'
[2023-03-15T23:26:09.132Z] When I call system.bootstrap() on unknown host, I should get an API fault # features/step_definitions/api_common.rb:31
[2023-03-15T23:26:09.132Z] This scenario took: 5 seconds
[2023-03-15T23:26:09.132Z] 
[2023-03-15T23:26:09.132Z] Scenario: Bootstrap a salt-ssh system with activation key and default contact method                                                                  # features/secondary/min_bootstrap_api.feature:67
[2023-03-15T23:26:09.132Z] This scenario ran at: 2023-03-16 00:26:02 +0100
[2023-03-15T23:26:09.132Z] #<Thread:0x00007fa9c18aec20 /root/spacewalk/testsuite/features/support/api_test.rb:64 run> terminated with exception (report_on_exception is true):
[2023-03-15T23:26:09.132Z] /root/spacewalk/testsuite/features/support/http_client.rb:99:in `call': API failure: [Selected activation key cannot be used as its contact method is not compatible with the salt-ssh systems.] (RuntimeError)
[2023-03-15T23:26:09.132Z] from /root/spacewalk/testsuite/features/support/api_test.rb:68:in `block (2 levels) in call'
[2023-03-15T23:26:09.132Z] from /root/spacewalk/testsuite/features/support/api_test.rb:65:in `synchronize'
[2023-03-15T23:26:09.132Z] from /root/spacewalk/testsuite/features/support/api_test.rb:65:in `block in call'
[2023-03-15T23:26:09.132Z] When I call system.bootstrap() on a Salt minion with saltSSH = true, but with activation key with default contact method, I should get an API fault # features/step_definitions/api_common.rb:42

consoleText.txt consoleText_testsuite_only.txt

nodeg avatar Mar 15 '23 08:03 nodeg

deprecated Object#=~

  • https://bugs.ruby-lang.org/issues/15231
  • https://ruby-doc.org/core-3.1.1/Object.html#method-i-3D~

Ruby < 2.7.6

image

Ruby >= 2.7.6

image image

But there are other valid methods for the Regex and String objects:

Occurrences

https://github.com/search?q=repo%3Auyuni-project%2Fuyuni+%3D%7E+language%3ARuby&type=code&l=Ruby

Links

  • https://www.rubyguides.com/2015/06/ruby-regex/
  • https://stackoverflow.com/questions/3025838/what-is-the-operator-in-ruby

nodeg avatar Mar 28 '23 09:03 nodeg

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 10 days.

github-actions[bot] avatar Oct 10 '23 01:10 github-actions[bot]

:wave: Hello! Thanks for contributing to our project. Acceptance tests will take some time (aprox. 1h), please be patient :coffee: You can see the progress at the end of this page and at https://github.com/uyuni-project/uyuni/pull/6555/checks Once tests finish, if they fail, you can check :eyes: the cucumber report. See the link at the output of the action. You can also check the artifacts section, which contains the logs at https://github.com/uyuni-project/uyuni/pull/6555/checks. See the troubleshooting guide if you need any help.

Happy hacking! :warning: You should not merge if acceptance tests fail to pass. :warning:

github-actions[bot] avatar Oct 30 '23 14:10 github-actions[bot]

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 10 days.

github-actions[bot] avatar Dec 30 '23 01:12 github-actions[bot]

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 10 days.

github-actions[bot] avatar Feb 29 '24 01:02 github-actions[bot]

Closing until the 5.0 release. After that, we can do those refactors.

nodeg avatar Feb 29 '24 12:02 nodeg