trema 0.5.1 → 0.6.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/Rakefile +2 -0
- data/bin/trema +17 -2
- data/cucumber.yml +7 -0
- data/features/.nav +47 -0
- data/features/{logging.feature → api/logging.feature} +1 -7
- data/features/{send_flow_mod_add.feature → api/send_flow_mod_add.feature} +2 -7
- data/features/handlers/barrier_reply.feature +30 -0
- data/features/{echo_reply_handler.feature → handlers/echo_reply.feature} +14 -13
- data/features/handlers/hello_failed.feature +56 -0
- data/features/handlers/packet_in.feature +32 -0
- data/features/handlers/start.feature +31 -0
- data/features/handlers/switch_disconnected.feature +34 -0
- data/features/handlers/switch_ready.feature +26 -0
- data/features/logger/debug.feature +41 -0
- data/features/logger/error.feature +41 -0
- data/features/logger/fatal.feature +41 -0
- data/features/logger/info.feature +41 -0
- data/features/logger/warn.feature +41 -0
- data/features/step_definitions/README.txt +2 -0
- data/features/step_definitions/dump_flows_steps.rb +13 -0
- data/features/step_definitions/rest_api_steps.rb +40 -0
- data/features/step_definitions/show_stats_steps.rb +31 -4
- data/features/step_definitions/trema_steps.rb +72 -0
- data/features/support/hooks.rb +4 -1
- data/features/trema_delete_link/README.md +5 -0
- data/features/{trema_delete_link.feature → trema_delete_link/delete_link.feature} +9 -13
- data/features/trema_delete_link/socket_dir_option.feature +12 -0
- data/features/trema_killall/README.md +5 -0
- data/features/trema_killall/all_option.feature +20 -0
- data/features/{trema_killall.feature → trema_killall/killall.feature} +10 -28
- data/features/trema_killall/socket_dir_option.feature +38 -0
- data/features/trema_run/README.md +5 -0
- data/features/trema_run/conf_option.feature +66 -0
- data/features/trema_run/daemonize_option.feature +19 -0
- data/features/trema_run/log_dir_option.feature +32 -0
- data/features/trema_run/logging_level_option.feature +30 -0
- data/features/trema_run/openflow13_option.feature +39 -0
- data/features/trema_run/pid_dir_option.feature +32 -0
- data/features/trema_run/port_option.feature +32 -0
- data/features/trema_run/run.feature +83 -0
- data/features/trema_run/socket_dir_option.feature +34 -0
- data/features/trema_start/README.md +5 -0
- data/features/trema_start/socket_dir_option.feature +9 -0
- data/features/{trema_start.feature → trema_start/start.feature} +23 -24
- data/features/trema_stop/README.md +5 -0
- data/features/trema_stop/socket_dir_option.feature +9 -0
- data/features/{trema_stop.feature → trema_stop/stop.feature} +7 -12
- data/lib/trema/command.rb +15 -2
- data/lib/trema/controller.rb +16 -2
- data/lib/trema/switch.rb +25 -26
- data/lib/trema/version.rb +1 -1
- data/trema.gemspec +8 -7
- metadata +73 -26
- data/features/cleanup_on_failure.feature +0 -118
- data/features/step_definitions/README.md +0 -7
- data/features/trema_run.feature +0 -72
@@ -0,0 +1,40 @@
|
|
1
|
+
begin
|
2
|
+
require 'rack/test'
|
3
|
+
|
4
|
+
World(Rack::Test::Methods)
|
5
|
+
|
6
|
+
Given(/^I send and accept JSON$/) do
|
7
|
+
header 'Accept', 'application/json'
|
8
|
+
header 'Cotent-Type', 'application/json'
|
9
|
+
end
|
10
|
+
|
11
|
+
Given(/^I send a GET request for "([^\"]*)"$/) do |path|
|
12
|
+
in_current_dir { get path }
|
13
|
+
end
|
14
|
+
|
15
|
+
# rubocop:disable LineLength
|
16
|
+
Given(/^I send a POST request for "([^\"]*)" with body "([^\"]*)"$/) do |path, body|
|
17
|
+
in_current_dir { post path, Object.instance_eval(body) }
|
18
|
+
end
|
19
|
+
# rubocop:enable LineLength
|
20
|
+
|
21
|
+
# rubocop:disable LineLength
|
22
|
+
Given(/^I send a DELETE request for "([^\"]*)" with body "([^\"]*)"$/) do |path, body|
|
23
|
+
in_current_dir { delete path, Object.instance_eval(body) }
|
24
|
+
end
|
25
|
+
# rubocop:enable LineLength
|
26
|
+
|
27
|
+
Then(/^the response should be "([^\"]*)"$/) do |status|
|
28
|
+
expect(last_response.status).to eq(status.to_i)
|
29
|
+
end
|
30
|
+
|
31
|
+
Then(/^the JSON response should be "([^\"]*)"$/) do |json|
|
32
|
+
expect(JSON.parse(last_response.body)).to eq(JSON.parse(json))
|
33
|
+
end
|
34
|
+
|
35
|
+
Then(/^the JSON response should be:$/) do |json|
|
36
|
+
expect(JSON.parse(last_response.body)).to eq(JSON.parse(json))
|
37
|
+
end
|
38
|
+
rescue LoadError
|
39
|
+
$stderr.puts 'Rack is disabled'
|
40
|
+
end
|
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
Then(/^the number of packets sent from "(.*?)" should be:$/) do |host_name, table|
|
4
4
|
command = "trema show_stats #{host_name}"
|
5
|
-
step "I
|
5
|
+
step "I run `#{command}`"
|
6
6
|
|
7
7
|
result = {}
|
8
|
-
|
8
|
+
cd('.') do
|
9
9
|
output_from(command).split("\n").each do |each|
|
10
10
|
case each
|
11
11
|
when /Packets sent/
|
@@ -27,10 +27,10 @@ end
|
|
27
27
|
|
28
28
|
Then(/^the number of packets received by "(.*?)" should be:$/) do |host_name, table|
|
29
29
|
command = "trema show_stats #{host_name}"
|
30
|
-
step "I
|
30
|
+
step "I run `#{command}`"
|
31
31
|
|
32
32
|
result = Hash.new(0)
|
33
|
-
|
33
|
+
cd('.') do
|
34
34
|
received = false
|
35
35
|
output_from(command).split("\n").each do |each|
|
36
36
|
case each
|
@@ -53,4 +53,31 @@ Then(/^the number of packets received by "(.*?)" should be:$/) do |host_name, ta
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
+
Then(/^the total number of received packets should be:$/) do |table|
|
57
|
+
table.hashes[0].each_pair do |host_name, npackets|
|
58
|
+
command = "trema show_stats #{host_name}"
|
59
|
+
step "I run `#{command}`"
|
60
|
+
|
61
|
+
result = 0
|
62
|
+
cd('.') do
|
63
|
+
received = false
|
64
|
+
output_from(command).split("\n").each do |each|
|
65
|
+
case each
|
66
|
+
when /Packets sent/
|
67
|
+
next
|
68
|
+
when /Packets received/
|
69
|
+
received = true
|
70
|
+
next
|
71
|
+
when /(\S+) -> (\S+) = (\d+) packet/
|
72
|
+
next unless received
|
73
|
+
result += Regexp.last_match(3).to_i
|
74
|
+
else
|
75
|
+
fail "Failed to parse line '#{each}'"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
expect(result).to eq(npackets.to_i)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
56
83
|
# rubocop:enable LineLength
|
@@ -0,0 +1,72 @@
|
|
1
|
+
Given(/^I use OpenFlow 1\.0$/) do
|
2
|
+
@open_flow_version = :open_flow10
|
3
|
+
end
|
4
|
+
|
5
|
+
Given(/^I use OpenFlow 1\.3$/) do
|
6
|
+
@open_flow_version = :open_flow13
|
7
|
+
end
|
8
|
+
|
9
|
+
Given(/^a socket directory named "([^"]*)"$/) do |socket_directory|
|
10
|
+
step %(a directory named "#{socket_directory}")
|
11
|
+
ENV['TREMA_SOCKET_DIR'] = socket_directory
|
12
|
+
end
|
13
|
+
|
14
|
+
Then(/^a socket file named "([^"]*)" should exist$/) do |socket_file|
|
15
|
+
cd('.') do
|
16
|
+
expect(FileTest.socket?(socket_file)).to be_truthy
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
When(/^I trema run "([^"]*)"$/) do |controller_file|
|
21
|
+
controller_path = if controller_file.include?('/')
|
22
|
+
File.join '..', '..', controller_file
|
23
|
+
else
|
24
|
+
controller_file
|
25
|
+
end
|
26
|
+
step %(I run `trema run #{controller_path} -d`)
|
27
|
+
end
|
28
|
+
|
29
|
+
When(/^I trema run "([^"]*)" interactively$/) do |controller_file|
|
30
|
+
controller_path = if controller_file.include?('/')
|
31
|
+
File.join '..', '..', controller_file
|
32
|
+
else
|
33
|
+
controller_file
|
34
|
+
end
|
35
|
+
step %(I run `trema run #{controller_path}` interactively)
|
36
|
+
step %(I successfully run `sleep 3`)
|
37
|
+
end
|
38
|
+
|
39
|
+
# rubocop:disable LineLength
|
40
|
+
When(/^I trema run "([^"]*)"( interactively)? with the configuration "([^"]*)"$/) do |controller_file, interactive, configuration_file|
|
41
|
+
open_flow_option = @open_flow_version == :open_flow13 ? ' --openflow13' : ''
|
42
|
+
controller_path = if controller_file.include?('/')
|
43
|
+
File.join '..', '..', controller_file
|
44
|
+
else
|
45
|
+
controller_file
|
46
|
+
end
|
47
|
+
run_arguments = "#{controller_path}#{open_flow_option} -c #{configuration_file}"
|
48
|
+
if interactive
|
49
|
+
step %(I run `trema run #{run_arguments}` interactively)
|
50
|
+
else
|
51
|
+
step %(I successfully run `trema run #{run_arguments} -d`)
|
52
|
+
end
|
53
|
+
step %(I successfully run `sleep 3`)
|
54
|
+
end
|
55
|
+
# rubocop:enable LineLength
|
56
|
+
|
57
|
+
When(/^I trema killall "([^"]*)"$/) do |controller_name|
|
58
|
+
step %(I successfully run `trema killall #{controller_name}`)
|
59
|
+
end
|
60
|
+
|
61
|
+
# rubocop:disable LineLength
|
62
|
+
Then(/^the log file "([^"]*)" should contain following messages:$/) do |log_file, messages|
|
63
|
+
step %(a file named "#{log_file}" should exist)
|
64
|
+
messages.rows.flatten.each do |each|
|
65
|
+
step %(the file "#{log_file}" should contain "#{each}")
|
66
|
+
end
|
67
|
+
end
|
68
|
+
# rubocop:enable LineLength
|
69
|
+
|
70
|
+
Then(/^the command returns immediately$/) do
|
71
|
+
# noop
|
72
|
+
end
|
data/features/support/hooks.rb
CHANGED
@@ -3,11 +3,14 @@ Before do
|
|
3
3
|
end
|
4
4
|
|
5
5
|
Before('@sudo') do
|
6
|
+
ENV['TREMA_LOG_DIR'] = '.'
|
7
|
+
ENV['TREMA_PID_DIR'] = '.'
|
8
|
+
ENV['TREMA_SOCKET_DIR'] = '.'
|
6
9
|
fail 'sudo authentication failed' unless system 'sudo -v'
|
7
10
|
@aruba_timeout_seconds = 10
|
8
11
|
end
|
9
12
|
|
10
13
|
After do
|
11
|
-
run
|
14
|
+
run "trema killall --all -S #{ENV['TREMA_SOCKET_DIR']}"
|
12
15
|
sleep 5
|
13
16
|
end
|
@@ -1,12 +1,8 @@
|
|
1
|
-
Feature:
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
| TREMA_PID_DIR | . |
|
7
|
-
| TREMA_SOCKET_DIR | . |
|
8
|
-
And a file named "packet_in_controller.rb" with:
|
9
|
-
"""
|
1
|
+
Feature: delete_link
|
2
|
+
@sudo
|
3
|
+
Scenario: trema delete_link 0xabc host1
|
4
|
+
Given a file named "packet_in_controller.rb" with:
|
5
|
+
"""ruby
|
10
6
|
class PacketInController < Trema::Controller
|
11
7
|
def packet_in(dpid, message)
|
12
8
|
logger.info 'new packet_in'
|
@@ -14,7 +10,7 @@ Feature: trema start command
|
|
14
10
|
end
|
15
11
|
"""
|
16
12
|
And a file named "trema.conf" with:
|
17
|
-
"""
|
13
|
+
"""ruby
|
18
14
|
vswitch { datapath_id 0xabc }
|
19
15
|
vhost('host1') { ip '192.168.0.1' }
|
20
16
|
vhost('host2') { ip '192.168.0.2' }
|
@@ -22,9 +18,9 @@ Feature: trema start command
|
|
22
18
|
link '0xabc', 'host2'
|
23
19
|
"""
|
24
20
|
And I run `trema run packet_in_controller.rb -c trema.conf -d`
|
25
|
-
|
26
|
-
@sudo
|
27
|
-
Scenario: trema delete_link 0xabc host1
|
28
21
|
When I successfully run `trema delete_link 0xabc host1`
|
29
22
|
And I successfully run `trema send_packets --source host1 --dest host2`
|
30
23
|
Then the file "PacketInController.log" should not contain "new packet_in"
|
24
|
+
|
25
|
+
@wip
|
26
|
+
Scenario: "link not found" error
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Feature: --all option
|
2
|
+
|
3
|
+
--all option kills all known trema processes
|
4
|
+
|
5
|
+
@sudo
|
6
|
+
Scenario: killall --all
|
7
|
+
Given a file named "null_controller.rb" with:
|
8
|
+
"""ruby
|
9
|
+
class NullController < Trema::Controller; end
|
10
|
+
"""
|
11
|
+
And a file named "void_controller.rb" with:
|
12
|
+
"""ruby
|
13
|
+
class VoidController < Trema::Controller; end
|
14
|
+
"""
|
15
|
+
And I successfully run `trema run null_controller.rb -d`
|
16
|
+
And I successfully run `trema run void_controller.rb -p 6654 -d`
|
17
|
+
When I successfully run `trema killall --all`
|
18
|
+
Then the following files should not exist:
|
19
|
+
| NullController.pid |
|
20
|
+
| VoidController.pid |
|
@@ -1,53 +1,35 @@
|
|
1
|
-
Feature:
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
| TREMA_PID_DIR | . |
|
7
|
-
| TREMA_SOCKET_DIR | . |
|
8
|
-
And a file named "null_controller.rb" with:
|
9
|
-
"""
|
1
|
+
Feature: killall
|
2
|
+
@sudo
|
3
|
+
Scenario: killall controller_name
|
4
|
+
Given a file named "null_controller.rb" with:
|
5
|
+
"""ruby
|
10
6
|
class NullController < Trema::Controller; end
|
11
7
|
"""
|
12
8
|
And a file named "trema.conf" with:
|
13
|
-
"""
|
9
|
+
"""ruby
|
14
10
|
vswitch { datapath_id 0xabc }
|
15
11
|
vhost('host1') { ip '192.168.0.1' }
|
16
12
|
vhost('host2') { ip '192.168.0.2' }
|
17
13
|
link '0xabc', 'host1'
|
18
14
|
link '0xabc', 'host2'
|
19
15
|
"""
|
20
|
-
And I run `trema run null_controller.rb -c trema.conf -d`
|
21
16
|
And a file named "void_controller.rb" with:
|
22
|
-
"""
|
17
|
+
"""ruby
|
23
18
|
class VoidController < Trema::Controller; end
|
24
19
|
"""
|
25
|
-
And I run `trema run
|
26
|
-
|
27
|
-
@sudo
|
28
|
-
Scenario: killall controller_name
|
20
|
+
And I successfully run `trema run null_controller.rb -c trema.conf -d`
|
21
|
+
And I successfully run `trema run void_controller.rb -p 6654 -d`
|
29
22
|
When I successfully run `trema killall NullController`
|
30
23
|
Then virtual links should not exist
|
31
|
-
And I successfully run `ls`
|
32
24
|
And the following files should not exist:
|
33
25
|
| NullController.pid |
|
34
26
|
| vhost.host1.pid |
|
35
27
|
| vhost.host2.pid |
|
36
28
|
And the following files should exist:
|
37
29
|
| VoidController.pid |
|
38
|
-
|
39
|
-
@sudo
|
40
|
-
Scenario: killall --all
|
41
|
-
When I successfully run `trema killall --all`
|
42
|
-
Then virtual links should not exist
|
43
|
-
And the following files should not exist:
|
44
|
-
| NullController.pid |
|
45
|
-
| VoidController.pid |
|
46
|
-
| vhost.host1.pid |
|
47
|
-
| vhost.host2.pid |
|
48
30
|
|
49
31
|
@sudo
|
50
|
-
Scenario:
|
32
|
+
Scenario: "Controller process does not exist" error
|
51
33
|
When I run `trema killall NO_SUCH_NAME`
|
52
34
|
Then the exit status should not be 0
|
53
35
|
And the output should contain:
|
@@ -0,0 +1,38 @@
|
|
1
|
+
Feature: -S (--socket_dir) option
|
2
|
+
|
3
|
+
-S (--socket_dir) option specifies the location to find socket files
|
4
|
+
|
5
|
+
@sudo
|
6
|
+
Scenario: -S option
|
7
|
+
Given a file named "null_controller.rb" with:
|
8
|
+
"""ruby
|
9
|
+
class NullController < Trema::Controller; end
|
10
|
+
"""
|
11
|
+
And I successfully run `trema run null_controller.rb -d`
|
12
|
+
When I successfully run `trema killall NullController -S .`
|
13
|
+
And the file "NullController.pid" should not exist
|
14
|
+
|
15
|
+
@sudo
|
16
|
+
Scenario: --socket_dir option
|
17
|
+
Given a file named "null_controller.rb" with:
|
18
|
+
"""ruby
|
19
|
+
class NullController < Trema::Controller; end
|
20
|
+
"""
|
21
|
+
And I successfully run `trema run null_controller.rb -d`
|
22
|
+
When I successfully run `trema killall NullController --socket_dir .`
|
23
|
+
And the file "NullController.pid" should not exist
|
24
|
+
|
25
|
+
@sudo
|
26
|
+
Scenario: "Controller process does not exist" error
|
27
|
+
Given a file named "null_controller.rb" with:
|
28
|
+
"""ruby
|
29
|
+
class NullController < Trema::Controller; end
|
30
|
+
"""
|
31
|
+
And I successfully run `trema run null_controller.rb -d`
|
32
|
+
When I run `trema killall NullController -S /tmp`
|
33
|
+
Then the exit status should not be 0
|
34
|
+
And the output should contain:
|
35
|
+
"""
|
36
|
+
Controller process "NullController" does not exist.
|
37
|
+
"""
|
38
|
+
And the file "NullController.pid" should exist
|
@@ -0,0 +1,66 @@
|
|
1
|
+
Feature: -c (--conf) option
|
2
|
+
|
3
|
+
-c (--conf) option specifies emulated network configuration
|
4
|
+
|
5
|
+
Background:
|
6
|
+
Given a file named "hello.rb" with:
|
7
|
+
"""ruby
|
8
|
+
class Hello < Trema::Controller
|
9
|
+
def switch_ready(dpid)
|
10
|
+
logger.info format('Hello %s!', dpid.to_hex)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
"""
|
14
|
+
And a file named "trema.conf" with:
|
15
|
+
"""ruby
|
16
|
+
vswitch { datapath_id 0xabc }
|
17
|
+
"""
|
18
|
+
|
19
|
+
@sudo
|
20
|
+
Scenario: -c option
|
21
|
+
When I successfully run `trema run hello.rb -c trema.conf -d`
|
22
|
+
And I run `sleep 5`
|
23
|
+
Then the file "Hello.log" should contain "Hello 0xabc!"
|
24
|
+
|
25
|
+
@sudo
|
26
|
+
Scenario: --conf option
|
27
|
+
When I successfully run `trema run hello.rb --conf trema.conf -d`
|
28
|
+
And I run `sleep 5`
|
29
|
+
Then the file "Hello.log" should contain "Hello 0xabc!"
|
30
|
+
|
31
|
+
@sudo
|
32
|
+
Scenario: "No such file" error
|
33
|
+
When I run `trema run hello.rb -c nosuchfile -d`
|
34
|
+
Then the exit status should not be 0
|
35
|
+
And the stderr should contain:
|
36
|
+
"""
|
37
|
+
No such file
|
38
|
+
"""
|
39
|
+
|
40
|
+
@sudo
|
41
|
+
Scenario: NameError
|
42
|
+
Given a file named "invalid_trema.conf" with:
|
43
|
+
"""
|
44
|
+
Foo Bar Baz
|
45
|
+
"""
|
46
|
+
And a file named "null_controller.rb" with:
|
47
|
+
"""ruby
|
48
|
+
class NullController < Trema::Controller; end
|
49
|
+
"""
|
50
|
+
When I run `trema run null_controller.rb -c invalid_trema.conf`
|
51
|
+
Then the exit status should not be 0
|
52
|
+
Then the output should contain "uninitialized constant Phut::Syntax::Baz (NameError)"
|
53
|
+
|
54
|
+
@sudo
|
55
|
+
Scenario: SyntaxError
|
56
|
+
Given a file named "invalid_trema.conf" with:
|
57
|
+
"""
|
58
|
+
Today is 19 June 2015
|
59
|
+
"""
|
60
|
+
And a file named "null_controller.rb" with:
|
61
|
+
"""ruby
|
62
|
+
class NullController < Trema::Controller; end
|
63
|
+
"""
|
64
|
+
When I run `trema run null_controller.rb -c invalid_trema.conf`
|
65
|
+
Then the exit status should not be 0
|
66
|
+
And the output should contain "(SyntaxError)"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Feature: -d (--daemonize) option
|
2
|
+
|
3
|
+
-d (--daemonize) runs a controller as a daemon
|
4
|
+
|
5
|
+
Background:
|
6
|
+
Given a file named "null_controller.rb" with:
|
7
|
+
"""ruby
|
8
|
+
class NullController < Trema::Controller; end
|
9
|
+
"""
|
10
|
+
|
11
|
+
@sudo
|
12
|
+
Scenario: -d option
|
13
|
+
When I successfully run `trema run null_controller.rb -d`
|
14
|
+
Then the command returns immediately
|
15
|
+
|
16
|
+
@sudo
|
17
|
+
Scenario: --daemonize option
|
18
|
+
When I successfully run `trema run null_controller.rb --daemonize`
|
19
|
+
Then the command returns immediately
|
@@ -0,0 +1,32 @@
|
|
1
|
+
Feature: -L (--log_dir) option
|
2
|
+
|
3
|
+
-L (--log_dir) option specifies the location to put log files
|
4
|
+
|
5
|
+
Background:
|
6
|
+
Given a file named "null_controller.rb" with:
|
7
|
+
"""ruby
|
8
|
+
class NullController < Trema::Controller; end
|
9
|
+
"""
|
10
|
+
|
11
|
+
@sudo
|
12
|
+
Scenario: -L option
|
13
|
+
Given a directory named "log"
|
14
|
+
When I successfully run `trema run null_controller.rb -L log -d`
|
15
|
+
And I run `sleep 3`
|
16
|
+
Then a file named "log/NullController.log" should exist
|
17
|
+
|
18
|
+
@sudo
|
19
|
+
Scenario: --log_dir option
|
20
|
+
Given a directory named "log"
|
21
|
+
When I successfully run `trema run null_controller.rb --log_dir log -d`
|
22
|
+
And I run `sleep 3`
|
23
|
+
Then a file named "log/NullController.log" should exist
|
24
|
+
|
25
|
+
@sudo
|
26
|
+
Scenario: "No such directory" error
|
27
|
+
When I run `trema run null_controller.rb -L log -d`
|
28
|
+
Then the exit status should not be 0
|
29
|
+
And the stderr should contain:
|
30
|
+
"""
|
31
|
+
No such directory
|
32
|
+
"""
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Feature: -l (--logging_level) option
|
2
|
+
Background:
|
3
|
+
Given a file named "hello.rb" with:
|
4
|
+
"""ruby
|
5
|
+
class Hello < Trema::Controller
|
6
|
+
def start(_args)
|
7
|
+
logger.debug 'Konnichi Wa'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
"""
|
11
|
+
|
12
|
+
@sudo
|
13
|
+
Scenario: the default logging level
|
14
|
+
When I trema run "hello.rb"
|
15
|
+
And the file "Hello.log" should not contain "DEBUG -- : Konnichi Wa"
|
16
|
+
|
17
|
+
@sudo
|
18
|
+
Scenario: --logging_level debug
|
19
|
+
When I run `trema run hello.rb --logging_level debug -d`
|
20
|
+
And I run `sleep 3`
|
21
|
+
And the file "Hello.log" should contain "DEBUG -- : Konnichi Wa"
|
22
|
+
|
23
|
+
@sudo
|
24
|
+
Scenario: "Invalid logging level" error
|
25
|
+
When I run `trema run hello.rb --logging_level hoge -d`
|
26
|
+
Then the exit status should not be 0
|
27
|
+
And the stderr should contain:
|
28
|
+
"""
|
29
|
+
Invalid logging level: hoge
|
30
|
+
"""
|
@@ -0,0 +1,39 @@
|
|
1
|
+
Feature: --openflow13 option
|
2
|
+
|
3
|
+
Use --openflow13 option to enable OpenFlow 1.3
|
4
|
+
|
5
|
+
Background:
|
6
|
+
Given a file named "openflow_version.rb" with:
|
7
|
+
"""ruby
|
8
|
+
class OpenflowVersion < Trema::Controller
|
9
|
+
def switch_ready(dpid)
|
10
|
+
send_message dpid, Echo::Request.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def echo_reply(dpid, message)
|
14
|
+
logger.info "ofp_version = #{message.ofp_version}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
"""
|
18
|
+
And a file named "trema.conf" with:
|
19
|
+
"""ruby
|
20
|
+
vswitch { datapath_id 0xabc }
|
21
|
+
"""
|
22
|
+
|
23
|
+
@sudo
|
24
|
+
Scenario: --openflow13 option
|
25
|
+
When I successfully run `trema run openflow_version.rb --openflow13 -c trema.conf -d`
|
26
|
+
And I run `sleep 5`
|
27
|
+
Then the file "OpenflowVersion.log" should contain "ofp_version = 4"
|
28
|
+
|
29
|
+
@sudo
|
30
|
+
Scenario: --no-openflow13 option
|
31
|
+
When I successfully run `trema run openflow_version.rb --no-openflow13 -c trema.conf -d`
|
32
|
+
And I run `sleep 5`
|
33
|
+
Then the file "OpenflowVersion.log" should contain "ofp_version = 1"
|
34
|
+
|
35
|
+
@sudo
|
36
|
+
Scenario: the default OpenFlow version is 1.0
|
37
|
+
When I successfully run `trema run openflow_version.rb -c trema.conf -d`
|
38
|
+
And I run `sleep 5`
|
39
|
+
Then the file "OpenflowVersion.log" should contain "ofp_version = 1"
|
@@ -0,0 +1,32 @@
|
|
1
|
+
Feature: -P (--pid_dir) option
|
2
|
+
|
3
|
+
-P (--pid_dir) option specifies the location to put pid files
|
4
|
+
|
5
|
+
Background:
|
6
|
+
Given a file named "null_controller.rb" with:
|
7
|
+
"""ruby
|
8
|
+
class NullController < Trema::Controller; end
|
9
|
+
"""
|
10
|
+
|
11
|
+
@sudo
|
12
|
+
Scenario: -P option
|
13
|
+
Given a directory named "pid"
|
14
|
+
When I successfully run `trema run null_controller.rb -P pid -d`
|
15
|
+
And I run `sleep 3`
|
16
|
+
Then a file named "pid/NullController.pid" should exist
|
17
|
+
|
18
|
+
@sudo
|
19
|
+
Scenario: --pid_dir option
|
20
|
+
Given a directory named "pid"
|
21
|
+
When I successfully run `trema run null_controller.rb --pid_dir pid -d`
|
22
|
+
And I run `sleep 3`
|
23
|
+
Then a file named "pid/NullController.pid" should exist
|
24
|
+
|
25
|
+
@sudo
|
26
|
+
Scenario: "No such directory" error
|
27
|
+
When I run `trema run null_controller.rb -P pid -d`
|
28
|
+
Then the exit status should not be 0
|
29
|
+
And the stderr should contain:
|
30
|
+
"""
|
31
|
+
No such directory
|
32
|
+
"""
|
@@ -0,0 +1,32 @@
|
|
1
|
+
Feature: -p (--port) option
|
2
|
+
|
3
|
+
-p (--port) option overrides the default openflow channel port.
|
4
|
+
|
5
|
+
Background:
|
6
|
+
Given a file named "switch_ready.rb" with:
|
7
|
+
"""ruby
|
8
|
+
class SwitchReady < Trema::Controller
|
9
|
+
def switch_ready(dpid)
|
10
|
+
logger.info 'connected to port 1234'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
"""
|
14
|
+
And a file named "trema.conf" with:
|
15
|
+
"""ruby
|
16
|
+
vswitch {
|
17
|
+
datapath_id 0xabc
|
18
|
+
port 1234
|
19
|
+
}
|
20
|
+
"""
|
21
|
+
|
22
|
+
@sudo
|
23
|
+
Scenario: -p option
|
24
|
+
When I successfully run `trema run -p 1234 switch_ready.rb -c trema.conf -d`
|
25
|
+
And I run `sleep 5`
|
26
|
+
Then the file "SwitchReady.log" should contain "connected to port 1234"
|
27
|
+
|
28
|
+
@sudo
|
29
|
+
Scenario: --port option
|
30
|
+
When I successfully run `trema run --port 1234 switch_ready.rb -c trema.conf -d`
|
31
|
+
And I run `sleep 5`
|
32
|
+
Then the file "SwitchReady.log" should contain "connected to port 1234"
|