diff --git a/testsuite/features/support/system_monitoring.rb b/testsuite/features/support/system_monitoring.rb index 08d6f22cbe3..8dc57476b42 100644 --- a/testsuite/features/support/system_monitoring.rb +++ b/testsuite/features/support/system_monitoring.rb @@ -32,7 +32,6 @@ def last_onboarding_duration(host) onboarding_events = events.select { |event| event['summary'].include? 'certs, channels, packages' } last_event_id = onboarding_events.last['id'] event_details = $api_test.system.get_event_details(system_id, last_event_id) - Time.parse(event_details['completed']) - Time.parse(event_details['picked_up']) # Convert XMLRPC::DateTime to Ruby's Time if necessary completed_time = event_details['completed'].is_a?(XMLRPC::DateTime) ? event_details['completed'].to_time : Time.parse(event_details['completed']) picked_up_time = event_details['picked_up'].is_a?(XMLRPC::DateTime) ? event_details['picked_up'].to_time : Time.parse(event_details['picked_up']) @@ -46,9 +45,10 @@ 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_wait = CHANNEL_TO_SYNC_BY_OS_PRODUCT_VERSION.dig(product, os_product_version) - 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? + channels_to_evaluate = CHANNEL_TO_SYNC_BY_OS_PRODUCT_VERSION.dig(product, os_product_version) + 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? get_target('server').extract('/var/log/rhn/reposync.log', '/tmp/reposync.log') raise ScriptError, 'The file with repository synchronization logs doesn\'t exist or is empty' if !File.exist?('/tmp/reposync.log') || File.empty?('/tmp/reposync.log') @@ -56,23 +56,25 @@ def product_synchronization_duration(os_product_version) duration = 0 channel_to_evaluate = false matches = 0 + channel_name = '' log_content = File.readlines('/tmp/reposync.log') $stdout.puts("Content of reposync.log:\n#{log_content.join}") 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) - end - if line.include?('Total time: ') && channel_to_evaluate - match = line.match(/Total time: (\d+):(\d+):(\d+)/) - hours, minutes, seconds = match.captures.map(&:to_i) - total_seconds = (hours * 3600) + (minutes * 60) + seconds - duration += total_seconds - matches += 1 - channel_to_evaluate = false + channel_to_evaluate = channels_to_evaluate.include?(channel_name) end + next unless line.include?('Total time: ') && channel_to_evaluate + + 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_wait.size + $stdout.puts("Error extracting the synchronization duration of #{os_product_version}") if matches < channels_to_evaluate.size duration end @@ -108,3 +110,4 @@ def channel_synchronization_duration(channel) duration end +