Skip to content

Commit

Permalink
Merge branch 'release/0.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
yasuhito committed Mar 18, 2015
2 parents 19c743d + d56d24e commit 32ab9e9
Show file tree
Hide file tree
Showing 26 changed files with 1,719 additions and 113 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ rvm:
- ruby-head

before_install:
- sudo apt-get update -qq
- sudo apt-get install libpcap-dev -qq
- gem update bundler

matrix:
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
## develop (unreleased)


## 0.3.0 (3/18/2015)
### Changes
* Phut 0.3.1.


## 0.2.0 (2/13/2015)
### Changes
* Put patch_panel arguments (config file) after `--`.
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
source 'https://rubygems.org'

gem 'phut', github: 'trema/phut', branch: 'develop'
gem 'trema', github: 'trema/trema_ruby', branch: 'develop'

group :development, :test do
gem 'aruba', require: false
gem 'cucumber', require: false
gem 'flay', require: false
gem 'flog', require: false
gem 'guard', require: false
gem 'guard-bundler', require: false
Expand Down
90 changes: 45 additions & 45 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
GIT
remote: git://github.com/trema/phut.git
revision: e28ea0b14036853ae61a73e2a3d48d56400a0a9d
branch: develop
specs:
phut (0.1.0)
gli (~> 2.12.2)
pio (~> 0.15.0)
pry (~> 0.10.1)

GIT
remote: git://github.com/trema/trema_ruby.git
revision: 41354a44af537668e5f806031ffe21b2393a154f
revision: 66d5c47c7e89488e48d6d71064f521d48a3dacd2
branch: develop
specs:
trema (0.1.0)
bundler (~> 1.8.0)
gli (~> 2.12.0)
pio (~> 0.15.0)
bundler (~> 1.8.5)
gli (~> 2.13.0)
phut (~> 0.3.1)
pio (~> 0.18.2)
rake

GEM
Expand All @@ -39,38 +30,41 @@ GEM
timers (~> 4.0.0)
childprocess (0.5.5)
ffi (~> 1.0, >= 1.0.11)
codeclimate-test-reporter (0.4.6)
codeclimate-test-reporter (0.4.7)
simplecov (>= 0.7.1, < 1.0.0)
coderay (1.1.0)
concord (0.1.5)
adamantium (~> 0.2.0)
equalizer (~> 0.0.9)
coveralls (0.7.9)
coveralls (0.7.11)
multi_json (~> 1.10)
rest-client (~> 1.7)
rest-client (>= 1.6.8, < 2)
simplecov (~> 0.9.1)
term-ansicolor (~> 1.3)
thor (~> 0.19.1)
cucumber (1.3.18)
cucumber (1.3.19)
builder (>= 2.1.2)
diff-lcs (>= 1.1.3)
gherkin (~> 2.12)
multi_json (>= 1.7.5, < 2.0)
multi_test (>= 0.1.1)
multi_test (>= 0.1.2)
diff-lcs (1.2.5)
docile (1.1.5)
equalizer (0.0.9)
ffi (1.9.6)
ffi (1.9.8)
flay (2.6.1)
ruby_parser (~> 3.0)
sexp_processor (~> 4.0)
flog (4.3.2)
ruby_parser (~> 3.1, > 3.1.0)
sexp_processor (~> 4.4)
formatador (0.2.5)
gherkin (2.12.2)
multi_json (~> 1.3)
given_core (3.6.0)
given_core (3.7.0)
sorcerer (>= 0.3.7)
gli (2.12.2)
guard (2.12.1)
gli (2.13.0)
guard (2.12.5)
formatador (>= 0.2.4)
listen (~> 2.7)
lumberjack (~> 1.0)
Expand Down Expand Up @@ -98,7 +92,7 @@ GEM
sparkr (>= 0.2.0)
term-ansicolor
yard (~> 0.8.7.5)
listen (2.8.5)
listen (2.9.0)
celluloid (>= 0.15.2)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
Expand All @@ -107,16 +101,20 @@ GEM
thread_safe (~> 0.3, >= 0.3.1)
method_source (0.8.2)
mime-types (2.4.3)
multi_json (1.10.1)
multi_json (1.11.0)
multi_test (0.1.2)
nenv (0.2.0)
netrc (0.10.2)
notiffany (0.0.5)
netrc (0.10.3)
notiffany (0.0.6)
nenv (~> 0.1)
shellany (~> 0.0)
parser (2.2.0.2)
parser (2.2.0.3)
ast (>= 1.1, < 3.0)
pio (0.15.0)
phut (0.3.1)
gli (~> 2.13.0)
pio (~> 0.18.2)
pry (~> 0.10.1)
pio (0.18.2)
bindata (~> 2.1.0)
powerpack (0.1.0)
procto (0.0.2)
Expand All @@ -129,55 +127,57 @@ GEM
rb-fsevent (0.9.4)
rb-inotify (0.9.5)
ffi (>= 0.5.0)
reek (2.0.0)
reek (2.0.2)
parser (~> 2.2)
rainbow (~> 2.0)
require_all (~> 1.3)
unparser (~> 0.2.2)
rest-client (1.7.2)
require_all (1.3.2)
rest-client (1.7.3)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
rspec (3.2.0)
rspec-core (~> 3.2.0)
rspec-expectations (~> 3.2.0)
rspec-mocks (~> 3.2.0)
rspec-core (3.2.0)
rspec-core (3.2.2)
rspec-support (~> 3.2.0)
rspec-expectations (3.2.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.2.0)
rspec-given (3.6.0)
given_core (= 3.6.0)
rspec-given (3.7.0)
given_core (= 3.7.0)
rspec (>= 2.14.0)
rspec-mocks (3.2.0)
rspec-mocks (3.2.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.2.0)
rspec-support (3.2.1)
rubocop (0.29.0)
rspec-support (3.2.2)
rubocop (0.29.1)
astrolabe (~> 1.3)
parser (>= 2.2.0.1, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.4)
ruby-progressbar (1.7.1)
ruby_parser (3.6.4)
ruby_parser (3.6.5)
sexp_processor (~> 4.1)
sexp_processor (4.4.5)
sexp_processor (4.5.0)
shellany (0.0.1)
simplecov (0.9.1)
simplecov (0.9.2)
docile (~> 1.1.0)
multi_json (~> 1.0)
simplecov-html (~> 0.8.0)
simplecov-html (0.8.0)
simplecov-html (~> 0.9.0)
simplecov-html (0.9.0)
slop (3.6.0)
sorcerer (1.0.2)
sparkr (0.4.1)
term-ansicolor (1.3.0)
tins (~> 1.0)
thor (0.19.1)
thread_safe (0.3.4)
thread_safe (0.3.5)
timers (4.0.1)
hitimes
tins (1.3.4)
tins (1.3.5)
unparser (0.2.2)
abstract_type (~> 0.0.7)
adamantium (~> 0.2.0)
Expand All @@ -196,13 +196,13 @@ DEPENDENCIES
codeclimate-test-reporter
coveralls
cucumber
flay
flog
guard
guard-bundler
guard-rspec
guard-rubocop
inch
phut!
rake
reek
rspec
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ OpenFlow controller that emulates a software patch panel.
[inch]: http://inch-ci.org/github/trema/patch_panel


Prerequisites
-------------

* Ruby 2.0.0 or higher ([RVM][rvm]).
* [Open vSwitch][openvswitch] (`apt-get install openvswitch-switch`).

[rvm]: https://rvm.io/
[openvswitch]: https://openvswitch.org/


Install
-------

Expand Down
2 changes: 1 addition & 1 deletion Rakefile
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 }
119 changes: 70 additions & 49 deletions features/patch_panel.feature
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 |
Loading

0 comments on commit 32ab9e9

Please sign in to comment.