# # # patch "lua_hooks.cc" # from [9bff5982da56fbb75b4299178b78f55f0b4b95f2] # to [2ba09f87d8dc16a1957cad5abc98565a7c87cc7c] # # patch "tests/common/netsync-hooks_with_notes.lua" # from [9ac0fce9c0c5646239c38b438f625ffca1473877] # to [7f3c021a933500a16ac5f2c1ec6c486962aa55ca] # # patch "tests/exchanging_work_via_netsync,_with_notes/__driver__.lua" # from [d9f6406315e92e7e2e192ddd7cfa0894093ad368] # to [0be268de9da52c1e06e9d5351c8abc6e079118d2] # # patch "tests/exchanging_work_via_netsync,_with_notes/testnotes.test" # from [0d5619c37ae36d4cb1a361f413a257c2514a2bd7] # to [5fa00ad10b7ba5551b960503af166f16922f7456] # # patch "tests/exchanging_work_via_netsync,_with_notes/testnotes2.test" # from [9535c4e90bbd9d7f16182ed64af26684a9a64e5e] # to [46346a823a01c8c47739ea63414a343be84a9d4f] # ============================================================ --- lua_hooks.cc 9bff5982da56fbb75b4299178b78f55f0b4b95f2 +++ lua_hooks.cc 2ba09f87d8dc16a1957cad5abc98565a7c87cc7c @@ -838,12 +838,28 @@ lua_hooks::hook_note_netsync_start(size_ utf8 include_pattern, utf8 exclude_pattern) { + string type; + switch (sync_type) + { + case 1: + type = "push"; + break; + case 2: + type = "pull"; + break; + case 3: + type = "sync"; + break; + default: + type = "unknown"; + break; + } Lua ll(st); return ll .func("note_netsync_start") .push_int(session_id) .push_str(my_role) - .push_int(sync_type) + .push_str(type) .push_str(remote_host) .push_str(remote_keyname()) .push_str(include_pattern()) ============================================================ --- tests/common/netsync-hooks_with_notes.lua 9ac0fce9c0c5646239c38b438f625ffca1473877 +++ tests/common/netsync-hooks_with_notes.lua 7f3c021a933500a16ac5f2c1ec6c486962aa55ca @@ -1,34 +1,50 @@ logfile = nil logfile = nil -function note_netsync_start() - logfile = io.open("testnotes.log","w") - logfile:write("start ---------------------------------------------------\n") +function note_netsync_start(session_id, my_role, sync_type, + remote_host, remote_keyname, + includes, excludes) + logfile = io.open("testnotes-" .. my_role .. ".log","w") + logfile:write(session_id .. " start ---------------------------------------------------\n") + logfile:write(session_id .. " start: sync_type = " .. sync_type .. "\n") + logfile:write(session_id .. " start: remote_host = " .. remote_host .. "\n") + logfile:write(session_id .. " start: remote_keyname = " .. remote_keyname .. "\n") + logfile:write(session_id .. " start: includes = " .. includes .. "\n") + logfile:write(session_id .. " start: excludes = " .. excludes .. "\n") end -function note_netsync_revision_received(new_id, revision, certs) - logfile:write("revision: new_id = " .. new_id .. "\n") - logfile:write("revision: revision = " .. revision .. "\n") +function note_netsync_revision_received(new_id, revision, certs, session_id) + logfile:write(session_id .. " revision: new_id = " .. new_id .. "\n") + logfile:write(session_id .. " revision: revision = " .. revision .. "\n") for i, cert in pairs(certs) do - logfile:write("revision: cert.name = " .. cert.name .. "\n") - logfile:write("revision: cert.value = " .. cert.value .. "\n") - logfile:write("revision: cert.key = " .. cert.key .. "\n") + logfile:write(session_id .. " revision: cert.name = " .. cert.name .. "\n") + logfile:write(session_id .. " revision: cert.value = " .. cert.value .. "\n") + logfile:write(session_id .. " revision: cert.key = " .. cert.key .. "\n") end end -function note_netsync_cert_received(rev_id, key, name, value) - logfile:write("cert: rev_id = " .. rev_id .. "\n") - logfile:write("cert: name = " .. name .. "\n") - logfile:write("cert: value = " .. value .. "\n") - logfile:write("cert: key = " .. key .. "\n") +function note_netsync_cert_received(rev_id, key, name, value, session_id) + logfile:write(session_id .. " cert: rev_id = " .. rev_id .. "\n") + logfile:write(session_id .. " cert: name = " .. name .. "\n") + logfile:write(session_id .. " cert: value = " .. value .. "\n") + logfile:write(session_id .. " cert: key = " .. key .. "\n") end -function note_netsync_pubkey_received(keyname) - logfile:write("pubkey: " .. keyname .. "\n") +function note_netsync_pubkey_received(keyname, session_id) + logfile:write(session_id .. " pubkey: " .. keyname .. "\n") end -function note_netsync_end() - logfile:write("end -----------------------------------------------------\n") +function note_netsync_end(session_id, status, + bytes_in, bytes_out, + certs_in, certs_out, + revs_in, revs_out, + keys_in, keys_out) + logfile:write(session_id .. " end: status = " .. status .. "\n") + logfile:write(session_id .. " end: bytes in/out = " .. bytes_in .. "/" .. bytes_out .. "\n") + logfile:write(session_id .. " end: certs in/out = " .. certs_in .. "/" .. certs_out .. "\n") + logfile:write(session_id .. " end: revs in/out = " .. revs_in .. "/" .. revs_out .. "\n") + logfile:write(session_id .. " end: keys in/out = " .. keys_in .. "/" .. keys_out .. "\n") + logfile:write(session_id .. " end -----------------------------------------------------\n") logfile:close() end ============================================================ --- tests/exchanging_work_via_netsync,_with_notes/__driver__.lua d9f6406315e92e7e2e192ddd7cfa0894093ad368 +++ tests/exchanging_work_via_netsync,_with_notes/__driver__.lua 0be268de9da52c1e06e9d5351c8abc6e079118d2 @@ -13,8 +13,9 @@ end table.insert(revs, t) end -function evaluate(filename) - local dat = readfile(filename) +function evaluate(correctfile, logfile) + check(get(correctfile)) + local dat = readfile(correctfile) dat = string.gsub(dat, "REV1", revs[1].rev) dat = string.gsub(dat, "MAN1", revs[1].man) dat = string.gsub(dat, "FILE1", revs[1].f) @@ -23,7 +24,17 @@ function evaluate(filename) dat = string.gsub(dat, "MAN2", revs[2].man) dat = string.gsub(dat, "FILE2", revs[2].f) dat = string.gsub(dat, "DATE2", revs[2].date) - writefile(filename, dat) + writefile(correctfile, dat) + + canonicalize(logfile) + dat = readfile(logfile) + dat = string.gsub(dat, "^%d+ ", "") + dat = string.gsub(dat, "\n%d+ ", "\n") + dat = string.gsub(dat, "\n[^\n]*remote_host[^\n]*\n", "\n") + dat = string.gsub(dat, "\n[^\n]*bytes in/out[^\n]*\n", "\n") + writefile(logfile, dat) + + check(samefile(logfile, correctfile)) end -- Checking the effect of a new revisions @@ -38,20 +49,14 @@ netsync.pull("testbranch") netsync.pull("testbranch") -check(get("testnotes.test")) -evaluate("testnotes.test") -canonicalize("testnotes.log") -check(samefile("testnotes.log", "testnotes.test")) +evaluate("testnotes.test", "testnotes-client.log") -- Checking the effect of a simple cert change check(mtn("tag", revs[1].rev, "testtag"), 0, false, false) netsync.pull("testbranch") -check(get("testnotes2.test", "testnotes.test")) -evaluate("testnotes.test") -canonicalize("testnotes.log") -check(samefile("testnotes.log", "testnotes.test")) +evaluate("testnotes2.test", "testnotes-client.log") -- Checking that a netsync with nothing new will not trigger the -- note_netsync hooks ============================================================ --- tests/exchanging_work_via_netsync,_with_notes/testnotes.test 0d5619c37ae36d4cb1a361f413a257c2514a2bd7 +++ tests/exchanging_work_via_netsync,_with_notes/testnotes.test 5fa00ad10b7ba5551b960503af166f16922f7456 @@ -1,4 +1,8 @@ start ---------------------------------- start --------------------------------------------------- +start: sync_type = pull +start: remote_keyname = address@hidden +start: includes = testbranch +start: excludes = revision: new_id = REV1 revision: revision = format_version "1" @@ -48,4 +52,8 @@ revision: cert.key = address@hidden revision: cert.name = author revision: cert.value = address@hidden revision: cert.key = address@hidden +end: status = 200 +end: certs in/out = 8/0 +end: revs in/out = 2/0 +end: keys in/out = 1/0 end ----------------------------------------------------- ============================================================ --- tests/exchanging_work_via_netsync,_with_notes/testnotes2.test 9535c4e90bbd9d7f16182ed64af26684a9a64e5e +++ tests/exchanging_work_via_netsync,_with_notes/testnotes2.test 46346a823a01c8c47739ea63414a343be84a9d4f @@ -1,6 +1,14 @@ start ---------------------------------- start --------------------------------------------------- +start: sync_type = pull +start: remote_keyname = address@hidden +start: includes = testbranch +start: excludes = cert: rev_id = REV1 cert: name = tag cert: value = testtag cert: key = address@hidden +end: status = 200 +end: certs in/out = 1/0 +end: revs in/out = 0/0 +end: keys in/out = 0/0 end -----------------------------------------------------