Skip to content

Commit

Permalink
Replace calls to Bud#stop_bg with Bud#stop.
Browse files Browse the repository at this point in the history
 with an instance that hasn't been started running via #run_bg, calling the stop
 method #stop_bg isn't ideal.
  • Loading branch information
neilconway committed Nov 3, 2011
1 parent 132fbd7 commit d71b4d2
Show file tree
Hide file tree
Showing 20 changed files with 99 additions and 108 deletions.
3 changes: 1 addition & 2 deletions bfs/bfs_master.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def start_background_task_thread
end
end

def stop_bg
def stop
unregister_callback(@task)
super
end
Expand All @@ -67,4 +67,3 @@ def bg_besteffort_request(c, o, r)
DataProtocolClient.send_replicate(c, r, o)
end
end

2 changes: 1 addition & 1 deletion bfs/datanode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ def initialize(dataport=nil, opts={})

def stop_datanode
@dp_server.stop_server
stop_bg
stop
end
end
6 changes: 3 additions & 3 deletions test/tc_besteffort_delivery.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def broken_test_besteffort_delivery
assert_equal(1, rd.pipe_sent_perm.length)
assert_equal(sendtup, rd.pipe_sent_perm.first)
}
rd.stop_bg
rd.stop
end

def test_bed_delivery
Expand Down Expand Up @@ -67,7 +67,7 @@ def test_bed_delivery
rcv.sync_do {
assert_equal(tuples.sort, rcv.pipe_out_perm.to_a.sort)
}
snd.stop_bg
rcv.stop_bg
snd.stop
rcv.stop
end
end
14 changes: 7 additions & 7 deletions test/tc_bfs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ def test_directorystuff1
assert_equal(["3"], four)

#dump_internal_state(b)
b.stop_bg
s.stop_bg
b.stop
s.stop
end

def dump_internal_state(rt)
Expand All @@ -94,7 +94,7 @@ def test_fsmaster
b = FSC.new(@opts)
b.run_bg
do_basic_fs_tests(b)
b.stop_bg
b.stop
end

def test_rms
Expand Down Expand Up @@ -129,8 +129,8 @@ def test_rms
m.sync_do
m.sync_do

m.stop_bg
b.stop_bg
m.stop
b.stop
end

def new_datanode(dp, master_port)
Expand All @@ -150,8 +150,8 @@ def tnest_addchunks
do_addchunks(b)

dn.stop_datanode
#dn2.stop_bg
b.stop_bg
#dn2.stop
b.stop
end

def assert_resp(inst, reqid, data)
Expand Down
6 changes: 3 additions & 3 deletions test/tc_carts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def test_replicated_destructive_cart
rep.run_bg
#rep2.run_bg
cart_test_dist(prog, cli, rep, rep2)
rep.stop_bg
rep.stop
end

def test_replicated_disorderly_cart
Expand All @@ -104,7 +104,7 @@ def test_replicated_disorderly_cart
rep.run_bg
#rep2.run_bg
cart_test_dist(prog, cli, rep, rep2)
rep.stop_bg
rep.stop
end

def test_destructive_cart
Expand Down Expand Up @@ -142,7 +142,7 @@ def cart_test_internal(program, dotest, client=nil, *others)
# temporarily disabled.
#assert_equal(4, cli.memo.first.array.length, "crap, i got #{cli.memo.first.inspect}") if dotest
}
program.stop_bg
program.stop
end

def add_members(b, *hosts)
Expand Down
14 changes: 7 additions & 7 deletions test/tc_chord.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,11 @@ def no_test_find
begin
do_lookup_tests(my_nodes)
rescue Test::Unit::AssertionFailedError
my_nodes.each{|n| n.stop_bg}
my_nodes.each{|n| n.stop}
raise
end
puts "done"
my_nodes.each{|n| n.stop_bg}
my_nodes.each{|n| n.stop}
end

def no_test_join
Expand Down Expand Up @@ -292,11 +292,11 @@ def no_test_join
print "checking lookups"
do_lookup_tests(@my_nodes)
rescue Test::Unit::AssertionFailedError
@my_nodes.each{|n| n.stop_bg}
@my_nodes.each{|n| n.stop}
raise
end
puts "done"
@my_nodes.each{|n| n.stop_bg}
@my_nodes.each{|n| n.stop}
end

def test_stabilize
Expand Down Expand Up @@ -358,15 +358,15 @@ def test_stabilize
print "checking lookups"
do_lookup_tests(@my_nodes)
rescue Test::Unit::AssertionFailedError
@my_nodes.each{|n| n.stop_bg}
@my_nodes.each{|n| n.stop}
raise
end
puts "done"

# # now stop node 1 and check result of stabilization again
# # clear xferq
# (1..xferq.length).each { xferq.pop }
# @my_nodes[1].stop_bg
# @my_nodes[1].stop
# # check localkeys
# print "checking localkeys after 1 leaves"
# x = xferq.pop
Expand All @@ -381,6 +381,6 @@ def test_stabilize
# # @my_nodes.map{|n| [n.ip_port, n.localkeys.to_a]})
# puts "done"

@my_nodes.each{|n| n.stop_bg}
@my_nodes.each{|n| n.stop}
end
end
8 changes: 4 additions & 4 deletions test/tc_dastardly_delivery.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ def test_dd_delivery_reorder
assert_not_equal(tuples,
rcv.pipe_out_perm.to_a.sort { |a, b| a[1] <=> b[1] }.map { |m| m[0] } )
}
snd.stop_bg
rcv.stop_bg
snd.stop
rcv.stop
end

def test_dd_delivery_send_once
Expand Down Expand Up @@ -106,7 +106,7 @@ def test_dd_delivery_send_once
assert_equal(tuples[0],
rcv.pipe_out_perm.to_a[0][0])
}
snd.stop_bg
rcv.stop_bg
snd.stop
rcv.stop
end
end
8 changes: 4 additions & 4 deletions test/tc_demonic_delivery.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def test_dd_delivery_reliable
rcv.sync_do {
assert_equal(tuples.sort, rcv.pipe_out_perm.to_a.sort)
}
snd.stop_bg
rcv.stop_bg
snd.stop
rcv.stop
end

def test_dd_delivery_demonic
Expand Down Expand Up @@ -101,7 +101,7 @@ def test_dd_delivery_demonic
assert_equal(tuples.sort.slice(2, tuples.length),
rcv.pipe_out_perm.to_a.sort)
}
snd.stop_bg
rcv.stop_bg
snd.stop
rcv.stop
end
end
43 changes: 19 additions & 24 deletions test/tc_e2e_bfs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ def clean
def md5_of(name)
Digest::MD5.hexdigest(File.read(name))
end

def files_in_dir(dir)
Dir.new(dir).entries.length - 2
end
end

def ntest_concurrent_clients
b = BFSMasterServer.new(@opts.merge(:port => 44444))
Expand All @@ -49,9 +49,9 @@ def ntest_concurrent_clients
#res = s2.dispatch_command(["ls", "/"])
s2.dispatch_command(["create", "/test2"])



Thread.new do

Thread.new do
rd = File.open(TEST_FILE, "r")
s1.dispatch_command(["append", "/test1"], rd)
rd.close
Expand All @@ -75,14 +75,12 @@ def ntest_concurrent_clients
s2.dispatch_command(["read", "/test2"], fp)
fp.close
assert_equal(md5_of(TEST_FILE), md5_of(file))


end

def ntest_many_datanodes
b = BFSMasterServer.new(@opts.merge(:port => "33333"))
b.run_bg

dns = []
ports = []
(0..6).each do |i|
Expand Down Expand Up @@ -111,18 +109,18 @@ def ntest_many_datanodes
chunk[entry] = []
end
chunk[entry] << p

unless node[p]
node[p] = []
end
end
node[p] << entry
end
end
end

assert_equal(25, chunk.keys.length)
chunk.each_pair do |k, v|
assert(v.length >= REP_FACTOR, "low replication: #{v.length} for #{k}")
if v.length > REP_FACTOR
if v.length > REP_FACTOR
puts "\texpeced #{REP_FACTOR}, got #{v.length} for #{k}"
end
end
Expand All @@ -133,17 +131,16 @@ def ntest_many_datanodes
end

dns.each {|d| d.stop_datanode }
b.stop_bg
s.stop_bg

b.stop
s.stop
end

def do_read(rt)
file = "/tmp/bfstest_" + (1 + rand(1000)).to_s
fp = File.open(file, "w")
rt.dispatch_command(["read", "/peter"], fp)
fp.close
assert_equal(md5_of(TEST_FILE), md5_of(file))
assert_equal(md5_of(TEST_FILE), md5_of(file))
end

def test_client
Expand All @@ -165,7 +162,7 @@ def test_client
s.sync_do
rd = File.open(TEST_FILE, "r")
s.dispatch_command(["append", "/peter"], rd)
rd.close
rd.close
s.sync_do
do_read(s)

Expand All @@ -176,8 +173,6 @@ def test_client
# failover
do_read(s)



dn2.stop_datanode
puts "DB: @#{b.budtime}, }all down"

Expand All @@ -201,10 +196,10 @@ def test_client
b.delta(:bg_timer)
do_read(s)
dn4.stop_datanode
s.stop_bg
b.stop_bg
s.stop
b.stop
end

# not the dryest
def new_datanode(dp, master_port)
dn = DN.new(dp, @opts.merge(:tag => "P#{dp}"))
Expand Down
2 changes: 1 addition & 1 deletion test/tc_heartbeat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ def test_heartbeat_group
end
end

hb_list.each {|h| h.stop_bg}
hb_list.each {|h| h.stop}
end
end
20 changes: 10 additions & 10 deletions test/tc_kvs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def ntest_wl5
v.run_bg
#add_members(v, "localhost:12352")
assert_raise(Bud::KeyConstraintError) { workload2(v) }
v.stop_bg
v.stop
end

def test_wl1
Expand All @@ -52,8 +52,8 @@ def test_wl1
v.sync_do{ assert_equal("bak", v.kvs__kvstate.first[1]) }
v2.sync_do{ assert_equal(1, v2.kvs__kvstate.length) }
v2.sync_do{ assert_equal("bak", v2.kvs__kvstate.first[1]) }
v.stop_bg
v2.stop_bg
v.stop
v2.stop
end

def test_simple
Expand All @@ -69,7 +69,7 @@ def test_simple
assert_equal("bak", v.kvget_response.first[2])
}

v.stop_bg
v.stop
end

def test_del
Expand All @@ -82,7 +82,7 @@ def test_del
v.sync_do { v.kvdel <+ [['foo', 23525]] }
v.sync_do
v.sync_do { assert_equal(0, v.kvstate.length) }
v.stop_bg
v.stop
end

def ntest_persistent_kvs
Expand All @@ -94,16 +94,16 @@ def ntest_persistent_kvs
workload1(p)
p.sync_do { assert_equal(1, p.kvstate.length) }
p.sync_do { assert_equal("bak", p.kvstate.first[1]) }
p.stop_bg
p.stop

p2 = SSPKVS.new(:dbm_dir => dir)
p2.run_bg
p2.sync_do{}
p2.sync_do{}
p2.sync_do{}
p2.sync_do
p2.sync_do
p2.sync_do
p2.sync_do { assert_equal(1, p2.kvstate.length) }
p2.sync_do { assert_equal("bak", p2.kvstate.first[1]) }
p2.stop_bg
p2.stop
end

=begin
Expand Down
Loading

0 comments on commit d71b4d2

Please sign in to comment.