Commit 8ce7b900 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch 'prune-flaky-examples-after-30-days' into 'master'

Prune flaky examples after 30 days

See merge request gitlab-org/gitlab!23335
parents b610c7c2 c9c6af4c
...@@ -64,4 +64,4 @@ flaky-examples-check: ...@@ -64,4 +64,4 @@ flaky-examples-check:
script: script:
- '[[ -f $NEW_FLAKY_SPECS_REPORT ]] || echo "{}" > ${NEW_FLAKY_SPECS_REPORT}' - '[[ -f $NEW_FLAKY_SPECS_REPORT ]] || echo "{}" > ${NEW_FLAKY_SPECS_REPORT}'
- scripts/merge-reports ${NEW_FLAKY_SPECS_REPORT} rspec_flaky/new_*_*.json - scripts/merge-reports ${NEW_FLAKY_SPECS_REPORT} rspec_flaky/new_*_*.json
- scripts/detect-new-flaky-examples $NEW_FLAKY_SPECS_REPORT - scripts/flaky_examples/detect-new-flaky-examples $NEW_FLAKY_SPECS_REPORT
...@@ -10,7 +10,7 @@ module RspecFlaky ...@@ -10,7 +10,7 @@ module RspecFlaky
# This class is responsible for loading/saving JSON reports, and pruning # This class is responsible for loading/saving JSON reports, and pruning
# outdated examples. # outdated examples.
class Report < SimpleDelegator class Report < SimpleDelegator
OUTDATED_DAYS_THRESHOLD = 90 OUTDATED_DAYS_THRESHOLD = 30
attr_reader :flaky_examples attr_reader :flaky_examples
......
...@@ -24,5 +24,5 @@ puts "Current report has #{report.size} entries." ...@@ -24,5 +24,5 @@ puts "Current report has #{report.size} entries."
new_report = report.prune_outdated new_report = report.prune_outdated
puts "New report has #{new_report.size} entries: #{report.size - new_report.size} entries older than 90 days were removed." puts "New report has #{new_report.size} entries: #{report.size - new_report.size} entries older than #{RspecFlaky::Report::OUTDATED_DAYS_THRESHOLD} days were removed."
puts "Saved #{new_report_file}." if new_report.write(new_report_file) puts "Saved #{new_report_file}." if new_report.write(new_report_file)
...@@ -25,7 +25,7 @@ function update_tests_metadata() { ...@@ -25,7 +25,7 @@ function update_tests_metadata() {
scripts/merge-reports "${FLAKY_RSPEC_SUITE_REPORT_PATH}" rspec_flaky/all_*.json scripts/merge-reports "${FLAKY_RSPEC_SUITE_REPORT_PATH}" rspec_flaky/all_*.json
export FLAKY_RSPEC_GENERATE_REPORT="1" export FLAKY_RSPEC_GENERATE_REPORT="1"
scripts/prune-old-flaky-specs "${FLAKY_RSPEC_SUITE_REPORT_PATH}" scripts/flaky_examples/prune-old-flaky-examples "${FLAKY_RSPEC_SUITE_REPORT_PATH}"
if [[ -n ${TESTS_METADATA_S3_BUCKET} ]]; then if [[ -n ${TESTS_METADATA_S3_BUCKET} ]]; then
scripts/sync-reports put "${TESTS_METADATA_S3_BUCKET}" "${FLAKY_RSPEC_SUITE_REPORT_PATH}" scripts/sync-reports put "${TESTS_METADATA_S3_BUCKET}" "${FLAKY_RSPEC_SUITE_REPORT_PATH}"
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
require 'spec_helper' require 'spec_helper'
describe RspecFlaky::Report, :aggregate_failures do describe RspecFlaky::Report, :aggregate_failures do
let(:a_hundred_days) { 3600 * 24 * 100 } let(:thirty_one_days) { 3600 * 24 * 31 }
let(:collection_hash) do let(:collection_hash) do
{ {
a: { example_id: 'spec/foo/bar_spec.rb:2' }, a: { example_id: 'spec/foo/bar_spec.rb:2' },
b: { example_id: 'spec/foo/baz_spec.rb:3', first_flaky_at: (Time.now - a_hundred_days).to_s, last_flaky_at: (Time.now - a_hundred_days).to_s } b: { example_id: 'spec/foo/baz_spec.rb:3', first_flaky_at: (Time.now - thirty_one_days).to_s, last_flaky_at: (Time.now - thirty_one_days).to_s }
} }
end end
let(:suite_flaky_example_report) do let(:suite_flaky_example_report) do
...@@ -109,7 +109,7 @@ describe RspecFlaky::Report, :aggregate_failures do ...@@ -109,7 +109,7 @@ describe RspecFlaky::Report, :aggregate_failures do
end end
describe '#prune_outdated' do describe '#prune_outdated' do
it 'returns a new collection without the examples older than 90 days by default' do it 'returns a new collection without the examples older than 30 days by default' do
new_report = flaky_examples.to_h.dup.tap { |r| r.delete(:b) } new_report = flaky_examples.to_h.dup.tap { |r| r.delete(:b) }
new_flaky_examples = report.prune_outdated new_flaky_examples = report.prune_outdated
...@@ -119,7 +119,7 @@ describe RspecFlaky::Report, :aggregate_failures do ...@@ -119,7 +119,7 @@ describe RspecFlaky::Report, :aggregate_failures do
end end
it 'accepts a given number of days' do it 'accepts a given number of days' do
new_flaky_examples = report.prune_outdated(days: 200) new_flaky_examples = report.prune_outdated(days: 32)
expect(new_flaky_examples.to_h).to eq(report.to_h) expect(new_flaky_examples.to_h).to eq(report.to_h)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment