# 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 traceback from autotest_lib.client.common_lib.cros.network import ap_constants from autotest_lib.server import utils AUTHOR = 'krisr, wiley, jabele' NAME = 'network_WiFi_ChaosConfigFailure' TIME = 'SHORT' TEST_TYPE = 'server' DOC = """ This test is run when a chaos APConfigurator fails to successfully configure an AP. It will grab screenshots and print stack traces of the failure. This control file is only run directly to simulate APConfigurator failures for test purposes. """ from autotest_lib.server.cros.chaos_ap_configurators \ import ap_configurator_factory from autotest_lib.server.cros.chaos_ap_configurators import ap_spec def run_chaos_config_failure(machine): args_dict = utils.args_to_dict(args) host = hosts.create_host(machine) debug_aps = ['chromeos3-row2-rack1-host2',] tested_ap_spec = ap_spec.APSpec(hostnames=debug_aps) factory = ap_configurator_factory.APConfiguratorFactory() ap = factory.get_ap_configurators_by_spec(tested_ap_spec)[0] ap.set_using_ap_spec(tested_ap_spec) ap.apply_settings() ## Simulate test failure by forcing state and gathering artifacts try: raise RuntimeError("Simulated APConfigurator Error") except Exception: trace = ''.join(traceback.format_exc()) ap.store_config_failure(trace) job.run_test('network_WiFi_ChaosConfigFailure', ap=ap, error_string=ap_constants.AP_CONFIG_FAIL, tag=ap.ssid) parallel_simple(run_chaos_config_failure, machines)