|
@@ -18,8 +18,10 @@ import subprocess
|
|
|
import re
|
|
|
|
|
|
@step('start bind10(?: with configuration (\S+))?' +\
|
|
|
- '(?: with cmdctl port (\d+))?(?: as (\S+))?')
|
|
|
-def start_bind10(step, config_file, cmdctl_port, process_name):
|
|
|
+ '(?: with cmdctl port (\d+))?' +\
|
|
|
+ '(?: with msgq socket file (\S+))?' +\
|
|
|
+ '(?: as (\S+))?')
|
|
|
+def start_bind10(step, config_file, cmdctl_port, msgq_sockfile, process_name):
|
|
|
"""
|
|
|
Start BIND 10 with the given optional config file, cmdctl port, and
|
|
|
store the running process in world with the given process name.
|
|
@@ -29,6 +31,8 @@ def start_bind10(step, config_file, cmdctl_port, process_name):
|
|
|
directory.
|
|
|
cmdctl_port ('with cmdctl port <portnr>', optional): The port on which
|
|
|
b10-cmdctl listens for bindctl commands. Defaults to 47805.
|
|
|
+ msgq_sockfile ('with msgq socket file', optional): The msgq socket file
|
|
|
+ that will be used for internal communication
|
|
|
process_name ('as <name>', optional). This is the name that can be used
|
|
|
in the following steps of the scenario to refer to this
|
|
|
BIND 10 instance. Defaults to 'bind10'.
|
|
@@ -57,10 +61,10 @@ def start_bind10(step, config_file, cmdctl_port, process_name):
|
|
|
world.processes.add_process(step, process_name, args)
|
|
|
|
|
|
# check output to know when startup has been completed
|
|
|
- message = world.processes.wait_for_stderr_str(process_name,
|
|
|
- ["BIND10_STARTUP_COMPLETE",
|
|
|
- "BIND10_STARTUP_ERROR"])
|
|
|
- assert message == "BIND10_STARTUP_COMPLETE", "Got: " + str(message)
|
|
|
+ (message, line) = world.processes.wait_for_stderr_str(process_name,
|
|
|
+ ["BIND10_STARTUP_COMPLETE",
|
|
|
+ "BIND10_STARTUP_ERROR"])
|
|
|
+ assert message == "BIND10_STARTUP_COMPLETE", "Got: " + str(line)
|
|
|
|
|
|
@step('wait for bind10 auth (?:of (\w+) )?to start')
|
|
|
def wait_for_auth(step, process_name):
|
|
@@ -75,15 +79,24 @@ def wait_for_auth(step, process_name):
|
|
|
world.processes.wait_for_stderr_str(process_name, ['AUTH_SERVER_STARTED'],
|
|
|
False)
|
|
|
|
|
|
-@step('have bind10 running(?: with configuration ([\w.]+))?')
|
|
|
-def have_bind10_running(step, config_file):
|
|
|
+@step('have bind10 running(?: with configuration ([\S]+))?' +\
|
|
|
+ '(?: with cmdctl port (\d+))?' +\
|
|
|
+ '(?: as ([\S]+))?')
|
|
|
+def have_bind10_running(step, config_file, cmdctl_port, process_name):
|
|
|
"""
|
|
|
Compound convenience step for running bind10, which consists of
|
|
|
start_bind10 and wait_for_auth.
|
|
|
Currently only supports the 'with configuration' option.
|
|
|
"""
|
|
|
- step.given('start bind10 with configuration ' + config_file)
|
|
|
- step.given('wait for bind10 auth to start')
|
|
|
+ start_step = 'start bind10 with configuration ' + config_file
|
|
|
+ wait_step = 'wait for bind10 auth to start'
|
|
|
+ if cmdctl_port is not None:
|
|
|
+ start_step += ' with cmdctl port ' + str(cmdctl_port)
|
|
|
+ if process_name is not None:
|
|
|
+ start_step += ' as ' + process_name
|
|
|
+ wait_step = 'wait for bind10 auth of ' + process_name + ' to start'
|
|
|
+ step.given(start_step)
|
|
|
+ step.given(wait_step)
|
|
|
|
|
|
@step('set bind10 configuration (\S+) to (.*)(?: with cmdctl port (\d+))?')
|
|
|
def set_config_command(step, name, value, cmdctl_port):
|
|
@@ -106,3 +119,23 @@ def set_config_command(step, name, value, cmdctl_port):
|
|
|
bindctl.stdin.write("quit\n")
|
|
|
result = bindctl.wait()
|
|
|
assert result == 0, "bindctl exit code: " + str(result)
|
|
|
+
|
|
|
+@step('send bind10 the command (.+)(?: with cmdctl port (\d+))?')
|
|
|
+def send_command(step, command, cmdctl_port):
|
|
|
+ """
|
|
|
+ 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.
|
|
|
+ """
|
|
|
+ if cmdctl_port is None:
|
|
|
+ cmdctl_port = '47805'
|
|
|
+ args = ['bindctl', '-p', cmdctl_port]
|
|
|
+ bindctl = subprocess.Popen(args, 1, None, subprocess.PIPE,
|
|
|
+ subprocess.PIPE, None)
|
|
|
+ bindctl.stdin.write(command + "\n")
|
|
|
+ bindctl.stdin.write("quit\n")
|
|
|
+ result = bindctl.wait()
|
|
|
+ assert result == 0, "bindctl exit code: " + str(result)
|