trema 0.8.4 → 0.9.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 +6 -0
 - data/README.md +6 -0
 - data/bin/trema +12 -4
 - data/features/.nav +6 -0
 - data/features/api/logging.feature +10 -3
 - data/features/api/send_flow_mod_add.feature +8 -3
 - data/features/handlers/barrier_reply.feature +6 -1
 - data/features/handlers/description_stats_reply.feature +6 -1
 - data/features/handlers/echo_reply.feature +6 -1
 - data/features/handlers/hello_failed.feature +6 -1
 - data/features/handlers/packet_in.feature +8 -3
 - data/features/handlers/start.feature +6 -1
 - data/features/handlers/switch_disconnected.feature +6 -1
 - data/features/handlers/switch_ready.feature +6 -1
 - data/features/logger/debug.feature +10 -4
 - data/features/logger/error.feature +10 -4
 - data/features/logger/fatal.feature +10 -4
 - data/features/logger/info.feature +10 -4
 - data/features/logger/warn.feature +10 -4
 - data/features/step_definitions/dump_flows_steps.rb +6 -8
 - data/features/step_definitions/rest_api_steps.rb +3 -3
 - data/features/step_definitions/show_stats_steps.rb +3 -1
 - data/features/step_definitions/trema_steps.rb +17 -8
 - data/features/support/hooks.rb +3 -6
 - data/features/trema_delete_link/delete_link.feature +7 -0
 - data/features/trema_dump_flows/dump_flows.feature +49 -0
 - data/features/trema_killall/all_option.feature +6 -1
 - data/features/trema_killall/killall.feature +6 -1
 - data/features/trema_killall/socket_dir_option.feature +7 -0
 - data/features/trema_netns/README.md +5 -0
 - data/features/trema_netns/netns.feature +55 -0
 - data/features/trema_run/conf_option.feature +8 -3
 - data/features/trema_run/daemonize_option.feature +6 -1
 - data/features/trema_run/log_dir_option.feature +7 -3
 - data/features/trema_run/logging_level_option.feature +7 -2
 - data/features/trema_run/openflow13_option.feature +9 -4
 - data/features/trema_run/pid_dir_option.feature +7 -3
 - data/features/trema_run/port_option.feature +8 -3
 - data/features/trema_run/run.feature +7 -0
 - data/features/trema_run/socket_dir_option.feature +13 -11
 - data/features/trema_start/start.feature +10 -5
 - data/features/trema_stop/stop.feature +8 -3
 - data/lib/trema/version.rb +1 -1
 - data/spec/spec_helper.rb +1 -1
 - data/trema.gemspec +8 -8
 - metadata +21 -19
 - data/.ruby-version +0 -1
 
| 
         @@ -1,6 +1,11 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            Feature: Trema::Controller#logger.warn
         
     | 
| 
       2 
2 
     | 
    
         
             
              Background:
         
     | 
| 
       3 
     | 
    
         
            -
                Given  
     | 
| 
      
 3 
     | 
    
         
            +
                Given I set the environment variables to:
         
     | 
| 
      
 4 
     | 
    
         
            +
                  | variable         | value |
         
     | 
| 
      
 5 
     | 
    
         
            +
                  | TREMA_LOG_DIR    | .     |
         
     | 
| 
      
 6 
     | 
    
         
            +
                  | TREMA_PID_DIR    | .     |
         
     | 
| 
      
 7 
     | 
    
         
            +
                  | TREMA_SOCKET_DIR | .     |
         
     | 
| 
      
 8 
     | 
    
         
            +
                And a file named "hello.rb" with:
         
     | 
| 
       4 
9 
     | 
    
         
             
                  """ruby
         
     | 
| 
       5 
10 
     | 
    
         
             
                  class Hello < Trema::Controller
         
     | 
| 
       6 
11 
     | 
    
         
             
                    def start(_args)
         
     | 
| 
         @@ -12,6 +17,7 @@ Feature: Trema::Controller#logger.warn 
     | 
|
| 
       12 
17 
     | 
    
         
             
              @sudo
         
     | 
| 
       13 
18 
     | 
    
         
             
              Scenario: the default logging level
         
     | 
| 
       14 
19 
     | 
    
         
             
                When I trema run "hello.rb" interactively
         
     | 
| 
      
 20 
     | 
    
         
            +
                And sleep 2
         
     | 
| 
       15 
21 
     | 
    
         
             
                And I trema killall "Hello"
         
     | 
| 
       16 
22 
     | 
    
         
             
                Then the output should contain "Konnichi Wa"
         
     | 
| 
       17 
23 
     | 
    
         
             
                And the file "Hello.log" should contain "WARN -- : Konnichi Wa"
         
     | 
| 
         @@ -19,7 +25,7 @@ Feature: Trema::Controller#logger.warn 
     | 
|
| 
       19 
25 
     | 
    
         
             
              @sudo
         
     | 
| 
       20 
26 
     | 
    
         
             
              Scenario: --logging_level warn
         
     | 
| 
       21 
27 
     | 
    
         
             
                When I run `trema run hello.rb --logging_level warn` interactively
         
     | 
| 
       22 
     | 
    
         
            -
                And  
     | 
| 
      
 28 
     | 
    
         
            +
                And sleep 2
         
     | 
| 
       23 
29 
     | 
    
         
             
                And I trema killall "Hello"
         
     | 
| 
       24 
30 
     | 
    
         
             
                Then the output should contain "Konnichi Wa"
         
     | 
| 
       25 
31 
     | 
    
         
             
                And the file "Hello.log" should contain "WARN -- : Konnichi Wa"
         
     | 
| 
         @@ -27,7 +33,7 @@ Feature: Trema::Controller#logger.warn 
     | 
|
| 
       27 
33 
     | 
    
         
             
              @sudo
         
     | 
| 
       28 
34 
     | 
    
         
             
              Scenario: -v
         
     | 
| 
       29 
35 
     | 
    
         
             
                When I run `trema -v run hello.rb` interactively
         
     | 
| 
       30 
     | 
    
         
            -
                And  
     | 
| 
      
 36 
     | 
    
         
            +
                And sleep 2
         
     | 
| 
       31 
37 
     | 
    
         
             
                And I trema killall "Hello"
         
     | 
| 
       32 
38 
     | 
    
         
             
                Then the output should contain "Konnichi Wa"
         
     | 
| 
       33 
39 
     | 
    
         
             
                And the file "Hello.log" should contain "WARN -- : Konnichi Wa"
         
     | 
| 
         @@ -35,7 +41,7 @@ Feature: Trema::Controller#logger.warn 
     | 
|
| 
       35 
41 
     | 
    
         
             
              @sudo
         
     | 
| 
       36 
42 
     | 
    
         
             
              Scenario: --verbose
         
     | 
| 
       37 
43 
     | 
    
         
             
                When I run `trema --verbose run hello.rb` interactively
         
     | 
| 
       38 
     | 
    
         
            -
                And  
     | 
| 
      
 44 
     | 
    
         
            +
                And sleep 2
         
     | 
| 
       39 
45 
     | 
    
         
             
                And I trema killall "Hello"
         
     | 
| 
       40 
46 
     | 
    
         
             
                Then the output should contain "Konnichi Wa"
         
     | 
| 
       41 
47 
     | 
    
         
             
                And the file "Hello.log" should contain "WARN -- : Konnichi Wa"
         
     | 
| 
         @@ -1,13 +1,11 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
               
     | 
| 
       5 
     | 
    
         
            -
               
     | 
| 
       6 
     | 
    
         
            -
              expect( 
     | 
| 
      
 1 
     | 
    
         
            +
            Then(/^the switch "(.*?)" has (\d+) flow entr(?:y|ies)$/) do |switch, number|
         
     | 
| 
      
 2 
     | 
    
         
            +
              # FIXME: Read TREMA_SOCKET_DIR in trema dump_flows
         
     | 
| 
      
 3 
     | 
    
         
            +
              command = "trema dump_flows #{switch} -S ."
         
     | 
| 
      
 4 
     | 
    
         
            +
              step "I successfully run `#{command}`"
         
     | 
| 
      
 5 
     | 
    
         
            +
              dump_flows = aruba.command_monitor.find(Aruba.platform.detect_ruby(command))
         
     | 
| 
      
 6 
     | 
    
         
            +
              expect(dump_flows.output.split("\n").size - 1).to eq(number.to_i)
         
     | 
| 
       7 
7 
     | 
    
         
             
            end
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
            Then(/^the switch "(.*?)" has no flow entry$/) do |switch|
         
     | 
| 
       10 
10 
     | 
    
         
             
              step %(the switch "#{switch}" has 0 flow entry)
         
     | 
| 
       11 
11 
     | 
    
         
             
            end
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
            # rubocop:enable LineLength
         
     | 
| 
         @@ -9,18 +9,18 @@ begin 
     | 
|
| 
       9 
9 
     | 
    
         
             
              end
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
       11 
11 
     | 
    
         
             
              Given(/^I send a GET request for "([^\"]*)"$/) do |path|
         
     | 
| 
       12 
     | 
    
         
            -
                 
     | 
| 
      
 12 
     | 
    
         
            +
                cd('.') { get path }
         
     | 
| 
       13 
13 
     | 
    
         
             
              end
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
              # rubocop:disable LineLength
         
     | 
| 
       16 
16 
     | 
    
         
             
              Given(/^I send a POST request for "([^\"]*)" with body "([^\"]*)"$/) do |path, body|
         
     | 
| 
       17 
     | 
    
         
            -
                 
     | 
| 
      
 17 
     | 
    
         
            +
                cd('.') { post path, Object.instance_eval(body) }
         
     | 
| 
       18 
18 
     | 
    
         
             
              end
         
     | 
| 
       19 
19 
     | 
    
         
             
              # rubocop:enable LineLength
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
21 
     | 
    
         
             
              # rubocop:disable LineLength
         
     | 
| 
       22 
22 
     | 
    
         
             
              Given(/^I send a DELETE request for "([^\"]*)" with body "([^\"]*)"$/) do |path, body|
         
     | 
| 
       23 
     | 
    
         
            -
                 
     | 
| 
      
 23 
     | 
    
         
            +
                cd('.') { delete path, Object.instance_eval(body) }
         
     | 
| 
       24 
24 
     | 
    
         
             
              end
         
     | 
| 
       25 
25 
     | 
    
         
             
              # rubocop:enable LineLength
         
     | 
| 
       26 
26 
     | 
    
         | 
| 
         @@ -29,10 +29,12 @@ Then(/^the number of packets received by "(.*?)" should be:$/) do |host_name, ta 
     | 
|
| 
       29 
29 
     | 
    
         
             
              command = "trema show_stats #{host_name}"
         
     | 
| 
       30 
30 
     | 
    
         
             
              step "I run `#{command}`"
         
     | 
| 
       31 
31 
     | 
    
         | 
| 
      
 32 
     | 
    
         
            +
              output = aruba.command_monitor.find(Aruba.platform.detect_ruby(command)).output
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
       32 
34 
     | 
    
         
             
              result = Hash.new(0)
         
     | 
| 
       33 
35 
     | 
    
         
             
              cd('.') do
         
     | 
| 
       34 
36 
     | 
    
         
             
                received = false
         
     | 
| 
       35 
     | 
    
         
            -
                 
     | 
| 
      
 37 
     | 
    
         
            +
                output.split("\n").each do |each|
         
     | 
| 
       36 
38 
     | 
    
         
             
                  case each
         
     | 
| 
       37 
39 
     | 
    
         
             
                  when /Packets sent/
         
     | 
| 
       38 
40 
     | 
    
         
             
                    next
         
     | 
| 
         @@ -26,14 +26,14 @@ When(/^I trema run "([^"]*)"$/) do |controller_file| 
     | 
|
| 
       26 
26 
     | 
    
         
             
              step %(I run `trema run #{controller_path} -d`)
         
     | 
| 
       27 
27 
     | 
    
         
             
            end
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
      
 29 
     | 
    
         
            +
            Given(/^I trema run "([^"]*)" with args "([^"]*)"$/) do |controller, args|
         
     | 
| 
      
 30 
     | 
    
         
            +
              controller_path = File.join('..', '..', controller)
         
     | 
| 
      
 31 
     | 
    
         
            +
              step %(I successfully run `trema run #{controller_path} #{args}`)
         
     | 
| 
      
 32 
     | 
    
         
            +
              step %(sleep 10)
         
     | 
| 
      
 33 
     | 
    
         
            +
            end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
       29 
35 
     | 
    
         
             
            When(/^I trema run "([^"]*)" interactively$/) do |controller_file|
         
     | 
| 
       30 
     | 
    
         
            -
               
     | 
| 
       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`)
         
     | 
| 
      
 36 
     | 
    
         
            +
              step %(I run `trema run #{controller_file}` interactively)
         
     | 
| 
       37 
37 
     | 
    
         
             
            end
         
     | 
| 
       38 
38 
     | 
    
         | 
| 
       39 
39 
     | 
    
         
             
            # rubocop:disable LineLength
         
     | 
| 
         @@ -50,7 +50,7 @@ When(/^I trema run "([^"]*)"( interactively)? with the configuration "([^"]*)"$/ 
     | 
|
| 
       50 
50 
     | 
    
         
             
              else
         
     | 
| 
       51 
51 
     | 
    
         
             
                step %(I successfully run `trema run #{run_arguments} -d`)
         
     | 
| 
       52 
52 
     | 
    
         
             
              end
         
     | 
| 
       53 
     | 
    
         
            -
              step %( 
     | 
| 
      
 53 
     | 
    
         
            +
              step %(sleep 10)
         
     | 
| 
       54 
54 
     | 
    
         
             
            end
         
     | 
| 
       55 
55 
     | 
    
         
             
            # rubocop:enable LineLength
         
     | 
| 
       56 
56 
     | 
    
         | 
| 
         @@ -58,6 +58,11 @@ When(/^I trema killall "([^"]*)"$/) do |controller_name| 
     | 
|
| 
       58 
58 
     | 
    
         
             
              step %(I successfully run `trema killall #{controller_name}`)
         
     | 
| 
       59 
59 
     | 
    
         
             
            end
         
     | 
| 
       60 
60 
     | 
    
         | 
| 
      
 61 
     | 
    
         
            +
            When(/^I delete the link between "([^"]*)" and "([^"]*)"$/) do |peer1, peer2|
         
     | 
| 
      
 62 
     | 
    
         
            +
              step %(I successfully run `trema delete_link #{peer1} #{peer2}`)
         
     | 
| 
      
 63 
     | 
    
         
            +
              step %(sleep 3)
         
     | 
| 
      
 64 
     | 
    
         
            +
            end
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
       61 
66 
     | 
    
         
             
            # rubocop:disable LineLength
         
     | 
| 
       62 
67 
     | 
    
         
             
            Then(/^the log file "([^"]*)" should contain following messages:$/) do |log_file, messages|
         
     | 
| 
       63 
68 
     | 
    
         
             
              step %(a file named "#{log_file}" should exist)
         
     | 
| 
         @@ -70,3 +75,7 @@ end 
     | 
|
| 
       70 
75 
     | 
    
         
             
            Then(/^the command returns immediately$/) do
         
     | 
| 
       71 
76 
     | 
    
         
             
              # noop
         
     | 
| 
       72 
77 
     | 
    
         
             
            end
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
            When(/^sleep (\d+)$/) do |time|
         
     | 
| 
      
 80 
     | 
    
         
            +
              sleep time.to_i
         
     | 
| 
      
 81 
     | 
    
         
            +
            end
         
     | 
    
        data/features/support/hooks.rb
    CHANGED
    
    | 
         @@ -3,14 +3,11 @@ 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'] = '.'
         
     | 
| 
       9 
6 
     | 
    
         
             
              fail 'sudo authentication failed' unless system 'sudo -v'
         
     | 
| 
       10 
     | 
    
         
            -
              @aruba_timeout_seconds =  
     | 
| 
      
 7 
     | 
    
         
            +
              @aruba_timeout_seconds = 15
         
     | 
| 
       11 
8 
     | 
    
         
             
            end
         
     | 
| 
       12 
9 
     | 
    
         | 
| 
       13 
10 
     | 
    
         
             
            After do
         
     | 
| 
       14 
     | 
    
         
            -
              run  
     | 
| 
       15 
     | 
    
         
            -
              sleep  
     | 
| 
      
 11 
     | 
    
         
            +
              run 'trema killall --all -S .'
         
     | 
| 
      
 12 
     | 
    
         
            +
              sleep 10
         
     | 
| 
       16 
13 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,4 +1,11 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            Feature: delete_link
         
     | 
| 
      
 2 
     | 
    
         
            +
              Background:
         
     | 
| 
      
 3 
     | 
    
         
            +
                Given I set the environment variables to:
         
     | 
| 
      
 4 
     | 
    
         
            +
                  | variable         | value |
         
     | 
| 
      
 5 
     | 
    
         
            +
                  | TREMA_LOG_DIR    | .     |
         
     | 
| 
      
 6 
     | 
    
         
            +
                  | TREMA_PID_DIR    | .     |
         
     | 
| 
      
 7 
     | 
    
         
            +
                  | TREMA_SOCKET_DIR | .     |
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
       2 
9 
     | 
    
         
             
              @sudo
         
     | 
| 
       3 
10 
     | 
    
         
             
              Scenario: trema delete_link 0xabc host1
         
     | 
| 
       4 
11 
     | 
    
         
             
                Given a file named "packet_in_controller.rb" with:
         
     | 
| 
         @@ -0,0 +1,49 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Feature: dump_flows
         
     | 
| 
      
 2 
     | 
    
         
            +
              Background:
         
     | 
| 
      
 3 
     | 
    
         
            +
                Given I set the environment variables to:
         
     | 
| 
      
 4 
     | 
    
         
            +
                  | variable         | value |
         
     | 
| 
      
 5 
     | 
    
         
            +
                  | TREMA_LOG_DIR    | .     |
         
     | 
| 
      
 6 
     | 
    
         
            +
                  | TREMA_PID_DIR    | .     |
         
     | 
| 
      
 7 
     | 
    
         
            +
                  | TREMA_SOCKET_DIR | .     |
         
     | 
| 
      
 8 
     | 
    
         
            +
                And a file named "noop_controller.rb" with:
         
     | 
| 
      
 9 
     | 
    
         
            +
                  """ruby
         
     | 
| 
      
 10 
     | 
    
         
            +
                  class NoopController < Trema::Controller; end
         
     | 
| 
      
 11 
     | 
    
         
            +
                  """
         
     | 
| 
      
 12 
     | 
    
         
            +
                And a file named "flow_mod_controller.rb" with:
         
     | 
| 
      
 13 
     | 
    
         
            +
                  """ruby
         
     | 
| 
      
 14 
     | 
    
         
            +
                  class FlowModController < Trema::Controller
         
     | 
| 
      
 15 
     | 
    
         
            +
                    def switch_ready(datapath_id)
         
     | 
| 
      
 16 
     | 
    
         
            +
                      send_flow_mod_add(datapath_id, match: Match.new)
         
     | 
| 
      
 17 
     | 
    
         
            +
                    end
         
     | 
| 
      
 18 
     | 
    
         
            +
                  end
         
     | 
| 
      
 19 
     | 
    
         
            +
                  """
         
     | 
| 
      
 20 
     | 
    
         
            +
                And a file named "trema.conf" with:
         
     | 
| 
      
 21 
     | 
    
         
            +
                  """ruby
         
     | 
| 
      
 22 
     | 
    
         
            +
                  vswitch { datapath_id 0xabc }
         
     | 
| 
      
 23 
     | 
    
         
            +
                  """
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
              @sudo
         
     | 
| 
      
 26 
     | 
    
         
            +
              Scenario: dump_flows (no flow entries)
         
     | 
| 
      
 27 
     | 
    
         
            +
                Given I trema run "noop_controller.rb" with the configuration "trema.conf"
         
     | 
| 
      
 28 
     | 
    
         
            +
                When I successfully run `trema dump_flows 0xabc`
         
     | 
| 
      
 29 
     | 
    
         
            +
                Then the output from "trema dump_flows 0xabc" should not contain "actions=drop"
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
              @sudo
         
     | 
| 
      
 32 
     | 
    
         
            +
              Scenario: dump_flows (one flow entry)
         
     | 
| 
      
 33 
     | 
    
         
            +
                Given I trema run "flow_mod_controller.rb" with the configuration "trema.conf"
         
     | 
| 
      
 34 
     | 
    
         
            +
                When I successfully run `trema dump_flows 0xabc`
         
     | 
| 
      
 35 
     | 
    
         
            +
                Then the output from "trema dump_flows 0xabc" should contain "actions=drop"
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
              @sudo
         
     | 
| 
      
 38 
     | 
    
         
            +
              Scenario: dump_flows OpenFlow 1.3 (no flow entries)
         
     | 
| 
      
 39 
     | 
    
         
            +
                Given I use OpenFlow 1.3
         
     | 
| 
      
 40 
     | 
    
         
            +
                And I trema run "noop_controller.rb" with the configuration "trema.conf"
         
     | 
| 
      
 41 
     | 
    
         
            +
                When I successfully run `trema dump_flows 0xabc`
         
     | 
| 
      
 42 
     | 
    
         
            +
                Then the output from "trema dump_flows 0xabc" should not contain "actions=drop"
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
              @sudo
         
     | 
| 
      
 45 
     | 
    
         
            +
              Scenario: dump_flows OpenFlow 1.3 (one flow entry)
         
     | 
| 
      
 46 
     | 
    
         
            +
                Given I use OpenFlow 1.3
         
     | 
| 
      
 47 
     | 
    
         
            +
                And I trema run "flow_mod_controller.rb" with the configuration "trema.conf"
         
     | 
| 
      
 48 
     | 
    
         
            +
                When I successfully run `trema dump_flows 0xabc`
         
     | 
| 
      
 49 
     | 
    
         
            +
                Then the output from "trema dump_flows 0xabc" should contain "actions=drop"
         
     | 
| 
         @@ -4,7 +4,12 @@ Feature: --all option 
     | 
|
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
              @sudo
         
     | 
| 
       6 
6 
     | 
    
         
             
              Scenario: killall --all
         
     | 
| 
       7 
     | 
    
         
            -
                Given  
     | 
| 
      
 7 
     | 
    
         
            +
                Given I set the environment variables to:
         
     | 
| 
      
 8 
     | 
    
         
            +
                  | variable         | value |
         
     | 
| 
      
 9 
     | 
    
         
            +
                  | TREMA_LOG_DIR    | .     |
         
     | 
| 
      
 10 
     | 
    
         
            +
                  | TREMA_PID_DIR    | .     |
         
     | 
| 
      
 11 
     | 
    
         
            +
                  | TREMA_SOCKET_DIR | .     |
         
     | 
| 
      
 12 
     | 
    
         
            +
                And a file named "null_controller.rb" with:
         
     | 
| 
       8 
13 
     | 
    
         
             
                  """ruby
         
     | 
| 
       9 
14 
     | 
    
         
             
                  class NullController < Trema::Controller; end
         
     | 
| 
       10 
15 
     | 
    
         
             
                  """
         
     | 
| 
         @@ -1,7 +1,12 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            Feature: killall
         
     | 
| 
       2 
2 
     | 
    
         
             
              @sudo
         
     | 
| 
       3 
3 
     | 
    
         
             
              Scenario: killall controller_name
         
     | 
| 
       4 
     | 
    
         
            -
                Given  
     | 
| 
      
 4 
     | 
    
         
            +
                Given I set the environment variables to:
         
     | 
| 
      
 5 
     | 
    
         
            +
                  | variable         | value |
         
     | 
| 
      
 6 
     | 
    
         
            +
                  | TREMA_LOG_DIR    | .     |
         
     | 
| 
      
 7 
     | 
    
         
            +
                  | TREMA_PID_DIR    | .     |
         
     | 
| 
      
 8 
     | 
    
         
            +
                  | TREMA_SOCKET_DIR | .     |
         
     | 
| 
      
 9 
     | 
    
         
            +
                And a file named "null_controller.rb" with:
         
     | 
| 
       5 
10 
     | 
    
         
             
                  """ruby
         
     | 
| 
       6 
11 
     | 
    
         
             
                  class NullController < Trema::Controller; end
         
     | 
| 
       7 
12 
     | 
    
         
             
                  """
         
     | 
| 
         @@ -2,6 +2,13 @@ Feature: -S (--socket_dir) option 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
              -S (--socket_dir) option specifies the location to find socket files
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
      
 5 
     | 
    
         
            +
              Background:
         
     | 
| 
      
 6 
     | 
    
         
            +
                Given I set the environment variables to:
         
     | 
| 
      
 7 
     | 
    
         
            +
                  | variable         | value |
         
     | 
| 
      
 8 
     | 
    
         
            +
                  | TREMA_LOG_DIR    | .     |
         
     | 
| 
      
 9 
     | 
    
         
            +
                  | TREMA_PID_DIR    | .     |
         
     | 
| 
      
 10 
     | 
    
         
            +
                  | TREMA_SOCKET_DIR | .     |
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
       5 
12 
     | 
    
         
             
              @sudo
         
     | 
| 
       6 
13 
     | 
    
         
             
              Scenario: -S option
         
     | 
| 
       7 
14 
     | 
    
         
             
                Given a file named "null_controller.rb" with:
         
     | 
| 
         @@ -0,0 +1,55 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Feature: netns
         
     | 
| 
      
 2 
     | 
    
         
            +
              Background:
         
     | 
| 
      
 3 
     | 
    
         
            +
                Given I set the environment variables to:
         
     | 
| 
      
 4 
     | 
    
         
            +
                  | variable         | value |
         
     | 
| 
      
 5 
     | 
    
         
            +
                  | TREMA_LOG_DIR    | .     |
         
     | 
| 
      
 6 
     | 
    
         
            +
                  | TREMA_PID_DIR    | .     |
         
     | 
| 
      
 7 
     | 
    
         
            +
                  | TREMA_SOCKET_DIR | .     |
         
     | 
| 
      
 8 
     | 
    
         
            +
                And a file named "simple_hub.rb" with:
         
     | 
| 
      
 9 
     | 
    
         
            +
                  """ruby
         
     | 
| 
      
 10 
     | 
    
         
            +
                  class SimpleHub < Trema::Controller
         
     | 
| 
      
 11 
     | 
    
         
            +
                    def switch_ready(dpid)
         
     | 
| 
      
 12 
     | 
    
         
            +
                      send_flow_mod_add(
         
     | 
| 
      
 13 
     | 
    
         
            +
                        dpid,
         
     | 
| 
      
 14 
     | 
    
         
            +
                        match: Match.new,
         
     | 
| 
      
 15 
     | 
    
         
            +
                        actions: SendOutPort.new(:flood)
         
     | 
| 
      
 16 
     | 
    
         
            +
                      )
         
     | 
| 
      
 17 
     | 
    
         
            +
                    end
         
     | 
| 
      
 18 
     | 
    
         
            +
                  end
         
     | 
| 
      
 19 
     | 
    
         
            +
                  """
         
     | 
| 
      
 20 
     | 
    
         
            +
                And a file named "simple_hub.conf" with:
         
     | 
| 
      
 21 
     | 
    
         
            +
                  """ruby
         
     | 
| 
      
 22 
     | 
    
         
            +
                  vswitch('simple_hub') { dpid 0x1 }
         
     | 
| 
      
 23 
     | 
    
         
            +
                  netns('host1') {
         
     | 
| 
      
 24 
     | 
    
         
            +
                    ip '192.168.1.2'
         
     | 
| 
      
 25 
     | 
    
         
            +
                    netmask '255.255.255.0'
         
     | 
| 
      
 26 
     | 
    
         
            +
                    route net: '0.0.0.0', gateway: '192.168.1.1'
         
     | 
| 
      
 27 
     | 
    
         
            +
                  }
         
     | 
| 
      
 28 
     | 
    
         
            +
                  netns('host2') {
         
     | 
| 
      
 29 
     | 
    
         
            +
                    ip '192.168.1.3'
         
     | 
| 
      
 30 
     | 
    
         
            +
                    netmask '255.255.255.0'
         
     | 
| 
      
 31 
     | 
    
         
            +
                    route net: '0.0.0.0', gateway: '192.168.1.1'
         
     | 
| 
      
 32 
     | 
    
         
            +
                  }
         
     | 
| 
      
 33 
     | 
    
         
            +
                  link 'simple_hub', 'host1'
         
     | 
| 
      
 34 
     | 
    
         
            +
                  link 'simple_hub', 'host2'
         
     | 
| 
      
 35 
     | 
    
         
            +
                  """
         
     | 
| 
      
 36 
     | 
    
         
            +
                And I trema run "simple_hub.rb" with the configuration "simple_hub.conf"
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
              @sudo
         
     | 
| 
      
 39 
     | 
    
         
            +
              Scenario: netns namespece
         
     | 
| 
      
 40 
     | 
    
         
            +
                When I run `trema netns host1` interactively
         
     | 
| 
      
 41 
     | 
    
         
            +
                And I type "ip addr"
         
     | 
| 
      
 42 
     | 
    
         
            +
                And I type "exit"
         
     | 
| 
      
 43 
     | 
    
         
            +
                Then the stdout should contain "192.168.1.2"
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
              @sudo
         
     | 
| 
      
 46 
     | 
    
         
            +
              Scenario Outline: netns namespece command
         
     | 
| 
      
 47 
     | 
    
         
            +
                When I run `<command>`
         
     | 
| 
      
 48 
     | 
    
         
            +
                Then the stdout should contain "<output>"
         
     | 
| 
      
 49 
     | 
    
         
            +
                Examples:
         
     | 
| 
      
 50 
     | 
    
         
            +
                   |command                                  |output                             |
         
     | 
| 
      
 51 
     | 
    
         
            +
                   |trema netns host1 ip add show host1      |192.168.1.2                        |
         
     | 
| 
      
 52 
     | 
    
         
            +
                   |trema netns host1 -- ping -c1 192.168.1.3|1 packets transmitted, 1 received, |
         
     | 
| 
      
 53 
     | 
    
         
            +
                   |trema netns host1 "ping -c1 192.168.1.3" |1 packets transmitted, 1 received, |
         
     | 
| 
      
 54 
     | 
    
         
            +
                   |trema netns host1 "ip addr \| grep 127"  |127.0.0.1                          |
         
     | 
| 
      
 55 
     | 
    
         
            +
                   |trema netns host1 ls $PWD                |simple_hub.conf                    |
         
     | 
| 
         @@ -3,7 +3,12 @@ Feature: -c (--conf) option 
     | 
|
| 
       3 
3 
     | 
    
         
             
              -c (--conf) option specifies emulated network configuration
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
              Background:
         
     | 
| 
       6 
     | 
    
         
            -
                Given  
     | 
| 
      
 6 
     | 
    
         
            +
                Given I set the environment variables to:
         
     | 
| 
      
 7 
     | 
    
         
            +
                  | variable         | value |
         
     | 
| 
      
 8 
     | 
    
         
            +
                  | TREMA_LOG_DIR    | .     |
         
     | 
| 
      
 9 
     | 
    
         
            +
                  | TREMA_PID_DIR    | .     |
         
     | 
| 
      
 10 
     | 
    
         
            +
                  | TREMA_SOCKET_DIR | .     |
         
     | 
| 
      
 11 
     | 
    
         
            +
                And a file named "hello.rb" with:
         
     | 
| 
       7 
12 
     | 
    
         
             
                  """ruby
         
     | 
| 
       8 
13 
     | 
    
         
             
                  class Hello < Trema::Controller
         
     | 
| 
       9 
14 
     | 
    
         
             
                    def switch_ready(dpid)
         
     | 
| 
         @@ -19,13 +24,13 @@ Feature: -c (--conf) option 
     | 
|
| 
       19 
24 
     | 
    
         
             
              @sudo
         
     | 
| 
       20 
25 
     | 
    
         
             
              Scenario: -c option
         
     | 
| 
       21 
26 
     | 
    
         
             
                When I successfully run `trema run hello.rb -c trema.conf -d`
         
     | 
| 
       22 
     | 
    
         
            -
                And  
     | 
| 
      
 27 
     | 
    
         
            +
                And sleep 5
         
     | 
| 
       23 
28 
     | 
    
         
             
                Then the file "Hello.log" should contain "Hello 0xabc!"
         
     | 
| 
       24 
29 
     | 
    
         | 
| 
       25 
30 
     | 
    
         
             
              @sudo
         
     | 
| 
       26 
31 
     | 
    
         
             
              Scenario: --conf option
         
     | 
| 
       27 
32 
     | 
    
         
             
                When I successfully run `trema run hello.rb --conf trema.conf -d`
         
     | 
| 
       28 
     | 
    
         
            -
                And  
     | 
| 
      
 33 
     | 
    
         
            +
                And sleep 5
         
     | 
| 
       29 
34 
     | 
    
         
             
                Then the file "Hello.log" should contain "Hello 0xabc!"
         
     | 
| 
       30 
35 
     | 
    
         | 
| 
       31 
36 
     | 
    
         
             
              @sudo
         
     | 
| 
         @@ -3,7 +3,12 @@ Feature: -d (--daemonize) option 
     | 
|
| 
       3 
3 
     | 
    
         
             
              -d (--daemonize) runs a controller as a daemon
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
              Background:
         
     | 
| 
       6 
     | 
    
         
            -
                Given  
     | 
| 
      
 6 
     | 
    
         
            +
                Given I set the environment variables to:
         
     | 
| 
      
 7 
     | 
    
         
            +
                  | variable         | value |
         
     | 
| 
      
 8 
     | 
    
         
            +
                  | TREMA_LOG_DIR    | .     |
         
     | 
| 
      
 9 
     | 
    
         
            +
                  | TREMA_PID_DIR    | .     |
         
     | 
| 
      
 10 
     | 
    
         
            +
                  | TREMA_SOCKET_DIR | .     |
         
     | 
| 
      
 11 
     | 
    
         
            +
                And a file named "null_controller.rb" with:
         
     | 
| 
       7 
12 
     | 
    
         
             
                  """ruby
         
     | 
| 
       8 
13 
     | 
    
         
             
                  class NullController < Trema::Controller; end
         
     | 
| 
       9 
14 
     | 
    
         
             
                  """
         
     | 
| 
         @@ -3,7 +3,11 @@ Feature: -L (--log_dir) option 
     | 
|
| 
       3 
3 
     | 
    
         
             
              -L (--log_dir) option specifies the location to put log files
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
              Background:
         
     | 
| 
       6 
     | 
    
         
            -
                Given  
     | 
| 
      
 6 
     | 
    
         
            +
                Given I set the environment variables to:
         
     | 
| 
      
 7 
     | 
    
         
            +
                  | variable         | value |
         
     | 
| 
      
 8 
     | 
    
         
            +
                  | TREMA_PID_DIR    | .     |
         
     | 
| 
      
 9 
     | 
    
         
            +
                  | TREMA_SOCKET_DIR | .     |
         
     | 
| 
      
 10 
     | 
    
         
            +
                And a file named "null_controller.rb" with:
         
     | 
| 
       7 
11 
     | 
    
         
             
                  """ruby
         
     | 
| 
       8 
12 
     | 
    
         
             
                  class NullController < Trema::Controller; end
         
     | 
| 
       9 
13 
     | 
    
         
             
                  """
         
     | 
| 
         @@ -12,14 +16,14 @@ Feature: -L (--log_dir) option 
     | 
|
| 
       12 
16 
     | 
    
         
             
              Scenario: -L option
         
     | 
| 
       13 
17 
     | 
    
         
             
                Given a directory named "log"
         
     | 
| 
       14 
18 
     | 
    
         
             
                When I successfully run `trema run null_controller.rb -L log -d`
         
     | 
| 
       15 
     | 
    
         
            -
                And  
     | 
| 
      
 19 
     | 
    
         
            +
                And sleep 3
         
     | 
| 
       16 
20 
     | 
    
         
             
                Then a file named "log/NullController.log" should exist
         
     | 
| 
       17 
21 
     | 
    
         | 
| 
       18 
22 
     | 
    
         
             
              @sudo
         
     | 
| 
       19 
23 
     | 
    
         
             
              Scenario: --log_dir option
         
     | 
| 
       20 
24 
     | 
    
         
             
                Given a directory named "log"
         
     | 
| 
       21 
25 
     | 
    
         
             
                When I successfully run `trema run null_controller.rb --log_dir log -d`
         
     | 
| 
       22 
     | 
    
         
            -
                And  
     | 
| 
      
 26 
     | 
    
         
            +
                And sleep 3
         
     | 
| 
       23 
27 
     | 
    
         
             
                Then a file named "log/NullController.log" should exist
         
     | 
| 
       24 
28 
     | 
    
         | 
| 
       25 
29 
     | 
    
         
             
              @sudo
         
     | 
| 
         @@ -1,6 +1,11 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            Feature: -l (--logging_level) option
         
     | 
| 
       2 
2 
     | 
    
         
             
              Background:
         
     | 
| 
       3 
     | 
    
         
            -
                Given  
     | 
| 
      
 3 
     | 
    
         
            +
                Given I set the environment variables to:
         
     | 
| 
      
 4 
     | 
    
         
            +
                  | variable         | value |
         
     | 
| 
      
 5 
     | 
    
         
            +
                  | TREMA_LOG_DIR    | .     |
         
     | 
| 
      
 6 
     | 
    
         
            +
                  | TREMA_PID_DIR    | .     |
         
     | 
| 
      
 7 
     | 
    
         
            +
                  | TREMA_SOCKET_DIR | .     |
         
     | 
| 
      
 8 
     | 
    
         
            +
                And a file named "hello.rb" with:
         
     | 
| 
       4 
9 
     | 
    
         
             
                  """ruby
         
     | 
| 
       5 
10 
     | 
    
         
             
                  class Hello < Trema::Controller
         
     | 
| 
       6 
11 
     | 
    
         
             
                    def start(_args)
         
     | 
| 
         @@ -17,7 +22,7 @@ Feature: -l (--logging_level) option 
     | 
|
| 
       17 
22 
     | 
    
         
             
              @sudo
         
     | 
| 
       18 
23 
     | 
    
         
             
              Scenario: --logging_level debug
         
     | 
| 
       19 
24 
     | 
    
         
             
                When I run `trema run hello.rb --logging_level debug -d`
         
     | 
| 
       20 
     | 
    
         
            -
                And  
     | 
| 
      
 25 
     | 
    
         
            +
                And sleep 3
         
     | 
| 
       21 
26 
     | 
    
         
             
                And the file "Hello.log" should contain "DEBUG -- : Konnichi Wa"
         
     | 
| 
       22 
27 
     | 
    
         | 
| 
       23 
28 
     | 
    
         
             
              @sudo
         
     | 
| 
         @@ -3,7 +3,12 @@ Feature: --openflow13 option 
     | 
|
| 
       3 
3 
     | 
    
         
             
              Use --openflow13 option to enable OpenFlow 1.3
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
              Background:
         
     | 
| 
       6 
     | 
    
         
            -
                Given  
     | 
| 
      
 6 
     | 
    
         
            +
                Given I set the environment variables to:
         
     | 
| 
      
 7 
     | 
    
         
            +
                  | variable         | value |
         
     | 
| 
      
 8 
     | 
    
         
            +
                  | TREMA_LOG_DIR    | .     |
         
     | 
| 
      
 9 
     | 
    
         
            +
                  | TREMA_PID_DIR    | .     |
         
     | 
| 
      
 10 
     | 
    
         
            +
                  | TREMA_SOCKET_DIR | .     |
         
     | 
| 
      
 11 
     | 
    
         
            +
                And a file named "openflow_version.rb" with:
         
     | 
| 
       7 
12 
     | 
    
         
             
                  """ruby
         
     | 
| 
       8 
13 
     | 
    
         
             
                  class OpenflowVersion < Trema::Controller
         
     | 
| 
       9 
14 
     | 
    
         
             
                    def switch_ready(dpid)
         
     | 
| 
         @@ -23,17 +28,17 @@ Feature: --openflow13 option 
     | 
|
| 
       23 
28 
     | 
    
         
             
              @sudo
         
     | 
| 
       24 
29 
     | 
    
         
             
              Scenario: --openflow13 option
         
     | 
| 
       25 
30 
     | 
    
         
             
                When I successfully run `trema run openflow_version.rb --openflow13 -c trema.conf -d`
         
     | 
| 
       26 
     | 
    
         
            -
                And  
     | 
| 
      
 31 
     | 
    
         
            +
                And sleep 5
         
     | 
| 
       27 
32 
     | 
    
         
             
                Then the file "OpenflowVersion.log" should contain "ofp_version = 4"
         
     | 
| 
       28 
33 
     | 
    
         | 
| 
       29 
34 
     | 
    
         
             
              @sudo
         
     | 
| 
       30 
35 
     | 
    
         
             
              Scenario: --no-openflow13 option
         
     | 
| 
       31 
36 
     | 
    
         
             
                When I successfully run `trema run openflow_version.rb --no-openflow13 -c trema.conf -d`
         
     | 
| 
       32 
     | 
    
         
            -
                And  
     | 
| 
      
 37 
     | 
    
         
            +
                And sleep 5
         
     | 
| 
       33 
38 
     | 
    
         
             
                Then the file "OpenflowVersion.log" should contain "ofp_version = 1"
         
     | 
| 
       34 
39 
     | 
    
         | 
| 
       35 
40 
     | 
    
         
             
              @sudo
         
     | 
| 
       36 
41 
     | 
    
         
             
              Scenario: the default OpenFlow version is 1.0
         
     | 
| 
       37 
42 
     | 
    
         
             
                When I successfully run `trema run openflow_version.rb -c trema.conf -d`
         
     | 
| 
       38 
     | 
    
         
            -
                And  
     | 
| 
      
 43 
     | 
    
         
            +
                And sleep 5
         
     | 
| 
       39 
44 
     | 
    
         
             
                Then the file "OpenflowVersion.log" should contain "ofp_version = 1"
         
     |