コード例 #1
0
 def test_close(self):
     server = barrier.listen_server()
     # cannot bind on the same port again
     self.assertRaises(socket.error, barrier.listen_server)
     server.close()
     # now we can
     server = barrier.listen_server()
     server.close()
コード例 #2
0
 def test_close(self):
     server = barrier.listen_server()
     # cannot bind on the same port again
     self.assertRaises(socket.error, barrier.listen_server)
     server.close()
     # now we can
     server = barrier.listen_server()
     server.close()
コード例 #3
0
    def run_once(self, our_addr, hostnames, master, timeout=120):
        # A reusable local server as we're using multiple barriers in one test.
        server = barrier.listen_server()

        # Basic barrier rendezvous test.
        self.job.barrier(our_addr, 'First', timeout=timeout,
                         listen_server=server).rendezvous(*hostnames)
        logging.info('1. rendezvous "First" complete.')
        time.sleep(2)

        # A rendezvous_servers using a different master than the default.
        self.job.barrier(our_addr, 'Second', timeout=timeout,
                         listen_server=server
                         ).rendezvous_servers(hostnames[-1], *hostnames[:-1])
        logging.info('2. rendezvous_servers "Second" complete.')
        time.sleep(2)

        # A regular rendezvous, this time testing the abort functionality.
        try:
            self.job.barrier(our_addr, 'WillAbort', timeout=timeout,
                             listen_server=server
                             ).rendezvous(abort=True, *hostnames)
        except error.BarrierAbortError:
            pass
        except error.BarrierError, e:
            # We did get an error from the barrier, but was is acceptable or
            # not?  Site code may not be able to indicate an explicit abort.
            self.job.record('WARN', None, 'barriertest',
                            'BarrierError %s instead of BarrierAbortError.' % e)
コード例 #4
0
    def run_once(self, our_addr, hostnames, master, timeout=120):
        # A reusable local server as we're using multiple barriers in one test.
        server = barrier.listen_server()

        # Basic barrier rendezvous test.
        self.job.barrier(our_addr, 'First', timeout=timeout,
                         listen_server=server).rendezvous(*hostnames)
        logging.info('1. rendezvous "First" complete.')
        time.sleep(2)

        # A rendezvous_servers using a different master than the default.
        self.job.barrier(our_addr, 'Second', timeout=timeout,
                         listen_server=server
                         ).rendezvous_servers(hostnames[-1], *hostnames[:-1])
        logging.info('2. rendezvous_servers "Second" complete.')
        time.sleep(2)

        # A regular rendezvous, this time testing the abort functionality.
        try:
            self.job.barrier(our_addr, 'WillAbort', timeout=timeout,
                             listen_server=server
                             ).rendezvous(abort=True, *hostnames)
        except error.BarrierAbortError:
            pass
        except error.BarrierError, e:
            # We did get an error from the barrier, but was is acceptable or
            # not?  Site code may not be able to indicate an explicit abort.
            self.job.record('WARN', None, 'barriertest',
                            'BarrierError %s instead of BarrierAbortError.' % e)
コード例 #5
0
 def test_reusing_listen_server(self):
     """
     Test that reusing the same listen server object works.
     """
     server = barrier.listen_server()
     self._rendezvous_test(10, listen_server=server)
     self._rendezvous_test(10, listen_server=server)
     self._rendezvous_test(10, listen_server=server)
コード例 #6
0
 def test_reusing_listen_server(self):
     """
     Test that reusing the same listen server object works.
     """
     server = barrier.listen_server()
     self.rendezvous_test(10, listen_server=server)
     self.rendezvous_test(10, listen_server=server)
     self.rendezvous_test(10, listen_server=server)
コード例 #7
0
        def migration_scenario(self):
            sync = SyncData(self.master_id(), self.hostid, self.hosts,
                            self.id, self.sync_server)
            srchost = self.params.get("hosts")[0]
            dsthost = self.params.get("hosts")[1]
            vms = [params.get("vms").split()[0]]

            def worker(mig_data):
                vm = mig_data.vms[0]
                session = vm.wait_for_login(timeout=self.login_timeout)

                cpuflags.install_cpuflags_util_on_vm(test, vm, install_path,
                                                     extra_flags="-msse3 -msse2")

                cmd = ("%s/cpuflags-test --stressmem %d,%d" %
                       (os.path.join(install_path, "cpu_flags"),
                        vm_mem * 4, vm_mem / 2))
                logging.debug("Sending command: %s" % (cmd))
                session.sendline(cmd)

            if self.master_id() == self.hostid:
                server_port = utils_misc.find_free_port(5200, 6000)
                server = listen_server(port=server_port)
                data_len = 0
                sync.sync(server_port, timeout=120)
                client = server.socket.accept()[0]
                endtime = time.time() + 30
                while endtime > time.time():
                    data_len += len(client.recv(2048))
                client.close()
                server.close()
                self.link_speed = data_len / (30 * 1024 * 1024)
                logging.info("Link speed %d MB/s" % (self.link_speed))
                ms = utils.convert_data_size(mig_speed, 'M')
                if (ms > data_len / 30):
                    logging.warn("Migration speed %s MB/s is set faster than "
                                 "real link speed %d MB/s" % (mig_speed,
                                                              self.link_speed))
                else:
                    self.link_speed = ms / (1024 * 1024)
            else:
                data = ""
                for _ in range(10000):
                    data += "i"
                server_port = sync.sync(timeout=120)[self.master_id()]
                sock = socket.socket(socket.AF_INET,
                                     socket.SOCK_STREAM)
                sock.connect((self.master_id(), server_port))
                try:
                    endtime = time.time() + 10
                    while endtime > time.time():
                        sock.sendall(data)
                    sock.close()
                except:
                    pass
            self.migrate_wait(vms, srchost, dsthost, worker)
        def migration_scenario(self):
            sync = SyncData(self.master_id(), self.hostid, self.hosts,
                            self.id, self.sync_server)
            srchost = self.params.get("hosts")[0]
            dsthost = self.params.get("hosts")[1]
            vms = [params.get("vms").split()[0]]

            def worker(mig_data):
                vm = mig_data.vms[0]
                session = vm.wait_for_login(timeout=self.login_timeout)

                cpuflags.install_cpuflags_util_on_vm(test, vm, install_path,
                                                     extra_flags="-msse3 -msse2")

                cmd = ("%s/cpuflags-test --stressmem %d,%d" %
                       (os.path.join(install_path, "cpu_flags"),
                        vm_mem * 4, vm_mem / 2))
                logging.debug("Sending command: %s" % (cmd))
                session.sendline(cmd)

            if self.master_id() == self.hostid:
                server_port = utils_misc.find_free_port(5200, 6000)
                server = listen_server(port=server_port)
                data_len = 0
                sync.sync(server_port, timeout=120)
                client = server.socket.accept()[0]
                endtime = time.time() + 30
                while endtime > time.time():
                    data_len += len(client.recv(2048))
                client.close()
                server.close()
                self.link_speed = data_len / (30 * 1024 * 1024)
                logging.info("Link speed %d MB/s" % (self.link_speed))
                ms = utils.convert_data_size(mig_speed, 'M')
                if (ms > data_len / 30):
                    logging.warn("Migration speed %s MB/s is set faster than "
                                 "real link speed %d MB/s" % (mig_speed,
                                                              self.link_speed))
                else:
                    self.link_speed = ms / (1024 * 1024)
            else:
                data = ""
                for _ in range(10000):
                    data += "i"
                server_port = sync.sync(timeout=120)[self.master_id()]
                sock = socket.socket(socket.AF_INET,
                                     socket.SOCK_STREAM)
                sock.connect((self.master_id(), server_port))
                try:
                    endtime = time.time() + 10
                    while endtime > time.time():
                        sock.sendall(data)
                    sock.close()
                except:
                    pass
            self.migrate_wait(vms, srchost, dsthost, worker)
コード例 #9
0
    def test_send_receive_net_object_timeout(self):
        ls = barrier.listen_server(port=syncdata._DEFAULT_PORT)

        server = self._start_server(ls, timewait=5)

        self.assertRaisesRegexp(
            error.NetCommunicationError, "Failed to receive python"
            " object over the network.", self._client, "127.0.0.1", 2)
        server.join()
        ls.close()
コード例 #10
0
    def test_send_receive_net_object(self):
        ls = barrier.listen_server(port=syncdata._DEFAULT_PORT)

        send_data = {'aa': ['bb', 'xx', ('ss')]}
        server = self._start_server(ls, send_data)

        recv_data = self._client("127.0.0.1", 10)
        server.join()
        ls.close()

        self.assertEqual(recv_data, send_data)
コード例 #11
0
    def test_send_receive_net_object_timeout_in_communication(self):
        ls = barrier.listen_server(port=syncdata._DEFAULT_PORT)

        send_data = {'aa': ['bb', 'xx', ('ss')]}
        server = self._start_server(ls, send_data, timewait=5, connbreak=True)

        self.assertRaisesRegexp(
            error.NetCommunicationError, "Failed to receive python"
            " object over the network.", self._client, "127.0.0.1", 2)
        server.join()
        ls.close()
コード例 #12
0
    def test_send_receive_net_object(self):
        ls = barrier.listen_server(port=syncdata._DEFAULT_PORT)

        send_data = {"aa": ["bb", "xx", ("ss")]}
        server = self._start_server(ls, send_data)

        recv_data = self._client("127.0.0.1", 10)
        server.join()
        ls.close()

        self.assertEqual(recv_data, send_data)
コード例 #13
0
    def test_send_receive_net_object_timeout(self):
        ls = barrier.listen_server(port=syncdata._DEFAULT_PORT)

        server = self._start_server(ls, timewait=5)

        self.assertRaisesRegexp(error.NetCommunicationError,
                                "Failed to receive python"
                                " object over the network.",
                                self._client, "127.0.0.1", 2)
        server.join()
        ls.close()
コード例 #14
0
    def test_send_receive_net_object(self):
        ls = barrier.listen_server(port=syncdata._DEFAULT_PORT)

        send_data = {'aa': ['bb', 'xx', ('ss')]}
        server = self._start_server(ls, send_data)

        recv_data = self._client("127.0.0.1", 10)
        server.join()
        ls.close()

        self.assertEqual(recv_data, send_data)
コード例 #15
0
    def test_send_receive_net_object_timeout_in_communication(self):
        ls = barrier.listen_server(port=syncdata._DEFAULT_PORT)

        send_data = {'aa': ['bb', 'xx', ('ss')]}
        server = self._start_server(ls, send_data,
                                    timewait=5, connbreak=True)

        self.assertRaisesRegexp(error.NetCommunicationError,
                                "Failed to receive python"
                                " object over the network.",
                                 self._client, "127.0.0.1", 2)
        server.join()
        ls.close()
コード例 #16
0
    def execute(self, timeout_sync, timeout_start, timeout_stop, hostid,
                masterid, all_ids):
        """
        @param timeout_sync: Seconds to wait for the synchronization of all
                hosts that will be launching profilers. (local_sync_profilers)
        @param timeout_start: Seconds to wait for each of the initial
                sync_profilers and start_profilers barriers between this
                host and the master to be reached.
        @param timeout_stop: Seconds to wait for this host and the master to
                reach each of the stop_profilers and finish_profilers barriers.
        @param hostid: This host's id (typically the hostname).
        @param masterid: The master barrier host id where autoserv is running.
        @param all_ids: A list of all hosts to synchronize profilers on.
        """
        profilers = self.job.profilers

        barrier_server = barrier.listen_server(port=11920)
        b0 = self.job.barrier(hostid,
                              "sync_profilers",
                              timeout_start,
                              listen_server=barrier_server)
        b0.rendezvous_servers(masterid, hostid)

        b1 = self.job.barrier(hostid,
                              "start_profilers",
                              timeout_start,
                              listen_server=barrier_server)
        b1.rendezvous_servers(masterid, hostid)

        b2 = self.job.barrier(hostid, "local_sync_profilers", timeout_sync)
        b2.rendezvous(*all_ids)

        profilers.start(self)

        b3 = self.job.barrier(hostid,
                              "stop_profilers",
                              timeout_stop,
                              listen_server=barrier_server)
        b3.rendezvous_servers(masterid, hostid)

        profilers.stop(self)
        profilers.report(self)

        b4 = self.job.barrier(hostid,
                              "finish_profilers",
                              timeout_stop,
                              listen_server=barrier_server)
        b4.rendezvous_servers(masterid, hostid)

        barrier_server.close()
コード例 #17
0
    def execute(self, timeout_sync, timeout_start, timeout_stop,
                hostid, masterid, all_ids):
        """
        @param timeout_sync: Seconds to wait for the synchronization of all
                hosts that will be launching profilers. (local_sync_profilers)
        @param timeout_start: Seconds to wait for each of the initial
                sync_profilers and start_profilers barriers between this
                host and the master to be reached.
        @param timeout_stop: Seconds to wait for this host and the master to
                reach each of the stop_profilers and finish_profilers barriers.
        @param hostid: This host's id (typically the hostname).
        @param masterid: The master barrier host id where autoserv is running.
        @param all_ids: A list of all hosts to synchronize profilers on.
        """
        profilers = self.job.profilers

        barrier_server = barrier.listen_server(port=11920)
        b0 = self.job.barrier(hostid, "sync_profilers", timeout_start,
                              listen_server=barrier_server)
        b0.rendezvous_servers(masterid, hostid)

        b1 = self.job.barrier(hostid, "start_profilers", timeout_start,
                              listen_server=barrier_server)
        b1.rendezvous_servers(masterid, hostid)

        b2 = self.job.barrier(hostid, "local_sync_profilers", timeout_sync)
        b2.rendezvous(*all_ids)

        profilers.start(self)

        b3 = self.job.barrier(hostid, "stop_profilers", timeout_stop,
                              listen_server=barrier_server)
        b3.rendezvous_servers(masterid, hostid)

        profilers.stop(self)
        profilers.report(self)

        b4 = self.job.barrier(hostid, "finish_profilers", timeout_stop,
                              listen_server=barrier_server)
        b4.rendezvous_servers(masterid, hostid)

        barrier_server.close()
コード例 #18
0
    def _server(self, address, port):
        self.listen_server = barrier.listen_server(address, port)
        logging.debug("Wait for clients")
        self.listen_server.socket.settimeout(_DEFAULT_TIMEOUT)
        while not self.exit_event.isSet():
            try:
                connection = self.listen_server.socket.accept()
                logging.debug("Client %s connected.", connection[1][0])
                session_id, hosts, timeout = net_recv_object(connection[0],
                                                             _DEFAULT_TIMEOUT)
                self._clean_sessions()
                if session_id not in self.sessions:
                    logging.debug("Add new session")
                    self.sessions[session_id] = SessionData(hosts, timeout)

                logging.debug("Start recv thread.")
                utils.InterruptedThread(self._recv_data, (connection,
                                                          self.sessions[session_id])).start()

            except (socket.timeout, error.NetCommunicationError):
                self._clean_sessions()
        logging.debug("SyncListenServer on closed.")
コード例 #19
0
    def _server(self, address, port):
        self.listen_server = barrier.listen_server(address, port)
        logging.debug("Wait for clients")
        self.listen_server.socket.settimeout(_DEFAULT_TIMEOUT)
        while not self.exit_event.isSet():
            try:
                connection = self.listen_server.socket.accept()
                logging.debug("Client %s connected.", connection[1][0])
                session_id, hosts, timeout = net_recv_object(
                    connection[0], _DEFAULT_TIMEOUT)
                self._clean_sessions()
                if session_id not in self.sessions:
                    logging.debug("Add new session")
                    self.sessions[session_id] = SessionData(hosts, timeout)

                logging.debug("Start recv thread.")
                utils.InterruptedThread(
                    self._recv_data,
                    (connection, self.sessions[session_id])).start()

            except (socket.timeout, error.NetCommunicationError):
                self._clean_sessions()
        logging.debug("SyncListenServer on closed.")
コード例 #20
0
 def _server(self, address, port):
     self.listen_server = barrier.listen_server()
     self.exit_event.wait()
コード例 #21
0
 def test_init(self):
     server = barrier.listen_server()
     server.close()
コード例 #22
0
 def _server(self, address, port):
     self.listen_server = barrier.listen_server()
     self.exit_event.wait()
コード例 #23
0
 def test_init(self):
     server = barrier.listen_server()
     server.close()