trema 0.3.3 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. data/ruby/trema/flow-removed.c +3 -0
  2. data/ruby/trema/match.c +19 -0
  3. data/ruby/trema/packet-in.c +3 -0
  4. data/ruby/trema/port.c +12 -0
  5. data/ruby/trema/send-out-port.rb +1 -1
  6. data/ruby/trema/version.rb +1 -1
  7. data/spec/spec_helper.rb +8 -0
  8. data/spec/support/action.rb +4 -4
  9. data/spec/trema/barrier-request_spec.rb +1 -1
  10. data/spec/trema/cli_spec.rb +1 -3
  11. data/spec/trema/controller_spec.rb +1 -1
  12. data/spec/trema/dsl/configuration_spec.rb +24 -24
  13. data/spec/trema/dsl/link_spec.rb +4 -6
  14. data/spec/trema/dsl/run_spec.rb +7 -11
  15. data/spec/trema/dsl/runner_spec.rb +9 -9
  16. data/spec/trema/dsl/switch_spec.rb +5 -11
  17. data/spec/trema/dsl/vhost_spec.rb +1 -3
  18. data/spec/trema/dsl/vswitch_spec.rb +7 -15
  19. data/spec/trema/echo-request_spec.rb +1 -1
  20. data/spec/trema/enqueue_spec.rb +4 -4
  21. data/spec/trema/features-reply_spec.rb +1 -1
  22. data/spec/trema/features-request_spec.rb +1 -1
  23. data/spec/trema/flow-removed_spec.rb +19 -19
  24. data/spec/trema/get-config-request_spec.rb +1 -1
  25. data/spec/trema/hardware-switch_spec.rb +3 -3
  26. data/spec/trema/host_spec.rb +2 -2
  27. data/spec/trema/list-switches-reply_spec.rb +1 -1
  28. data/spec/trema/mac_spec.rb +1 -1
  29. data/spec/trema/match_spec.rb +8 -8
  30. data/spec/trema/open-vswitch_spec.rb +6 -6
  31. data/spec/trema/openflow-error_spec.rb +15 -15
  32. data/spec/trema/packet-in_spec.rb +210 -208
  33. data/spec/trema/packet-out_spec.rb +4 -6
  34. data/spec/trema/port-mod_spec.rb +28 -29
  35. data/spec/trema/port-status-modify_spec.rb +2 -2
  36. data/spec/trema/port_spec.rb +9 -9
  37. data/spec/trema/queue-get-config-reply_spec.rb +2 -2
  38. data/spec/trema/send-out-port_spec.rb +53 -43
  39. data/spec/trema/set-config_spec.rb +2 -2
  40. data/spec/trema/set-eth-dst-addr_spec.rb +3 -3
  41. data/spec/trema/set-eth-src-addr_spec.rb +3 -3
  42. data/spec/trema/set-ip-dst-addr_spec.rb +20 -16
  43. data/spec/trema/set-ip-src-addr_spec.rb +20 -16
  44. data/spec/trema/set-ip-tos_spec.rb +20 -21
  45. data/spec/trema/set-transport-dst-port_spec.rb +22 -23
  46. data/spec/trema/set-transport-src-port_spec.rb +22 -23
  47. data/spec/trema/set-vlan-priority_spec.rb +20 -21
  48. data/spec/trema/set-vlan-vid_spec.rb +20 -21
  49. data/spec/trema/shell/vhost_spec.rb +7 -7
  50. data/spec/trema/shell/vswitch_spec.rb +8 -8
  51. data/spec/trema/stats-reply_spec.rb +23 -23
  52. data/spec/trema/strip-vlan-header_spec.rb +9 -9
  53. data/spec/trema/switch-daemon_spec.rb +15 -15
  54. data/spec/trema/util_spec.rb +2 -6
  55. data/spec/trema/vendor-action_spec.rb +24 -36
  56. metadata +4 -4
@@ -20,39 +20,38 @@ require File.join( File.dirname( __FILE__ ), "..", "spec_helper" )
20
20
  require "trema"
21
21
 
22
22
 
23
- describe SetIpTos, ".new( number )" do
23
+ describe SetIpTos, ".new( type_of_service )", :type => "actions" do
24
24
  subject { SetIpTos.new( type_of_service ) }
25
25
 
26
- context "when type_of_service == 32" do
26
+ context "with type_of_service (32)" do
27
27
  let( :type_of_service ) { 32 }
28
28
  its( :type_of_service ) { should == 32 }
29
29
  end
30
30
 
31
- it_validates "option range", :type_of_service, 0..( 2 ** 8 - 1 )
32
- end
33
-
34
-
35
- describe SetIpTos, %{.new( "32" )} do
36
- it { expect { SetIpTos.new( "32" ) }.to raise_error( TypeError ) }
37
- end
31
+ it_validates "option is within range", :type_of_service, 0..( 2 ** 8 - 1 )
38
32
 
33
+ context %{with type_of_service ("32")} do
34
+ let( :type_of_service ) { "32" }
35
+ it { expect { subject }.to raise_error( TypeError ) }
36
+ end
39
37
 
40
- describe SetIpTos, ".new( [ 32 ] )" do
41
- it { expect { SetIpTos.new( [ 32 ] ) }.to raise_error( TypeError ) }
42
- end
38
+ context %{with type_of_service ([32])} do
39
+ let( :type_of_service ) { [ 32 ] }
40
+ it { expect { subject }.to raise_error( TypeError ) }
41
+ end
43
42
 
43
+ context "when sending a Flow Mod with SetIpTos" do
44
+ let( :type_of_service ) { 4 }
44
45
 
45
- describe SetIpTos, ".new( VALID OPTION )" do
46
- context "when sending #flow_mod(add) with action set to mod_nw_tos" do
47
- it "should have a flow with action set to mod_nw_tos" do
48
- class FlowModAddController < Controller; end
46
+ it "should insert a new flow entry with action (mod_nw_tos:4)" do
47
+ class TestController < Controller; end
49
48
  network {
50
49
  vswitch { datapath_id 0xabc }
51
- }.run( FlowModAddController ) {
52
- controller( "FlowModAddController" ).send_flow_mod_add( 0xabc, :actions => SetIpTos.new( 4 ) )
53
- sleep 2 # FIXME: wait to send_flow_mod_add
54
- vswitch( "0xabc" ).should have( 1 ).flows
55
- vswitch( "0xabc" ).flows[0].actions.should match( /mod_nw_tos:4/ )
50
+ }.run( TestController ) {
51
+ controller( "TestController" ).send_flow_mod_add( 0xabc, :actions => subject )
52
+ sleep 2
53
+ expect( vswitch( "0xabc" ) ).to have( 1 ).flows
54
+ expect( vswitch( "0xabc" ).flows[ 0 ].actions ).to eq( "mod_nw_tos:4" )
56
55
  }
57
56
  end
58
57
  end
@@ -20,39 +20,38 @@ require File.join( File.dirname( __FILE__ ), "..", "spec_helper" )
20
20
  require "trema"
21
21
 
22
22
 
23
- describe SetTransportDstPort, "new( number )" do
24
- subject { SetTransportDstPort.new number }
23
+ describe SetTransportDstPort, "new( port_number )", :type => "actions" do
24
+ subject { SetTransportDstPort.new port_number }
25
25
 
26
- context "when number == 5555" do
27
- let( :number ) { 5555 }
26
+ context "with port_number (5555)" do
27
+ let( :port_number ) { 5555 }
28
28
  its( :port_number ) { should == 5555 }
29
29
  end
30
30
 
31
- it_validates "option range", :number, 0..( 2 ** 16 - 1 )
32
- end
33
-
34
-
35
- describe SetTransportDstPort, ".new( string )" do
36
- it { expect { SetTransportDstPort.new( "5555" ) }.to raise_error( TypeError ) }
37
- end
31
+ it_validates "option is within range", :port_number, 0..( 2 ** 16 - 1 )
38
32
 
33
+ context %{with invalid port_number ("5555")} do
34
+ let( :port_number ) { "5555" }
35
+ it { expect { subject }.to raise_error( TypeError ) }
36
+ end
39
37
 
40
- describe SetTransportDstPort, ".new( array )" do
41
- it { expect { SetTransportDstPort.new( [ 1, 2, 3 ] ) }.to raise_error( TypeError ) }
42
- end
38
+ context %{with invalid port_number ([1, 2, 3])} do
39
+ let( :port_number ) { [ 1, 2, 3 ] }
40
+ it { expect { subject }.to raise_error( TypeError ) }
41
+ end
43
42
 
43
+ context "when sending a Flow Mod with SetTransportDstPort" do
44
+ let( :port_number ) { 5555 }
44
45
 
45
- describe SetTransportDstPort, ".new( VALID OPTION )" do
46
- context "when sending #flow_mod(add) with action set to mod_tp_dst" do
47
- it "should have a flow with action set to mod_tp_dst" do
48
- class FlowModAddController < Controller; end
46
+ it "should insert a new flow entry with action (mod_tp_dst:5555)" do
47
+ class TestController < Controller; end
49
48
  network {
50
49
  vswitch { datapath_id 0xabc }
51
- }.run( FlowModAddController ) {
52
- controller( "FlowModAddController" ).send_flow_mod_add( 0xabc, :actions => SetTransportDstPort.new( 5555 ) )
53
- sleep 2 # FIXME: wait to send_flow_mod_add
54
- vswitch( "0xabc" ).should have( 1 ).flows
55
- vswitch( "0xabc" ).flows[0].actions.should match( /mod_tp_dst:5555/ )
50
+ }.run( TestController ) {
51
+ controller( "TestController" ).send_flow_mod_add( 0xabc, :actions => subject )
52
+ sleep 2
53
+ expect( vswitch( "0xabc" ) ).to have( 1 ).flows
54
+ expect( vswitch( "0xabc" ).flows[ 0 ].actions ).to eq( "mod_tp_dst:5555" )
56
55
  }
57
56
  end
58
57
  end
@@ -20,39 +20,38 @@ require File.join( File.dirname( __FILE__ ), "..", "spec_helper" )
20
20
  require "trema"
21
21
 
22
22
 
23
- describe SetTransportSrcPort, "new( number )" do
24
- subject { SetTransportSrcPort.new number }
23
+ describe SetTransportSrcPort, "new( port_number )", :type => "actions" do
24
+ subject { SetTransportSrcPort.new port_number }
25
25
 
26
- context "when number == 5555" do
27
- let( :number ) { 5555 }
26
+ context "with port_number (5555)" do
27
+ let( :port_number ) { 5555 }
28
28
  its( :port_number ) { should == 5555 }
29
29
  end
30
30
 
31
- it_validates "option range", :number, 0..( 2 ** 16 - 1 )
32
- end
33
-
34
-
35
- describe SetTransportSrcPort, ".new( string )" do
36
- it { expect { SetTransportSrcPort.new( "5555" ) }.to raise_error( TypeError ) }
37
- end
31
+ it_validates "option is within range", :port_number, 0..( 2 ** 16 - 1 )
38
32
 
33
+ context %{with invalid port_number ("5555")} do
34
+ let( :port_number ) { "5555" }
35
+ it { expect { subject }.to raise_error( TypeError ) }
36
+ end
39
37
 
40
- describe SetTransportSrcPort, ".new( array )" do
41
- it { expect { SetTransportSrcPort.new( [ 1, 2, 3 ] ) }.to raise_error( TypeError ) }
42
- end
38
+ context %{with invalid port_number ([1, 2, 3])} do
39
+ let( :port_number ) { [ 1, 2, 3 ] }
40
+ it { expect { subject }.to raise_error( TypeError ) }
41
+ end
43
42
 
43
+ context "when sending a Flow Mod with SetTransportSrcPort" do
44
+ let( :port_number ) { 5555 }
44
45
 
45
- describe SetTransportSrcPort, ".new( VALID OPTION )" do
46
- context "when sending #flow_mod(add) with action set to mod_tp_src" do
47
- it "should have a flow with action set to mod_tp_src" do
48
- class FlowModAddController < Controller; end
46
+ it "should insert a new flow entry with action (mod_tp_src:5555)" do
47
+ class TestController < Controller; end
49
48
  network {
50
49
  vswitch { datapath_id 0xabc }
51
- }.run( FlowModAddController ) {
52
- controller( "FlowModAddController" ).send_flow_mod_add( 0xabc, :actions => SetTransportSrcPort.new( 5555 ) )
53
- sleep 2 # FIXME: wait to send_flow_mod_add
54
- vswitch( "0xabc" ).should have( 1 ).flows
55
- vswitch( "0xabc" ).flows[0].actions.should match( /mod_tp_src:5555/ )
50
+ }.run( TestController ) {
51
+ controller( "TestController" ).send_flow_mod_add( 0xabc, :actions => subject )
52
+ sleep 2
53
+ expect( vswitch( "0xabc" ) ).to have( 1 ).flows
54
+ expect( vswitch( "0xabc" ).flows[ 0 ].actions ).to eq( "mod_tp_src:5555" )
56
55
  }
57
56
  end
58
57
  end
@@ -20,39 +20,38 @@ require File.join( File.dirname( __FILE__ ), "..", "spec_helper" )
20
20
  require "trema"
21
21
 
22
22
 
23
- describe SetVlanPriority, ".new( number )" do
23
+ describe SetVlanPriority, ".new(vlan_priority)", :type => "actions" do
24
24
  subject { SetVlanPriority.new( vlan_priority ) }
25
25
 
26
- context "when vlan_priority == 4" do
26
+ context "with vlan_priority (4)" do
27
27
  let( :vlan_priority ) { 4 }
28
28
  its( :vlan_priority ) { should == 4 }
29
29
  end
30
30
 
31
- it_validates "option range", :vlan_priority, 0..7
32
- end
33
-
34
-
35
- describe SetVlanPriority, %{.new( "4" )} do
36
- it { expect { SetVlanPriority.new( "4" ) }.to raise_error( TypeError ) }
37
- end
31
+ it_validates "option is within range", :vlan_priority, 0..7
38
32
 
33
+ context %{with vlan_priority ("4")} do
34
+ let( :vlan_priority ) { "4" }
35
+ it { expect { subject }.to raise_error( TypeError ) }
36
+ end
39
37
 
40
- describe SetVlanPriority, ".new( [ 4 ] )" do
41
- it { expect { SetVlanPriority.new( [ 4 ] ) }.to raise_error( TypeError ) }
42
- end
38
+ context "with vlan_priority ([4])" do
39
+ let( :vlan_priority ) { [ 4 ] }
40
+ it { expect { subject }.to raise_error( TypeError ) }
41
+ end
43
42
 
43
+ context "when sending a Flow Mod with SetVlanVid" do
44
+ let( :vlan_priority ) { 7 }
44
45
 
45
- describe SetVlanPriority, ".new( VALID OPTION )" do
46
- context "when sending #flow_mod(add) with action set to mod_vlan_pcp" do
47
- it "should have a flow with action set to mod_vlan_pcp" do
48
- class FlowModAddController < Controller; end
46
+ it "should insert a new flow with action (mod_vlan_pcp:7)" do
47
+ class TestController < Controller; end
49
48
  network {
50
49
  vswitch { datapath_id 0xabc }
51
- }.run( FlowModAddController ) {
52
- controller( "FlowModAddController" ).send_flow_mod_add( 0xabc, :actions => SetVlanPriority.new( 7 ) )
53
- sleep 2 # FIXME: wait to send_flow_mod_add
54
- vswitch( "0xabc" ).should have( 1 ).flows
55
- vswitch( "0xabc" ).flows[0].actions.should match( /mod_vlan_pcp:7/ )
50
+ }.run( TestController ) {
51
+ controller( "TestController" ).send_flow_mod_add( 0xabc, :actions => subject )
52
+ sleep 2
53
+ expect( vswitch( "0xabc" ) ).to have( 1 ).flows
54
+ expect( vswitch( "0xabc" ).flows[ 0 ].actions ).to eq( "mod_vlan_pcp:7" )
56
55
  }
57
56
  end
58
57
  end
@@ -20,39 +20,38 @@ require File.join( File.dirname( __FILE__ ), "..", "spec_helper" )
20
20
  require "trema"
21
21
 
22
22
 
23
- describe SetVlanVid, ".new( number )" do
23
+ describe SetVlanVid, ".new(vlan_id)", :type => "actions" do
24
24
  subject { SetVlanVid.new( vlan_id ) }
25
25
 
26
- context "when vlan_id == 1024" do
26
+ context "with vlan_id (1024)" do
27
27
  let( :vlan_id ) { 1024 }
28
28
  its( :vlan_id ) { should == 1024 }
29
29
  end
30
30
 
31
- it_validates "option range", :vlan_id, 1..4095
32
- end
33
-
34
-
35
- describe SetVlanVid, %{.new( "1024" )} do
36
- it { expect { SetVlanVid.new( "1024" ) }.to raise_error( TypeError ) }
37
- end
31
+ it_validates "option is within range", :vlan_id, 1..4095
38
32
 
33
+ context %{with vlan_id ("1024")} do
34
+ let( :vlan_id ) { "1024" }
35
+ it { expect { subject }.to raise_error( TypeError ) }
36
+ end
39
37
 
40
- describe SetVlanVid, ".new( [ 1024 ] )" do
41
- it { expect { SetVlanVid.new( [ 1024 ] ) }.to raise_error( TypeError ) }
42
- end
38
+ context "with vlan_id ([1024])" do
39
+ let( :vlan_id ) { [ 1024 ] }
40
+ it { expect { subject }.to raise_error( TypeError ) }
41
+ end
43
42
 
43
+ context "when sending a Flow Mod with SetVlanVid" do
44
+ let( :vlan_id ) { 1024 }
44
45
 
45
- describe SetVlanVid, ".new( VALID OPTION )" do
46
- context "when sending #flow_mod(add) with action set to mod_vlan_vid" do
47
- it "should have a flow with action set to mod_vlan_vid" do
48
- class FlowModAddController < Controller; end
46
+ it "should insert a new flow entry with action (mod_vlan_vid:1024)" do
47
+ class TestController < Controller; end
49
48
  network {
50
49
  vswitch { datapath_id 0xabc }
51
- }.run( FlowModAddController ) {
52
- controller( "FlowModAddController" ).send_flow_mod_add( 0xabc, :actions => SetVlanVid.new( 1024 ) )
53
- sleep 2 # FIXME: wait to send_flow_mod_add
54
- vswitch( "0xabc" ).should have( 1 ).flows
55
- vswitch( "0xabc" ).flows[0].actions.should match( /mod_vlan_vid:1024/ )
50
+ }.run( TestController ) {
51
+ controller( "TestController" ).send_flow_mod_add( 0xabc, :actions => subject )
52
+ sleep 2
53
+ expect( vswitch( "0xabc" ) ).to have( 1 ).flows
54
+ expect( vswitch( "0xabc" ).flows[ 0 ].actions ).to eq( "mod_vlan_vid:1024" )
56
55
  }
57
56
  end
58
57
  end
@@ -31,8 +31,8 @@ describe Trema::Shell, ".vhost" do
31
31
  it "should create a new vhost if name given" do
32
32
  Trema::Shell.vhost( "host1" )
33
33
 
34
- Trema::Host.should have( 1 ).host
35
- Trema::Host[ "host1" ].name.should == "host1"
34
+ expect( Trema::Host ).to have( 1 ).host
35
+ expect( Trema::Host[ "host1" ].name ).to eq( "host1" )
36
36
  end
37
37
 
38
38
 
@@ -44,11 +44,11 @@ describe Trema::Shell, ".vhost" do
44
44
  mac "00:00:00:1:1:1"
45
45
  }
46
46
 
47
- Trema::Host.should have( 1 ).host
48
- Trema::Host[ "host1" ].name.should == "host1"
49
- Trema::Host[ "host1" ].ip.should == "192.168.100.1"
50
- Trema::Host[ "host1" ].promisc.should be_true
51
- Trema::Host[ "host1" ].mac.should == "00:00:00:1:1:1"
47
+ expect( Trema::Host ).to have( 1 ).host
48
+ expect( Trema::Host[ "host1" ].name ).to eq( "host1" )
49
+ expect( Trema::Host[ "host1" ].ip ).to eq( "192.168.100.1" )
50
+ expect( Trema::Host[ "host1" ].promisc ).to be_true
51
+ expect( Trema::Host[ "host1" ].mac ).to eq( "00:00:00:1:1:1" )
52
52
  end
53
53
  end
54
54
 
@@ -51,20 +51,20 @@ describe Trema::Shell, ".vswitch" do
51
51
 
52
52
  it "should create a new vswitch if name given" do
53
53
  Trema::Shell.vswitch { dpid "0xabc" }
54
- Trema::OpenflowSwitch.should have( 1 ).switch
55
- Trema::OpenflowSwitch[ "0xabc" ].name.should == "0xabc"
56
- Trema::OpenflowSwitch[ "0xabc" ].dpid_short.should == "0xabc"
57
- Trema::OpenflowSwitch[ "0xabc" ].dpid_long.should == "0000000000000abc"
54
+ expect( Trema::OpenflowSwitch ).to have( 1 ).switch
55
+ expect( Trema::OpenflowSwitch[ "0xabc" ].name ).to eq( "0xabc" )
56
+ expect( Trema::OpenflowSwitch[ "0xabc" ].dpid_short ).to eq( "0xabc" )
57
+ expect( Trema::OpenflowSwitch[ "0xabc" ].dpid_long ).to eq( "0000000000000abc" )
58
58
  end
59
59
 
60
60
 
61
61
  it "should create a new vswitch if dpid given" do
62
62
  Trema::Shell.vswitch "0xabc"
63
63
 
64
- Trema::OpenflowSwitch.should have( 1 ).switch
65
- Trema::OpenflowSwitch[ "0xabc" ].name.should == "0xabc"
66
- Trema::OpenflowSwitch[ "0xabc" ].dpid_short.should == "0xabc"
67
- Trema::OpenflowSwitch[ "0xabc" ].dpid_long.should == "0000000000000abc"
64
+ expect( Trema::OpenflowSwitch ).to have( 1 ).switch
65
+ expect( Trema::OpenflowSwitch[ "0xabc" ].name ).to eq( "0xabc" )
66
+ expect( Trema::OpenflowSwitch[ "0xabc" ].dpid_short ).to eq( "0xabc" )
67
+ expect( Trema::OpenflowSwitch[ "0xabc" ].dpid_long ).to eq( "0000000000000abc" )
68
68
  end
69
69
 
70
70
 
@@ -190,11 +190,11 @@ describe StatsReply, ".new( VALID OPTIONS )" do
190
190
  vswitch( "desc-stats" ) { datapath_id 0xabc }
191
191
  }.run( DescStatsController ) {
192
192
  controller( "DescStatsController" ).should_receive( :stats_reply ) do | datapath_id, message |
193
- datapath_id.should == 0xabc
194
- message.type.should == 0
195
- message.stats[ 0 ].mfr_desc.should eq( "Nicira Networks, Inc." )
196
- message.stats[ 0 ].hw_desc.should eq( "Open vSwitch" )
197
- message.stats[ 0 ].should respond_to :to_s
193
+ expect( datapath_id ).to eq( 0xabc )
194
+ expect( message.type ).to eq( 0 )
195
+ expect( message.stats[ 0 ].mfr_desc ).to eq( "Nicira Networks, Inc." )
196
+ expect( message.stats[ 0 ].hw_desc ).to eq( "Open vSwitch" )
197
+ expect( message.stats[ 0 ] ).to respond_to :to_s
198
198
  end
199
199
 
200
200
  controller( "DescStatsController" ).send_message( 0xabc,
@@ -228,10 +228,10 @@ describe StatsReply, ".new( VALID OPTIONS )" do
228
228
  sleep 2 # FIXME: wait to send_packets
229
229
 
230
230
  controller( "FlowStatsController" ).should_receive( :stats_reply ) do | datapath_id, message |
231
- datapath_id.should == 0xabc
232
- message.type.should == 1
233
- message.stats[ 0 ].packet_count.should == 2
234
- message.stats[ 0 ].should respond_to :to_s
231
+ expect( datapath_id ).to eq( 0xabc )
232
+ expect( message.type ).to eq( 1 )
233
+ expect( message.stats[ 0 ].packet_count ).to eq( 2 )
234
+ expect( message.stats[ 0 ] ).to respond_to :to_s
235
235
  end
236
236
  match = Match.new( :dl_type =>0x800, :nw_proto => 17 )
237
237
  controller( "FlowStatsController" ).send_message( 0xabc,
@@ -265,11 +265,11 @@ describe StatsReply, ".new( VALID OPTIONS )" do
265
265
  sleep 2 # FIXME: wait to send_packets
266
266
 
267
267
  controller( "AggregateStatsController" ).should_receive( :stats_reply ) do | datapath_id, message |
268
- datapath_id.should == 0xabc
269
- message.type.should == 2
270
- message.stats[ 0 ].packet_count.should == 10
271
- message.stats[ 0 ].flow_count.should == 1
272
- message.stats[ 0 ].should respond_to :to_s
268
+ expect( datapath_id ).to eq( 0xabc )
269
+ expect( message.type ).to eq( 2 )
270
+ expect( message.stats[ 0 ].packet_count ).to eq( 10 )
271
+ expect( message.stats[ 0 ].flow_count ).to eq( 1 )
272
+ expect( message.stats[ 0 ] ).to respond_to :to_s
273
273
  end
274
274
  match = Match.new( :dl_type =>0x800, :nw_proto => 17 )
275
275
  controller( "AggregateStatsController" ).send_message( 0xabc,
@@ -300,10 +300,10 @@ describe StatsReply, ".new( VALID OPTIONS )" do
300
300
  sleep 2 # FIXME: wait to send_packets
301
301
 
302
302
  controller( "PortStatsController" ).should_receive( :stats_reply ) do | datapath_id, message |
303
- datapath_id.should == 0xabc
304
- message.type.should == 4
305
- message.stats[ 0 ].should be_an_instance_of( Trema::PortStatsReply )
306
- message.stats[ 0 ].should respond_to :to_s
303
+ expect( datapath_id ).to eq( 0xabc )
304
+ expect( message.type ).to eq( 4 )
305
+ expect( message.stats[ 0 ] ).to be_an_instance_of( Trema::PortStatsReply )
306
+ expect( message.stats[ 0 ] ).to respond_to :to_s
307
307
  end
308
308
  controller( "PortStatsController" ).send_message( 0xabc,
309
309
  PortStatsRequest.new( :port_no => 1 ) )
@@ -332,11 +332,11 @@ describe StatsReply, ".new( VALID OPTIONS )" do
332
332
  sleep 2 # FIXME: wait to send_packets
333
333
 
334
334
  controller( "TableStatsController" ).should_receive( :stats_reply ) do | datapath_id, message |
335
- datapath_id.should == 0xabc
336
- message.type.should == 3
337
- message.transaction_id.should == 123
338
- message.stats[ 0 ].should be_an_instance_of(Trema::TableStatsReply)
339
- message.stats[ 0 ].should respond_to :to_s
335
+ expect( datapath_id ).to eq( 0xabc )
336
+ expect( message.type ).to eq( 3 )
337
+ expect( message.transaction_id ).to eq( 123 )
338
+ expect( message.stats[ 0 ] ).to be_an_instance_of(Trema::TableStatsReply)
339
+ expect( message.stats[ 0 ] ).to respond_to :to_s
340
340
  end
341
341
  controller( "TableStatsController" ).send_message( 0xabc,
342
342
  TableStatsRequest.new( :transaction_id => 123 ) )
@@ -20,17 +20,17 @@ require File.join( File.dirname( __FILE__ ), "..", "spec_helper" )
20
20
  require "trema"
21
21
 
22
22
 
23
- describe StripVlanHeader, ".new" do
24
- context "when sending #flow_mod(add) with action set to strip_vlan" do
25
- it "should have a flow with action set to strip_vlan" do
26
- class FlowModAddController < Controller; end
23
+ describe StripVlanHeader, :type => "actions" do
24
+ context "when sending a Flow Mod with StripVlanHeader" do
25
+ it "should insert a new flow entry with action (strip_vlan)" do
26
+ class TestController < Controller; end
27
27
  network {
28
28
  vswitch { datapath_id 0xabc }
29
- }.run( FlowModAddController ) {
30
- controller( "FlowModAddController" ).send_flow_mod_add( 0xabc, :actions => StripVlanHeader.new )
31
- sleep 2 # FIXME: wait to send_flow_mod_add
32
- vswitch( "0xabc" ).should have( 1 ).flows
33
- vswitch( "0xabc" ).flows[ 0 ].actions.should match( /strip_vlan/ )
29
+ }.run( TestController ) {
30
+ controller( "TestController" ).send_flow_mod_add( 0xabc, :actions => subject )
31
+ sleep 2
32
+ expect( vswitch( "0xabc" ) ).to have( 1 ).flows
33
+ expect( vswitch( "0xabc" ).flows[ 0 ].actions ).to eq( "strip_vlan" )
34
34
  }
35
35
  end
36
36
  end