diff --git a/src/program/lwaftr/bench/README b/src/program/lwaftr/bench/README index 61ef88d282..ff2610ce5c 100644 --- a/src/program/lwaftr/bench/README +++ b/src/program/lwaftr/bench/README @@ -21,9 +21,6 @@ Usage: bench CONF IPV4-IN.PCAP IPV6-IN.PCAP as the identifier. This must be unique amongst other snabb processes. --cpu Bind lwAFTR bench to the given CPU - --reconfigurable Allow run-time configuration query and update. - This runs as two processes, a leader and a - follower, rather than just one. Run the lwAFTR with input from IPV4-IN.PCAP and IPV6-IN.PCAP. The bench command is used to get an idea of the raw speed of the lwaftr without diff --git a/src/program/lwaftr/bench/bench.lua b/src/program/lwaftr/bench/bench.lua index cb7280195b..adbf8e4630 100644 --- a/src/program/lwaftr/bench/bench.lua +++ b/src/program/lwaftr/bench/bench.lua @@ -31,10 +31,8 @@ function parse_args(args) function handlers.b(arg) opts.bench_file = arg end function handlers.y() opts.hydra = true end function handlers.h() show_usage(0) end - function handlers.reconfigurable() opts.reconfigurable = true end args = lib.dogetopt(args, handlers, "n:hyb:D:", { - help="h", hydra="y", ["bench-file"]="b", duration="D", name="n", cpu=1, - reconfigurable = 0 }) + help="h", hydra="y", ["bench-file"]="b", duration="D", name="n", cpu=1}) if #args ~= 3 then show_usage(1) end return opts, scheduling, unpack(args) end @@ -50,13 +48,8 @@ function run(args) end local graph = config.new() - if opts.reconfigurable then - setup.reconfigurable(scheduling, setup.load_bench, graph, conf, - inv4_pcap, inv6_pcap, 'sinkv4', 'sinkv6') - else - setup.apply_scheduling(scheduling) - setup.load_bench(graph, conf, inv4_pcap, inv6_pcap, 'sinkv4', 'sinkv6') - end + setup.reconfigurable(scheduling, setup.load_bench, graph, conf, + inv4_pcap, inv6_pcap, 'sinkv4', 'sinkv6') app.configure(graph) local function start_sampling_for_pid(pid) @@ -65,27 +58,19 @@ function run(args) csv:add_app('sinkv6', { 'input' }, { input=opts.hydra and 'encap' or 'Encap.' }) csv:activate() end - if opts.reconfigurable then - for _,pid in ipairs(app.configuration.apps['leader'].arg.follower_pids) do - -- The worker will be fed its configuration by the - -- leader, but we don't know when that will all be ready. - -- Just retry if this doesn't succeed. - local function start_sampling() - if not pcall(start_sampling_for_pid, pid) then - io.stderr:write("Waiting on follower "..pid.." to start ".. - "before recording statistics...\n") - timer.activate(timer.new('retry_csv', start_sampling, 1e9)) - end - end - timer.activate(timer.new('spawn_csv_stats', start_sampling, 10e6)) + for _,pid in ipairs(app.configuration.apps['leader'].arg.follower_pids) do + -- The worker will be fed its configuration by the + -- leader, but we don't know when that will all be ready. + -- Just retry if this doesn't succeed. + local function start_sampling() + if not pcall(start_sampling_for_pid, pid) then + io.stderr:write("Waiting on follower "..pid.." to start ".. + "before recording statistics...\n") + timer.activate(timer.new('retry_csv', start_sampling, 1e9)) + end end - else - start_sampling_for_pid(S.getpid()) + timer.activate(timer.new('spawn_csv_stats', start_sampling, 10e6)) end - if not opts.reconfigurable then - -- The leader does not need all the CPU, only the followers do. - app.busywait = true - end app.main({duration=opts.duration}) end diff --git a/src/program/lwaftr/doc/CHANGELOG.md b/src/program/lwaftr/doc/CHANGELOG.md index 6f96bc0eed..79e619d7ea 100644 --- a/src/program/lwaftr/doc/CHANGELOG.md +++ b/src/program/lwaftr/doc/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## [2017.07.02] + +* Deprecate the --reconfigurable flags in favour of the lwaftr always + being reconfigurable. + ## [2017.07.01] - 2017-08-04 * New YANG schema snabb-softwire-v2 replaces old snabb-softwire-v1 diff --git a/src/program/lwaftr/run/README b/src/program/lwaftr/run/README index b79946748b..a95ff5891a 100644 --- a/src/program/lwaftr/run/README +++ b/src/program/lwaftr/run/README @@ -9,9 +9,6 @@ Required arguments: --on-a-stick One single NIC for INET-side and B4-side Optional arguments: - --reconfigurable Allow run-time configuration query and update. - This runs as two processes, a leader and a - follower, rather than just one. --virtio Use virtio-net interfaces instead of Intel 82599 --ring-buffer-size Set Intel 82599 receive buffer size --cpu Bind the lwAFTR to the given CPU diff --git a/src/program/lwaftr/run/run.lua b/src/program/lwaftr/run/run.lua index 30ec1919e6..a670f6bba7 100644 --- a/src/program/lwaftr/run/run.lua +++ b/src/program/lwaftr/run/run.lua @@ -102,7 +102,10 @@ function parse_args(args) .." (valid values: flush, warn, off)") end end - function handlers.reconfigurable() opts.reconfigurable = true end + function handlers.reconfigurable() + io.stderr:write("Warning: the --reconfigurable flag has been deprecated") + io.stderr:write(" as the lwaftr is now always reconfigurable.\n") + end function handlers.h() show_usage(0) end lib.dogetopt(args, handlers, "b:c:vD:yhir:n:", { conf = "c", v4 = 1, v6 = 1, ["v4-pci"] = 1, ["v6-pci"] = 1, @@ -172,13 +175,7 @@ function run(args) setup_fn, setup_args = setup.load_phy, { 'inetNic', 'b4sideNic' } end - if opts.reconfigurable then - setup.reconfigurable(scheduling, setup_fn, c, conf, unpack(setup_args)) - else - setup.apply_scheduling(scheduling) - setup_fn(c, conf, unpack(setup_args)) - end - + setup.reconfigurable(scheduling, setup_fn, c, conf, unpack(setup_args)) engine.configure(c) if opts.verbosity >= 2 then @@ -206,40 +203,26 @@ function run(args) end csv:activate() end - if opts.reconfigurable then - local pids = engine.configuration.apps['leader'].arg.follower_pids - for _,pid in ipairs(pids) do - local function start_sampling() - -- The worker will be fed its configuration by the - -- leader, but we don't know when that will all be ready. - -- Just retry if this doesn't succeed. - if not pcall(add_csv_stats_for_pid, pid) then - io.stderr:write("Waiting on follower "..pid.." to start ".. - "before recording statistics...\n") - timer.activate(timer.new('retry_csv', start_sampling, 2e9)) - end - end - timer.activate(timer.new('spawn_csv_stats', start_sampling, 50e6)) - end - else - add_csv_stats_for_pid(S.getpid()) + local pids = engine.configuration.apps['leader'].arg.follower_pids + for _,pid in ipairs(pids) do + local function start_sampling() + -- The worker will be fed its configuration by the + -- leader, but we don't know when that will all be ready. + -- Just retry if this doesn't succeed. + if not pcall(add_csv_stats_for_pid, pid) then + io.stderr:write("Waiting on follower "..pid.." to start ".. + "before recording statistics...\n") + timer.activate(timer.new('retry_csv', start_sampling, 2e9)) + end + end + timer.activate(timer.new('spawn_csv_stats', start_sampling, 50e6)) end end if opts.ingress_drop_monitor then - if opts.reconfigurable then - io.stderr:write("Warning: Ingress drop monitor not yet supported ".. - "in multiprocess mode.\n") - else - local mon = ingress_drop_monitor.new({action=opts.ingress_drop_monitor}) - timer.activate(mon:timer()) - end + io.stderr:write("Warning: Ingress drop monitor not yet supported\n") end - if not opts.reconfigurable then - -- The leader does not need all the CPU, only the followers do. - engine.busywait = true - end if opts.duration then engine.main({duration=opts.duration, report={showlinks=true}}) else diff --git a/src/program/lwaftr/tests/propbased/common.lua b/src/program/lwaftr/tests/propbased/common.lua index bf7611ec45..7e612f8c42 100644 --- a/src/program/lwaftr/tests/propbased/common.lua +++ b/src/program/lwaftr/tests/propbased/common.lua @@ -12,16 +12,16 @@ function make_handle_prop_args(name, duration, pidbox) print("Usage: snabb lwaftr quickcheck prop_sameval PCI_ADDR") os.exit(1) end - + local pci_addr = prop_args[1] assert(S.stat(pci.path(pci_addr)), string.format("Invalid PCI address: %s", pci_addr)) - + local pid = S.fork() if pid == 0 then local cmdline = {"snabb", "lwaftr", "run", "-D", tostring(duration), "--conf", "program/lwaftr/tests/data/icmp_on_fail.conf", - "--reconfigurable", "--on-a-stick", pci_addr} + "--on-a-stick", pci_addr} lib.execv(("/proc/%d/exe"):format(S.getpid()), cmdline) else pidbox[1] = pid diff --git a/src/program/lwaftr/tests/subcommands/bench_test.py b/src/program/lwaftr/tests/subcommands/bench_test.py index 95df53f23d..bdcc6fdc7c 100644 --- a/src/program/lwaftr/tests/subcommands/bench_test.py +++ b/src/program/lwaftr/tests/subcommands/bench_test.py @@ -18,19 +18,12 @@ class TestBench(BaseTestCase): str(BENCHDATA_DIR / 'ipv6-0550.pcap'), ] - def execute_bench_test(self, cmd_args): - self.run_cmd(cmd_args) + def test_bench(self): + self.run_cmd(self.cmd_args) self.assertTrue(BENCHMARK_PATH.is_file(), 'Cannot find {}'.format(BENCHMARK_PATH)) BENCHMARK_PATH.unlink() - def test_bench_not_reconfigurable(self): - self.execute_bench_test(self.cmd_args) - - def test_bench_reconfigurable(self): - reconf_args = list(self.cmd_args) - reconf_args.insert(3, '--reconfigurable') - self.execute_bench_test(reconf_args) if __name__ == '__main__': unittest.main() diff --git a/src/program/lwaftr/tests/subcommands/config_test.py b/src/program/lwaftr/tests/subcommands/config_test.py index 2932dff402..184492d268 100644 --- a/src/program/lwaftr/tests/subcommands/config_test.py +++ b/src/program/lwaftr/tests/subcommands/config_test.py @@ -17,7 +17,7 @@ DAEMON_PROC_NAME = 'config-test-daemon' DAEMON_ARGS = [ - str(SNABB_CMD), 'lwaftr', 'bench', '--reconfigurable', + str(SNABB_CMD), 'lwaftr', 'bench', '--bench-file', '/dev/null', '--name', DAEMON_PROC_NAME, str(DATA_DIR / 'icmp_on_fail.conf'), diff --git a/src/program/lwaftr/tests/subcommands/query_test.py b/src/program/lwaftr/tests/subcommands/query_test.py index 65789078e7..a1723c09c1 100644 --- a/src/program/lwaftr/tests/subcommands/query_test.py +++ b/src/program/lwaftr/tests/subcommands/query_test.py @@ -14,7 +14,7 @@ RUN_DIR = Path('/var/run/snabb') @unittest.skipUnless(SNABB_PCI0 and SNABB_PCI1, 'NICs not configured') -class TestQueryStandard(BaseTestCase): +class TestQuery(BaseTestCase): daemon_args = ( str(SNABB_CMD), 'lwaftr', 'run', @@ -71,27 +71,13 @@ def test_query_by_name(self): name_args.extend(('--name', DAEMON_PROC_NAME)) self.execute_query_test(name_args) - -@unittest.skipUnless(SNABB_PCI0 and SNABB_PCI1, 'NICs not configured') -class TestQueryReconfigurable(TestQueryStandard): - - daemon_args = ( - str(SNABB_CMD), 'lwaftr', 'run', '--reconfigurable', - '--name', DAEMON_PROC_NAME, - '--conf', str(DATA_DIR / 'no_icmp.conf'), - '--v4', SNABB_PCI0, - '--v6', SNABB_PCI1, - ) - def get_all_leader_pids(self): - output = str(self.run_cmd(('ps', 'aux')), ENC) - pids = [] - for line in output.splitlines(): - if ((SNABB_PCI0 in line) and - ('--reconfigurable' in line) and - ('grep' not in line)): - pids.append(line.split()[1]) - return pids + leaders = [] + for instance in RUN_DIR.iterdir(): + group = RUN_DIR / instance.name / 'group' + if not group.is_symlink(): + leaders.append(instance.name) + return leaders def get_leader_pid(self): for pid in self.get_all_leader_pids(): diff --git a/src/program/lwaftr/tests/subcommands/run_test.py b/src/program/lwaftr/tests/subcommands/run_test.py index ab6a531ada..a4e40f892b 100644 --- a/src/program/lwaftr/tests/subcommands/run_test.py +++ b/src/program/lwaftr/tests/subcommands/run_test.py @@ -21,18 +21,10 @@ class TestRun(BaseTestCase): '--v6', SNABB_PCI1 ) - def execute_run_test(self, cmd_args): - output = self.run_cmd(cmd_args) + def test_run(self): + output = self.run_cmd(self.cmd_args) self.assertIn(b'link report', output, b'\n'.join((b'OUTPUT', output))) - def test_run_not_reconfigurable(self): - self.execute_run_test(self.cmd_args) - - def test_run_reconfigurable(self): - reconf_args = list(self.cmd_args) - reconf_args.insert(3, '--reconfigurable') - self.execute_run_test(reconf_args) - if __name__ == '__main__': unittest.main()