trema 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/ruby/trema/flow-removed.c +3 -0
- data/ruby/trema/match.c +19 -0
- data/ruby/trema/packet-in.c +3 -0
- data/ruby/trema/port.c +12 -0
- data/ruby/trema/send-out-port.rb +1 -1
- data/ruby/trema/version.rb +1 -1
- data/spec/spec_helper.rb +8 -0
- data/spec/support/action.rb +4 -4
- data/spec/trema/barrier-request_spec.rb +1 -1
- data/spec/trema/cli_spec.rb +1 -3
- data/spec/trema/controller_spec.rb +1 -1
- data/spec/trema/dsl/configuration_spec.rb +24 -24
- data/spec/trema/dsl/link_spec.rb +4 -6
- data/spec/trema/dsl/run_spec.rb +7 -11
- data/spec/trema/dsl/runner_spec.rb +9 -9
- data/spec/trema/dsl/switch_spec.rb +5 -11
- data/spec/trema/dsl/vhost_spec.rb +1 -3
- data/spec/trema/dsl/vswitch_spec.rb +7 -15
- data/spec/trema/echo-request_spec.rb +1 -1
- data/spec/trema/enqueue_spec.rb +4 -4
- data/spec/trema/features-reply_spec.rb +1 -1
- data/spec/trema/features-request_spec.rb +1 -1
- data/spec/trema/flow-removed_spec.rb +19 -19
- data/spec/trema/get-config-request_spec.rb +1 -1
- data/spec/trema/hardware-switch_spec.rb +3 -3
- data/spec/trema/host_spec.rb +2 -2
- data/spec/trema/list-switches-reply_spec.rb +1 -1
- data/spec/trema/mac_spec.rb +1 -1
- data/spec/trema/match_spec.rb +8 -8
- data/spec/trema/open-vswitch_spec.rb +6 -6
- data/spec/trema/openflow-error_spec.rb +15 -15
- data/spec/trema/packet-in_spec.rb +210 -208
- data/spec/trema/packet-out_spec.rb +4 -6
- data/spec/trema/port-mod_spec.rb +28 -29
- data/spec/trema/port-status-modify_spec.rb +2 -2
- data/spec/trema/port_spec.rb +9 -9
- data/spec/trema/queue-get-config-reply_spec.rb +2 -2
- data/spec/trema/send-out-port_spec.rb +53 -43
- data/spec/trema/set-config_spec.rb +2 -2
- data/spec/trema/set-eth-dst-addr_spec.rb +3 -3
- data/spec/trema/set-eth-src-addr_spec.rb +3 -3
- data/spec/trema/set-ip-dst-addr_spec.rb +20 -16
- data/spec/trema/set-ip-src-addr_spec.rb +20 -16
- data/spec/trema/set-ip-tos_spec.rb +20 -21
- data/spec/trema/set-transport-dst-port_spec.rb +22 -23
- data/spec/trema/set-transport-src-port_spec.rb +22 -23
- data/spec/trema/set-vlan-priority_spec.rb +20 -21
- data/spec/trema/set-vlan-vid_spec.rb +20 -21
- data/spec/trema/shell/vhost_spec.rb +7 -7
- data/spec/trema/shell/vswitch_spec.rb +8 -8
- data/spec/trema/stats-reply_spec.rb +23 -23
- data/spec/trema/strip-vlan-header_spec.rb +9 -9
- data/spec/trema/switch-daemon_spec.rb +15 -15
- data/spec/trema/util_spec.rb +2 -6
- data/spec/trema/vendor-action_spec.rb +24 -36
- metadata +4 -4
data/ruby/trema/flow-removed.c
CHANGED
@@ -223,6 +223,9 @@ flow_removed_byte_count( VALUE self ) {
|
|
223
223
|
void
|
224
224
|
Init_flow_removed() {
|
225
225
|
cFlowRemoved = rb_define_class_under( mTrema, "FlowRemoved", rb_cObject );
|
226
|
+
rb_define_const( cFlowRemoved, "OFPRR_IDLE_TIMEOUT", INT2NUM( OFPRR_IDLE_TIMEOUT ) );
|
227
|
+
rb_define_const( cFlowRemoved, "OFPRR_HARD_TIMEOUT", INT2NUM( OFPRR_HARD_TIMEOUT ) );
|
228
|
+
rb_define_const( cFlowRemoved, "OFPRR_DELETE", INT2NUM( OFPRR_DELETE ) );
|
226
229
|
rb_define_method( cFlowRemoved, "initialize", flow_removed_init, 1 );
|
227
230
|
rb_define_method( cFlowRemoved, "datapath_id", flow_removed_datapath_id, 0 );
|
228
231
|
rb_define_method( cFlowRemoved, "transaction_id", flow_removed_transaction_id, 0 );
|
data/ruby/trema/match.c
CHANGED
@@ -564,6 +564,25 @@ void
|
|
564
564
|
Init_match() {
|
565
565
|
cMatch = rb_define_class_under( mTrema, "Match", rb_cObject );
|
566
566
|
rb_define_alloc_func( cMatch, match_alloc );
|
567
|
+
rb_define_const( cMatch, "OFPFW_IN_PORT", INT2NUM( OFPFW_IN_PORT ) );
|
568
|
+
rb_define_const( cMatch, "OFPFW_DL_VLAN", INT2NUM( OFPFW_DL_VLAN ) );
|
569
|
+
rb_define_const( cMatch, "OFPFW_DL_SRC", INT2NUM( OFPFW_DL_SRC ) );
|
570
|
+
rb_define_const( cMatch, "OFPFW_DL_DST", INT2NUM( OFPFW_DL_DST ) );
|
571
|
+
rb_define_const( cMatch, "OFPFW_DL_TYPE", INT2NUM( OFPFW_DL_TYPE ) );
|
572
|
+
rb_define_const( cMatch, "OFPFW_NW_PROTO", INT2NUM( OFPFW_NW_PROTO ) );
|
573
|
+
rb_define_const( cMatch, "OFPFW_TP_SRC", INT2NUM( OFPFW_TP_SRC ) );
|
574
|
+
rb_define_const( cMatch, "OFPFW_TP_DST", INT2NUM( OFPFW_TP_DST ) );
|
575
|
+
rb_define_const( cMatch, "OFPFW_NW_SRC_SHIFT", INT2NUM( OFPFW_NW_SRC_SHIFT ) );
|
576
|
+
rb_define_const( cMatch, "OFPFW_NW_SRC_BITS", INT2NUM( OFPFW_NW_SRC_BITS ) );
|
577
|
+
rb_define_const( cMatch, "OFPFW_NW_SRC_MASK", INT2NUM( OFPFW_NW_SRC_MASK ) );
|
578
|
+
rb_define_const( cMatch, "OFPFW_NW_SRC_ALL", INT2NUM( OFPFW_NW_SRC_ALL ) );
|
579
|
+
rb_define_const( cMatch, "OFPFW_NW_DST_SHIFT", INT2NUM( OFPFW_NW_DST_SHIFT ) );
|
580
|
+
rb_define_const( cMatch, "OFPFW_NW_DST_BITS", INT2NUM( OFPFW_NW_DST_BITS ) );
|
581
|
+
rb_define_const( cMatch, "OFPFW_NW_DST_MASK", INT2NUM( OFPFW_NW_DST_MASK ) );
|
582
|
+
rb_define_const( cMatch, "OFPFW_NW_DST_ALL", INT2NUM( OFPFW_NW_DST_ALL ) );
|
583
|
+
rb_define_const( cMatch, "OFPFW_DL_VLAN_PCP", INT2NUM( OFPFW_DL_VLAN_PCP ) );
|
584
|
+
rb_define_const( cMatch, "OFPFW_NW_TOS", INT2NUM( OFPFW_NW_TOS ) );
|
585
|
+
rb_define_const( cMatch, "OFPFW_ALL", INT2NUM( OFPFW_ALL ) );
|
567
586
|
rb_define_method( cMatch, "initialize", match_init, -1 );
|
568
587
|
rb_define_method( cMatch, "compare", match_compare, 1 );
|
569
588
|
rb_define_method( cMatch, "replace", match_replace, 1 );
|
data/ruby/trema/packet-in.c
CHANGED
@@ -1083,6 +1083,9 @@ Init_packet_in() {
|
|
1083
1083
|
cPacketIn = rb_define_class_under( mTrema, "PacketIn", rb_cObject );
|
1084
1084
|
rb_define_alloc_func( cPacketIn, packet_in_alloc );
|
1085
1085
|
|
1086
|
+
rb_define_const( cPacketIn, "OFPR_NO_MATCH", INT2NUM( OFPR_NO_MATCH ) );
|
1087
|
+
rb_define_const( cPacketIn, "OFPR_ACTION", INT2NUM( OFPR_ACTION ) );
|
1088
|
+
|
1086
1089
|
rb_define_method( cPacketIn, "initialize_copy", packet_in_init_copy, 1 );
|
1087
1090
|
|
1088
1091
|
rb_define_method( cPacketIn, "datapath_id", packet_in_datapath_id, 0 );
|
data/ruby/trema/port.c
CHANGED
@@ -304,6 +304,18 @@ Init_port() {
|
|
304
304
|
|
305
305
|
rb_define_const( cPort, "OFPPC_PORT_DOWN", INT2NUM( OFPPC_PORT_DOWN ) );
|
306
306
|
rb_define_const( cPort, "OFPPS_LINK_DOWN", INT2NUM( OFPPS_LINK_DOWN ) );
|
307
|
+
rb_define_const( cPort, "OFPPF_10MB_HD", INT2NUM( OFPPF_10MB_HD ) );
|
308
|
+
rb_define_const( cPort, "OFPPF_10MB_FD", INT2NUM( OFPPF_10MB_FD ) );
|
309
|
+
rb_define_const( cPort, "OFPPF_100MB_HD", INT2NUM( OFPPF_100MB_HD ) );
|
310
|
+
rb_define_const( cPort, "OFPPF_100MB_FD", INT2NUM( OFPPF_100MB_FD ) );
|
311
|
+
rb_define_const( cPort, "OFPPF_1GB_HD", INT2NUM( OFPPF_1GB_HD ) );
|
312
|
+
rb_define_const( cPort, "OFPPF_1GB_FD", INT2NUM( OFPPF_1GB_FD ) );
|
313
|
+
rb_define_const( cPort, "OFPPF_10GB_FD", INT2NUM( OFPPF_10GB_FD ) );
|
314
|
+
rb_define_const( cPort, "OFPPF_COPPER", INT2NUM( OFPPF_COPPER ) );
|
315
|
+
rb_define_const( cPort, "OFPPF_FIBER", INT2NUM( OFPPF_FIBER ) );
|
316
|
+
rb_define_const( cPort, "OFPPF_AUTONEG", INT2NUM( OFPPF_AUTONEG ) );
|
317
|
+
rb_define_const( cPort, "OFPPF_PAUSE", INT2NUM( OFPPF_PAUSE ) );
|
318
|
+
rb_define_const( cPort, "OFPPF_PAUSE_ASYM", INT2NUM( OFPPF_PAUSE_ASYM ) );
|
307
319
|
|
308
320
|
rb_define_method( cPort, "initialize", port_init, 1 );
|
309
321
|
rb_define_method( cPort, "number", port_number, 0 );
|
data/ruby/trema/send-out-port.rb
CHANGED
data/ruby/trema/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -41,6 +41,14 @@ Dir[ "#{ File.dirname( __FILE__ ) }/support/**/*.rb" ].each do | each |
|
|
41
41
|
end
|
42
42
|
|
43
43
|
|
44
|
+
RSpec.configure do | config |
|
45
|
+
config.expect_with :rspec do | c |
|
46
|
+
# Ensure that 'expect' is used and disable 'should' for consistency
|
47
|
+
c.syntax = :expect
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
|
44
52
|
include Trema
|
45
53
|
|
46
54
|
|
data/spec/support/action.rb
CHANGED
@@ -20,20 +20,20 @@ require "rubygems"
|
|
20
20
|
require "rspec"
|
21
21
|
|
22
22
|
|
23
|
-
shared_examples_for "option range" do | option, range |
|
24
|
-
context "
|
23
|
+
shared_examples_for "option is within range" do | option, range |
|
24
|
+
context "with #{ option } (#{ range })" do
|
25
25
|
let( option ) { range.first }
|
26
26
|
it { expect { subject }.not_to raise_error( ArgumentError ) }
|
27
27
|
end
|
28
28
|
|
29
29
|
|
30
|
-
context "
|
30
|
+
context "with #{ option } (< #{ range.first })" do
|
31
31
|
let( option ) { range.first - 1 }
|
32
32
|
it { expect { subject }.to raise_error( ArgumentError ) }
|
33
33
|
end
|
34
34
|
|
35
35
|
|
36
|
-
context "
|
36
|
+
context "with #{ option } (> #{ range.last })" do
|
37
37
|
let( option ) { range.last + 1 }
|
38
38
|
it { expect { subject }.to raise_error( ArgumentError ) }
|
39
39
|
end
|
@@ -28,7 +28,7 @@ shared_examples_for "barrier request message" do
|
|
28
28
|
vswitch( "barrier-request" ) { datapath_id 0xabc }
|
29
29
|
}.run( BarrierRequestController ) {
|
30
30
|
controller( "BarrierRequestController" ).send_message( 0xabc, subject )
|
31
|
-
IO.read( File.join( Trema.log, "openflowd.barrier-request.log" ) ).
|
31
|
+
expect( IO.read( File.join( Trema.log, "openflowd.barrier-request.log" ) ) ).to include( "OFPT_BARRIER_REQUEST" )
|
32
32
|
}
|
33
33
|
end
|
34
34
|
end
|
data/spec/trema/cli_spec.rb
CHANGED
@@ -135,9 +135,7 @@ module Trema
|
|
135
135
|
|
136
136
|
|
137
137
|
it "should raise if both --duration and --n_pkts are specified" do
|
138
|
-
|
139
|
-
@cli.send_packets( @dest, :duration => 10, :n_pkts => 10 )
|
140
|
-
end.should raise_error( "--duration and --n_pkts are exclusive." )
|
138
|
+
expect { @cli.send_packets( @dest, :duration => 10, :n_pkts => 10 ) }.to raise_error( "--duration and --n_pkts are exclusive." )
|
141
139
|
end
|
142
140
|
end
|
143
141
|
|
@@ -58,7 +58,7 @@ module Trema
|
|
58
58
|
}.run( FlowModAddController ) {
|
59
59
|
controller( "FlowModAddController" ).send_flow_mod_add( 0xabc )
|
60
60
|
sleep 20 # FIXME: wait to send_flow_mod_add
|
61
|
-
vswitch( "0xabc" ).
|
61
|
+
expect( vswitch( "0xabc" ) ).to have( 1 ).flows
|
62
62
|
}
|
63
63
|
end
|
64
64
|
end
|
@@ -32,82 +32,82 @@ module Trema
|
|
32
32
|
|
33
33
|
context "when parsing trema configurations" do
|
34
34
|
it "should remember apps" do
|
35
|
-
@context.
|
35
|
+
expect( @context ).to have( 0 ).apps
|
36
36
|
|
37
37
|
Trema::App.add mock( "app #0", :name => "app #0" )
|
38
38
|
Trema::App.add mock( "app #1", :name => "app #1" )
|
39
39
|
Trema::App.add mock( "app #2", :name => "app #2" )
|
40
40
|
|
41
|
-
@context.
|
41
|
+
expect( @context ).to have( 3 ).apps
|
42
42
|
|
43
|
-
@context.apps[ "app #0" ].name.
|
44
|
-
@context.apps[ "app #1" ].name.
|
45
|
-
@context.apps[ "app #2" ].name.
|
43
|
+
expect( @context.apps[ "app #0" ].name ).to eq( "app #0" )
|
44
|
+
expect( @context.apps[ "app #1" ].name ).to eq( "app #1" )
|
45
|
+
expect( @context.apps[ "app #2" ].name ).to eq( "app #2" )
|
46
46
|
end
|
47
47
|
|
48
48
|
|
49
49
|
it "should remember hosts" do
|
50
|
-
@context.
|
50
|
+
expect( @context ).to have( 0 ).hosts
|
51
51
|
|
52
52
|
Trema::Host.add mock( "host #0", :name => "host #0" )
|
53
53
|
Trema::Host.add mock( "host #1", :name => "host #1" )
|
54
54
|
Trema::Host.add mock( "host #2", :name => "host #2" )
|
55
55
|
|
56
|
-
@context.
|
56
|
+
expect( @context ).to have( 3 ).hosts
|
57
57
|
|
58
|
-
@context.hosts[ "host #0" ].name.
|
59
|
-
@context.hosts[ "host #1" ].name.
|
60
|
-
@context.hosts[ "host #2" ].name.
|
58
|
+
expect( @context.hosts[ "host #0" ].name ).to eq( "host #0" )
|
59
|
+
expect( @context.hosts[ "host #1" ].name ).to eq( "host #1" )
|
60
|
+
expect( @context.hosts[ "host #2" ].name ).to eq( "host #2" )
|
61
61
|
end
|
62
62
|
|
63
63
|
|
64
64
|
it "should remember links" do
|
65
|
-
@context.
|
65
|
+
expect( @context ).to have( 0 ).links
|
66
66
|
|
67
67
|
Trema::Link.add mock( "link #0", :name => "link #0" )
|
68
68
|
Trema::Link.add mock( "link #1", :name => "link #1" )
|
69
69
|
Trema::Link.add mock( "link #2", :name => "link #2" )
|
70
70
|
|
71
|
-
@context.
|
71
|
+
expect( @context ).to have( 3 ).links
|
72
72
|
|
73
|
-
@context.links[ "link #0" ].name.
|
74
|
-
@context.links[ "link #1" ].name.
|
75
|
-
@context.links[ "link #2" ].name.
|
73
|
+
expect( @context.links[ "link #0" ].name ).to eq( "link #0" )
|
74
|
+
expect( @context.links[ "link #1" ].name ).to eq( "link #1" )
|
75
|
+
expect( @context.links[ "link #2" ].name ).to eq( "link #2" )
|
76
76
|
end
|
77
77
|
|
78
78
|
|
79
79
|
it "should remember filter settings" do
|
80
|
-
@context.packetin_filter.
|
80
|
+
expect( @context.packetin_filter ).to be_nil
|
81
81
|
|
82
82
|
packetin_filter = mock( "filter", :name => "filter" )
|
83
83
|
Trema::PacketinFilter.add packetin_filter
|
84
84
|
|
85
|
-
@context.packetin_filter.
|
85
|
+
expect( @context.packetin_filter ).to eq( packetin_filter )
|
86
86
|
end
|
87
87
|
|
88
88
|
|
89
89
|
it "should remember switch manager" do
|
90
|
-
@context.switch_manager.
|
90
|
+
expect( @context.switch_manager ).to be_nil
|
91
91
|
|
92
92
|
switch_manager = mock( "switch manager", :name => "switch manager" )
|
93
93
|
Trema::SwitchManager.add switch_manager
|
94
94
|
|
95
|
-
@context.switch_manager.
|
95
|
+
expect( @context.switch_manager ).to eq( switch_manager )
|
96
96
|
end
|
97
97
|
|
98
98
|
|
99
99
|
it "should remember switches" do
|
100
|
-
@context.
|
100
|
+
expect( @context ).to have( 0 ).switches
|
101
101
|
|
102
102
|
Trema::OpenflowSwitch.add mock( "switch #0", :name => "switch #0" )
|
103
103
|
Trema::OpenflowSwitch.add mock( "switch #1", :name => "switch #1" )
|
104
104
|
Trema::OpenflowSwitch.add mock( "switch #2", :name => "switch #2" )
|
105
105
|
|
106
|
-
@context.
|
106
|
+
expect( @context ).to have( 3 ).switches
|
107
107
|
|
108
|
-
@context.switches[ "switch #0" ].name.
|
109
|
-
@context.switches[ "switch #1" ].name.
|
110
|
-
@context.switches[ "switch #2" ].name.
|
108
|
+
expect( @context.switches[ "switch #0" ].name ).to eq( "switch #0" )
|
109
|
+
expect( @context.switches[ "switch #1" ].name ).to eq( "switch #1" )
|
110
|
+
expect( @context.switches[ "switch #2" ].name ).to eq( "switch #2" )
|
111
111
|
end
|
112
112
|
end
|
113
113
|
end
|
data/spec/trema/dsl/link_spec.rb
CHANGED
@@ -27,9 +27,7 @@ module Trema
|
|
27
27
|
describe Link do
|
28
28
|
context %[when parsing "link peerA peerB"] do
|
29
29
|
it %[recognizes "link peerA peerB" directive] do
|
30
|
-
|
31
|
-
Link.new "Host", "Switch"
|
32
|
-
end.should_not raise_error
|
30
|
+
expect { Link.new "Host", "Switch" }.not_to raise_error
|
33
31
|
end
|
34
32
|
end
|
35
33
|
|
@@ -37,9 +35,9 @@ module Trema
|
|
37
35
|
context "when getting attributes of a link" do
|
38
36
|
it "remembers peers" do
|
39
37
|
link = Link.new( "Host", "Switch" )
|
40
|
-
link.peers.size.
|
41
|
-
link.peers.
|
42
|
-
link.peers.
|
38
|
+
expect( link.peers.size ).to eq( 2 )
|
39
|
+
expect( link.peers ).to include( "Host" )
|
40
|
+
expect( link.peers ).to include( "Switch" )
|
43
41
|
end
|
44
42
|
end
|
45
43
|
end
|
data/spec/trema/dsl/run_spec.rb
CHANGED
@@ -32,16 +32,12 @@ module Trema
|
|
32
32
|
|
33
33
|
context %[when parsing "run { ... }"] do
|
34
34
|
it %[recognizes "path COMMAND_PATH" directive] do
|
35
|
-
|
36
|
-
@run.path "/usr/bin/tremario"
|
37
|
-
end.should_not raise_error
|
35
|
+
expect { @run.path "/usr/bin/tremario" }.not_to raise_error
|
38
36
|
end
|
39
37
|
|
40
38
|
|
41
39
|
it %[recognizes "options OPTIONS..." directive] do
|
42
|
-
|
43
|
-
@run.options "--verbose", "--color"
|
44
|
-
end.should_not raise_error
|
40
|
+
expect { @run.options "--verbose", "--color" }.not_to raise_error
|
45
41
|
end
|
46
42
|
end
|
47
43
|
|
@@ -49,21 +45,21 @@ module Trema
|
|
49
45
|
context "when getting the attributes of an run" do
|
50
46
|
it "returns its name" do
|
51
47
|
@run.path "/usr/bin/tremario"
|
52
|
-
@run[ :name ].
|
48
|
+
expect( @run[ :name ] ).to eq( "tremario" )
|
53
49
|
end
|
54
50
|
|
55
51
|
|
56
52
|
it "returns its path" do
|
57
53
|
@run.path "/usr/bin/tremario"
|
58
|
-
@run[ :path ].
|
54
|
+
expect( @run[ :path ] ).to eq( "/usr/bin/tremario" )
|
59
55
|
end
|
60
56
|
|
61
57
|
|
62
58
|
it "returns its options" do
|
63
59
|
@run.options "--verbose", "--color"
|
64
|
-
@run[ :options ].size.
|
65
|
-
@run[ :options ].
|
66
|
-
@run[ :options ].
|
60
|
+
expect( @run[ :options ].size ).to eq( 2 )
|
61
|
+
expect( @run[ :options ] ).to include( "--verbose" )
|
62
|
+
expect( @run[ :options ] ).to include( "--color" )
|
67
63
|
end
|
68
64
|
end
|
69
65
|
end
|
@@ -111,23 +111,23 @@ module Trema
|
|
111
111
|
|
112
112
|
host0.should_receive( :run! ).once
|
113
113
|
host0.should_receive( :add_arp_entry ).with do | arg |
|
114
|
-
arg.size.
|
115
|
-
arg.
|
116
|
-
arg.
|
114
|
+
expect( arg.size ).to eq( 2 )
|
115
|
+
expect( arg ).to include( host1 )
|
116
|
+
expect( arg ).to include( host2 )
|
117
117
|
end
|
118
118
|
|
119
119
|
host1.should_receive( :run! ).once
|
120
120
|
host1.should_receive( :add_arp_entry ).with do | arg |
|
121
|
-
arg.size.
|
122
|
-
arg.
|
123
|
-
arg.
|
121
|
+
expect( arg.size ).to eq( 2 )
|
122
|
+
expect( arg ).to include( host0 )
|
123
|
+
expect( arg ).to include( host2 )
|
124
124
|
end
|
125
125
|
|
126
126
|
host2.should_receive( :run! ).once
|
127
127
|
host2.should_receive( :add_arp_entry ).with do | arg |
|
128
|
-
arg.size.
|
129
|
-
arg.
|
130
|
-
arg.
|
128
|
+
expect( arg.size ).to eq( 2 )
|
129
|
+
expect( arg ).to include( host0 )
|
130
|
+
expect( arg ).to include( host1 )
|
131
131
|
end
|
132
132
|
|
133
133
|
context = mock(
|
@@ -32,23 +32,17 @@ module Trema
|
|
32
32
|
|
33
33
|
context %[when parsing "switch { ... }"] do
|
34
34
|
it %[recognizes "dpid DATAPATH_ID" directive] do
|
35
|
-
|
36
|
-
@switch.dpid "0xabc"
|
37
|
-
end.should_not raise_error
|
35
|
+
expect { @switch.dpid "0xabc" }.not_to raise_error
|
38
36
|
end
|
39
37
|
|
40
38
|
|
41
39
|
it %[recognizes "datapath_id DATAPATH_ID" directive] do
|
42
|
-
|
43
|
-
@switch.datapath_id "0xabc"
|
44
|
-
end.should_not raise_error
|
40
|
+
expect { @switch.datapath_id "0xabc" }.not_to raise_error
|
45
41
|
end
|
46
42
|
|
47
43
|
|
48
44
|
it %[recognizes "ports PORT_NUMBERS" directive] do
|
49
|
-
|
50
|
-
@switch.ports "0-4"
|
51
|
-
end.should_not raise_error
|
45
|
+
expect { @switch.ports "0-4" }.not_to raise_error
|
52
46
|
end
|
53
47
|
end
|
54
48
|
|
@@ -56,13 +50,13 @@ module Trema
|
|
56
50
|
context "when getting the attributes of a switch" do
|
57
51
|
it "returns its dpid in long format" do
|
58
52
|
@switch.dpid "0xabc"
|
59
|
-
@switch[ :dpid_long ].
|
53
|
+
expect( @switch[ :dpid_long ] ).to eq( "0000000000000abc" )
|
60
54
|
end
|
61
55
|
|
62
56
|
|
63
57
|
it "returns its dpid in short format" do
|
64
58
|
@switch.dpid "0xabc"
|
65
|
-
@switch[ :dpid_short ].
|
59
|
+
expect( @switch[ :dpid_short ] ).to eq( "0xabc" )
|
66
60
|
end
|
67
61
|
end
|
68
62
|
end
|
@@ -96,9 +96,7 @@ module Trema
|
|
96
96
|
|
97
97
|
context "when promisc INVALID_VALUE" do
|
98
98
|
specify do
|
99
|
-
|
100
|
-
@vhost.promisc "INVALID_VALUE"
|
101
|
-
end.should raise_error( Trema::DSL::SyntaxError )
|
99
|
+
expect { @vhost.promisc "INVALID_VALUE" }.to raise_error( Trema::DSL::SyntaxError )
|
102
100
|
end
|
103
101
|
end
|
104
102
|
end
|
@@ -32,30 +32,22 @@ module Trema
|
|
32
32
|
|
33
33
|
context %[when parsing "vswitch { ... }"] do
|
34
34
|
it %[recognizes "dpid DATAPATH_ID" directive] do
|
35
|
-
|
36
|
-
@vswitch.dpid "0xabc"
|
37
|
-
end.should_not raise_error
|
35
|
+
expect { @vswitch.dpid "0xabc" }.not_to raise_error
|
38
36
|
end
|
39
37
|
|
40
38
|
|
41
39
|
it %[recognizes "datapath_id DATAPATH_ID" directive] do
|
42
|
-
|
43
|
-
@vswitch.datapath_id "0xabc"
|
44
|
-
end.should_not raise_error
|
40
|
+
expect { @vswitch.datapath_id "0xabc" }.not_to raise_error
|
45
41
|
end
|
46
42
|
|
47
43
|
|
48
44
|
it %[recognizes "ports PORT_NUMBERS" directive] do
|
49
|
-
|
50
|
-
@vswitch.ports "0-4"
|
51
|
-
end.should_not raise_error
|
45
|
+
expect { @vswitch.ports "0-4" }.not_to raise_error
|
52
46
|
end
|
53
47
|
|
54
48
|
|
55
49
|
it %[recognizes "ip IP_ADDRESS" directive] do
|
56
|
-
|
57
|
-
@vswitch.ip "192.168.0.1"
|
58
|
-
end.should_not raise_error
|
50
|
+
expect { @vswitch.ip "192.168.0.1" }.not_to raise_error
|
59
51
|
end
|
60
52
|
end
|
61
53
|
|
@@ -63,19 +55,19 @@ module Trema
|
|
63
55
|
context "when getting the attributes of a vswitch" do
|
64
56
|
it "returns its dpid in long format" do
|
65
57
|
@vswitch.dpid "0xabc"
|
66
|
-
@vswitch[ :dpid_long ].
|
58
|
+
expect( @vswitch[ :dpid_long ] ).to eq( "0000000000000abc" )
|
67
59
|
end
|
68
60
|
|
69
61
|
|
70
62
|
it "returns its dpid in short format" do
|
71
63
|
@vswitch.dpid "0xabc"
|
72
|
-
@vswitch[ :dpid_short ].
|
64
|
+
expect( @vswitch[ :dpid_short ] ).to eq( "0xabc" )
|
73
65
|
end
|
74
66
|
|
75
67
|
|
76
68
|
it "returns its ip address" do
|
77
69
|
@vswitch.ip "192.168.0.1"
|
78
|
-
@vswitch[ :ip ].
|
70
|
+
expect( @vswitch[ :ip ] ).to eq( "192.168.0.1" )
|
79
71
|
end
|
80
72
|
end
|
81
73
|
end
|