Commit 1b1c1296 authored by Andrejs Cunskis's avatar Andrejs Cunskis

Merge branch 'acunskis-resource-export-unique-attr' into 'master'

E2E: Add timestamp field to collected fabrication data

See merge request gitlab-org/gitlab!79998
parents 9e36cb3e 4d420ac8
...@@ -99,7 +99,7 @@ module QA ...@@ -99,7 +99,7 @@ module QA
# @param [Symbol] http_method # @param [Symbol] http_method
# @param [Integer] fabrication_time # @param [Integer] fabrication_time
# @return [Hash] # @return [Hash]
def fabrication_stats(resource:, info:, fabrication_method:, http_method:, fabrication_time:, **) def fabrication_stats(resource:, info:, fabrication_method:, http_method:, fabrication_time:, timestamp:, **)
{ {
name: 'fabrication-stats', name: 'fabrication-stats',
time: time, time: time,
...@@ -113,7 +113,8 @@ module QA ...@@ -113,7 +113,8 @@ module QA
fields: { fields: {
fabrication_time: fabrication_time, fabrication_time: fabrication_time,
info: info, info: info,
job_url: QA::Runtime::Env.ci_job_url job_url: QA::Runtime::Env.ci_job_url,
timestamp: timestamp
} }
} }
end end
......
...@@ -38,7 +38,8 @@ module QA ...@@ -38,7 +38,8 @@ module QA
api_path: api_path, api_path: api_path,
fabrication_method: fabrication_method, fabrication_method: fabrication_method,
fabrication_time: fabrication_time, fabrication_time: fabrication_time,
http_method: resource.api_fabrication_http_method http_method: resource.api_fabrication_http_method,
timestamp: Time.now.to_s
} }
end end
......
# frozen_string_literal: true # frozen_string_literal: true
require 'rspec/core/sandbox' require 'rspec/core/sandbox'
require 'active_support/testing/time_helpers'
describe QA::Support::Formatters::TestStatsFormatter do describe QA::Support::Formatters::TestStatsFormatter do
include QA::Support::Helpers::StubEnv include QA::Support::Helpers::StubEnv
include QA::Specs::Helpers::RSpec include QA::Specs::Helpers::RSpec
include ActiveSupport::Testing::TimeHelpers
let(:url) { "http://influxdb.net" } let(:url) { "http://influxdb.net" }
let(:token) { "token" } let(:token) { "token" }
...@@ -214,7 +216,8 @@ describe QA::Support::Formatters::TestStatsFormatter do ...@@ -214,7 +216,8 @@ describe QA::Support::Formatters::TestStatsFormatter do
api_path: '/project', api_path: '/project',
fabrication_method: :api, fabrication_method: :api,
fabrication_time: 1, fabrication_time: 1,
http_method: :post http_method: :post,
timestamp: Time.now.to_s
}] }]
} }
end end
...@@ -233,11 +236,16 @@ describe QA::Support::Formatters::TestStatsFormatter do ...@@ -233,11 +236,16 @@ describe QA::Support::Formatters::TestStatsFormatter do
fields: { fields: {
fabrication_time: 1, fabrication_time: 1,
info: "with id '1'", info: "with id '1'",
job_url: ci_job_url job_url: ci_job_url,
timestamp: Time.now.to_s
} }
} }
end end
around do |example|
freeze_time { example.run }
end
it 'exports fabrication stats data to influxdb' do it 'exports fabrication stats data to influxdb' do
run_spec run_spec
......
# frozen_string_literal: true # frozen_string_literal: true
require 'active_support/testing/time_helpers'
RSpec.describe QA::Tools::TestResourceDataProcessor do RSpec.describe QA::Tools::TestResourceDataProcessor do
include QA::Support::Helpers::StubEnv include QA::Support::Helpers::StubEnv
include ActiveSupport::Testing::TimeHelpers
subject(:processor) { Class.new(described_class).instance } subject(:processor) { Class.new(described_class).instance }
...@@ -19,7 +22,8 @@ RSpec.describe QA::Tools::TestResourceDataProcessor do ...@@ -19,7 +22,8 @@ RSpec.describe QA::Tools::TestResourceDataProcessor do
api_path: api_path, api_path: api_path,
fabrication_method: method, fabrication_method: method,
fabrication_time: time, fabrication_time: time,
http_method: :post http_method: :post,
timestamp: Time.now.to_s
}] }]
} }
end end
...@@ -28,6 +32,10 @@ RSpec.describe QA::Tools::TestResourceDataProcessor do ...@@ -28,6 +32,10 @@ RSpec.describe QA::Tools::TestResourceDataProcessor do
processor.collect(resource: resource, info: info, fabrication_method: method, fabrication_time: time) processor.collect(resource: resource, info: info, fabrication_method: method, fabrication_time: time)
end end
around do |example|
freeze_time { example.run }
end
describe '.collect' do describe '.collect' do
it 'collects and stores resource' do it 'collects and stores resource' do
expect(processor.resources).to eq(result) expect(processor.resources).to eq(result)
......
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