Exemplo n.º 1
0
def test_master(master, master_class, path):
  print('Trying %s' % master)
  context = pathstack()
  start = time.time()
  if not masters_util.stop_master(master, path):
    return False
  try:
    # Try to backup paths we may not want to overwite.
    context.backup_if_present(os.path.join(path, 'twistd.log'))
    context.backup_if_present(os.path.join(path, 'git_poller_*.git'))
    try:
      if not masters_util.start_master(master, path):
        return False
      name = master_class.project_name
      port1 = master_class.master_port
      port2 = master_class.master_port_alt
      # We pass both the read/write and read-only ports, even though querying
      # either one alone would be sufficient sign of success.
      res = masters_util.wait_for_start(master, name, path, [port1, port2])
      if res:
        logging.info('Success in %1.1fs' % (time.time() - start))
      return res
    finally:
      masters_util.stop_master(master, path)
  finally:
    context.restore_backup()
Exemplo n.º 2
0
def test_master(master, path, name, ports):
  if not masters_util.stop_master(master, path):
    return False
  logging.info('%s Starting', master)
  start = time.time()
  with BackupPaths(path, ['twistd.log', 'twistd.log.?', 'git_poller_*.git',
                          'state.sqlite']):
    try:
      if not masters_util.start_master(master, path, dry_run=True):
        return False
      res = masters_util.wait_for_start(master, name, path, ports)
      if not res:
        logging.info('%s Success in %1.1fs', master, (time.time() - start))
      return res
    finally:
      masters_util.stop_master(master, path, force=True)
Exemplo n.º 3
0
def test_master(master, name, path):
    print('Trying %s' % master)
    start = time.time()
    if not masters_util.stop_master(master, path):
        return False
    # Try to backup twistd.log
    twistd_log = os.path.join(path, 'twistd.log')
    had_twistd_log = os.path.isfile(twistd_log)
    # Try to backup a Git workdir.
    git_workdir = os.path.join(path, 'git_poller_src.git')
    had_git_workdir = os.path.isdir(git_workdir)
    try:
        if had_twistd_log:
            os.rename(twistd_log, twistd_log + '_')
        if had_git_workdir:
            if subprocess.call(['mv', git_workdir, git_workdir + '_']) != 0:
                print >> sys.stderr, 'ERROR: Failed to rename %s' % git_workdir
        try:
            if not masters_util.start_master(master, path):
                return False

            res = masters_util.wait_for_start(master, name, path)
            if res:
                logging.info('Success in %1.1fs' % (time.time() - start))
            return res
        finally:
            masters_util.stop_master(master, path)
    finally:
        if had_twistd_log:
            os.rename(twistd_log + '_', twistd_log)
        if (os.path.isdir(git_workdir)
                and subprocess.call(['rm', '-rf', git_workdir]) != 0):
            print >> sys.stderr, 'ERROR: Failed to remove %s' % git_workdir
        if had_git_workdir:
            if subprocess.call(['mv', git_workdir + '_', git_workdir]) != 0:
                print >> sys.stderr, 'ERROR: Failed to rename %s' % (
                    git_workdir + '_')