Module: Hive
- Defined in:
- lib/hive.rb,
lib/hive/log.rb,
lib/hive/device.rb,
lib/hive/worker.rb,
lib/hive/results.rb,
lib/hive/register.rb,
lib/hive/controller.rb,
lib/hive/diagnostic.rb,
lib/hive/file_system.rb,
lib/hive/device/shell.rb,
lib/hive/worker/shell.rb,
lib/hive/port_allocator.rb,
lib/hive/controller/shell.rb,
lib/hive/execution_script.rb,
lib/hive/diagnostic_runner.rb
Overview
The Hive automated testing framework
Defined Under Namespace
Classes: Controller, Device, Diagnostic, DiagnosticRunner, ExecutionScript, FileSystem, Log, PortAllocator, Register, Results, Worker
Constant Summary collapse
- DAEMON_NAME =
Chamber.env.daemon_name? ? Chamber.env.daemon_name : 'HIVE'
- LOG_DIRECTORY =
File. Chamber.env.logging.directory
- PIDS_DIRECTORY =
LOG_DIRECTORY
Class Method Summary collapse
- .config ⇒ Object
- .hive_mind ⇒ Object
-
.hostname ⇒ Object
Get the hostname of the Hive.
-
.ip_address ⇒ Object
Get the IP address of the Hive.
- .logger ⇒ Object
-
.poll ⇒ Object
Poll the device database.
- .register ⇒ Object
-
.send_statistics ⇒ Object
Gather and send statistics.
Class Method Details
.config ⇒ Object
43 44 45 |
# File 'lib/hive.rb', line 43 def self.config Chamber.env end |
.hive_mind ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/hive.rb', line 68 def self.hive_mind Hive.logger.debug "Sysname: #{Sys::Uname.sysname}" Hive.logger.debug "Release: #{Sys::Uname.release}" if ! @hive_mind if @hive_mind = MindMeld::Hive.new( url: Chamber.env.network.hive_mind? ? Chamber.env.network.hive_mind : nil, pem: Chamber.env.network.cert ? Chamber.env.network.cert : nil, ca_file: Chamber.env.network.cafile ? Chamber.env.network.cafile : nil, verify_mode: Chamber.env.network.verify_mode ? Chamber.env.network.verify_mode : nil, device: { hostname: Hive.hostname, version: Gem::Specification.find_by_name('hive-runner').version.to_s, runner_plugins: Hash[Gem::Specification.all.select{ |g| g.name =~ /hive-runner-/ }.map { |p| [p.name, p.version.to_s] }], macs: Mac.addrs, ips: [Hive.ip_address], brand: Hive.config.brand? ? Hive.config.brand : 'BBC', model: Hive.config.model? ? Hive.config.model : 'Hive', operating_system_name: Sys::Uname.sysname, operating_system_version: Sys::Uname.release, device_type: 'Hive' } ) and Etc.respond_to?(:nprocessors) # Require Ruby >= 2.2 @hive_mind.add_statistics( label: 'Processor count', value: Etc.nprocessors, format: 'integer' ) if Chamber.env.diagnostics? && Chamber.env.diagnostics.hive? && Chamber.env.diagnostics.hive.load_warning? && Chamber.env.diagnostics.hive.load_error? @hive_mind.add_statistics( [ { label: 'Load average warning threshold', value: Chamber.env.diagnostics.hive.load_warning, format: 'float' }, { label: 'Load average error threshold', value: Chamber.env.diagnostics.hive.load_error, format: 'float' } ] ) end @hive_mind.flush_statistics if @logger @logger.hive_mind = @hive_mind end end end @hive_mind end |
.hostname ⇒ Object
Get the hostname of the Hive
155 156 157 |
# File 'lib/hive.rb', line 155 def self.hostname Socket.gethostname.split('.').first end |
.ip_address ⇒ Object
Get the IP address of the Hive
149 150 151 152 |
# File 'lib/hive.rb', line 149 def self.ip_address ip = Socket.ip_address_list.detect { |intf| intf.ipv4_private? } ip.ip_address end |
.logger ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/hive.rb', line 47 def self.logger if ! @logger @logger = Hive::Log.new if Hive.config.logging.main_filename? @logger.add_logger("#{LOG_DIRECTORY}/#{Hive.config.logging.main_filename}", Chamber.env.logging.main_level? ? Chamber.env.logging.main_level : 'INFO') end if Hive.config.logging.console_level? @logger.add_logger(STDOUT, Hive.config.logging.console_level) end @logger.default_progname = 'Hive core' end if ! @logger.hive_mind @logger.hive_mind = @hive_mind end @logger end |
.poll ⇒ Object
Poll the device database
127 128 129 130 131 132 133 134 135 136 |
# File 'lib/hive.rb', line 127 def self.poll Hive.logger.debug "Polling hive" rtn = Hive.hive_mind.poll Hive.logger.debug "Return data: #{rtn}" if rtn.has_key? 'error' Hive.logger.warn "Hive polling failed: #{rtn['error']}" else Hive.logger.info "Successfully polled hive" end end |