def test_create_creates_server_over_adb_with_proper_config(self): self.assertIsInstance( iperf_server.create([{ 'AndroidDevice': '53R147', 'port': 0 }])[0], IPerfServerOverAdb, 'create() failed to create IPerfServerOverAdb for a valid config.')
def test_create_creates_server_over_ssh_with_ssh_config_and_port(self, _): self.assertIsInstance( iperf_server.create([{ 'ssh_config': { 'user': '', 'host': '' }, 'port': '' }])[0], IPerfServerOverSsh, 'create() failed to create IPerfServerOverSsh for a valid config.')
def setup_class(self): """Initializes common test hardware and parameters. This function initializes hardwares and compiles parameters that are common to all tests in this class. """ self.dut = self.android_devices[-1] req_params = ['sap_test_params', 'testbed_params'] opt_params = ['golden_files_list', 'OTASniffer'] self.unpack_userparams(req_params, opt_params) self.testclass_params = self.sap_test_params self.num_atten = self.attenuators[0].instrument.num_atten self.iperf_server = ipf.create([{ 'AndroidDevice': self.android_devices[0].serial, 'port': '5201' }])[0] self.iperf_client = ipc.create([{ 'AndroidDevice': self.android_devices[1].serial, 'port': '5201' }])[0] if hasattr(self, 'OTASniffer') and self.testbed_params['sniffer_enable']: self.sniffer = ota_sniffer.create(self.OTASniffer)[0] self.log_path = os.path.join(logging.log_path, 'results') os.makedirs(self.log_path, exist_ok=True) if not hasattr(self, 'golden_files_list'): if 'golden_results_path' in self.testbed_params: self.golden_files_list = [ os.path.join(self.testbed_params['golden_results_path'], file) for file in os.listdir(self.testbed_params['golden_results_path']) ] else: self.log.warning('No golden files found.') self.golden_files_list = [] self.testclass_results = [] # Turn WiFi ON for dev in self.android_devices: wutils.wifi_toggle_state(dev, True)
def _reserve_server(self, subnet): """Reserves an available IPerfServer for use in a stream from another WmmTransceiver. If none are available, a new one is created. Args: subnet: string, subnet of test network, to retrieve the appropriate server address Returns: (string, int) representing the IPerfServer address and port """ reserved_server = None for server in self._iperf_servers: if self._iperf_servers[server] == AVAILABLE: reserved_server = server break else: iperf_server_config = self._iperf_config iperf_server_config.update({'port': self._next_server_port}) self._next_server_port += 1 reserved_server = iperf_server.create([iperf_server_config])[0] self._iperf_server_ports[reserved_server.port] = reserved_server self._iperf_servers[reserved_server] = UNAVAILABLE reserved_server.start() end_time = time.time() + DEFAULT_IP_ADDR_TIMEOUT while time.time() < end_time: if self.wlan_device: addresses = utils.get_interface_ip_addresses( self.wlan_device.device, self._test_interface) else: addresses = reserved_server.get_interface_ip_addresses( self._test_interface) for addr in addresses['ipv4_private']: if utils.ip_in_subnet(addr, subnet): return (addr, reserved_server.port) raise AttributeError( 'Reserved server has no ipv4 address in the %s subnet' % subnet)
def test_create_raises_value_error_on_bad_config_dict(self): with self.assertRaises(ValueError): iperf_server.create([{ 'AndroidDevice': '53R147', 'ssh_config': {} }])
def test_create_cannot_create_local_iperf_server_with_bad_str(self): with self.assertRaises(ValueError): iperf_server.create(['12345BAD_STRING'])
def test_create_creates_local_iperf_server_with_str(self): self.assertIsInstance( iperf_server.create(['12345'])[0], IPerfServer, 'create() failed to create IPerfServer for integer input.')