hive-runner 2.0.1 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/hive_setup +5 -4
- data/lib/hive.rb +48 -2
- data/lib/hive/file_system.rb +9 -23
- data/lib/hive/worker.rb +13 -9
- metadata +26 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e207ec510637bfa6487c519394b19e812d0b8cb7
|
4
|
+
data.tar.gz: bf62fa9fdcd02e893bf1c774c72f106684d343dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe11351de90fc9333ef2c16c1fd67bb24795c3cc0539716d37f6026ba20c229d6abff2e749a5802834a97871b13d60347ac12bed5b8f904ff310ee37483b91f8
|
7
|
+
data.tar.gz: 038c7db4752776eee051e410ce40b7ec65fc3b024113fe5bff48bfea692b0853565b2ac305496394de7e5d113ce9693602f7422ede8357000f727f879ba8b0ba
|
data/bin/hive_setup
CHANGED
@@ -134,10 +134,11 @@ File.open("#{dir}/config/settings.yml", 'w') do |f|
|
|
134
134
|
f.puts ''
|
135
135
|
f.puts ' # Configuration for various network options'
|
136
136
|
f.puts ' network:'
|
137
|
-
f.puts ' scheduler:
|
138
|
-
f.puts ' devicedb:
|
139
|
-
f.puts '
|
140
|
-
f.puts '
|
137
|
+
f.puts ' scheduler: http://scheduler'
|
138
|
+
f.puts ' devicedb: http://devicedb'
|
139
|
+
f.puts ' #hive_mind: http://hive_mind'
|
140
|
+
f.puts ' # cert: /path/to/certificate.pem'
|
141
|
+
f.puts ' # cafile: /path/to/certificate-authorities.pem'
|
141
142
|
f.puts ''
|
142
143
|
f.puts ' # Configuration for diagnostic plugins'
|
143
144
|
f.puts ' diagnostics:'
|
data/lib/hive.rb
CHANGED
@@ -2,6 +2,7 @@ require 'chamber'
|
|
2
2
|
require 'hive/log'
|
3
3
|
require 'hive/register'
|
4
4
|
require 'devicedb_comms'
|
5
|
+
require 'mind_meld'
|
5
6
|
require 'macaddr'
|
6
7
|
require 'socket'
|
7
8
|
|
@@ -29,7 +30,9 @@ module Hive
|
|
29
30
|
else
|
30
31
|
fail 'Missing logging section in configuration file'
|
31
32
|
end
|
32
|
-
|
33
|
+
@hive_mind = MindMeld.new(
|
34
|
+
url: Chamber.env.network.hive_mind? ? Chamber.env.network.hive_mind : nil
|
35
|
+
)
|
33
36
|
DeviceDBComms.configure do |config|
|
34
37
|
config.url = Chamber.env.network.devicedb
|
35
38
|
config.pem_file = Chamber.env.network.cert
|
@@ -59,12 +62,35 @@ module Hive
|
|
59
62
|
@devicedb[section] ||= Object.const_get('DeviceDBComms').const_get(section).new()
|
60
63
|
end
|
61
64
|
|
65
|
+
def self.hive_mind
|
66
|
+
@hive_mind
|
67
|
+
end
|
68
|
+
|
62
69
|
def self.register
|
63
70
|
@register ||= Hive::Register.new
|
64
71
|
end
|
65
72
|
|
66
73
|
# Get the id of the hive from the device database
|
67
|
-
def self.
|
74
|
+
def self.hive_mind_id
|
75
|
+
if ! @hive_mind_id
|
76
|
+
Hive.logger.info "About to poll"
|
77
|
+
reg = @hive_mind.register(
|
78
|
+
hostname: Hive.hostname,
|
79
|
+
version: Gem::Specification.find_by_name('hive-runner').version.to_s,
|
80
|
+
runner_plugins: Hash[Gem::Specification.find_all_by_name(/hive-runner-*/).map { |p| [p.name, p.version.to_s] }],
|
81
|
+
macs: [Hive.mac_address],
|
82
|
+
ips: [Hive.ip_address],
|
83
|
+
brand: Hive.config.brand? ? Hive.config.brand : 'BBC',
|
84
|
+
model: Hive.config.model? ? Hive.config.model : 'Hive',
|
85
|
+
device_type: 'Hive'
|
86
|
+
)
|
87
|
+
@hive_mind_id = reg['id']
|
88
|
+
end
|
89
|
+
@hive_mind_id || -1
|
90
|
+
end
|
91
|
+
|
92
|
+
# Get the id of the hive from the device database
|
93
|
+
def self.id
|
68
94
|
if ! @devicedb_id
|
69
95
|
Hive.logger.info "Attempting to register the hive as #{Hive.hostname}"
|
70
96
|
register_response = self.devicedb('Hive').register(Hive.hostname, Hive.mac_address, Hive.ip_address)
|
@@ -81,6 +107,7 @@ module Hive
|
|
81
107
|
|
82
108
|
# Poll the device database
|
83
109
|
def self.poll
|
110
|
+
# DeviceDB
|
84
111
|
id = self.id
|
85
112
|
if id and id > 0
|
86
113
|
Hive.logger.debug "Polling hive: #{id}"
|
@@ -98,6 +125,25 @@ module Hive
|
|
98
125
|
Hive.logger.warn "Unable to poll hive"
|
99
126
|
end
|
100
127
|
end
|
128
|
+
|
129
|
+
# Hive Mind
|
130
|
+
id = self.hive_mind_id
|
131
|
+
if id and id > 0
|
132
|
+
Hive.logger.debug "Polling hive: #{id}"
|
133
|
+
# rtn = @hivemind.poll(id)
|
134
|
+
# Hive.logger.debug "Return data: #{rtn}"
|
135
|
+
# if rtn['error'].present?
|
136
|
+
# Hive.logger.warn "Hive polling failed: #{rtn['error']}"
|
137
|
+
# else
|
138
|
+
# Hive.logger.info "Successfully polled hive"
|
139
|
+
# end
|
140
|
+
else
|
141
|
+
if id
|
142
|
+
Hive.logger.debug "Skipping polling of hive"
|
143
|
+
else
|
144
|
+
Hive.logger.warn "Unable to poll hive"
|
145
|
+
end
|
146
|
+
end
|
101
147
|
end
|
102
148
|
|
103
149
|
# Get the IP address of the Hive
|
data/lib/hive/file_system.rb
CHANGED
@@ -39,33 +39,19 @@ module Hive
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def fetch_build(build_url, destination_path)
|
42
|
-
if !fetch_build_with_curl(build_url, destination_path)
|
43
|
-
@log.info( "Initial build fetch failed -- trying again shortly")
|
44
|
-
sleep 5
|
45
|
-
if !fetch_build_with_curl(build_url, destination_path)
|
46
|
-
raise "Build could not be downloaded"
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def fetch_build_with_curl(build_url, destination_path)
|
52
|
-
cert_path = Hive.config.network['cert']
|
53
|
-
cabundle_path = Hive.config.network['cafile']
|
54
42
|
base_url = Hive.config.network['scheduler']
|
55
43
|
apk_url = base_url + '/' + build_url
|
56
|
-
|
44
|
+
|
45
|
+
job = Hive::Messages::Job.new
|
46
|
+
response = job.fetch(apk_url)
|
57
47
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
if $? != 0
|
62
|
-
@log.info("Curl error #{$?}: #{response.to_s}")
|
63
|
-
false
|
64
|
-
Hive::Messages
|
65
|
-
else
|
66
|
-
@log.info("Curl seems happy, checking integrity of downloaded file")
|
67
|
-
check_build_integrity( destination_path )
|
48
|
+
tempfile = Tempfile.new('build.apk')
|
49
|
+
File.open(tempfile.path,'w') do |f|
|
50
|
+
f.write response.body
|
68
51
|
end
|
52
|
+
|
53
|
+
copy_file(tempfile.path, destination_path)
|
54
|
+
check_build_integrity( destination_path )
|
69
55
|
end
|
70
56
|
|
71
57
|
def check_build_integrity( destination_path )
|
data/lib/hive/worker.rb
CHANGED
@@ -124,9 +124,7 @@ module Hive
|
|
124
124
|
# Upload results
|
125
125
|
@file_system.finalise_results_directory
|
126
126
|
upload_files(@job, @file_system.results_path, @file_system.logs_path)
|
127
|
-
|
128
|
-
f.puts "#{Process.pid} completed"
|
129
|
-
end
|
127
|
+
set_job_state_to :completed
|
130
128
|
@job.error('Worker killed')
|
131
129
|
@log.info "Worker terminated"
|
132
130
|
exit
|
@@ -139,9 +137,7 @@ module Hive
|
|
139
137
|
begin
|
140
138
|
@log.info "Setting job paths"
|
141
139
|
@file_system = Hive::FileSystem.new(@job.job_id, Hive.config.logging.home, @log)
|
142
|
-
|
143
|
-
f.puts "#{Process.pid} running"
|
144
|
-
end
|
140
|
+
set_job_state_to :preparing
|
145
141
|
|
146
142
|
if ! @job.repository.to_s.empty?
|
147
143
|
@log.info "Checking out the repository"
|
@@ -175,6 +171,7 @@ module Hive
|
|
175
171
|
@log.info "Appending test script to execution script"
|
176
172
|
@script.append_bash_cmd @job.command
|
177
173
|
|
174
|
+
set_job_state_to :running
|
178
175
|
@job.start
|
179
176
|
|
180
177
|
@log.info "Pre-execution setup"
|
@@ -189,6 +186,7 @@ module Hive
|
|
189
186
|
|
190
187
|
begin
|
191
188
|
@log.info "Post-execution cleanup"
|
189
|
+
set_job_state_to :uploading
|
192
190
|
post_script(@job, @file_system, @script)
|
193
191
|
|
194
192
|
# Upload results
|
@@ -202,6 +200,7 @@ module Hive
|
|
202
200
|
|
203
201
|
if exception
|
204
202
|
@job.error( exception.message )
|
203
|
+
set_job_state_to :completed
|
205
204
|
raise exception
|
206
205
|
else
|
207
206
|
@job.complete
|
@@ -212,9 +211,7 @@ module Hive
|
|
212
211
|
exit
|
213
212
|
end
|
214
213
|
|
215
|
-
|
216
|
-
f.puts "#{Process.pid} completed"
|
217
|
-
end
|
214
|
+
set_job_state_to :completed
|
218
215
|
exit_value == 0
|
219
216
|
end
|
220
217
|
|
@@ -396,5 +393,12 @@ module Hive
|
|
396
393
|
@log.warn("Use @port_allocator.release_all_ports instead")
|
397
394
|
@port_allocator.release_all_ports
|
398
395
|
end
|
396
|
+
|
397
|
+
# Set job info file
|
398
|
+
def set_job_state_to state
|
399
|
+
File.open("#{@file_system.home_path}/job_info", 'w') do |f|
|
400
|
+
f.puts "#{Process.pid} #{state}"
|
401
|
+
end
|
402
|
+
end
|
399
403
|
end
|
400
404
|
end
|
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.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Haig
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chamber
|
@@ -112,16 +112,22 @@ dependencies:
|
|
112
112
|
name: hive-messages
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - "
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: 1.0.3
|
118
|
+
- - "<"
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '1.1'
|
118
121
|
type: :runtime
|
119
122
|
prerelease: false
|
120
123
|
version_requirements: !ruby/object:Gem::Requirement
|
121
124
|
requirements:
|
122
|
-
- - "
|
125
|
+
- - ">="
|
123
126
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
127
|
+
version: 1.0.3
|
128
|
+
- - "<"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '1.1'
|
125
131
|
- !ruby/object:Gem::Dependency
|
126
132
|
name: devicedb_comms
|
127
133
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,6 +142,20 @@ dependencies:
|
|
136
142
|
- - "~>"
|
137
143
|
- !ruby/object:Gem::Version
|
138
144
|
version: '0.1'
|
145
|
+
- !ruby/object:Gem::Dependency
|
146
|
+
name: mind_meld
|
147
|
+
requirement: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - "~>"
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
type: :runtime
|
153
|
+
prerelease: false
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - "~>"
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
139
159
|
- !ruby/object:Gem::Dependency
|
140
160
|
name: code_cache
|
141
161
|
requirement: !ruby/object:Gem::Requirement
|