diff --git a/testsuite/features/reposync/srv_sync_repo_sync.feature b/testsuite/features/reposync/srv_sync_repo_sync.feature new file mode 100644 index 000000000000..3edae5612be9 --- /dev/null +++ b/testsuite/features/reposync/srv_sync_repo_sync.feature @@ -0,0 +1,55 @@ +# Copyright (c) 2023 SUSE LLC +# Licensed under the terms of the MIT license. + +Feature: Strict Mode for Channel Synchronization + In order to control strict mode synchronization + As an admin user + I want to be able to toggle strict mode synchronization via the UI and command line + +Scenario: Create Test-strict-channel + Given I am authorized for the "Admin" section + And I prepare a channel clone for strict mode testing + And I follow the left menu "Software > Manage > Channels" + And I follow "Create Channel" + And I enter "Test-Strict-Channel" as "Channel Name" + And I enter "test-strict-channel" as "Channel Label" + And I enter "Test-Strict-Channel for testing" as "Channel Summary" + And I click on "Create Channel" + Then I should see a "Channel Test-Strict-Channel created." text + +Scenario: Prepare repos for strict test + Given I am authorized for the "Admin" section + And I follow the left menu "Software > Manage > Repositories" + And I follow "Create Repository" + And I enter "fake-rpm-repo-modified" as "label" + And I enter "http://localhost/pub/TestRepoRpmUpdates_STRICT_TEST/" as "url" + And I uncheck "metadataSigned" + And I click on "Create Repository" + Then I should see a "Repository created successfully" text + +@rrichardson-test +Scenario: Testing strict mode + Given I am authorized for the "Admin" section + And I follow the left menu "Software > Manage > Channels" + And I follow "Test-Strict-Channel" + And I follow "Repositories" in the "content area" + And I check "fake-rpm-repo" in the list + And I click on "Save Repositories" + And I follow "Sync" in the "content area" + And I click on "Sync Now" + And I wait at most 60 seconds until I do not see "Repository sync is running." text, refreshing the page + And I check the amount of packages in channel "test-strict-channel" + And I follow "Add / Remove" + And I uncheck "fake-rpm-repo" in the list + And I check "fake-rpm-repo-modified" in the list + And I click on "Save Repositories" + And I follow "Sync" in the "content area" + And I check "no-strict" + And I click on "Sync Now" + And I wait at most 60 seconds until I do not see "Repository sync is running." text, refreshing the page + Then The amount of packages in channel "Test-Strict-Channel" should be the same as before + + And I uncheck "no-strict" + And I click on "Sync Now" + And I wait at most 60 seconds until I do not see "Repository sync is running." text, refreshing the page + Then The amount of packages in channel "Test-Strict-Channel" should be fewer than before diff --git a/testsuite/features/step_definitions/command_steps.rb b/testsuite/features/step_definitions/command_steps.rb index e48240def98b..0491bf0f72ec 100644 --- a/testsuite/features/step_definitions/command_steps.rb +++ b/testsuite/features/step_definitions/command_steps.rb @@ -117,6 +117,49 @@ end # Channels +When(/^I prepare a channel clone for strict mode testing$/) do + get_target('server').run('cp -r /srv/www/htdocs/pub/TestRepoRpmUpdates /srv/www/htdocs/pub/TestRepoRpmUpdates_STRICT_TEST') + get_target('server').run('rm -rf /srv/www/htdocs/pub/TestRepoRpmUpdates_STRICT_TEST/repodata') + %w[i586 src x86_64].each do |folder| + get_target('server').run("rm -f /srv/www/htdocs/pub/TestRepoRpmUpdates_STRICT_TEST/#{folder}/rute-dummy-2.0-1.2.*.rpm") + end + get_target('server').run('createrepo_c /srv/www/htdocs/pub/TestRepoRpmUpdates_STRICT_TEST') + get_target('server').run('gzip -dc /srv/www/htdocs/pub/TestRepoRpmUpdates/repodata/*-updateinfo.xml.gz > /tmp/updateinfo.xml') + get_target('server').run('modifyrepo_c --verbose --mdtype updateinfo /tmp/updateinfo.xml /srv/www/htdocs/pub/TestRepoRpmUpdates_STRICT_TEST/repodata') +end + +Given(/^I am logged into the API$/) do + server_node = get_target('server') + api_url = "https://#{server_node.public_ip}/rhn/manager/api/auth/login" + response = get_target('server').run("curl -H 'Content-Type: application/json' -d '{'login': 'admin', 'password': 'admin'}' -i #{api_url}") + raise 'Failed to login to the API' unless response.code == 200 +end + +$package_amount = nil + +When(/^I check the amount of packages in channel "([^"]*)"$/) do |channel_label| + channels = $api_test.channel.list_all_channels + if channels.key?(channel_label) + package_amount = channels[channel_label]['packages'] + puts "Package amount for 'test-strict': #{package_amount}" + else + puts "#{channel_label} channel not found." + end +end + +Then(/^The amount of packages in channel "([^"]*)" should be the same as before$/) do |channel_label| + channels = $api_test.channel.list_all_channels + if channels.key?(channel_label) && ($package_amount != channels[channel_label]['packages']) + raise 'Package counts do not match' + end +end + +Then(/^The amount of packages in channel "([^"]*)" should be fewer than before$/) do |channel_label| + channels = $api_test.channel.list_all_channels + if channels.key?(channel_label) && channels[channel_label]['packages'] >= $package_amount + raise 'Package count is not fewer than before' + end +end When(/^I delete these channels with spacewalk-remove-channel:$/) do |table| channels_cmd = 'spacewalk-remove-channel ' diff --git a/testsuite/features/step_definitions/navigation_steps.rb b/testsuite/features/step_definitions/navigation_steps.rb index 504575bff9e8..687b22ef319a 100644 --- a/testsuite/features/step_definitions/navigation_steps.rb +++ b/testsuite/features/step_definitions/navigation_steps.rb @@ -941,6 +941,14 @@ row.set(true) end +When(/^I uncheck "([^"]*)" in the list$/) do |text| + top_level_xpath_query = "//div[@class=\"table-responsive\"]/table/tbody/tr[.//td[contains(.,'#{text}')]]//input[@type='checkbox']" + row = find(:xpath, top_level_xpath_query, match: :first) + raise "xpath: #{top_level_xpath_query} not found" if row.nil? + + row.set(false) +end + # # Test if an option is selected # diff --git a/testsuite/features/support/namespaces/channel.rb b/testsuite/features/support/namespaces/channel.rb index 47ce0cc589d9..eb9ee822ad5a 100644 --- a/testsuite/features/support/namespaces/channel.rb +++ b/testsuite/features/support/namespaces/channel.rb @@ -33,6 +33,26 @@ def verify_channel(label) .include?(label) end + def list_all_channels + channels = @test.call('channel.listAllChannels', sessionKey: @test.token) + + mapped_channels = + channels.map do |channel| + [ + channel['label'], + { + 'id' => channel['id'], + 'name' => channel['name'], + 'provider_name' => channel['provider_name'], + 'packages' => channel['packages'], + 'systems' => channel['systems'], + 'arch_name' => channel['arch_name'] + } + ] + end + mapped_channels.to_h + end + def list_software_channels channels = @test.call('channel.listSoftwareChannels', sessionKey: @test.token) channels.map { |channel| channel['label'] } diff --git a/testsuite/run_sets/github_validation/github_validation_core.yml b/testsuite/run_sets/github_validation/github_validation_core.yml index 3dc0be5f7a24..72a170c42d49 100644 --- a/testsuite/run_sets/github_validation/github_validation_core.yml +++ b/testsuite/run_sets/github_validation/github_validation_core.yml @@ -10,6 +10,7 @@ - features/reposync/srv_create_fake_repositories.feature - features/reposync/srv_sync_fake_channels.feature - features/reposync/srv_create_activationkey.feature +- features/reposync/srv_sync_repo_sync.feature - features/core/srv_osimage.feature - features/core/srv_docker.feature ## Container features END ###