quality: Add test cases for table_stats messages
This commit is contained in:
parent
2bfccd693f
commit
344c00d31d
3 changed files with 52 additions and 3 deletions
|
|
@ -11,8 +11,8 @@ defmodule Openflow.Multipart.Table.Request do
|
|||
|
||||
def ofp_type, do: 18
|
||||
|
||||
def new(xid \\ 0) do
|
||||
%Request{xid: xid}
|
||||
def new(options \\ []) do
|
||||
%Request{xid: options[:xid] || 0}
|
||||
end
|
||||
|
||||
def read("") do
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ defmodule OfpQueueStatsTest do
|
|||
tx_bytes: 0,
|
||||
tx_errors: 0,
|
||||
tx_packets: 0
|
||||
},
|
||||
},
|
||||
%Openflow.Multipart.QueueStats{
|
||||
duration_nsec: 0,
|
||||
duration_sec: 0,
|
||||
|
|
|
|||
49
test/lib/openflow/ofp_table_stats_test.exs
Normal file
49
test/lib/openflow/ofp_table_stats_test.exs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
defmodule OfpTableStatsTest do
|
||||
use ExUnit.Case
|
||||
|
||||
describe "Openflow.Multipart.Table.Request" do
|
||||
test "with default values" do
|
||||
table_stats =
|
||||
%Openflow.Multipart.Table.Request{}
|
||||
|> Map.to_list()
|
||||
|> Openflow.Multipart.Table.Request.new()
|
||||
|> Openflow.to_binary()
|
||||
|> Openflow.read()
|
||||
|> Kernel.elem(1)
|
||||
|
||||
assert table_stats.xid == 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "Openflow.Multipart.Table.Reply" do
|
||||
test "with test packet_data" do
|
||||
table_stats =
|
||||
"test/packet_data/4-28-ofp_table_stats_reply.packet"
|
||||
|> File.read!()
|
||||
|> Openflow.read()
|
||||
|> Kernel.elem(1)
|
||||
|
||||
%Openflow.Multipart.Table.Reply{
|
||||
aux_id: nil,
|
||||
datapath_id: nil,
|
||||
flags: [],
|
||||
tables: [
|
||||
%Openflow.Multipart.TableStats{
|
||||
active_count: 4,
|
||||
lookup_count: 4,
|
||||
matched_count: 4,
|
||||
table_id: 0
|
||||
},
|
||||
%Openflow.Multipart.TableStats{
|
||||
active_count: 4,
|
||||
lookup_count: 4,
|
||||
matched_count: 4,
|
||||
table_id: 1
|
||||
}
|
||||
],
|
||||
version: 4,
|
||||
xid: 0
|
||||
} = table_stats
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue