Commit 4d420ac8 authored by Andrejs Cunskis's avatar Andrejs Cunskis

Add timestamp field to collected fabrication data

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