Skip to content

Commit

Permalink
Fixes #184
Browse files Browse the repository at this point in the history
  • Loading branch information
Kazuya Suzuki committed Jul 19, 2012
1 parent 147422a commit e23b8fc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ruby/trema/stats-reply.c
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ handle_stats_reply(
}

VALUE r_stats_reply = rb_funcall( cStatsReply, rb_intern( "new" ), 1, attributes );
rb_funcall( controller, rb_intern( "stats_reply" ), 1, r_stats_reply );
rb_funcall( controller, rb_intern( "stats_reply" ), 2, ULL2NUM( datapath_id ), r_stats_reply );
}


Expand Down
15 changes: 10 additions & 5 deletions spec/trema/stats-reply_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ class DescStatsController < Controller; end
network {
vswitch( "desc-stats" ) { datapath_id 0xabc }
}.run( DescStatsController ) {
controller( "DescStatsController" ).should_receive( :stats_reply ) do | message |
controller( "DescStatsController" ).should_receive( :stats_reply ) do | datapath_id, message |
datapath_id.should == 0xabc
message.type.should == 0
message.stats[ 0 ].mfr_desc.should eq( "Nicira Networks, Inc." )
message.stats[ 0 ].hw_desc.should eq( "Open vSwitch" )
Expand Down Expand Up @@ -226,7 +227,8 @@ class FlowStatsController < Controller; end
send_packets "host1", "host2", :n_pkts => 2
sleep 2 # FIXME: wait to send_packets

controller( "FlowStatsController" ).should_receive( :stats_reply ) do | message |
controller( "FlowStatsController" ).should_receive( :stats_reply ) do | datapath_id, message |
datapath_id.should == 0xabc
message.type.should == 1
message.stats[ 0 ].packet_count.should == 2
message.stats[ 0 ].should respond_to :to_s
Expand Down Expand Up @@ -262,7 +264,8 @@ class AggregateStatsController < Controller; end
send_packets "host1", "host2", :n_pkts => 10
sleep 2 # FIXME: wait to send_packets

controller( "AggregateStatsController" ).should_receive( :stats_reply ) do | message |
controller( "AggregateStatsController" ).should_receive( :stats_reply ) do | datapath_id, message |
datapath_id.should == 0xabc
message.type.should == 2
message.stats[ 0 ].packet_count.should == 10
message.stats[ 0 ].flow_count.should == 1
Expand Down Expand Up @@ -295,7 +298,8 @@ class PortStatsController < Controller; end
send_packets "host1", "host2"
sleep 2 # FIXME: wait to send_packets

controller( "PortStatsController" ).should_receive( :stats_reply ) do | message |
controller( "PortStatsController" ).should_receive( :stats_reply ) do | datapath_id, message |
datapath_id.should == 0xabc
message.type.should == 4
message.stats[ 0 ].should be_an_instance_of(Trema::PortStatsReply)
message.stats[ 0 ].should respond_to :to_s
Expand Down Expand Up @@ -325,7 +329,8 @@ class TableStatsController < Controller; end
send_packets "host1", "host2"
sleep 2 # FIXME: wait to send_packets

controller( "TableStatsController" ).should_receive( :stats_reply ) do | message |
controller( "TableStatsController" ).should_receive( :stats_reply ) do | datapath_id, message |
datapath_id.should == 0xabc
message.type.should == 3
message.transaction_id.should == 123
message.stats[ 0 ].should be_an_instance_of(Trema::TableStatsReply)
Expand Down

0 comments on commit e23b8fc

Please sign in to comment.