Class: TestBed
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#allUpAndRunning, #checkRequirements, #createInstanceId, #debug, #getApplicationTypes, #getApps, #getLocalApplications, #getNewInstanceName, #getOrCreate, #log_direct, #run, #runAndWait, #waitUntilAllUpAndRunning
Constructor Details
#initialize(ops = {}) ⇒ TestBed
Returns a new instance of TestBed.
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/appswarm/test_bed.rb', line 6
def initialize(ops={})
@@testbeds||=[]
@@testbeds<<self
@appClasses=loadApps(self)
@apps=[]
@options={:cronTime=>100000}
@tbedThreads={}
ops.each{|k,v|@options[k]=v}
@stopped=false
@stopping=false
@stopMutex=Mutex.new
@testbedId=ops[:testbedId]
@testbedId||=Crypt::hexdigest(rand.to_s)
trap("INT"){ stop! }
end
|
Instance Attribute Details
#apps ⇒ Object
Returns the value of attribute apps.
4
5
6
|
# File 'lib/appswarm/test_bed.rb', line 4
def apps
@apps
end
|
#options ⇒ Object
Returns the value of attribute options.
4
5
6
|
# File 'lib/appswarm/test_bed.rb', line 4
def options
@options
end
|
#testbedId ⇒ Object
Returns the value of attribute testbedId.
4
5
6
|
# File 'lib/appswarm/test_bed.rb', line 4
def testbedId
@testbedId
end
|
Class Method Details
.appswarmTestingDir ⇒ Object
123
124
125
|
# File 'lib/appswarm/test_bed.rb', line 123
def self.appswarmTestingDir
File.join(ENV["HOME"],".appswarm_testing")
end
|
.finishTesting ⇒ Object
131
132
133
|
# File 'lib/appswarm/test_bed.rb', line 131
def self.finishTesting
Dir.rmdir_f(appswarmTestingDir)
end
|
.testbeds ⇒ Object
127
128
129
|
# File 'lib/appswarm/test_bed.rb', line 127
def self.testbeds
@@testbeds||=[]
end
|
Instance Method Details
#appswarmBaseDir ⇒ Object
26
27
28
|
# File 'lib/appswarm/test_bed.rb', line 26
def appswarmBaseDir
File.join(ENV["HOME"],".appswarm")
end
|
#closeApp(app) ⇒ Object
54
55
56
57
58
59
|
# File 'lib/appswarm/test_bed.rb', line 54
def closeApp(app)
if @apps.member?(app)
app.stop
@apps.delete(app)
end
end
|
#getApp(type) ⇒ Object
47
48
49
|
# File 'lib/appswarm/test_bed.rb', line 47
def getApp(type)
getApps(type)[0]
end
|
#getAppByName(name) ⇒ Object
50
51
52
|
# File 'lib/appswarm/test_bed.rb', line 50
def getAppByName(name)
@apps.select{|app|app.getAppName==name}[0]
end
|
#getGlobalServices ⇒ Object
60
61
62
|
# File 'lib/appswarm/test_bed.rb', line 60
def getGlobalServices
@apps.select{|a|a.is_a?(GlobalService)}.map{|a|a.serviceID}
end
|
#getThread(app) ⇒ Object
43
44
45
|
# File 'lib/appswarm/test_bed.rb', line 43
def getThread(app)
@tbedThreads[app.object_id]
end
|
#log(*s) ⇒ Object
35
36
37
|
# File 'lib/appswarm/test_bed.rb', line 35
def log(*s)
TestLogger::log(*s)
end
|
#log_line(line) ⇒ Object
39
40
41
|
# File 'lib/appswarm/test_bed.rb', line 39
def log_line(line)
TestLogger::log(line)
end
|
#runCluster ⇒ Object
31
32
33
|
# File 'lib/appswarm/test_bed.rb', line 31
def runCluster
Appswarm::BASIC_APPS.each{|app|run(app,{})}
end
|
#stop ⇒ 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
|
# File 'lib/appswarm/test_bed.rb', line 68
def stop
@stopping=true
@stopMutex.synchronize {
@apps.p_each{|app|
log "APP: #{app}"
app.quit
}
log "QUITED"
@apps.each{|app|
log "Stopping #{app}"
begin
measureTime {
app.stop
}
rescue Object=>e
log"Failed to stop #{app} with error #{e}"
log e.backtrace
end
log "Stopped #{app}"
}
log "Waiting to shut down"
tries=10
while tries>0 and @tbedThreads.select{|k,t|t.alive?}.length>0
sleep 0.2
tries-=1
end
log "Joining threads of #{self}"
@tbedThreads.each{|k,v|
log v.stacktrace
}
@tbedThreads.each{|k,v|
v.kill if v.alive?
}
@tbedThreads.each{|k,v|
v.kill! if v.alive?
}
@tbedThreads.each{|k,v|
log "CRASH:",v.crashtrace if v.crashtrace?
}
@@testbeds.delete(self)
log "Stopped Testbed #{self}"
@stopped=true
}
end
|
#stop! ⇒ Object
64
65
66
67
|
# File 'lib/appswarm/test_bed.rb', line 64
def stop!
stop
killOtherThreads!
end
|