• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import traceback
6
7from autotest_lib.client.common_lib.cros.network import ap_constants
8from autotest_lib.server import utils
9
10AUTHOR = 'krisr, wiley, jabele'
11NAME = 'network_WiFi_ChaosConfigFailure'
12TIME = 'SHORT'
13TEST_TYPE = 'server'
14
15DOC = """
16This test is run when a chaos APConfigurator fails to successfully configure
17an AP.  It will grab screenshots and print stack traces of the failure.
18This control file is only run directly to simulate APConfigurator failures for
19test purposes.
20"""
21
22from autotest_lib.server.cros.chaos_ap_configurators \
23        import ap_configurator_factory
24from autotest_lib.server.cros.chaos_ap_configurators import ap_spec
25
26
27def run_chaos_config_failure(machine):
28    args_dict = utils.args_to_dict(args)
29    host = hosts.create_host(machine)
30    debug_aps = ['chromeos3-row2-rack1-host2',]
31    tested_ap_spec = ap_spec.APSpec(hostnames=debug_aps)
32    factory = ap_configurator_factory.APConfiguratorFactory()
33    ap = factory.get_ap_configurators_by_spec(tested_ap_spec)[0]
34    ap.set_using_ap_spec(tested_ap_spec)
35    ap.apply_settings()
36    ## Simulate test failure by forcing state and gathering artifacts
37    try:
38        raise RuntimeError("Simulated APConfigurator Error")
39    except Exception:
40        trace = ''.join(traceback.format_exc())
41        ap.store_config_failure(trace)
42    job.run_test('network_WiFi_ChaosConfigFailure', ap=ap,
43                  error_string=ap_constants.AP_CONFIG_FAIL, tag=ap.ssid)
44
45
46parallel_simple(run_chaos_config_failure, machines)
47