# # # add_file "tests/automate_netsync/pull_r1.expected" # content [0b6810e239e6d498cf412f017fcaae5db4cc2228] # # add_file "tests/automate_netsync/push_cert.expected" # content [dce134b636439cbd2a8d90597a99012766a0b7a0] # # add_file "tests/automate_netsync/sync.expected" # content [0863e27fd05569752d17e7f450818338d8d879e6] # # patch "tests/automate_netsync/__driver__.lua" # from [dadc8b3ee7814c288498e87d741b2c82ec3b9fa0] # to [d73f9dbf04372daddec8eb4c38b2a90ab86d5351] # ============================================================ --- tests/automate_netsync/__driver__.lua dadc8b3ee7814c288498e87d741b2c82ec3b9fa0 +++ tests/automate_netsync/__driver__.lua d73f9dbf04372daddec8eb4c38b2a90ab86d5351 @@ -1,3 +1,4 @@ +-- Test automate sync/pull/push include("/common/netsync.lua") include("/common/automate_stdio.lua") @@ -5,40 +6,70 @@ netsync.setup() mtn_setup() netsync.setup() +-- Create a base revision, in test.db branch 'foo' +-- Override date so we can compare it below +function mtn_date(...) + return mtn("--date=2010-09-01T12:00:00", ...) +end + addfile("testfile", "blah stuff") -commit("foo") +commit("foo", "R1", mtn_date) R1 = base_revision() +-- Serve test.db srv = netsync.start() -check(mtn2("automate", "pull", srv.address, "bar"), 0, false, false) -check(mtn2("automate", "get_revision", R1), 1, false, false) +-- Pull branch 'bar' from test.db to test2.db; nothing transferred, so +-- no output on stdout; stderr has progress messages, ticker +check(mtn2("automate", "pull", "mtn://" .. srv.address .. "?bar"), 0, nil, false) -check(mtn2("automate", "pull", srv.address, "foo"), 0, false, false) -check(mtn2("automate", "cert", R1, "test", "value"), 0, false, false) -check(mtn2("automate", "push", srv.address, "foo"), 0, false, false) +-- Fails because R1 is on branch 'foo' +check(mtn2("automate", "get_revision", R1), 1, nil, true) +check(qgrep("no revision 114f6aa58c7707bf83516d4080ca6268c36640ad found in database", "stderr")) +-- Pull branch 'foo', confirm output +get("pull_r1.expected") +check(mtn2("automate", "pull", "mtn://" .. srv.address .. "?foo"), 0, true, false) +canonicalize("stdout") +check(samefile("pull_r1.expected", "stdout")) +-- stderr has ticker; we don't check that here + +-- Push a cert from test2.db to test.db +get("push_cert.expected") +check(mtn2("automate", "cert", R1, "test", "value"), 0, nil, nil) +check(mtn2("automate", "push", "mtn://" .. srv.address .. "?foo"), 0, true, false) +canonicalize("stdout") +check(samefile("push_cert.expected", "stdout")) + srv:stop() +-- check that test.db and test2.db have the same data for R1 check_same_stdout( mtn("au", "get_revision", R1), mtn2("au", "get_revision", R1) ) +-- check that the test cert got transfered check(mtn("au", "certs", R1), 0, true, false) check(qgrep('name "test"', "stdout")) +-- Test 'automate stdio sync' output and ticker + +-- New file on a new branch in test.db addfile("testfile2", "blah foo") -commit("foo2") +commit("foo2", "R2", mtn_date) R2 = base_revision() srv = netsync.start() -local srvaddr = string.len(srv.address) .. ":" .. srv.address -local cmd = "l4:sync"..srvaddr.."4:foo*e" +local cmd = make_stdio_cmd({"sync", "mtn://" .. srv.address .. "?foo*"}) +get("sync.expected") check(mtn2("automate", "stdio"), 0, true, false, cmd) +output = parse_stdio(readfile("stdout"), 0, 0, "m") tickers = parse_stdio(readfile("stdout"), 0, 0, "t") +check(readfile("sync.expected") == output) + function any_of(tbl, val) for _,v in pairs(tbl) do if string.find(v, val) then @@ -66,3 +97,7 @@ srv:stop() check(any_of(tickers, "<;>;C;R;c;r;")) srv:stop() + +-- FIXME: check output format for key transfer + +-- end of file ============================================================ --- /dev/null +++ tests/automate_netsync/pull_r1.expected 0b6810e239e6d498cf412f017fcaae5db4cc2228 @@ -0,0 +1,20 @@ +receive revision + +revision [114f6aa58c7707bf83516d4080ca6268c36640ad] + + cert "branch" +value "foo" + key [46ec58576f9e4f34a9eede521422aa5fd299dc50] + + cert "changelog" +value "R1 +" + key [46ec58576f9e4f34a9eede521422aa5fd299dc50] + + cert "date" +value "2010-09-01T12:00:00" + key [46ec58576f9e4f34a9eede521422aa5fd299dc50] + + cert "author" +value "address@hidden" + key [46ec58576f9e4f34a9eede521422aa5fd299dc50] ============================================================ --- /dev/null +++ tests/automate_netsync/push_cert.expected dce134b636439cbd2a8d90597a99012766a0b7a0 @@ -0,0 +1,6 @@ +send cert + + cert "test" + value "value" + key [46ec58576f9e4f34a9eede521422aa5fd299dc50] +revision [114f6aa58c7707bf83516d4080ca6268c36640ad] ============================================================ --- /dev/null +++ tests/automate_netsync/sync.expected 0863e27fd05569752d17e7f450818338d8d879e6 @@ -0,0 +1,20 @@ +receive revision + +revision [2a46f4b909071fae756b4911a247ce3ff1c3c4ce] + + cert "branch" +value "foo2" + key [46ec58576f9e4f34a9eede521422aa5fd299dc50] + + cert "changelog" +value "R2 +" + key [46ec58576f9e4f34a9eede521422aa5fd299dc50] + + cert "date" +value "2010-09-01T12:00:00" + key [46ec58576f9e4f34a9eede521422aa5fd299dc50] + + cert "author" +value "address@hidden" + key [46ec58576f9e4f34a9eede521422aa5fd299dc50]