O TA ME SHI
This commit is contained in:
parent
4b4d6ce035
commit
67ad6900d8
2 changed files with 26 additions and 2 deletions
14
test/flay.ex
14
test/flay.ex
|
|
@ -31,6 +31,10 @@ defmodule Flay do
|
||||||
send_message(Desc.Request.new, state.datapath_id)
|
send_message(Desc.Request.new, state.datapath_id)
|
||||||
{:noreply, %{state|reply_to: from}}
|
{:noreply, %{state|reply_to: from}}
|
||||||
end
|
end
|
||||||
|
def handle_call(:flow_stats, from, state) do
|
||||||
|
send_message(Flow.Request.new, state.datapath_id)
|
||||||
|
{:noreply, %{state|reply_to: from}}
|
||||||
|
end
|
||||||
|
|
||||||
def handle_cast({:register_pid, tester_pid}, state) do
|
def handle_cast({:register_pid, tester_pid}, state) do
|
||||||
{:noreply, %{state|tester_pid: tester_pid}}
|
{:noreply, %{state|tester_pid: tester_pid}}
|
||||||
|
|
@ -40,6 +44,10 @@ defmodule Flay do
|
||||||
flow_opts_to_ofp_print(flow_opts)
|
flow_opts_to_ofp_print(flow_opts)
|
||||||
{:noreply, %{state|tester_pid: tester_pid}}
|
{:noreply, %{state|tester_pid: tester_pid}}
|
||||||
end
|
end
|
||||||
|
def handle_cast(:flow_del, state) do
|
||||||
|
send_flow_mod_delete(state.datapath_id, match: Match.new)
|
||||||
|
{:noreply, state}
|
||||||
|
end
|
||||||
|
|
||||||
def handle_info(%ErrorMsg{} = error, state) do
|
def handle_info(%ErrorMsg{} = error, state) do
|
||||||
send(state.tester_pid, error)
|
send(state.tester_pid, error)
|
||||||
|
|
@ -57,9 +65,13 @@ defmodule Flay do
|
||||||
GenServer.reply(state.reply_to, desc)
|
GenServer.reply(state.reply_to, desc)
|
||||||
{:noreply, %{state|reply_to: nil}}
|
{:noreply, %{state|reply_to: nil}}
|
||||||
end
|
end
|
||||||
|
def handle_info(%Flow.Reply{} = desc, state) do
|
||||||
|
GenServer.reply(state.reply_to, desc)
|
||||||
|
{:noreply, %{state|reply_to: nil}}
|
||||||
|
end
|
||||||
# `Catch all` function is required.
|
# `Catch all` function is required.
|
||||||
def handle_info(info, state) do
|
def handle_info(info, state) do
|
||||||
:ok = warn("[#{__MODULE__}] unhandled message #{inspect(info)}")
|
# :ok = warn("[#{__MODULE__}] unhandled message #{inspect(info)}")
|
||||||
{:noreply, state}
|
{:noreply, state}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ defmodule FlogTest do
|
||||||
Code.load_file("test/pf.ex")
|
Code.load_file("test/pf.ex")
|
||||||
|
|
||||||
# GIVEN
|
# GIVEN
|
||||||
setup_all do
|
setup do
|
||||||
setup_applications()
|
setup_applications()
|
||||||
wait_for_connected()
|
wait_for_connected()
|
||||||
ports = get_ports_desc()
|
ports = get_ports_desc()
|
||||||
|
|
@ -51,6 +51,11 @@ defmodule FlogTest do
|
||||||
cookie: cookie,
|
cookie: cookie,
|
||||||
timeout: timeout
|
timeout: timeout
|
||||||
]
|
]
|
||||||
|
|
||||||
|
on_exit fn ->
|
||||||
|
print_flows()
|
||||||
|
GenServer.cast(Flay, :flow_del)
|
||||||
|
end
|
||||||
{:ok, options}
|
{:ok, options}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -636,4 +641,11 @@ defmodule FlogTest do
|
||||||
port_desc = GenServer.call(Flay, :port_desc_stats, 5000)
|
port_desc = GenServer.call(Flay, :port_desc_stats, 5000)
|
||||||
port_desc.ports
|
port_desc.ports
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp print_flows do
|
||||||
|
flow_stats = GenServer.call(Flay, :flow_stats, 5000)
|
||||||
|
for flow <- flow_stats.flows do
|
||||||
|
IO.inspect(flow)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue