1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
includecommon("netsync.lua")
mtn_setup()
netsync.setup()
append("netsync.lua", "\
\
includedirpattern(get_confdir() .. \"/hooks.d\",\"*.conf\")\
includedirpattern(get_confdir() .. \"/hooks.d\",\"*.lua\")\
")
mkdir("hooks.d")
-- the server that shall receive the push from the other server
srv1 = netsync.start(2)
sleep(5)
-- the server that shall push to the other server. We add this
-- hook now, so the former server doesn't catch it
check(copy(srcdir.."/../extra/mtn-hooks/monotone-cluster-push.lua",
"hooks.d/monotone-cluster-push.lua"))
writefile("hooks.d/monotone-cluster-push.conf",
"MCP_debug = true\nMCP_verbose_startup=true\n")
writefile("cluster-push.rc",
"\
pattern \"*\"\
server \""..srv1.address.."\"\n")
srv2 = netsync.start(3)
sleep(5)
-- Move the hook, so we don't confuse the clients
rename("hooks.d/monotone-cluster-push.conf",
"hooks.d/monotone-cluster-push.conf.disabled")
rename("hooks.d/monotone-cluster-push.lua",
"hooks.d/monotone-cluster-push.lua.disabled")
-- Now, send something to the second server
addfile("foo", "bar")
commit()
srv2:push("testbranch",1)
pushed_rev=base_revision()
sleep(5)
-- Destroy the client setup and rebuild it, so we can pull frmo scratch
remove("test.db")
remove("_MTN")
mtn_setup()
-- Now, fetch from the first server
srv1:pull("testbranch",1)
check(mtn("checkout", "--branch=testbranch", "checkout"), 0, false, false)
savedir = chdir("checkout")
pulled_rev=base_revision()
chdir(savedir)
-- Check that the revisions are the same
check(pushed_rev == pulled_rev)
-- Cleanup
srv1:stop()
srv2:stop()
|