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