Commit 3244aa8e authored by Albert Salim's avatar Albert Salim

Merge branch '352164-remove-free-m-rspec-report' into 'master'

Remove `free -m` RSpec report

See merge request gitlab-org/gitlab!80084
parents 2a53dafc 2520edcc
......@@ -54,7 +54,6 @@
- knapsack/
- rspec/
- tmp/capybara/
- tmp/memory_test/
- log/*.log
reports:
junit: ${JUNIT_RESULT_FILE}
......@@ -573,7 +572,6 @@ rspec:coverage:
- rspec system pg12-as-if-foss decomposed
script:
- run_timed_command "bundle exec scripts/merge-simplecov"
- run_timed_command "bundle exec scripts/gather-test-memory-data"
coverage: '/LOC \((\d+\.\d+%)\) covered.$/'
artifacts:
name: coverage
......@@ -582,7 +580,6 @@ rspec:coverage:
- coverage/index.html
- coverage/assets/
- coverage/lcov/
- tmp/memory_test/
reports:
cobertura: coverage/coverage.xml
......
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'csv'
def join_csv_files(output_path, input_paths)
return if input_paths.empty?
input_csvs = input_paths.map do |input_path|
CSV.read(input_path, headers: true)
end
CSV.open(output_path, "w", headers: input_csvs.first.headers, write_headers: true) do |output_csv|
input_csvs.each do |input_csv|
input_csv.each do |line|
output_csv << line
end
end
end
end
join_csv_files('tmp/memory_test/report.csv', Dir['tmp/memory_test/*.csv'].sort)
......@@ -268,10 +268,6 @@ function rspec_paralellized_job() {
debug_rspec_variables
mkdir -p tmp/memory_test
export MEMORY_TEST_PATH="tmp/memory_test/${report_name}_memory.csv"
if [[ -n $RSPEC_TESTS_MAPPING_ENABLED ]]; then
tooling/bin/parallel_rspec --rspec_args "$(rspec_args "${rspec_opts}")" --filter "tmp/matching_tests.txt" || rspec_run_status=$?
else
......
......@@ -193,7 +193,6 @@ RSpec.configure do |config|
config.include RedisHelpers
config.include Rails.application.routes.url_helpers, type: :routing
config.include PolicyHelpers, type: :policy
config.include MemoryUsageHelper
config.include ExpectRequestWithStatus, type: :request
config.include IdempotentWorkerHelper, type: :worker
config.include RailsHelpers
......@@ -253,10 +252,6 @@ RSpec.configure do |config|
::Ci::ApplicationRecord.set_open_transactions_baseline
end
config.append_before do
Thread.current[:current_example_group] = ::RSpec.current_example.metadata[:example_group]
end
config.append_after do
ApplicationRecord.reset_open_transactions_baseline
::Ci::ApplicationRecord.reset_open_transactions_baseline
......
# frozen_string_literal: true
module MemoryUsageHelper
extend ActiveSupport::Concern
def gather_memory_data(csv_path)
write_csv_entry(csv_path,
{
example_group_path: TestEnv.topmost_example_group[:location],
example_group_description: TestEnv.topmost_example_group[:description],
time: Time.current,
job_name: ENV['CI_JOB_NAME']
}.merge(get_memory_usage))
end
def write_csv_entry(path, entry)
CSV.open(path, "a", headers: entry.keys, write_headers: !File.exist?(path)) do |file|
file << entry.values
end
end
def get_memory_usage
output, status = Gitlab::Popen.popen(%w(free -m))
abort "`free -m` return code is #{status}: #{output}" unless status == 0
result = output.split("\n")[1].split(" ")[1..]
attrs = %i(m_total m_used m_free m_shared m_buffers_cache m_available).freeze
attrs.zip(result).to_h
end
included do |config|
config.after(:all) do
gather_memory_data(ENV['MEMORY_TEST_PATH']) if ENV['MEMORY_TEST_PATH']
end
end
end
......@@ -371,17 +371,6 @@ module TestEnv
FileUtils.rm_rf(path)
end
def current_example_group
Thread.current[:current_example_group]
end
# looking for a top-level `describe`
def topmost_example_group
example_group = current_example_group
example_group = example_group[:parent_example_group] until example_group[:parent_example_group].nil?
example_group
end
def seed_db
Gitlab::DatabaseImporters::WorkItems::BaseTypeImporter.import
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