1# Copyright (c) 2010 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 5import random, time 6from autotest_lib.client.common_lib import error 7from autotest_lib.client.cros import power_strip 8from autotest_lib.server import autotest, test 9 10class platform_CryptohomeSyncStressServer(test.test): 11 version = 1 12 max_delay = 120 13 14 def run_once(self, host, power_addr, outlet, username, password): 15 # check parameters 16 if power_addr == None: 17 raise error.TestFail('Missing power_addr argument.') 18 if outlet == None: 19 raise error.TestFail('Missing outlet argument.') 20 if username == None: 21 raise error.TestFail('Missing user parameter.') 22 if password == None: 23 raise error.TestFail('Missing pass parameter.') 24 25 outlet = int(outlet) 26 27 at = autotest.Autotest(host) 28 boot_id = host.get_boot_id() 29 30 # log in and verify things work 31 self.job.set_state('client_fail', True) 32 at.run_test('platform_CryptohomeSyncStress', 33 username=username, password=password) 34 if self.job.get_state('client_fail'): 35 raise error.TestFail('Client test failed') 36 37 # wait for some delay 38 delay = random.randint(0, self.max_delay) 39 print 'Delaying for %s seconds and then restarting.' % (delay) 40 time.sleep(delay) 41 42 # restart client 43 power_strip.PowerStrip(power_addr).reboot(outlet) 44 host.wait_for_restart(old_boot_id=boot_id) 45