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