bind10_control.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. from lettuce import *
  2. import subprocess
  3. import re
  4. def check_lines(output, lines):
  5. for line in lines:
  6. if output.find(line) != -1:
  7. return line
  8. @step('start bind10(?: with configuration (\S+))?' +\
  9. '(?: with cmdctl port (\d+))?(?: as (\S+))?')
  10. def start_bind10(step, config_file, cmdctl_port, process_name):
  11. args = [ 'bind10', '-v' ]
  12. if config_file is not None:
  13. args.append('-p')
  14. args.append("configurations/")
  15. args.append('-c')
  16. args.append(config_file)
  17. if cmdctl_port is None:
  18. args.append('--cmdctl-port=47805')
  19. else:
  20. args.append('--cmdctl-port=' + cmdctl_port)
  21. if process_name is None:
  22. process_name = "bind10"
  23. else:
  24. args.append('-m')
  25. args.append(process_name + '_msgq.socket')
  26. world.processes.add_process(step, process_name, args)
  27. # check output to know when startup has been completed
  28. # TODO what to do on failure?
  29. message = world.processes.wait_for_stderr_str(process_name,
  30. ["BIND10_STARTUP_COMPLETE",
  31. "BIND10_STARTUP_ERROR"])
  32. assert message == "BIND10_STARTUP_COMPLETE", "Got: " + str(message)
  33. @step('wait for bind10 auth (?:of (\w+) )?to start')
  34. def wait_for_auth(step, process_name):
  35. if process_name is None:
  36. process_name = "bind10"
  37. world.processes.wait_for_stderr_str(process_name, ['AUTH_SERVER_STARTED'],
  38. False)
  39. @step('have bind10 running(?: with configuration ([\w.]+))?')
  40. def have_bind10_running(step, config_file):
  41. step.given('start bind10 with configuration ' + config_file)
  42. step.given('wait for bind10 auth to start')
  43. @step('set bind10 configuration (\S+) to (.*)')
  44. def set_config_command(step, name, value):
  45. args = ['bindctl', '-p', '47805']
  46. bindctl = subprocess.Popen(args, 1, None, subprocess.PIPE,
  47. subprocess.PIPE, None)
  48. bindctl.stdin.write("config set " + name + " " + value + "\n")
  49. bindctl.stdin.write("config commit\n")
  50. bindctl.stdin.write("quit\n")
  51. result = bindctl.wait()
  52. assert result == 0, "bindctl exit code: " + str(result)