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
bind10 module Xfrout should be running
bind10 module Xfrin 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):
step.given(start_step)
# 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.
Parameters:
commands: a sequence of strings which will be sent.
......@@ -140,6 +140,8 @@ def run_bindctl(commands, cmdctl_port=None):
for line in commands:
bindctl.stdin.write(line + "\n")
(stdout, stderr) = bindctl.communicate()
if ignore_failure:
return
result = bindctl.returncode
world.last_bindctl_stdout = stdout
world.last_bindctl_stderr = stderr
......@@ -306,19 +308,24 @@ def config_remove_command(step, name, value, cmdctl_port):
"quit"]
run_bindctl(commands, cmdctl_port)
@step('send bind10(?: with cmdctl port (\d+))? the command (.+)')
def send_command(step, cmdctl_port, command):
@step('send bind10(?: with cmdctl port (\d+))?( ignoring failure)? the command (.+)')
def send_command(step, cmdctl_port, ignore_failure, command):
"""
Run bindctl, send the given command, and exit bindctl.
Parameters:
command ('the command <command>'): The command to send.
cmdctl_port ('with cmdctl port <portnr>', optional): cmdctl port to send
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,
"quit"]
run_bindctl(commands, cmdctl_port)
run_bindctl(commands, cmdctl_port, ignore_failure is not None)
@step('bind10 module (\S+) should( not)? be running')
def module_is_running(step, name, not_str):
......
Markdown is supported
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