def test_A_pick_free_port(self):
     port = phlsys_web.pick_free_port()
     sock = socket.socket()
     # [ A] Ensure pick_free_port returns an available port by trying to
     #      bind a socket on that port
     sock.bind(('', port))
     sock.close()
Exemple #2
0
 def test_A_pick_free_port(self):
     port = phlsys_web.pick_free_port()
     sock = socket.socket()
     # [ A] Ensure pick_free_port returns an available port by trying to
     #      bind a socket on that port
     sock.bind(('', port))
     sock.close()
    def test_B_webserver(self):
        port = phlsys_web.pick_free_port()
        dirpath = tempfile.mkdtemp()
        filepath = os.path.join(dirpath, 'index.html')
        phlsys_fs.write_text_file(filepath, 'Hello World')
        # [ B] SimpleWebServer starts without any error
        server = phlsys_web.SimpleWebServer(dirpath, port)
        # Give subprocess enough time to start the server
        time.sleep(1)
        response = urllib2.urlopen("http://localhost:{}".format(port))
        # [ B] SimpleWebServer serves correct content
        self.assertEqual('Hello World', response.read())

        server.close()
Exemple #4
0
    def test_B_webserver(self):
        port = phlsys_web.pick_free_port()
        dirpath = tempfile.mkdtemp()
        filepath = os.path.join(dirpath, 'index.html')
        phlsys_fs.write_text_file(filepath, 'Hello World')
        # [ B] SimpleWebServer starts without any error
        server = phlsys_web.SimpleWebServer(dirpath, port)
        # Give subprocess enough time to start the server
        time.sleep(1)
        response = urllib2.urlopen("http://localhost:{}".format(port))
        # [ B] SimpleWebServer serves correct content
        self.assertEqual('Hello World', response.read())

        server.close()
    def __init__(self, root_dir, barc_cmd_path, arcyon_cmd_path, phab_uri, alice, bob):

        self._root_dir = root_dir
        self.central_path = os.path.join(self._root_dir, "central")
        os.makedirs(self.central_path)
        self._central_repo = phlsys_git.Repo(self.central_path)
        self._central_repo("init", "--bare")
        self.web_port = phlsys_web.pick_free_port()
        shutil.move(
            os.path.join(self.central_path, "hooks/post-update.sample"),
            os.path.join(self.central_path, "hooks/post-update"),
        )

        self._command_hold_path = os.path.join(self.central_path, "command/hold_dev_arcyd_refs")

        pre_receive_path = os.path.join(self.central_path, "hooks/pre-receive")
        phlsys_fs.write_text_file(pre_receive_path, _PRE_RECEIVE_HOLD_DEV_ARCYD_REFS)
        mode = os.stat(pre_receive_path).st_mode
        os.chmod(pre_receive_path, mode | stat.S_IEXEC)

        self._web = phlsys_web.SimpleWebServer(self.central_path, self.web_port)

        self._workers = []
        for account in (alice, bob):
            account_user = account[0]
            account_email = account[1]
            account_cert = account[2]
            worker_path = os.path.join(self._root_dir, account_user)
            os.makedirs(worker_path)
            self._workers.append(
                atet_worker.Worker(
                    phlsys_git.Repo(worker_path),
                    worker_path,
                    barc_cmd_path,
                    account_user,
                    account_email,
                    account_cert,
                    arcyon_cmd_path,
                    phab_uri,
                )
            )
            self._workers[-1].setup(self._central_repo.working_dir)

            if len(self._workers) == 1:
                self._workers[0].push_initial_commit()
            else:
                self._workers[-1].repo("checkout", "master")
Exemple #6
0
    def __init__(self, root_dir, barc_cmd_path, arcyon_cmd_path, phab_uri,
                 alice, bob):

        self._root_dir = root_dir
        self.central_path = os.path.join(self._root_dir, 'central')
        os.makedirs(self.central_path)
        self._central_repo = phlsys_git.Repo(self.central_path)
        self._central_repo("init", "--bare")
        self.web_port = phlsys_web.pick_free_port()
        shutil.move(
            os.path.join(self.central_path, 'hooks/post-update.sample'),
            os.path.join(self.central_path, 'hooks/post-update'))

        self._command_hold_path = os.path.join(self.central_path,
                                               'command/hold_dev_arcyd_refs')

        pre_receive_path = os.path.join(self.central_path, 'hooks/pre-receive')
        phlsys_fs.write_text_file(pre_receive_path,
                                  _PRE_RECEIVE_HOLD_DEV_ARCYD_REFS)
        mode = os.stat(pre_receive_path).st_mode
        os.chmod(pre_receive_path, mode | stat.S_IEXEC)

        self._web = phlsys_web.SimpleWebServer(self.central_path,
                                               self.web_port)

        self._workers = []
        for account in (alice, bob):
            account_user = account[0]
            account_email = account[1]
            account_cert = account[2]
            worker_path = os.path.join(self._root_dir, account_user)
            os.makedirs(worker_path)
            self._workers.append(
                atet_worker.Worker(phlsys_git.Repo(worker_path), worker_path,
                                   barc_cmd_path, account_user, account_email,
                                   account_cert, arcyon_cmd_path, phab_uri))
            self._workers[-1].setup(self._central_repo.working_dir)

            if len(self._workers) == 1:
                self._workers[0].push_initial_commit()
            else:
                self._workers[-1].repo('checkout', 'master')