Skip to content

Commit

Permalink
Fix the broken killall command.
Browse files Browse the repository at this point in the history
  • Loading branch information
yasuhito committed Jun 9, 2015
1 parent 6f0051b commit 374dbb0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
20 changes: 13 additions & 7 deletions bin/trema
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,21 @@ module Trema
c.flag [:S, :socket_dir], default_value: Trema::DEFAULT_SOCKET_DIR

c.action do |_global_options, options, args|
begin
if options[:all]
Trema.trema_processes(options[:socket_dir]).each(&:killall)
else
help_now! if args.size != 1
if options[:all]
Trema.trema_processes(options[:socket_dir]).each do |each|
begin
each.killall
rescue DRb::DRbConnError
true # OK (trema process exitted).
end
end
else
help_now! if args.size != 1
begin
Trema.trema_process(args[0], options[:socket_dir]).killall
rescue DRb::DRbConnError
true # OK (trema process exitted).
end
rescue DRb::DRbConnError
true # OK (trema process exitted).
end
end
end
Expand Down
11 changes: 9 additions & 2 deletions features/trema_killall.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,37 @@ Feature: trema killall command
And a file named "trema.conf" with:
"""
vswitch { datapath_id 0xabc }
vhost('host1') { ip '192.168.0.1' }
vhost('host2') { ip '192.168.0.2' }
link '0xabc', 'host1'
link '0xabc', 'host2'
"""
And I run `trema run null_controller.rb -c trema.conf -d`
And a file named "void_controller.rb" with:
"""
class VoidController < Trema::Controller; end
"""
And I run `trema run void_controller.rb -p 6654 -d`

@sudo
Scenario: killall controller_name
When I successfully run `trema killall NullController`
Then virtual links should not exist
And I successfully run `ls`
And the following files should not exist:
| NullController.pid |
| vhost.host1.pid |
| vhost.host2.pid |
And the following files should exist:
| VoidController.pid |

@sudo
Scenario: killall --all
When I successfully run `trema killall --all`
Then virtual links should not exist
And the following files should not exist:
| NullController.pid |
| VoidController.pid |
| vhost.host1.pid |
| vhost.host2.pid |

Expand Down

0 comments on commit 374dbb0

Please sign in to comment.