Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated Test report review #9505

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions testsuite/.rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Style/ArgumentsForwarding:
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/ArrayFirstLast:
Exclude:
- 'ext-tools/collect_and_tag_flaky_tests.rb'
- 'ext-tools/gh_issues_parser.rb'
- 'ext-tools/maintenance_crawler.rb'
- 'features/step_definitions/api_common.rb'
- 'features/step_definitions/command_steps.rb'
Expand Down Expand Up @@ -189,7 +189,7 @@ Style/RedundantStringEscape:
Style/RequireOrder:
Exclude:
- 'Rakefile'
- 'ext-tools/collect_and_tag_flaky_tests.rb'
- 'ext-tools/gh_issues_parser.rb'
- 'ext-tools/maintenance_crawler.rb'
- 'features/step_definitions/command_steps.rb'
- 'features/step_definitions/common_steps.rb'
Expand Down
1 change: 1 addition & 0 deletions testsuite/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ source 'https://rubygems.org'

gem 'bcrypt_pbkdf', '~> 1.0'
gem 'capybara', '3.40.0'
gem 'csv', '~> 3.3'
gem 'cucumber', '9.2.0'
gem 'cucumber-html-formatter', '21.7.0'
gem 'ed25519', '~> 1.2'
Expand Down
12 changes: 11 additions & 1 deletion testsuite/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,17 @@ namespace :utils do

desc 'Collect and tag flaky tests'
task :collect_and_tag_flaky_tests do
`ruby ext-tools/collect_and_tag_flaky_tests.rb features`
`ruby ext-tools/machine_learning/gh_issues_parser.rb --collect_and_tag --directory_path features`
end

desc 'Generate dataset from GH issues'
task :generate_dataset_gh_issues do
`ruby ext-tools/machine_learning/gh_issues_parser.rb --generate_dataset --output_path gh_issues_dataset.json`
end

desc 'Generate dataset from JSON Cucumber Test Report'
task :generate_dataset_cucumber_report do
`ruby ext-tools/machine_learning/cucumber_report_parser.rb --report_path cucumber_report/cucumber_report.html.json --output_path cucumber_report_dataset.json`
end
end

Expand Down
194 changes: 0 additions & 194 deletions testsuite/ext-tools/collect_and_tag_flaky_tests.rb

This file was deleted.

73 changes: 73 additions & 0 deletions testsuite/ext-tools/machine_learning/cucumber_report_history.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env ruby
# Copyright (c) 2024 SUSE LLC.
# Licensed under the terms of the MIT license.

require 'json'
require 'net/http'
require 'optparse'

# Parse command-line options
options = {}
parser =
OptionParser.new do |opts|
opts.banner = "Usage: #{$PROGRAM_NAME} [options]"

opts.on('-s', '--server SERVER', 'Prometheus server URL') do |server|
options[:server] = server
end

opts.on('-o', '--output_path FILEPATH', 'Output file path (JSON format)') do |filepath|
options[:output_path] = filepath
end

opts.on('-h', '--help', 'Display help') do
puts opts
exit
end
end

parser.parse!

# Ensure all required options are provided
unless options[:server] && options[:output_path]
puts 'Error: Missing required arguments.'
puts 'Use --help for usage information.'
exit 1
end

# Build the URL for Prometheus HTTP API
uri = URI("#{options[:server]}/api/v1/query")
uri.query = URI.encode_www_form({ query: 'jenkins_build_test_case_failure_age' })

begin
response = Net::HTTP.get_response(uri)
if response.is_a?(Net::HTTPSuccess)
data = JSON.parse(response.body)
label_mapping = {
'PASSED' => 0,
'SKIPPED' => 1,
'FIXED' => 2,
'REGRESSION' => 3,
'FAILED' => 4
}
dataset =
data['data']['result'].map do |result|
metric = result['metric']
{
label: label_mapping[metric['status']],
description: {
scenario: metric['case'],
feature: metric['suite'],
# jobname: metric['jobname'],
failedsince: metric['failedsince'].to_i,
age: result['value'][1].to_i
}
}
end
File.write(options[:output_path], dataset.to_json)
else
puts "Failed to fetch data from Prometheus: #{response.code} #{response.message}"
end
rescue StandardError => e
puts "An error occurred: #{e.message}"
end
Loading
Loading