Skip to content

Commit

Permalink
Fixing how we get the values of a map to make a deep copy of it
Browse files Browse the repository at this point in the history
  • Loading branch information
srbarrios committed Nov 15, 2024
1 parent 6abd7de commit 011f861
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 20 deletions.
8 changes: 4 additions & 4 deletions testsuite/features/step_definitions/command_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@
end

When(/^I use spacewalk-common-channel to add all "([^"]*)" channels with arch "([^"]*)"$/) do |channel, architecture|
channels_to_synchronize = CHANNEL_TO_SYNC_BY_OS_PRODUCT_VERSION.dig(product, channel) ||
CHANNEL_TO_SYNC_BY_OS_PRODUCT_VERSION.dig(product, "#{channel}-#{architecture}")
channels_to_synchronize = CHANNEL_TO_SYNC_BY_OS_PRODUCT_VERSION.dig(product, channel).clone ||
CHANNEL_TO_SYNC_BY_OS_PRODUCT_VERSION.dig(product, "#{channel}-#{architecture}").clone
channels_to_synchronize = filter_channels(channels_to_synchronize, ['beta']) unless $beta_enabled
raise ScriptError, "Synchronization error, channel #{channel} or #{channel}-#{architecture} in #{product} product not found" if channels_to_synchronize.nil? || channels_to_synchronize.empty?

Expand Down Expand Up @@ -326,7 +326,7 @@
When(/^I kill running spacewalk-repo-sync for "([^"]*)"$/) do |os_product_version|
next if CHANNEL_TO_SYNC_BY_OS_PRODUCT_VERSION.dig(product, os_product_version).nil?

channels_to_kill = CHANNEL_TO_SYNC_BY_OS_PRODUCT_VERSION[product][os_product_version]
channels_to_kill = CHANNEL_TO_SYNC_BY_OS_PRODUCT_VERSION.dig(product, os_product_version).clone
channels_to_kill = filter_channels(channels_to_kill, ['beta']) unless $beta_enabled
log "Killing channels:\n#{channels_to_kill}"
time_spent = 0
Expand Down Expand Up @@ -416,7 +416,7 @@
end

When(/^I wait until all synchronized channels for "([^"]*)" have finished$/) do |os_product_version|
channels_to_wait = CHANNEL_TO_SYNC_BY_OS_PRODUCT_VERSION.dig(product, os_product_version)
channels_to_wait = CHANNEL_TO_SYNC_BY_OS_PRODUCT_VERSION.dig(product, os_product_version).clone
channels_to_wait = filter_channels(channels_to_wait, ['beta']) unless $beta_enabled
raise ScriptError, "Synchronization error, channels for #{os_product_version} in #{product} not found" if channels_to_wait.nil?

Expand Down
5 changes: 3 additions & 2 deletions testsuite/features/support/commonlib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -731,10 +731,11 @@ def wait_action_complete(actionid, timeout: DEFAULT_TIMEOUT)
# @param channels [Array<String>] The list of channels to filter.
# @param filters [Array<String>] The list of filters to apply.
def filter_channels(channels, filters = [])
filtered_channels = channels.clone
filters.each do |filter|
channels.delete_if { |channel| channel.include? filter }
filtered_channels.delete_if { |channel| channel.include? filter }
end
channels
filtered_channels
end

# Mutex for processes accessing the API of the server via admin user
Expand Down
18 changes: 4 additions & 14 deletions testsuite/features/support/system_monitoring.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def last_onboarding_duration(host)
# @param os_product_version [String] the product name
# @return [Integer] the duration in seconds
def product_synchronization_duration(os_product_version)
channels_to_evaluate = CHANNEL_TO_SYNC_BY_OS_PRODUCT_VERSION.dig(product, os_product_version)
channels_to_evaluate = CHANNEL_TO_SYNC_BY_OS_PRODUCT_VERSION.dig(product, os_product_version).clone
$stdout.puts("Product: #{product}\n#{CHANNEL_TO_SYNC_BY_OS_PRODUCT_VERSION}\n#{CHANNEL_TO_SYNC_BY_OS_PRODUCT_VERSION.dig(product, os_product_version)}") if channels_to_evaluate.empty?
channels_to_evaluate = filter_channels(channels_to_evaluate, ['beta']) unless $beta_enabled
$stdout.puts("Channels to evaluate:\n#{channels_to_evaluate}")
raise ScriptError, "Synchronization error, channels for #{os_product_version} in #{product} not found" if channels_to_evaluate.nil?
Expand All @@ -61,7 +62,7 @@ def product_synchronization_duration(os_product_version)
log_content.each do |line|
if line.include?('Channel: ')
channel_name = line.split('Channel: ')[1].strip
channel_to_evaluate = channels_to_wait.include?(channel_name)
channel_to_evaluate = channels_to_evaluate.include?(channel_name)
end
next unless line.include?('Total time: ') && channel_to_evaluate

Expand All @@ -73,21 +74,10 @@ def product_synchronization_duration(os_product_version)
matches += 1
channel_to_evaluate = false
end

if matches < channels_to_wait.size
if matches < channels_to_evaluate.size
$stdout.puts("Error extracting the synchronization duration of #{os_product_version}")
$stdout.puts("Content of reposync.log:\n#{log_content.join}")
end

match = line.match(/Total time: (\d+):(\d+):(\d+)/)
hours, minutes, seconds = match.captures.map(&:to_i)
total_seconds = (hours * 3600) + (minutes * 60) + seconds
$stdout.puts("Channel #{channel_name} synchronization duration: #{total_seconds} seconds")
duration += total_seconds
matches += 1
channel_to_evaluate = false
end
$stdout.puts("Error extracting the synchronization duration of #{os_product_version}") if matches < channels_to_evaluate.size
duration
end

Expand Down

0 comments on commit 011f861

Please sign in to comment.