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