diff --git a/Gemfile b/Gemfile index 0d7b432..df63ebd 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,9 @@ source 'https://rubygems.org' +gem 'aruba' gem 'cucumber' gem 'pio' gem 'rake' gem 'rspec' gem 'rubocop' +gem 'phut' diff --git a/Gemfile.lock b/Gemfile.lock index 2539f81..c6c440a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,16 +1,27 @@ GEM remote: https://rubygems.org/ specs: - activesupport (4.2.5.1) + activesupport (4.2.6) i18n (~> 0.7) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) + aruba (0.14.1) + childprocess (~> 0.5.6) + contracts (~> 0.9) + cucumber (>= 1.3.19) + ffi (~> 1.9.10) + rspec-expectations (>= 2.99) + thor (~> 0.19) ast (2.2.0) bindata (2.1.0) builder (3.2.2) - cucumber (2.3.2) + childprocess (0.5.9) + ffi (~> 1.0, >= 1.0.11) + coderay (1.1.1) + contracts (0.13.0) + cucumber (2.3.3) builder (>= 2.1.2) cucumber-core (~> 1.4.0) cucumber-wire (~> 0.0.1) @@ -22,25 +33,37 @@ GEM gherkin (~> 3.2.0) cucumber-wire (0.0.1) diff-lcs (1.2.5) + ffi (1.9.10) gherkin (3.2.0) + gli (2.13.4) i18n (0.7.0) json (1.8.3) + method_source (0.8.2) minitest (5.8.4) multi_json (1.11.2) multi_test (0.1.2) parser (2.3.0.6) ast (~> 2.2) + phut (0.7.7) + activesupport (~> 4.2, >= 4.2.5) + gli (~> 2.13.4) + pio (~> 0.30.0) + pry (~> 0.10.3) pio (0.30.0) activesupport (~> 4.2, >= 4.2.4) bindata (~> 2.1.0) powerpack (0.1.1) + pry (0.10.3) + coderay (~> 1.1.0) + method_source (~> 0.8.1) + slop (~> 3.4) rainbow (2.1.0) - rake (10.5.0) + rake (11.1.1) rspec (3.4.0) rspec-core (~> 3.4.0) rspec-expectations (~> 3.4.0) rspec-mocks (~> 3.4.0) - rspec-core (3.4.3) + rspec-core (3.4.4) rspec-support (~> 3.4.0) rspec-expectations (3.4.0) diff-lcs (>= 1.2.0, < 2.0) @@ -56,6 +79,8 @@ GEM ruby-progressbar (~> 1.7) unicode-display_width (~> 1.0, >= 1.0.1) ruby-progressbar (1.7.5) + slop (3.6.0) + thor (0.19.1) thread_safe (0.3.5) tzinfo (1.2.2) thread_safe (~> 0.1) @@ -65,7 +90,9 @@ PLATFORMS ruby DEPENDENCIES + aruba cucumber + phut pio rake rspec diff --git a/features/net_tester.feature b/features/net_tester.feature new file mode 100644 index 0000000..7997176 --- /dev/null +++ b/features/net_tester.feature @@ -0,0 +1,27 @@ +# language: ja +フィーチャ: 最低限の NetTester 機能 + + ActiveFlow に必要な機能を洗い出すためのフィーチャ。 + 最小構成で NetTester を動かすのに必要な機能をテストする。 + うまく動いたらこのフィーチャとステップを trema/net_tester に移動すべし。 + + シナリオ: テスト用ホストを 2 台、NetTester 用スイッチを 2 台起動する + 前提 次の仮想ネットワーク設定ファイルで phut を起動する + """ruby + # ホスト接続用の Open vSwitch + vswitch('host_sw') { datapath_id 0x1 } + # 物理 Open vSwitch + vswitch('physical_sw') { datapath_id 0x2 } + # テスト対象のスイッチ + # WIP: このスイッチは普通のイーサネットスイッチとして動かす必要あり + vswitch('testee_sw') { datapath_id 0x3 } + + vhost ('host1') { ip '192.168.0.1' } + vhost ('host2') { ip '192.168.0.2' } + + link 'host_sw', 'physical_sw' + link 'host_sw', 'host1' + link 'host_sw', 'host2' + link 'physical_sw', 'testee_sw' + link 'physical_sw', 'testee_sw' + """ diff --git a/features/step_definitions/active_flow_steps.rb b/features/step_definitions/active_flow_steps.rb index 184e42b..5de7e8d 100644 --- a/features/step_definitions/active_flow_steps.rb +++ b/features/step_definitions/active_flow_steps.rb @@ -11,6 +11,12 @@ end # rubocop:enable LineLength +Given(/^次の仮想ネットワーク設定ファイルで phut を起動する$/) do |config| + @config_file = 'phut.conf' + step %(a file named "#{@config_file}" with:), config + step %(I successfully run `phut run -L. -P. -S. #{@config_file}`) +end + Given(/^次のテーブルを定義:$/) do |code| ActiveFlow.module_eval code end @@ -59,3 +65,9 @@ end end # rubocop:enable LineLength + +Then(/^phut を停止する$/) do + if @config_file + step %(I successfully run `phut -v stop -L. -P. -S. #{@config_file}`) + end +end diff --git a/features/support/env.rb b/features/support/env.rb index e2f5d21..4fba44c 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -1 +1,2 @@ require 'active_flow' +require 'aruba/cucumber' diff --git a/features/support/hooks.rb b/features/support/hooks.rb index aacd490..1cd5474 100644 --- a/features/support/hooks.rb +++ b/features/support/hooks.rb @@ -1,3 +1,6 @@ +# coding: utf-8 + After do + step %(phut を停止する) system "sudo ovs-vsctl del-br br0x#{@dpid}" if @dpid end