Beispiel #1
0
    def run_vpn_test(self, vpn_type):
        """Run a vpn test of |vpn_type|.

        @param vpn_type string type of VPN test to run.

        """
        manager = self._shill_proxy.manager
        server_address_and_prefix = '%s/%d' % (self.SERVER_ADDRESS,
                                               self.NETWORK_PREFIX)
        client_address_and_prefix = '%s/%d' % (self.CLIENT_ADDRESS,
                                               self.NETWORK_PREFIX)
        self._vpn_type = vpn_type
        self._expect_success = 'incorrect' not in vpn_type

        with shill_temporary_profile.ShillTemporaryProfile(
                manager, profile_name=self.TEST_PROFILE_NAME):
            with virtual_ethernet_pair.VirtualEthernetPair(
                    interface_name=self.SERVER_INTERFACE_NAME,
                    peer_interface_name=self.CLIENT_INTERFACE_NAME,
                    peer_interface_ip=client_address_and_prefix,
                    interface_ip=server_address_and_prefix,
                    ignore_shutdown_errors=True) as ethernet_pair:
                if not ethernet_pair.is_healthy:
                    raise error.TestFail('Virtual ethernet pair failed.')

                # When shill finds this ethernet interface, it will reset
                # its IP address and start a DHCP client.  We must configure
                # the static IP address through shill.
                self.configure_static_ip(self.CLIENT_INTERFACE_NAME,
                                         self.CLIENT_ADDRESS,
                                         self.NETWORK_PREFIX)

                with self.get_vpn_server() as server:
                    self.connect_vpn()
                    utils.ping(server.SERVER_IP_ADDRESS, tries=3)
    def wait_for_host(self, host=None, timeout=30):
        '''Wait for the DUT to come back up, with a timeout

        @param host: ip address or hostname of DUT
        @param timeout: maximum time in seconds to wait

        Returns True if the host comes up in time, False otherwise'''
        return client_utils.ping(host, deadline=timeout) == 0
    def cleanup(self):
        shutil.copy('/var/log/update_engine.log', self.resultsdir)

        # Turn adapters back on
        utils.run('ifconfig eth0 up', ignore_status=True)
        utils.run('ifconfig eth1 up', ignore_status=True)
        utils.start_service('recover_duts', ignore_status=True)

        # We can't return right after reconnecting the network or the server
        # test may not receive the message. So we wait a bit longer for the
        # DUT to be reconnected.
        utils.poll_for_condition(lambda: utils.ping(
            self._update_server, deadline=5, timeout=5) == 0,
                                 timeout=60,
                                 sleep_interval=1)
        logging.info('Online ready to return to server test')
Beispiel #4
0
    def run_once(self, host):
        """Clear the tpm owner, reboot the EC, and check the device boots"""
        tpm_utils.ClearTPMOwnerRequest(host)

        logging.info(tpm_utils.TPMStatus(host))

        self.servo.get_power_state_controller().reset()

        end_time = time.time() + self.TIMEOUT
        while utils.ping(host.ip, deadline=5, tries=1):
            if time.time() > end_time:
                self.ec.reboot()
                raise error.TestFail('DUT failed to boot')
            logging.info('DUT is still down (no response to ping)')

        logging.info('DUT is up')

        self.check_state((self.checkers.crossystem_checker, {
            'mainfw_type': 'normal'
        }))
    def run_once(self, update_url, time_without_network=120):
        self._update_server = urlparse.urlparse(update_url).hostname
        # DUTs in the lab have a service called recover_duts that is used to
        # check that the DUT is online and if it is not it will bring it back
        # online. We will need to stop this service for the length of this test.
        utils.stop_service('recover_duts', ignore_status=True)

        # Disable the network adapters.
        utils.run('ifconfig eth0 down')
        utils.run('ifconfig eth1 down')

        # Check that we are offline.
        result = utils.ping(self._update_server, deadline=5, timeout=5)
        if result != 2:
            raise error.TestFail('Ping succeeded even though we were offline.')

        # Get the update percentage as the network is down
        percent_before = utils.run('update_engine_client --status').stdout
        percent_before = percent_before.splitlines()[1].partition('=')[2]

        seconds = 1
        while seconds < time_without_network:
            logging.info(utils.run('update_engine_client --status').stdout)
            time.sleep(1)
            seconds = seconds + 1

        percent_after = utils.run('update_engine_client --status').stdout
        percent_after = percent_after.splitlines()[1].partition('=')[2]

        if percent_before != percent_after:
            if percent_before < percent_after:
                raise error.TestFail('The update continued while the network '
                                     'was supposedly disabled. Before: '
                                     '%s, After: %s' %
                                     (percent_before, percent_after))
            else:
                raise error.TestFail('The update appears to have restarted. '
                                     'Before: %s, After: %s' %
                                     (percent_before, percent_after))