• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2016 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 datetime, logging, time
6
7from autotest_lib.client.common_lib import error
8from autotest_lib.client.common_lib.cros import tpm_utils
9from autotest_lib.server import test
10from autotest_lib.server.cros.multimedia import remote_facade_factory
11
12LONG_TIMEOUT = 8
13SHORT_TIMEOUT = 5
14
15
16class enterprise_CFM_SessionStress(test.test):
17    """Stress tests the device in CFM kiosk mode by initiating a new hangout
18    session multiple times.
19    """
20    version = 1
21
22
23    def _run_hangout_session(self):
24        """Start a hangout session and do some checks before ending the session.
25
26        @raises error.TestFail if any of the checks fail.
27        """
28        current_time = datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
29        hangout_name = 'auto-hangout-' + current_time
30        logging.info('Session name: %s', hangout_name)
31
32        self.cfm_facade.start_new_hangout_session(hangout_name)
33        time.sleep(LONG_TIMEOUT)
34        self.cfm_facade.end_hangout_session()
35
36
37    def run_once(self, host, repeat):
38        """Runs the test."""
39        self.client = host
40
41        factory = remote_facade_factory.RemoteFacadeFactory(
42                host, no_chrome=True)
43        self.cfm_facade = factory.create_cfm_facade()
44
45        tpm_utils.ClearTPMOwnerRequest(self.client)
46
47        if self.client.servo:
48            self.client.servo.switch_usbkey('dut')
49            self.client.servo.set('usb_mux_sel3', 'dut_sees_usbkey')
50            time.sleep(SHORT_TIMEOUT)
51            self.client.servo.set('dut_hub1_rst1', 'off')
52            time.sleep(SHORT_TIMEOUT)
53
54        try:
55            self.cfm_facade.enroll_device()
56            self.cfm_facade.restart_chrome_for_cfm()
57            self.cfm_facade.wait_for_telemetry_commands()
58            self.cfm_facade.wait_for_oobe_start_page()
59
60            if not self.cfm_facade.is_oobe_start_page():
61                raise error.TestFail('CFM did not reach oobe screen.')
62
63            self.cfm_facade.skip_oobe_screen()
64
65            while repeat:
66                self._run_hangout_session()
67                time.sleep(SHORT_TIMEOUT)
68                repeat -= 1
69        except Exception as e:
70            raise error.TestFail(str(e))
71
72        tpm_utils.ClearTPMOwnerRequest(self.client)
73