Home | History | Annotate | Download | only in network_WiFi_RoamSuspend
      1 # Copyright (c) 2013 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 
      5 import logging
      6 import time
      7 
      8 from autotest_lib.client.common_lib.cros.network import xmlrpc_datatypes
      9 from autotest_lib.server.cros.network import hostap_config
     10 from autotest_lib.server.cros.network import wifi_cell_test_base
     11 
     12 class network_WiFi_RoamSuspend(wifi_cell_test_base.WiFiCellTestBase):
     13     """Tests roaming to an AP that changes while we're suspended.
     14 
     15     This test:
     16     1) Sets up a network with a single BSS.
     17     2) Connects the DUT to that network and that particular BSS.
     18     3) Places the DUT in suspend-to-RAM
     19     4) Replaces the BSS with another BSS on the same SSID.
     20     5) Watches to make sure the DUT connects to this BSS on resume.
     21 
     22     """
     23 
     24     version = 1
     25 
     26     FREQUENCY_1 = 2412
     27     FREQUENCY_2 = 5240
     28     BSSID_1 = "00:01:02:03:04:05"
     29     BSSID_2 = "06:07:08:09:0a:0b"
     30 
     31 
     32     def run_once(self):
     33         """Test body."""
     34         logging.info("- Set up AP, connect.")
     35         self.context.configure(hostap_config.HostapConfig(
     36                 frequency=network_WiFi_RoamSuspend.FREQUENCY_1,
     37                 mode=hostap_config.HostapConfig.MODE_11B,
     38                 bssid=network_WiFi_RoamSuspend.BSSID_1))
     39         router_ssid = self.context.router.get_ssid()
     40         self.context.assert_connect_wifi(xmlrpc_datatypes.AssociationParameters(
     41                 ssid=router_ssid))
     42 
     43         # For this short of a duration, the DUT should still consider itself
     44         # connected to the AP and simply resume without re-associating or
     45         # reconnect quickly enough without intervention from the connection
     46         # manager that it appears to remain connected.
     47         logging.info("- Short suspend, verify we're still connected.")
     48         self.context.client.do_suspend(10)
     49         self.context.assert_ping_from_dut()
     50 
     51         logging.info("- Reconfigure the AP during longer suspend.")
     52         self.context.client.do_suspend_bg(20)
     53         # Locally, let's wait 15 seconds to make sure the DUT is really asleep
     54         # before we proceed.
     55         time.sleep(15)
     56         self.context.configure(hostap_config.HostapConfig(
     57                 ssid=router_ssid,
     58                 frequency=network_WiFi_RoamSuspend.FREQUENCY_2,
     59                 mode=hostap_config.HostapConfig.MODE_11A,
     60                 bssid=network_WiFi_RoamSuspend.BSSID_2))
     61 
     62         logging.info("- Verify that we roam to same network w/new parameters.")
     63         self.context.wait_for_connection(router_ssid,
     64                                          network_WiFi_RoamSuspend.FREQUENCY_2)
     65         self.context.router.deconfig()
     66