-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
1,719 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
task default: [:spec, :cucumber, :quality] | ||
task quality: [:rubocop, :reek, :flog] | ||
task quality: [:rubocop, :reek, :flog, :flay] | ||
task travis: [:spec, :quality] | ||
|
||
Dir.glob('tasks/*.rake').each { |each| import each } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,88 @@ | ||
Feature: "Patch Panel" example | ||
Background: | ||
Given a file named "trema.conf" with: | ||
""" | ||
vswitch('patch') { datapath_id 0xabc } | ||
Given I set the environment variables to: | ||
| variable | value | | ||
| TREMA_LOG_DIR | . | | ||
| TREMA_PID_DIR | . | | ||
| TREMA_SOCKET_DIR | . | | ||
And a file named "trema.conf" with: | ||
""" | ||
vswitch('patch') { datapath_id 0xabc } | ||
vhost ('host1') { ip '192.168.0.1' } | ||
vhost ('host2') { ip '192.168.0.2' } | ||
vhost ('host1') { ip '192.168.0.1' } | ||
vhost ('host2') { ip '192.168.0.2' } | ||
link 'patch', 'host1' | ||
link 'patch', 'host2' | ||
""" | ||
link 'patch', 'host1' | ||
link 'patch', 'host2' | ||
""" | ||
|
||
@sudo | ||
Scenario: Run | ||
Given a file named "patch_panel.conf" with: | ||
""" | ||
1 2 | ||
""" | ||
And I run `trema -v run ../../lib/patch_panel.rb -c trema.conf -p . -l . -s .` interactively | ||
And I wait for stdout to contain "PatchPanel started (config = patch_panel.conf)" | ||
When I run `trema send_packets --source host1 --dest host2 --n_pkts 1` | ||
And I run `trema show_stats host1 --tx` | ||
And I run `trema show_stats host2 --rx` | ||
Then the output from "trema show_stats host1 --tx" should contain "192.168.0.2,1,192.168.0.1,1,1,50" | ||
And the output from "trema show_stats host2 --rx" should contain "192.168.0.2,1,192.168.0.1,1,1,50" | ||
|
||
@sudo | ||
Scenario: Run as a daemon | ||
Scenario: Default configuration file = patch_panel.conf | ||
Given a file named "patch_panel.conf" with: | ||
""" | ||
1 2 | ||
""" | ||
And I successfully run `trema run ../../lib/patch_panel.rb -c trema.conf -d -p . -l . -s .` | ||
And I wait until a file named "PatchPanel.pid" is created | ||
And I run `sleep 5` | ||
When I run `trema send_packets --source host1 --dest host2 --n_pkts 1` | ||
And I run `trema show_stats host1 --tx` | ||
And I run `trema show_stats host2 --rx` | ||
Then the output from "trema show_stats host1 --tx" should contain "192.168.0.2,1,192.168.0.1,1,1,50" | ||
And the output from "trema show_stats host2 --rx" should contain "192.168.0.2,1,192.168.0.1,1,1,50" | ||
""" | ||
1 2 | ||
""" | ||
When I successfully run `trema run ../../lib/patch_panel.rb -c trema.conf -d` | ||
And a file named "PatchPanel.log" should exist | ||
And the file "PatchPanel.log" should contain "PatchPanel started (config = patch_panel.conf)" | ||
|
||
@sudo | ||
Scenario: Run with an argument | ||
Scenario: Configuration file = my.conf | ||
Given a file named "my.conf" with: | ||
""" | ||
1 2 | ||
""" | ||
And I successfully run `trema run ../../lib/patch_panel.rb -c trema.conf -d -p . -l . -s . -- my.conf` | ||
And a file named "PatchPanel.log" should exist | ||
""" | ||
1 2 | ||
""" | ||
When I successfully run `trema run ../../lib/patch_panel.rb -c trema.conf -d -- my.conf` | ||
Then a file named "PatchPanel.log" should exist | ||
And the file "PatchPanel.log" should contain "PatchPanel started (config = my.conf)" | ||
|
||
@sudo | ||
Scenario: Run with an argument (nonexistent file). | ||
When I run `trema run ../../lib/patch_panel.rb -c trema.conf -p . -l . -s . -- NONEXISTENT.conf` | ||
Scenario: Configuration file does not exist | ||
When I run `trema run ../../lib/patch_panel.rb -c trema.conf -- NONEXISTENT.conf` | ||
Then the exit status should not be 0 | ||
Then the output should contain "error: No such file or directory - NONEXISTENT.conf" | ||
And the stderr should contain "error: No such file or directory - NONEXISTENT.conf" | ||
|
||
@sudo | ||
Scenario: Invalid configuration file | ||
Given a file named "patch_panel.conf" with: | ||
""" | ||
INVALID CONFIGURATION | ||
""" | ||
And I run `trema run ../../lib/patch_panel.rb -c trema.conf -p . -l . -s .` | ||
Then the output should contain "error: Invalid format: 'INVALID CONFIGURATION'" | ||
And the output should contain "RuntimeError" | ||
""" | ||
INVALID CONFIGURATION | ||
""" | ||
When I run `trema run ../../lib/patch_panel.rb -c trema.conf` | ||
Then the exit status should not be 0 | ||
And the stderr should contain "error: Invalid format: 'INVALID CONFIGURATION'" | ||
And the stderr should contain "RuntimeError" | ||
|
||
@sudo | ||
Scenario: Run | ||
Given a file named "patch_panel.conf" with: | ||
""" | ||
1 2 | ||
""" | ||
When I run `trema -v run ../../lib/patch_panel.rb -c trema.conf` interactively | ||
And I run `sleep 8` | ||
And I run `trema send_packets --source host1 --dest host2` | ||
And I run `trema send_packets --source host2 --dest host1` | ||
Then the number of packets received by "host1" should be: | ||
| source | #packets | | ||
| 192.168.0.2 | 1 | | ||
And the number of packets received by "host2" should be: | ||
| source | #packets | | ||
| 192.168.0.1 | 1 | | ||
|
||
@sudo | ||
Scenario: Run as a daemon | ||
Given a file named "patch_panel.conf" with: | ||
""" | ||
1 2 | ||
""" | ||
When I successfully run `trema run ../../lib/patch_panel.rb -c trema.conf -d` | ||
And I run `sleep 8` | ||
And I run `trema send_packets --source host1 --dest host2` | ||
And I run `trema send_packets --source host2 --dest host1` | ||
Then the number of packets received by "host1" should be: | ||
| source | #packets | | ||
| 192.168.0.2 | 1 | | ||
And the number of packets received by "host2" should be: | ||
| source | #packets | | ||
| 192.168.0.1 | 1 | |
Oops, something went wrong.