pio 0.18.2 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +3 -0
  3. data/README.md +40 -344
  4. data/Rakefile +32 -0
  5. data/bin/_guard-core +16 -0
  6. data/bin/byebug +16 -0
  7. data/bin/cc-tddium-post-worker +16 -0
  8. data/bin/cdiff +16 -0
  9. data/bin/coderay +16 -0
  10. data/bin/colortab +16 -0
  11. data/bin/coveralls +16 -0
  12. data/bin/cucumber +16 -0
  13. data/bin/decolor +16 -0
  14. data/bin/flay +16 -0
  15. data/bin/flog +16 -0
  16. data/bin/guard +16 -0
  17. data/bin/htmldiff +16 -0
  18. data/bin/inch +16 -0
  19. data/bin/ldiff +16 -0
  20. data/bin/listen +16 -0
  21. data/bin/minitar +16 -0
  22. data/bin/pry +16 -0
  23. data/bin/rake +16 -0
  24. data/bin/reek +16 -0
  25. data/bin/relish +16 -0
  26. data/bin/restclient +16 -0
  27. data/bin/rspec +16 -0
  28. data/bin/rubocop +16 -0
  29. data/bin/ruby-parse +16 -0
  30. data/bin/ruby-rewrite +16 -0
  31. data/bin/ruby_parse +16 -0
  32. data/bin/ruby_parse_extract_error +16 -0
  33. data/bin/sparkr +16 -0
  34. data/bin/term_display +16 -0
  35. data/bin/term_mandel +16 -0
  36. data/bin/thor +16 -0
  37. data/bin/unparser +16 -0
  38. data/bin/yard +16 -0
  39. data/bin/yardoc +16 -0
  40. data/bin/yri +16 -0
  41. data/features/arp.feature +61 -0
  42. data/features/dhcp.feature +4 -0
  43. data/features/icmp.feature +130 -0
  44. data/features/lldp.feature +47 -0
  45. data/features/open_flow10/echo_reply.feature +95 -0
  46. data/features/open_flow10/echo_request.feature +95 -0
  47. data/features/open_flow10/exact_match.feature +36 -0
  48. data/features/{features_read.feature → open_flow10/features_reply.feature} +54 -17
  49. data/features/open_flow10/features_request.feature +79 -0
  50. data/features/{flow_mod_read.feature → open_flow10/flow_mod.feature} +16 -21
  51. data/features/open_flow10/hello.feature +79 -0
  52. data/features/open_flow10/packet_in.feature +58 -0
  53. data/features/{packet_out_read.feature → open_flow10/packet_out.feature} +4 -5
  54. data/features/open_flow10/port_status.feature +23 -0
  55. data/features/open_flow13/echo_reply.feature +115 -0
  56. data/features/open_flow13/echo_request.feature +115 -0
  57. data/features/open_flow13/hello.feature +74 -0
  58. data/features/packet_data/echo13_reply_body.raw +0 -0
  59. data/features/packet_data/echo13_reply_no_body.raw +0 -0
  60. data/features/packet_data/echo13_request_body.raw +0 -0
  61. data/features/packet_data/echo13_request_no_body.raw +0 -0
  62. data/features/packet_data/hello13_no_version_bitmap.raw +0 -0
  63. data/features/packet_data/hello13_version_bitmap.raw +0 -0
  64. data/features/packet_data/udp_no_payload.raw +0 -0
  65. data/features/packet_data/udp_with_payload.raw +0 -0
  66. data/features/step_definitions/packet_data_steps.rb +49 -29
  67. data/features/support/env.rb +3 -0
  68. data/features/{udp_read.feature → udp.feature} +3 -4
  69. data/lib/pio.rb +1 -0
  70. data/lib/pio/echo.rb +67 -0
  71. data/lib/pio/hello13.rb +111 -0
  72. data/lib/pio/open_flow/message.rb +2 -1
  73. data/lib/pio/open_flow/open_flow_header.rb +21 -38
  74. data/lib/pio/open_flow/transaction_id.rb +25 -0
  75. data/lib/pio/version.rb +1 -1
  76. data/pio.gemspec +9 -14
  77. data/spec/pio/flow_mod_spec.rb +1 -1
  78. data/spec/pio/hello13_spec.rb +114 -0
  79. metadata +182 -138
  80. data/examples/arp_new.rb +0 -16
  81. data/examples/arp_read.rb +0 -4
  82. data/examples/dhcp_new.rb +0 -34
  83. data/examples/dhcp_read.rb +0 -4
  84. data/examples/echo_new.rb +0 -9
  85. data/examples/echo_read.rb +0 -4
  86. data/examples/features_new.rb +0 -28
  87. data/examples/features_read.rb +0 -4
  88. data/examples/flow_mod_new.rb +0 -13
  89. data/examples/flow_mod_read.rb +0 -6
  90. data/examples/hello_new.rb +0 -4
  91. data/examples/hello_read.rb +0 -4
  92. data/examples/icmp_new.rb +0 -21
  93. data/examples/icmp_read.rb +0 -4
  94. data/examples/lldp_new.rb +0 -4
  95. data/examples/lldp_read.rb +0 -4
  96. data/examples/packet_in_new.rb +0 -17
  97. data/examples/packet_in_read.rb +0 -5
  98. data/examples/packet_out_new.rb +0 -18
  99. data/examples/packet_out_read.rb +0 -6
  100. data/features/arp_read.feature +0 -10
  101. data/features/dhcp_read.feature +0 -6
  102. data/features/echo_read.feature +0 -29
  103. data/features/exact_match.feature +0 -38
  104. data/features/hello_read.feature +0 -14
  105. data/features/icmp_read.feature +0 -55
  106. data/features/lldp_read.feature +0 -26
  107. data/features/packet_in_read.feature +0 -22
  108. data/features/port_status_read.feature +0 -24
  109. data/features/step_definitions/pending_steps.rb +0 -3
  110. data/spec/pio/echo/reply_spec.rb +0 -135
  111. data/spec/pio/echo/request_spec.rb +0 -137
  112. data/spec/pio/features/reply_spec.rb +0 -137
  113. data/spec/pio/features/request_spec.rb +0 -112
  114. data/spec/pio/hello_spec.rb +0 -106
  115. data/spec/pio/lldp_spec.rb +0 -244
  116. data/spec/pio/packet_in_spec.rb +0 -146
@@ -1,24 +0,0 @@
1
- Feature: Pio::PortStatus.read
2
- Scenario: port_status.raw
3
- Given a packet data file "port_status.raw"
4
- When I try to parse the file with "PortStatus" class
5
- Then it should finish successfully
6
- And the parsed data have the following field and value:
7
- | field | value |
8
- | class | Pio::PortStatus |
9
- | ofp_version | 1 |
10
- | message_type | 12 |
11
- | message_length | 64 |
12
- | transaction_id | 4 |
13
- | xid | 4 |
14
- | reason | delete |
15
- | desc.port_no | 65533 |
16
- | desc.hardware_address | 01:02:03:04:05:06 |
17
- | desc.name | foo |
18
- | desc.config | [:no_flood] |
19
- | desc.state | [:stp_forward, :stp_block] |
20
- | desc.curr | [:port_10mb_hd] |
21
- | desc.advertised | [:port_1gb_fd] |
22
- | desc.supported | [:port_autoneg] |
23
- | desc.peer | [:port_pause_asym] |
24
-
@@ -1,3 +0,0 @@
1
- Given(/^PENDING/) do
2
- pending
3
- end
@@ -1,135 +0,0 @@
1
- require 'pio/echo'
2
-
3
- describe Pio::Echo::Reply do
4
- describe '.read' do
5
- When(:echo_reply) { Pio::Echo::Reply.read(binary) }
6
-
7
- context 'with an echo reply message' do
8
- Given(:binary) { [1, 3, 0, 8, 0, 0, 0, 0].pack('C*') }
9
-
10
- Then { echo_reply.ofp_version == 1 }
11
- Then { echo_reply.message_type == Pio::OpenFlow::ECHO_REPLY }
12
- Then { echo_reply.message_length == 8 }
13
- Then { echo_reply.transaction_id == 0 }
14
- Then { echo_reply.xid == 0 }
15
- Then { echo_reply.user_data.empty? }
16
- Then { echo_reply.user_data == '' }
17
- Then { echo_reply.body.empty? }
18
- Then { echo_reply.body == '' }
19
- Then { echo_reply.to_binary == [1, 3, 0, 8, 0, 0, 0, 0].pack('C*') }
20
- end
21
-
22
- context 'with a hello message' do
23
- Given(:binary) { [1, 0, 0, 8, 0, 0, 0, 0].pack('C*') }
24
-
25
- Then do
26
- echo_reply ==
27
- Failure(Pio::ParseError, 'Invalid Echo Reply message.')
28
- end
29
- end
30
- end
31
-
32
- describe '.new' do
33
- context 'with no arguments' do
34
- When(:echo_reply) { Pio::Echo::Reply.new }
35
-
36
- Then { echo_reply.ofp_version == 1 }
37
- Then { echo_reply.message_type == Pio::OpenFlow::ECHO_REPLY }
38
- Then { echo_reply.message_length == 8 }
39
- Then { echo_reply.transaction_id == 0 }
40
- Then { echo_reply.xid == 0 }
41
- Then { echo_reply.user_data.empty? }
42
- Then { echo_reply.user_data == '' }
43
- Then { echo_reply.body.empty? }
44
- Then { echo_reply.body == '' }
45
- Then { echo_reply.to_binary == [1, 3, 0, 8, 0, 0, 0, 0].pack('C*') }
46
- end
47
-
48
- context 'with 123' do
49
- When(:echo_reply) { Pio::Echo::Reply.new(123) }
50
-
51
- Then { echo_reply.ofp_version == 1 }
52
- Then { echo_reply.message_type == Pio::OpenFlow::ECHO_REPLY }
53
- Then { echo_reply.message_length == 8 }
54
- Then { echo_reply.transaction_id == 123 }
55
- Then { echo_reply.xid == 123 }
56
- Then { echo_reply.user_data.empty? }
57
- Then { echo_reply.user_data == '' }
58
- Then { echo_reply.body.empty? }
59
- Then { echo_reply.body == '' }
60
- Then { echo_reply.to_binary == [1, 3, 0, 8, 0, 0, 0, 123].pack('C*') }
61
- end
62
-
63
- context 'with transaction_id: 123' do
64
- When(:echo_reply) { Pio::Echo::Reply.new(transaction_id: 123) }
65
-
66
- Then { echo_reply.ofp_version == 1 }
67
- Then { echo_reply.message_type == Pio::OpenFlow::ECHO_REPLY }
68
- Then { echo_reply.message_length == 8 }
69
- Then { echo_reply.transaction_id == 123 }
70
- Then { echo_reply.xid == 123 }
71
- Then { echo_reply.user_data.empty? }
72
- Then { echo_reply.user_data == '' }
73
- Then { echo_reply.body.empty? }
74
- Then { echo_reply.body == '' }
75
- Then { echo_reply.to_binary == [1, 3, 0, 8, 0, 0, 0, 123].pack('C*') }
76
- end
77
-
78
- context 'with xid: 123' do
79
- When(:echo_reply) { Pio::Echo::Reply.new(xid: 123) }
80
-
81
- Then { echo_reply.ofp_version == 1 }
82
- Then { echo_reply.message_type == Pio::OpenFlow::ECHO_REPLY }
83
- Then { echo_reply.message_length == 8 }
84
- Then { echo_reply.transaction_id == 123 }
85
- Then { echo_reply.xid == 123 }
86
- Then { echo_reply.user_data.empty? }
87
- Then { echo_reply.user_data == '' }
88
- Then { echo_reply.body.empty? }
89
- Then { echo_reply.body == '' }
90
- Then { echo_reply.to_binary == [1, 3, 0, 8, 0, 0, 0, 123].pack('C*') }
91
- end
92
-
93
- context "with transaction_id: 123, user_data: 'foobar'" do
94
- When(:echo_reply) { Pio::Echo::Reply.new(xid: 123, user_data: 'foobar') }
95
-
96
- Then { echo_reply.ofp_version == 1 }
97
- Then { echo_reply.message_type == Pio::OpenFlow::ECHO_REPLY }
98
- Then { echo_reply.message_length == 14 }
99
- Then { echo_reply.transaction_id == 123 }
100
- Then { echo_reply.xid == 123 }
101
- Then { echo_reply.user_data == 'foobar' }
102
- Then { echo_reply.body == 'foobar' }
103
- Then do
104
- echo_reply.to_binary ==
105
- [1, 3, 0, 14, 0, 0, 0, 123, 102, 111, 111, 98, 97, 114].pack('C*')
106
- end
107
- end
108
-
109
- context 'with -1' do
110
- When(:result) { Pio::Echo::Reply.new(-1) }
111
-
112
- Then do
113
- result ==
114
- Failure(ArgumentError,
115
- 'Transaction ID should be an unsigned 32-bit integer.')
116
- end
117
- end
118
-
119
- context 'with 2**32' do
120
- When(:result) { Pio::Echo::Reply.new(2**32) }
121
-
122
- Then do
123
- result ==
124
- Failure(ArgumentError,
125
- 'Transaction ID should be an unsigned 32-bit integer.')
126
- end
127
- end
128
-
129
- context 'with :INVALID_ARGUMENT' do
130
- When(:result) { Pio::Echo::Reply.new(:INVALID_ARGUMENT) }
131
-
132
- Then { result == Failure(TypeError) }
133
- end
134
- end
135
- end
@@ -1,137 +0,0 @@
1
- require 'pio/echo'
2
-
3
- describe Pio::Echo::Request do
4
- describe '.read' do
5
- When(:echo_request) { Pio::Echo::Request.read(binary) }
6
-
7
- context 'with an echo request message' do
8
- Given(:binary) { [1, 2, 0, 8, 0, 0, 0, 0].pack('C*') }
9
-
10
- Then { echo_request.ofp_version == 1 }
11
- Then { echo_request.message_type == Pio::OpenFlow::ECHO_REQUEST }
12
- Then { echo_request.message_length == 8 }
13
- Then { echo_request.transaction_id == 0 }
14
- Then { echo_request.xid == 0 }
15
- Then { echo_request.user_data.empty? }
16
- Then { echo_request.user_data == '' }
17
- Then { echo_request.body.empty? }
18
- Then { echo_request.body == '' }
19
- Then { echo_request.to_binary == [1, 2, 0, 8, 0, 0, 0, 0].pack('C*') }
20
- end
21
-
22
- context 'with a hello message' do
23
- Given(:binary) { [1, 0, 0, 8, 0, 0, 0, 0].pack('C*') }
24
-
25
- Then do
26
- echo_request ==
27
- Failure(Pio::ParseError, 'Invalid Echo Request message.')
28
- end
29
- end
30
- end
31
-
32
- describe '.new' do
33
- context 'with no arguments' do
34
- When(:echo_request) { Pio::Echo::Request.new }
35
-
36
- Then { echo_request.ofp_version == 1 }
37
- Then { echo_request.message_type == Pio::OpenFlow::ECHO_REQUEST }
38
- Then { echo_request.message_length == 8 }
39
- Then { echo_request.transaction_id == 0 }
40
- Then { echo_request.xid == 0 }
41
- Then { echo_request.user_data.empty? }
42
- Then { echo_request.user_data == '' }
43
- Then { echo_request.body.empty? }
44
- Then { echo_request.body == '' }
45
- Then { echo_request.to_binary == [1, 2, 0, 8, 0, 0, 0, 0].pack('C*') }
46
- end
47
-
48
- context 'with 123' do
49
- When(:echo_request) { Pio::Echo::Request.new(123) }
50
-
51
- Then { echo_request.ofp_version == 1 }
52
- Then { echo_request.message_type == Pio::OpenFlow::ECHO_REQUEST }
53
- Then { echo_request.message_length == 8 }
54
- Then { echo_request.transaction_id == 123 }
55
- Then { echo_request.xid == 123 }
56
- Then { echo_request.user_data.empty? }
57
- Then { echo_request.user_data == '' }
58
- Then { echo_request.body.empty? }
59
- Then { echo_request.body == '' }
60
- Then { echo_request.to_binary == [1, 2, 0, 8, 0, 0, 0, 123].pack('C*') }
61
- end
62
-
63
- context 'with transaction_id: 123' do
64
- When(:echo_request) { Pio::Echo::Request.new(transaction_id: 123) }
65
-
66
- Then { echo_request.ofp_version == 1 }
67
- Then { echo_request.message_type == Pio::OpenFlow::ECHO_REQUEST }
68
- Then { echo_request.message_length == 8 }
69
- Then { echo_request.transaction_id == 123 }
70
- Then { echo_request.xid == 123 }
71
- Then { echo_request.user_data.empty? }
72
- Then { echo_request.user_data == '' }
73
- Then { echo_request.body.empty? }
74
- Then { echo_request.body == '' }
75
- Then { echo_request.to_binary == [1, 2, 0, 8, 0, 0, 0, 123].pack('C*') }
76
- end
77
-
78
- context 'with xid: 123' do
79
- When(:echo_request) { Pio::Echo::Request.new(xid: 123) }
80
-
81
- Then { echo_request.ofp_version == 1 }
82
- Then { echo_request.message_type == Pio::OpenFlow::ECHO_REQUEST }
83
- Then { echo_request.message_length == 8 }
84
- Then { echo_request.transaction_id == 123 }
85
- Then { echo_request.xid == 123 }
86
- Then { echo_request.user_data.empty? }
87
- Then { echo_request.user_data == '' }
88
- Then { echo_request.body.empty? }
89
- Then { echo_request.body == '' }
90
- Then { echo_request.to_binary == [1, 2, 0, 8, 0, 0, 0, 123].pack('C*') }
91
- end
92
-
93
- context "with transaction_id: 123, user_data: 'foobar'" do
94
- When(:echo_request) do
95
- Pio::Echo::Request.new(xid: 123, user_data: 'foobar')
96
- end
97
-
98
- Then { echo_request.ofp_version == 1 }
99
- Then { echo_request.message_type == Pio::OpenFlow::ECHO_REQUEST }
100
- Then { echo_request.message_length == 14 }
101
- Then { echo_request.transaction_id == 123 }
102
- Then { echo_request.xid == 123 }
103
- Then { echo_request.user_data == 'foobar' }
104
- Then { echo_request.body == 'foobar' }
105
- Then do
106
- echo_request.to_binary ==
107
- [1, 2, 0, 14, 0, 0, 0, 123, 102, 111, 111, 98, 97, 114].pack('C*')
108
- end
109
- end
110
-
111
- context 'with -1' do
112
- When(:result) { Pio::Echo::Request.new(-1) }
113
-
114
- Then do
115
- result ==
116
- Failure(ArgumentError,
117
- 'Transaction ID should be an unsigned 32-bit integer.')
118
- end
119
- end
120
-
121
- context 'with 2**32' do
122
- When(:result) { Pio::Echo::Request.new(2**32) }
123
-
124
- Then do
125
- result ==
126
- Failure(ArgumentError,
127
- 'Transaction ID should be an unsigned 32-bit integer.')
128
- end
129
- end
130
-
131
- context 'with :INVALID_ARGUMENT' do
132
- When(:result) { Pio::Echo::Request.new(:INVALID_ARGUMENT) }
133
-
134
- Then { result == Failure(TypeError) }
135
- end
136
- end
137
- end
@@ -1,137 +0,0 @@
1
- require 'pio/features'
2
-
3
- describe Pio::Features::Reply do
4
- context 'with a Features Reply message' do
5
- When(:result) { Pio::Features::Reply.read(binary) }
6
-
7
- describe '.read' do
8
- Given(:binary) do
9
- [0x01, 0x06, 0x00, 0xb0, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
10
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00,
11
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00,
12
- 0x0f, 0xff, 0x00, 0x02, 0x16, 0x7d, 0xa4, 0x37, 0xba, 0x10,
13
- 0x74, 0x72, 0x65, 0x6d, 0x61, 0x30, 0x2d, 0x30, 0x00, 0x00,
14
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00,
16
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17
- 0xff, 0xfe, 0x2a, 0xb4, 0xd6, 0x3c, 0x66, 0xba, 0x76, 0x73,
18
- 0x77, 0x5f, 0x30, 0x78, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00,
19
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
20
- 0x00, 0x01, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x00,
21
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
22
- 0x62, 0x94, 0x3a, 0xf6, 0x40, 0xdb, 0x74, 0x72, 0x65, 0x6d,
23
- 0x61, 0x31, 0x2d, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25
- 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00].pack('C*')
27
- end
28
-
29
- Then { result.class == Pio::Features::Reply }
30
- Then { result.ofp_version == 1 }
31
- Then do
32
- result.message_type ==
33
- Pio::OpenFlow::FEATURES_REPLY
34
- end
35
- Then { result.message_length == 176 }
36
- Then { result.transaction_id == 2 }
37
- Then { result.xid == 2 }
38
- Then { !result.body.empty? }
39
- Then { result.datapath_id == 1 }
40
- Then { result.n_buffers == 0x100 }
41
- Then { result.n_tables == 1 }
42
- Then do
43
- result.capabilities ==
44
- [:flow_stats, :table_stats, :port_stats, :arp_match_ip]
45
- end
46
- Then do
47
- result.actions ==
48
- [:output, :set_vlan_vid, :set_vlan_pcp, :strip_vlan,
49
- :set_dl_src, :set_dl_dst, :set_nw_src, :set_nw_dst,
50
- :set_nw_tos, :set_tp_src, :set_tp_dst, :enqueue]
51
- end
52
- Then { result.ports.size == 3 }
53
- Then { result.ports.all? { |each| each.port_no > 0 } }
54
- Then do
55
- result.ports.all? do |each|
56
- /^([0-9a-fA-F]{2}[:-]){5}[0-9a-fA-F]{2}$/i=~
57
- each.hardware_address.to_s
58
- end
59
- end
60
- Then { result.ports.all? { |each| !each.name.empty? } }
61
- Then { result.ports.any? { |each| each.config == [:port_down] } }
62
- Then { result.ports.any? { |each| each.state == [:link_down] } }
63
- Then { result.ports.all? { |each| each.curr.include? :port_copper } }
64
- Then { result.ports.all? { |each| each.advertised.empty? } }
65
- Then { result.ports.all? { |each| each.supported.empty? } }
66
- Then { result.ports.all? { |each| each.peer.empty? } }
67
- end
68
-
69
- context 'with a Hello message' do
70
- Given(:binary) { [1, 0, 0, 8, 0, 0, 0, 0].pack('C*') }
71
-
72
- When(:result) { Pio::Features::Reply.read(binary) }
73
-
74
- Then do
75
- result == Failure(Pio::ParseError,
76
- 'Invalid Features Reply message.')
77
- end
78
- end
79
- end
80
-
81
- Given(:options) do
82
- {
83
- dpid: 0x123,
84
- n_buffers: 0x100,
85
- n_tables: 0xfe,
86
- capabilities: [:flow_stats, :table_stats, :port_stats, :queue_stats,
87
- :arp_match_ip],
88
- actions: [:output, :set_vlan_vid, :set_vlan_pcp, :strip_vlan,
89
- :set_dl_src, :set_dl_dst, :set_nw_src, :set_nw_dst,
90
- :set_nw_tos, :set_tp_src, :set_tp_dst, :enqueue],
91
- ports: [{ port_no: 1,
92
- hardware_address: '11:22:33:44:55:66',
93
- name: 'port123',
94
- config: [:port_down],
95
- state: [:link_down],
96
- curr: [:port_10gb_fd, :port_copper] }]
97
- }
98
- end
99
-
100
- describe '.new' do
101
- When(:features_reply) { Pio::Features::Reply.new(options) }
102
-
103
- Then { features_reply.ofp_version == 1 }
104
- Then { features_reply.message_type == Pio::OpenFlow::FEATURES_REPLY }
105
- Then { features_reply.transaction_id == 0 }
106
- Then { features_reply.xid == 0 }
107
- Then { features_reply.dpid == 0x123 }
108
- Then { features_reply.n_buffers == 0x100 }
109
- Then { features_reply.n_tables == 0xfe }
110
- Then do
111
- features_reply.capabilities ==
112
- [:flow_stats, :table_stats, :port_stats, :queue_stats, :arp_match_ip]
113
- end
114
- Then do
115
- features_reply.actions ==
116
- [:output, :set_vlan_vid, :set_vlan_pcp, :strip_vlan, :set_dl_src,
117
- :set_dl_dst, :set_nw_src, :set_nw_dst, :set_nw_tos, :set_tp_src,
118
- :set_tp_dst, :enqueue]
119
- end
120
- Then { features_reply.ports.length == 1 }
121
- Then { features_reply.ports[0].port_no == 1 }
122
- Then { features_reply.ports[0].hardware_address == '11:22:33:44:55:66' }
123
- Then { features_reply.ports[0].name == 'port123' }
124
- Then { features_reply.ports[0].config == [:port_down] }
125
- Then { features_reply.ports[0].state == [:link_down] }
126
- Then { features_reply.ports[0].curr == [:port_10gb_fd, :port_copper] }
127
- Then { features_reply.ports[0].advertised.empty? }
128
- Then { features_reply.ports[0].supported.empty? }
129
- Then { features_reply.ports[0].peer.empty? }
130
-
131
- describe '#to_binary' do
132
- When(:result) { Pio::Features::Reply.new(options).to_binary }
133
-
134
- Then { result.length > 0 }
135
- end
136
- end
137
- end
@@ -1,112 +0,0 @@
1
- require 'pio/features'
2
-
3
- describe Pio::Features::Request do
4
- describe '.read' do
5
- When(:result) { Pio::Features::Request.read(binary) }
6
-
7
- context 'with a Features Request message' do
8
- Given(:binary) { [1, 5, 0, 8, 0, 0, 0, 0].pack('C*') }
9
-
10
- Then { result.class == Pio::Features::Request }
11
- Then { result.ofp_version == 1 }
12
- Then do
13
- result.message_type ==
14
- Pio::OpenFlow::FEATURES_REQUEST
15
- end
16
- Then { result.message_length == 8 }
17
- Then { result.transaction_id == 0 }
18
- Then { result.xid == 0 }
19
- Then { result.body.empty? }
20
- Then { result.body == '' }
21
- end
22
-
23
- context 'with a Hello message' do
24
- Given(:binary) { [1, 0, 0, 8, 0, 0, 0, 0].pack('C*') }
25
-
26
- Then do
27
- result == Failure(Pio::ParseError,
28
- 'Invalid Features Request message.')
29
- end
30
- end
31
- end
32
-
33
- describe '.new' do
34
- context 'with no arguments' do
35
- When(:result) { Pio::Features::Request.new }
36
-
37
- Then { result.ofp_version == 1 }
38
- Then { result.message_type == Pio::OpenFlow::FEATURES_REQUEST }
39
- Then { result.message_length == 8 }
40
- Then { result.transaction_id == 0 }
41
- Then { result.xid == 0 }
42
- Then { result.body.empty? }
43
- Then { result.body == '' }
44
- Then { result.to_binary == [1, 5, 0, 8, 0, 0, 0, 0].pack('C*') }
45
- end
46
-
47
- context 'with 123' do
48
- When(:result) { Pio::Features::Request.new(123) }
49
-
50
- Then { result.ofp_version == 1 }
51
- Then { result.message_type == Pio::OpenFlow::FEATURES_REQUEST }
52
- Then { result.message_length == 8 }
53
- Then { result.transaction_id == 123 }
54
- Then { result.xid == 123 }
55
- Then { result.body.empty? }
56
- Then { result.body == '' }
57
- Then { result.to_binary == [1, 5, 0, 8, 0, 0, 0, 123].pack('C*') }
58
- end
59
-
60
- context 'with transaction_id: 123' do
61
- When(:result) { Pio::Features::Request.new(transaction_id: 123) }
62
-
63
- Then { result.ofp_version == 1 }
64
- Then { result.message_type == Pio::OpenFlow::FEATURES_REQUEST }
65
- Then { result.message_length == 8 }
66
- Then { result.transaction_id == 123 }
67
- Then { result.xid == 123 }
68
- Then { result.body.empty? }
69
- Then { result.body == '' }
70
- Then { result.to_binary == [1, 5, 0, 8, 0, 0, 0, 123].pack('C*') }
71
- end
72
-
73
- context 'with xid: 123' do
74
- When(:result) { Pio::Features::Request.new(xid: 123) }
75
-
76
- Then { result.ofp_version == 1 }
77
- Then { result.message_type == Pio::OpenFlow::FEATURES_REQUEST }
78
- Then { result.message_length == 8 }
79
- Then { result.transaction_id == 123 }
80
- Then { result.xid == 123 }
81
- Then { result.body.empty? }
82
- Then { result.body == '' }
83
- Then { result.to_binary == [1, 5, 0, 8, 0, 0, 0, 123].pack('C*') }
84
- end
85
-
86
- context 'with -1' do
87
- When(:result) { Pio::Features::Request.new(-1) }
88
-
89
- Then do
90
- result ==
91
- Failure(ArgumentError,
92
- 'Transaction ID should be an unsigned 32-bit integer.')
93
- end
94
- end
95
-
96
- context 'with 2**32' do
97
- When(:result) { Pio::Features::Request.new(2**32) }
98
-
99
- Then do
100
- result ==
101
- Failure(ArgumentError,
102
- 'Transaction ID should be an unsigned 32-bit integer.')
103
- end
104
- end
105
-
106
- context 'with :INVALID_ARGUMENT' do
107
- When(:result) { Pio::Features::Request.new(:INVALID_ARGUMENT) }
108
-
109
- Then { result == Failure(TypeError) }
110
- end
111
- end
112
- end