Home | History | Annotate | Download | only in buffet_IntermittentConnectivity
      1 # Copyright 2015 The Chromium 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 
      5 from autotest_lib.client.bin import test
      6 from autotest_lib.client.common_lib.cros.tendo import buffet_tester
      7 
      8 class buffet_IntermittentConnectivity(test.test):
      9     """Test that buffet reconnects if it loses connectivity."""
     10     version = 1
     11 
     12     def initialize(self):
     13         self._helper = buffet_tester.BuffetTester()
     14 
     15 
     16     def run_once(self):
     17         """Test entry point."""
     18         # Erase all buffet state and restart it pointing to our fake
     19         # server, register with the cloud and check we can poll for
     20         # commands.
     21         self._helper.restart_buffet(reset_state=True)
     22         self._helper.check_buffet_status_is(buffet_tester.STATUS_UNCONFIGURED)
     23         device_id = self._helper.register_with_server()
     24         self._helper.check_buffet_is_polling(device_id)
     25 
     26         # Now make fake_device_server fail all request from Buffet
     27         # with HTTP Error Code 500 (Internal Server Error) and check
     28         # that we transition to the CONNECTING state.
     29         self._helper._fail_control_client.start_failing_requests()
     30         self._helper.check_buffet_status_is(
     31                 buffet_tester.STATUS_CONNECTING,
     32                 expected_device_id=device_id,
     33                 timeout_seconds=20)
     34 
     35         # Stop failing request from and check that we transition to
     36         # the CONNECTED state.
     37         self._helper._fail_control_client.stop_failing_requests()
     38         self._helper.check_buffet_status_is(
     39                 buffet_tester.STATUS_CONNECTED,
     40                 expected_device_id=device_id,
     41                 timeout_seconds=20)
     42         self._helper.check_buffet_is_polling(device_id)
     43 
     44 
     45     def cleanup(self):
     46         self._helper.close()
     47