1# Copyright 2019 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 5AUTHOR = "puthik" 6NAME = "power_Dashboard.fast_lab" 7TIME = "MEDIUM" 8TEST_CATEGORY = "Stress" 9TEST_CLASS = "suite" 10TEST_TYPE = "server" 11PY_VERSION = 3 12 13DOC = """ 14Sequence to make sure that power_Dashboard.full_lab tests work fine. 15""" 16 17import datetime 18from autotest_lib.client.common_lib import error 19from autotest_lib.client.common_lib import utils 20 21# Need separate list for client and server test due to how these test work. 22CLIENT_TESTS = [ 23 ('power_Standby', { 24 'tag' : '36sec', 'sample_hours' : 0.01, 'test_hours' : 0.01, 25 'bypass_check' : True}), 26 ('power_LoadTest', { 27 'tag' : 'fast', 'loop_time' : 180, 'loop_count' : 1, 28 'test_low_batt_p' : 6, 'check_network': False, 'ac_ok' : True, 29 'gaia_login' : False}), 30 ('power_Idle', { 31 'tag' : 'fast', 'warmup_secs' : 2, 'idle_secs' : 10}), 32 ('power_VideoPlayback', { 33 'tag' : 'fast', 'secs_per_video' : 10, 'fast' : True }), 34 ('power_VideoPlayback', { 35 'tag' : 'sw_decoder_fast', 'use_hw_decode' : False, 36 'secs_per_video' : 10, 'fast' : True }), 37 ('power_Display', { 38 'tag' : 'fast', 'secs_per_page' : 2}), 39 ('power_WebGL', { 40 'tag' : 'fast', 'duration' : 10}), 41] 42 43SERVO_V4_ETH_VENDOR = '0bda' 44SERVO_V4_ETH_PRODUCT = '8153' 45WIFI_SSID = 'powertest_ap' 46 47# Workaround to make it compatible with moblab autotest UI. 48global args_dict 49try: 50 args_dict 51except NameError: 52 args_dict = utils.args_to_dict(args) 53 54# Use time as pdash_note if not supplied to track all tests in same suite. 55pdash_note = args_dict.get('pdash_note', 56 NAME + '_' + datetime.datetime.utcnow().isoformat()) 57def run_client_test(machine): 58 client = hosts.create_host(machine) 59 60 wlan_ip = client.get_wlan_ip() 61 if not wlan_ip: 62 autotest.Autotest(client).run_test('stub_Pass') 63 if not client.connect_to_wifi(WIFI_SSID): 64 raise error.TestFail('Can not connect to wifi.') 65 wlan_ip = client.get_wlan_ip() 66 if not wlan_ip: 67 raise error.TestFail('Can not find wlan ip.') 68 69 # Check if we have servo v4 ethernet and can switch to wlan. 70 eth_usb = client.find_usb_devices(SERVO_V4_ETH_VENDOR, SERVO_V4_ETH_PRODUCT) 71 can_switch_to_wlan = len(eth_usb) == 1 and eth_usb[0] and wlan_ip 72 if can_switch_to_wlan: 73 wlan_machine = machine 74 if utils.host_is_in_power_lab(machine['hostname']): 75 wlan_machine['hostname'] = \ 76 utils.get_power_lab_wlan_hostname(machine['hostname']) 77 else: 78 wlan_machine['hostname'] = wlan_ip 79 client = hosts.create_host(wlan_machine) 80 eth_node = eth_usb[0] 81 82 client_at = autotest.Autotest(client) 83 84 for test, argv in CLIENT_TESTS: 85 client.reboot() 86 if can_switch_to_wlan: 87 client.unbind_usb_device(eth_node) 88 argv['pdash_note'] = pdash_note 89 argv['force_discharge'] = True 90 client_at.run_test(test, **argv) 91 92 client.reboot() 93 94 95parallel_simple(run_client_test, machines) 96