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..23f8f5ceb796 --- /dev/null +++ b/testsuite/features/reposync/srv_sync_repo_sync.feature @@ -0,0 +1,56 @@ +# Copyright (c) 2023 SUSE LLC +# Licensed under the terms of the MIT license. + +@susemanager +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 + +@susemanager +Scenario: Run synchronization with default strict mode + Given I am authorized for the "Admin" section + And I prepare a channel clone for strict mode testing + And I am on the Channels page + 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 + + And I follow "Repositories" in the content area + And I follow "Create Repository" + And I enter "TestRepo_Default" as "Repository Label" + And I enter "http://localhost/pub/TestRepoRpmUpdates/" as "Repository URL" + And I follow "Create Repository" + Then I should see a "Repository created successfully" text + + And I follow "Create Repository" + And I enter "TestRepo_Modified" as "Repository Label" + And I enter "http://localhost/pub/TestRepoRpmUpdates_STRICT_TEST/" as "Repository URL" + And I uncheck "Has Signed Metadata" + And I follow "Create Repository" + Then I should see a "Repository created successfully" text + + And I check "TestRepo_Default" + And I follow "Save Repositories" + And I follow "Sync" + 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 "TestRepo_Default" + And I check "TestRepo_Modified" + And I follow "Save Repositories" + And I follow "Sync" + And I check "Do not use strict mode" + 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 am logged into the API + Then The amount of packages in channel "Test-Strict-Channel" should be the same as before + + And I uncheck "Do not use strict mode" + 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 fewer than before \ No newline at end of file diff --git a/testsuite/features/step_definitions/command_steps.rb b/testsuite/features/step_definitions/command_steps.rb index a0dceddc9e70..994055bd8a4b 100644 --- a/testsuite/features/step_definitions/command_steps.rb +++ b/testsuite/features/step_definitions/command_steps.rb @@ -117,6 +117,55 @@ 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 + +$api_token = nil # TODO: Move elsewhere + +Given(/^I am logged into the API$/) do # TODO: Move elsewhere + api_url = "https://localhost/rhn/manager/api/auth/login" + response = RestClient.post(api_url, { login: "admin", password: "admin" }.to_json, { content_type: :json }) + raise "Failed to login to the API" unless response.code == 200 + + $api_token = response.cookies["pxt-session-cookie"] +end + +$previous_packages_count = nil + +When(/^i check the amount of packages in channel "([^"]*)"$/) do |channel_label| + api_url = "https://localhost/rhn/manager/api/listAllChannels" + response = RestClient.get(api_url, { content_type: :json, cookie: "pxt-session-cookie=#{$api_token}" }) + channels = JSON.parse(response.body)["result"] + channel = channels.find { |c| c["label"] == channel_label } + raise "Channel not found" unless channel + $previous_packages_count = channel["packages"] +end + +Then(/^The amount of packages in channel "([^"]*)" should be the same as before$/) do |channel_label| + api_url = "https://localhost/rhn/manager/api/listAllChannels" + response = RestClient.get(api_url, { content_type: :json, cookie: "pxt-session-cookie=#{$api_token}" }) + channels = JSON.parse(response.body)["result"] + channel = channels.find { |c| c["label"] == channel_label } + raise "Channel not found" unless channel + raise "Package counts do not match" unless $previous_packages_count == channel["packages"] +end + +Then(/^The amount of packages in channel "([^"]*)" should be fewer than before$/) do |channel_label| + api_url = "https://localhost/rhn/manager/api/listAllChannels" + response = RestClient.get(api_url, { content_type: :json, cookie: "pxt-session-cookie=#{$api_token}" }) + channels = JSON.parse(response.body)["result"] + channel = channels.find { |c| c["label"] == channel_label } + raise "Channel not found" unless channel + raise "Package count is not fewer than before" unless channel["packages"] < $previous_packages_count +end When(/^I delete these channels with spacewalk-remove-channel:$/) do |table| channels_cmd = 'spacewalk-remove-channel '