Class: DataHarvester
- Inherits:
-
Object
- Object
- DataHarvester
- Defined in:
- lib/data_harvester.rb
Overview
DataHarvester sends rspec result data to a database (InfluxDB) Allows aggregating the results of Rspec tests in one location.
Instance Attribute Summary collapse
-
#database_client ⇒ Object
readonly
Returns the value of attribute database_client.
Instance Method Summary collapse
- #generate_payload(example, extra_data: nil, tags: nil) ⇒ Object
-
#initialize(database: 'master', host: '127.0.0.1') ⇒ DataHarvester
constructor
A new instance of DataHarvester.
- #queue_send_data(example, series: 'test_results', extra_data: nil, tags: nil) ⇒ Object
Constructor Details
#initialize(database: 'master', host: '127.0.0.1') ⇒ DataHarvester
Returns a new instance of DataHarvester.
11 12 13 14 15 |
# File 'lib/data_harvester.rb', line 11 def initialize(database: 'master', host: '127.0.0.1') @database_client = InfluxDB::Client.new database: database, host: host, time_precision: 'u' end |
Instance Attribute Details
#database_client ⇒ Object (readonly)
Returns the value of attribute database_client.
9 10 11 |
# File 'lib/data_harvester.rb', line 9 def database_client @database_client end |
Instance Method Details
#generate_payload(example, extra_data: nil, tags: nil) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/data_harvester.rb', line 17 def generate_payload(example, extra_data: nil, tags: nil) # Rspec status is populated when the rspec after hooks complete, wait until then Timeout.timeout(5) { sleep 0.0001 while example.execution_result.status.nil? } data = default_data(example) data[:values].merge! extra_data if extra_data data[:tags] = if data end |
#queue_send_data(example, series: 'test_results', extra_data: nil, tags: nil) ⇒ Object
27 28 29 |
# File 'lib/data_harvester.rb', line 27 def queue_send_data(example, series: 'test_results', extra_data: nil, tags: nil) Concurrent::Promise.execute { send_data(example, series, extra_data: extra_data, tags: ) } end |