| # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import logging |
| import time |
| |
| from autotest_lib.client.common_lib.cros.network import xmlrpc_datatypes |
| from autotest_lib.server.cros.network import netperf_runner |
| from autotest_lib.server.cros.network import netperf_wifi_perf_logger |
| from autotest_lib.server.cros.network import netperf_session |
| from autotest_lib.server.cros.network import wifi_cell_test_base |
| |
| |
| class network_WiFi_Perf(wifi_cell_test_base.WiFiCellTestBase): |
| """Test maximal achievable bandwidth on several channels per band. |
| |
| Conducts a performance test for a set of specified router configurations |
| and reports results as keyval pairs. |
| |
| """ |
| |
| version = 1 |
| |
| NETPERF_CONFIGS = [ |
| netperf_runner.NetperfConfig( |
| netperf_runner.NetperfConfig.TEST_TYPE_TCP_STREAM), |
| netperf_runner.NetperfConfig( |
| netperf_runner.NetperfConfig.TEST_TYPE_TCP_MAERTS), |
| netperf_runner.NetperfConfig( |
| netperf_runner.NetperfConfig.TEST_TYPE_UDP_STREAM), |
| netperf_runner.NetperfConfig( |
| netperf_runner.NetperfConfig.TEST_TYPE_UDP_MAERTS), |
| ] |
| |
| |
| def parse_additional_arguments(self, commandline_args, additional_params): |
| """Hook into super class to take control files parameters. |
| |
| @param commandline_args dict of parsed parameters from the autotest. |
| @param additional_params list of HostapConfig objects. |
| |
| """ |
| self._ap_configs = additional_params |
| |
| |
| def run_once(self): |
| """Test body.""" |
| start_time = time.time() |
| for ap_config in self._ap_configs: |
| keyval_logger = netperf_wifi_perf_logger.NetperfWiFiPerfLogger( |
| ap_config, self.context.client, self.write_perf_keyval) |
| # Set up the router and associate the client with it. |
| self.context.configure(ap_config) |
| assoc_params = xmlrpc_datatypes.AssociationParameters( |
| ssid=self.context.router.get_ssid(), |
| security_config=ap_config.security_config) |
| self.context.assert_connect_wifi(assoc_params) |
| # Conduct the performance tests. |
| session = netperf_session.NetperfSession(self.context.client, |
| self.context.server) |
| session.warmup_stations() |
| keyval_logger.record_signal_keyval() |
| results = [session.run(config) |
| for config in self.NETPERF_CONFIGS] |
| map(keyval_logger.record_keyvals_for_result, results) |
| # Clean up router and client state for the next run. |
| self.context.client.shill.disconnect(self.context.router.get_ssid()) |
| self.context.router.deconfig() |
| end_time = time.time() |
| logging.info('Running time %0.1f seconds.', end_time - start_time) |