hive-runner 2.1.17 → 2.1.18

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d4704758c41182147429e0d686f6aac6f9fbfbde
4
- data.tar.gz: 4b53978303fb1d7a890b26b642a090d30af50f6a
3
+ metadata.gz: 864b65e5afdbe315bab0de8d11dd5a85cfcea66c
4
+ data.tar.gz: 41d1edb5fcdadb28c39c6703cbe94dfbf1095d1c
5
5
  SHA512:
6
- metadata.gz: f272540c420ddd01528d609cf746219032a5137ca4263f9a7dfa554e48f60130da34ad53784b8e6069985cee3eab99de963c7c72c98ac217726095acfed4ff0a
7
- data.tar.gz: 5d33248ba5945404a8097e1e091cda6fa400d0dd1feedc9437bb2387943d6afa42a836a51d434b918009f98f6729c8af3540a0335c7bd041896605ce3e8b03e3
6
+ metadata.gz: c01583109668be9ea0eda6f1c1c7200fa9601df84b150ee4a01e8392c067a427659aacb20ec8d3f685a895155d0c0a03e98cbd729bb754d398eef0364c346638
7
+ data.tar.gz: a9382cc9ac7ba6aa4c6a9fb38d23c71e6e495d830a8f114ff0f54e92520597ffbbbf97c2e9eb35c9b1fb1934f28922d463284290295326a0bb2ded576db42cf1
@@ -10,11 +10,12 @@ module Hive
10
10
  attr_accessor :last_run
11
11
  attr_reader :config, :device_api
12
12
 
13
- def initialize(config, options)
13
+ def initialize(config, options, hive_mind=nil)
14
14
  @options = options
15
15
  @config = config
16
16
  @serial = @options['serial']
17
17
  @device_api = @options['device_api']
18
+ @hive_mind = hive_mind
18
19
  end
19
20
 
20
21
  def should_run?
@@ -30,25 +31,25 @@ module Hive
30
31
  end
31
32
 
32
33
  def run
33
- Hive.logger.info("Trying to run diagnostic '#{self.class}'")
34
+ Hive.logger.debug("Trying to run diagnostic '#{self.class}'")
34
35
  if should_run?
35
36
  result = diagnose
36
37
  result = repair(result) if result.failed?
37
38
  @last_run = result
38
39
  else
39
- Hive.logger.info("Diagnostic '#{self.class}' last ran less than five minutes before")
40
+ Hive.logger.debug("Diagnostic '#{self.class}' last ran less than five minutes before")
40
41
  end
41
42
  @last_run
42
43
  end
43
44
 
44
45
  def pass(message= {}, data = {})
45
- Hive.logger.info(message)
46
- Hive::Results.new("pass", message, data )
46
+ Hive.logger.info("#{@device_api.serial_no} => #{message} #{data}")
47
+ Hive::Results.new("pass", message, data, @hive_mind)
47
48
  end
48
49
 
49
50
  def fail(message ={}, data = {})
50
- Hive.logger.info(message)
51
- Hive::Results.new("fail", message, data)
51
+ Hive.logger.info("#{@device_api.serial_no} => #{message} #{data}")
52
+ Hive::Results.new("fail", message, data, @hive_mind)
52
53
  end
53
54
  end
54
- end
55
+ end
@@ -2,9 +2,10 @@ module Hive
2
2
  class DiagnosticRunner
3
3
  attr_accessor :diagnostics, :options
4
4
 
5
- def initialize(options, diagnostics_config, platform)
5
+ def initialize(options, diagnostics_config, platform, hive_mind=nil)
6
6
  @options = options
7
7
  @platform = platform
8
+ @hive_mind = hive_mind
8
9
  @diagnostics = self.initialize_diagnostics(diagnostics_config[@platform]) if diagnostics_config.has_key?(@platform)
9
10
  end
10
11
 
@@ -13,7 +14,7 @@ module Hive
13
14
  @diagnostics = diagnostics_config.collect do |component, config|
14
15
  Hive.logger.info("Initializing #{component.capitalize} component for #{@platform.capitalize} diagnostic")
15
16
  require "hive/diagnostic/#{@platform}/#{component}"
16
- Object.const_get('Hive').const_get('Diagnostic').const_get(@platform.capitalize).const_get(component.capitalize).new(config, @options)
17
+ Object.const_get('Hive').const_get('Diagnostic').const_get(@platform.capitalize).const_get(component.capitalize).new(config, @options, @hive_mind)
17
18
  end
18
19
  else
19
20
  Hive.logger.info("No diagnostic specified for #{@platform}")
@@ -1,12 +1,13 @@
1
-
2
1
  module Hive
3
2
  class Results
4
3
  attr_reader :timestamp
5
- def initialize( state, message, data = {})
4
+ def initialize( state, message, data = {}, hive_mind=nil)
6
5
  @state = state
7
6
  @message = message
8
7
  @data = data
9
8
  @timestamp = Time.now
9
+ @hive_mind = hive_mind
10
+ submit_results
10
11
  end
11
12
 
12
13
  def failed?
@@ -16,5 +17,32 @@ module Hive
16
17
  def passed?
17
18
  @state == 'pass'
18
19
  end
20
+
21
+ def formulate_results
22
+ result = []
23
+ h = {}
24
+ @data.each do |k,v|
25
+ h[:label] = k.to_s
26
+ h[:unit] = v[:unit] || nil
27
+ if v[:value].instance_of?(Time)
28
+ h[:value] = v[:value].to_i
29
+ h[:format] = 'timestamp'
30
+ else
31
+ h[:value] = v[:value]
32
+ h[:format] = 'integer'
33
+ end
34
+ result << h
35
+ h = {}
36
+ end
37
+ result
38
+ end
39
+
40
+ def submit_results
41
+ if @hive_mind
42
+ @hive_mind.add_statistics(formulate_results)
43
+ @hive_mind.flush_statistics
44
+ end
45
+ end
46
+
19
47
  end
20
- end
48
+ end
@@ -54,7 +54,7 @@ module Hive
54
54
  @port_allocator = (@options.has_key?('port_allocator') ? @options['port_allocator'] : Hive::PortAllocator.new(ports: []))
55
55
 
56
56
  platform = self.class.to_s.scan(/[^:][^:]*/)[2].downcase
57
- @diagnostic_runner = Hive::DiagnosticRunner.new(@options, Hive.config.diagnostics, platform) if Hive.config.diagnostics? && Hive.config.diagnostics[platform]
57
+ @diagnostic_runner = Hive::DiagnosticRunner.new(@options, Hive.config.diagnostics, platform, @hive_mind) if Hive.config.diagnostics? && Hive.config.diagnostics[platform]
58
58
 
59
59
  Hive::Messages.configure do |config|
60
60
  config.base_path = Hive.config.network.scheduler
@@ -70,10 +70,10 @@ module Hive
70
70
  @log.info('Starting worker')
71
71
  while keep_running?
72
72
  begin
73
+ @log.clear
73
74
  diagnostics
74
75
  update_queues
75
76
  poll_queue
76
- @log.clear
77
77
  rescue DeviceNotReady => e
78
78
  @log.warn("#{e.message}\n");
79
79
  rescue StandardError => e
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hive-runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.17
4
+ version: 2.1.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Haig
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-07 00:00:00.000000000 Z
11
+ date: 2016-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chamber
@@ -305,7 +305,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
305
305
  version: '0'
306
306
  requirements: []
307
307
  rubyforge_project:
308
- rubygems_version: 2.6.7
308
+ rubygems_version: 2.5.1
309
309
  signing_key:
310
310
  specification_version: 4
311
311
  summary: Hive Runner