Class: Testbot::Server::Runner
Class Method Summary
collapse
Methods inherited from MemoryModel
all, attribute, #attributes, count, create, delete_all, #destroy, find, first, #id, #initialize, #type, #update
Constructor Details
This class inherits a constructor from MemoryModel
Class Method Details
.available_instances ⇒ Object
36
37
38
|
# File 'lib/server/runner.rb', line 36
def self.available_instances
find_all_available.inject(0) { |sum, r| r.idle_instances + sum }
end
|
.create_or_update_by_mac!(hash) ⇒ Object
12
13
14
15
16
17
18
|
# File 'lib/server/runner.rb', line 12
def self.create_or_update_by_mac!(hash)
if runner = find_by_uid(hash[:uid])
runner.update hash
else
Runner.create hash
end
end
|
.find_all_available ⇒ Object
32
33
34
|
# File 'lib/server/runner.rb', line 32
def self.find_all_available
all.find_all { |r| r.idle_instances && r.version == Testbot.version && r.last_seen_at > (Time.now - Runner.timeout) }
end
|
.find_all_outdated ⇒ Object
28
29
30
|
# File 'lib/server/runner.rb', line 28
def self.find_all_outdated
all.find_all { |r| r.version != Testbot.version }
end
|
.find_by_uid(uid) ⇒ Object
24
25
26
|
# File 'lib/server/runner.rb', line 24
def self.find_by_uid(uid)
all.find { |r| r.uid == uid }
end
|
.record!(hash) ⇒ Object
8
9
10
|
# File 'lib/server/runner.rb', line 8
def self.record!(hash)
create_or_update_by_mac!(hash)
end
|
.timeout ⇒ Object
20
21
22
|
# File 'lib/server/runner.rb', line 20
def self.timeout
10
end
|
.total_instances ⇒ Object
40
41
42
43
|
# File 'lib/server/runner.rb', line 40
def self.total_instances
return 1 if ENV['INTEGRATION_TEST']
find_all_available.inject(0) { |sum, r| r.max_instances + sum }
end
|