Home | History | Annotate | Download | only in network_WiFi_ChaosConfigFailure
      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 
      5 import traceback
      6 
      7 from autotest_lib.client.common_lib.cros.network import ap_constants
      8 from autotest_lib.server import utils
      9 
     10 AUTHOR = 'krisr, wiley, jabele'
     11 NAME = 'network_WiFi_ChaosConfigFailure'
     12 TIME = 'SHORT'
     13 TEST_TYPE = 'server'
     14 
     15 DOC = """
     16 This test is run when a chaos APConfigurator fails to successfully configure
     17 an AP.  It will grab screenshots and print stack traces of the failure.
     18 This control file is only run directly to simulate APConfigurator failures for
     19 test purposes.
     20 """
     21 
     22 from autotest_lib.server.cros.chaos_ap_configurators \
     23         import ap_configurator_factory
     24 from autotest_lib.server.cros.chaos_ap_configurators import ap_spec
     25 
     26 
     27 def 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 
     46 parallel_simple(run_chaos_config_failure, machines)
     47