Commit cacb5d70 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[2712] added lettuce test to confirm 'Cmdctl shutdown' now works correctly.

also confirmed it would fail without the change of this branch.  the execution
of bindctl would fail, so bind10_control.py needed to be updated so it can
ignore failure of bindctl if specified so.
parent b9c84e0e
...@@ -154,3 +154,18 @@ Feature: control with bindctl ...@@ -154,3 +154,18 @@ Feature: control with bindctl
bind10 module Xfrout should be running bind10 module Xfrout should be running
bind10 module Xfrin should be running bind10 module Xfrin should be running
bind10 module Zonemgr should be running bind10 module Zonemgr should be running
Scenario: Shutting down a certain module
# We could test with several modules, but for now we are particularly
# interested in shutting down cmdctl. It previously caused hangup,
# so this scenario confirms it's certainly fixed. Note: since cmdctl
# is a "needed" component, shutting it down will result in system
# shutdown. So "send bind10 command" will fail (it cannot complete
# "quite").
Given I have bind10 running with configuration bindctl/bindctl.config
And wait for bind10 stderr message BIND10_STARTED_CC
And wait for bind10 stderr message CMDCTL_STARTED
When I send bind10 ignoring failure the command Cmdctl shutdown
And wait for bind10 stderr message CMDCTL_EXITING
And wait for bind10 stderr message BIND10_SHUTDOWN_COMPLETE
...@@ -120,7 +120,7 @@ def have_bind10_running(step, config_file, cmdctl_port, process_name): ...@@ -120,7 +120,7 @@ def have_bind10_running(step, config_file, cmdctl_port, process_name):
step.given(start_step) step.given(start_step)
# function to send lines to bindctl, and store the result # function to send lines to bindctl, and store the result
def run_bindctl(commands, cmdctl_port=None): def run_bindctl(commands, cmdctl_port=None, ignore_failure=False):
"""Run bindctl. """Run bindctl.
Parameters: Parameters:
commands: a sequence of strings which will be sent. commands: a sequence of strings which will be sent.
...@@ -140,6 +140,8 @@ def run_bindctl(commands, cmdctl_port=None): ...@@ -140,6 +140,8 @@ def run_bindctl(commands, cmdctl_port=None):
for line in commands: for line in commands:
bindctl.stdin.write(line + "\n") bindctl.stdin.write(line + "\n")
(stdout, stderr) = bindctl.communicate() (stdout, stderr) = bindctl.communicate()
if ignore_failure:
return
result = bindctl.returncode result = bindctl.returncode
world.last_bindctl_stdout = stdout world.last_bindctl_stdout = stdout
world.last_bindctl_stderr = stderr world.last_bindctl_stderr = stderr
...@@ -306,19 +308,24 @@ def config_remove_command(step, name, value, cmdctl_port): ...@@ -306,19 +308,24 @@ def config_remove_command(step, name, value, cmdctl_port):
"quit"] "quit"]
run_bindctl(commands, cmdctl_port) run_bindctl(commands, cmdctl_port)
@step('send bind10(?: with cmdctl port (\d+))? the command (.+)') @step('send bind10(?: with cmdctl port (\d+))?( ignoring failure)? the command (.+)')
def send_command(step, cmdctl_port, command): def send_command(step, cmdctl_port, ignore_failure, command):
""" """
Run bindctl, send the given command, and exit bindctl. Run bindctl, send the given command, and exit bindctl.
Parameters: Parameters:
command ('the command <command>'): The command to send. command ('the command <command>'): The command to send.
cmdctl_port ('with cmdctl port <portnr>', optional): cmdctl port to send cmdctl_port ('with cmdctl port <portnr>', optional): cmdctl port to send
the command to. Defaults to 47805. the command to. Defaults to 47805.
Fails if cmdctl does not exit with status code 0. ignore_failure ('ignoring failure', optional): set to not None if bindctl
is expected to fail (and it's acceptable).
Fails if bindctl does not exit with status code 0 and ignore_failure
is not None.
""" """
commands = [command, commands = [command,
"quit"] "quit"]
run_bindctl(commands, cmdctl_port) run_bindctl(commands, cmdctl_port, ignore_failure is not None)
@step('bind10 module (\S+) should( not)? be running') @step('bind10 module (\S+) should( not)? be running')
def module_is_running(step, name, not_str): def module_is_running(step, name, not_str):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment