Fix for failing suspend stress tests

Initialize host with servo in control file and few
other changes.

BUG=chromium:463336
TEST=Ran locally

Change-Id: Ib9807aa4cc5e149c5778831997c54b7f87c205e6
Reviewed-on: https://chromium-review.googlesource.com/256193
Commit-Queue: Bindu Mahadev <bmahadev@chromium.org>
Tested-by: Bindu Mahadev <bmahadev@chromium.org>
Reviewed-by: Kris Rambish <krisr@chromium.org>
diff --git a/server/site_tests/network_WiFi_SuspendStress/control.11b b/server/site_tests/network_WiFi_SuspendStress/control.11b
index dcfcd9d..9c93257 100644
--- a/server/site_tests/network_WiFi_SuspendStress/control.11b
+++ b/server/site_tests/network_WiFi_SuspendStress/control.11b
@@ -4,11 +4,11 @@
 
 AUTHOR = 'krisr, tienchang, bmahadev'
 NAME = 'network_WiFi_SuspendStress.11b'
-TIME = 'SHORT'
+TIME = 'MEDIUM'
 TEST_TYPE = 'Server'
+DEPENDENCIES = 'servo, wificell'
 SUITE = ('wifi_matfunc, wifi_matfunc_bcm4356, wifi_matfunc_marvell8897,'
          'wifi_matfunc_intel7265')
-DEPENDENCIES = 'wificell, servo'
 DOC = """
 This test uses servo to simulate lid close and open events and checks that the
 wifi adapter is brought back up and connects to a 802.11b network on channels
@@ -17,9 +17,13 @@
 
 from autotest_lib.client.common_lib.cros.network import xmlrpc_datatypes
 from autotest_lib.server.cros.network import hostap_config
+from autotest_lib.server import utils
 
+args_dict = utils.args_to_dict(args)
+servo_args = hosts.CrosHost.get_servo_arguments(args_dict)
 
 def run(machine):
+    host = hosts.create_host(machine, servo_args=servo_args)
     b_mode = hostap_config.HostapConfig.MODE_11B
     configurations = [(hostap_config.HostapConfig(channel=1, mode=b_mode),
                        xmlrpc_datatypes.AssociationParameters()),
@@ -27,10 +31,10 @@
                        xmlrpc_datatypes.AssociationParameters()),
                       (hostap_config.HostapConfig(channel=11, mode=b_mode),
                        xmlrpc_datatypes.AssociationParameters())]
-    host = hosts.create_host(machine)
     job.run_test('network_WiFi_SuspendStress',
-                 tag=NAME.split('.')[1],
                  host=host,
+                 tag=NAME.split('.')[1],
+                 suspends=5,
                  raw_cmdline_args=args,
                  additional_params=configurations)
 
diff --git a/server/site_tests/network_WiFi_SuspendStress/control.11g b/server/site_tests/network_WiFi_SuspendStress/control.11g
index afdd49c..ae23bb6 100644
--- a/server/site_tests/network_WiFi_SuspendStress/control.11g
+++ b/server/site_tests/network_WiFi_SuspendStress/control.11g
@@ -4,11 +4,11 @@
 
 AUTHOR = 'krisr, tienchang, bmahadev'
 NAME = 'network_WiFi_SuspendStress.11g'
-TIME = 'SHORT'
+TIME = 'MEDIUM'
 TEST_TYPE = 'Server'
+DEPENDENCIES = 'servo, wificell'
 SUITE = ('wifi_matfunc, wifi_matfunc_bcm4356, wifi_matfunc_marvell8897,'
          'wifi_matfunc_intel7265')
-DEPENDENCIES = 'wificell, servo'
 DOC = """
 This test uses servo to simulate lid close and open events and checks that the
 wifi adapter is brought back up and connects to a 802.11g network on channels
@@ -17,9 +17,13 @@
 
 from autotest_lib.client.common_lib.cros.network import xmlrpc_datatypes
 from autotest_lib.server.cros.network import hostap_config
+from autotest_lib.server import utils
 
+args_dict = utils.args_to_dict(args)
+servo_args = hosts.CrosHost.get_servo_arguments(args_dict)
 
 def run(machine):
+    host = hosts.create_host(machine, servo_args=servo_args)
     g_mode = hostap_config.HostapConfig.MODE_11G
     configurations = [(hostap_config.HostapConfig(channel=1, mode=g_mode),
                        xmlrpc_datatypes.AssociationParameters()),
@@ -27,10 +31,10 @@
                        xmlrpc_datatypes.AssociationParameters()),
                       (hostap_config.HostapConfig(channel=11, mode=g_mode),
                        xmlrpc_datatypes.AssociationParameters())]
-    host = hosts.create_host(machine)
     job.run_test('network_WiFi_SuspendStress',
-                 tag=NAME.split('.')[1],
                  host=host,
+                 tag=NAME.split('.')[1],
+                 suspends=5,
                  raw_cmdline_args=args,
                  additional_params=configurations)
 
diff --git a/server/site_tests/network_WiFi_SuspendStress/control.24HT40 b/server/site_tests/network_WiFi_SuspendStress/control.24HT40
index 9fe7c90..37c53b0 100644
--- a/server/site_tests/network_WiFi_SuspendStress/control.24HT40
+++ b/server/site_tests/network_WiFi_SuspendStress/control.24HT40
@@ -4,34 +4,36 @@
 
 AUTHOR = 'krisr, tienchang, bmahadev'
 NAME = 'network_WiFi_SuspendStress.24HT40'
-TIME = 'SHORT'
+TIME = 'MEDIUM'
 TEST_TYPE = 'Server'
+DEPENDENCIES = 'servo, wificell'
 SUITE = ('wifi_matfunc, wifi_matfunc_bcm4356, wifi_matfunc_marvell8897,'
          'wifi_matfunc_intel7265')
-DEPENDENCIES = 'wificell, servo'
 DOC = """
 This test uses servo to simulate lid close and open events and checks that the
 wifi adapter is brought back up and connects to a 802.11n network on 2.4 GHz.
 """
 
 from autotest_lib.client.common_lib.cros.network import xmlrpc_datatypes
-from autotest_lib.client.common_lib.cros.network import xmlrpc_datatypes
 from autotest_lib.server.cros.network import hostap_config
+from autotest_lib.server import utils
 
+args_dict = utils.args_to_dict(args)
+servo_args = hosts.CrosHost.get_servo_arguments(args_dict)
 
 def run(machine):
+    host = hosts.create_host(machine, servo_args=servo_args)
     caps = [hostap_config.HostapConfig.N_CAPABILITY_GREENFIELD,
             hostap_config.HostapConfig.N_CAPABILITY_HT40]
     n = hostap_config.HostapConfig.MODE_11N_PURE
     configurations = [(hostap_config.HostapConfig(frequency=2437, mode=n,
                                                   n_capabilities=caps),
                        xmlrpc_datatypes.AssociationParameters())]
-    host = hosts.create_host(machine)
     job.run_test('network_WiFi_SuspendStress',
-                 tag=NAME.split('.')[1],
                  host=host,
+                 tag=NAME.split('.')[1],
+                 suspends=5,
                  raw_cmdline_args=args,
                  additional_params=configurations)
 
-
 parallel_simple(run, machines)
diff --git a/server/site_tests/network_WiFi_SuspendStress/control.5HT40 b/server/site_tests/network_WiFi_SuspendStress/control.5HT40
index bb92940..829dec8 100644
--- a/server/site_tests/network_WiFi_SuspendStress/control.5HT40
+++ b/server/site_tests/network_WiFi_SuspendStress/control.5HT40
@@ -4,11 +4,11 @@
 
 AUTHOR = 'krisr, tienchang, bmahadev'
 NAME = 'network_WiFi_SuspendStress.5HT40'
-TIME = 'SHORT'
+TIME = 'MEDIUM'
 TEST_TYPE = 'Server'
+DEPENDENCIES = 'servo, wificell'
 SUITE = ('wifi_matfunc, wifi_matfunc_bcm4356, wifi_matfunc_marvell8897,'
          'wifi_matfunc_intel7265')
-DEPENDENCIES = 'wificell, servo'
 DOC = """
 This test uses servo to simulate lid close and open events and checks that the
 wifi adapter is brought back up and connects to a 802.11n network on 5 GHz.
@@ -16,9 +16,13 @@
 
 from autotest_lib.client.common_lib.cros.network import xmlrpc_datatypes
 from autotest_lib.server.cros.network import hostap_config
+from autotest_lib.server import utils
 
+args_dict = utils.args_to_dict(args)
+servo_args = hosts.CrosHost.get_servo_arguments(args_dict)
 
 def run(machine):
+    host = hosts.create_host(machine, servo_args=servo_args)
     caps = [hostap_config.HostapConfig.N_CAPABILITY_GREENFIELD,
             hostap_config.HostapConfig.N_CAPABILITY_HT40_MINUS]
     n = hostap_config.HostapConfig.MODE_11N_PURE
@@ -26,10 +30,10 @@
                                                   mode=n,
                                                   n_capabilities=caps),
                        xmlrpc_datatypes.AssociationParameters())]
-    host = hosts.create_host(machine)
     job.run_test('network_WiFi_SuspendStress',
-                 tag=NAME.split('.')[1],
                  host=host,
+                 tag=NAME.split('.')[1],
+                 suspends=5,
                  raw_cmdline_args=args,
                  additional_params=configurations)
 
diff --git a/server/site_tests/network_WiFi_SuspendStress/control.Hidden b/server/site_tests/network_WiFi_SuspendStress/control.Hidden
index f7bda56..709b3ef 100644
--- a/server/site_tests/network_WiFi_SuspendStress/control.Hidden
+++ b/server/site_tests/network_WiFi_SuspendStress/control.Hidden
@@ -4,11 +4,11 @@
 
 AUTHOR = 'krisr, tienchang, bmahadev'
 NAME = 'network_WiFi_SuspendStress.Hidden'
-TIME = 'SHORT'
+TIME = 'MEDIUM'
 TEST_TYPE = 'Server'
+DEPENDENCIES = 'servo, wificell'
 SUITE = ('wifi_matfunc, wifi_matfunc_bcm4356, wifi_matfunc_marvell8897,'
          'wifi_matfunc_intel7265')
-DEPENDENCIES = 'wificell, servo'
 DOC = """
 This test uses servo to simulate lid close and open events and checks that the
 wifi adapter is brought back up and connects to a hidden network.
@@ -18,9 +18,13 @@
 
 from autotest_lib.client.common_lib.cros.network import xmlrpc_datatypes
 from autotest_lib.server.cros.network import hostap_config
+from autotest_lib.server import utils
 
+args_dict = utils.args_to_dict(args)
+servo_args = hosts.CrosHost.get_servo_arguments(args_dict)
 
 def run(machine):
+    host = hosts.create_host(machine, servo_args=servo_args)
     g = hostap_config.HostapConfig.MODE_11G
     n = hostap_config.HostapConfig.MODE_11N_PURE
     assoc_params = xmlrpc_datatypes.AssociationParameters()
@@ -33,12 +37,11 @@
             (hostap_config.HostapConfig(channel=48, mode=n, hide_ssid=True),
              copy.copy(assoc_params))]
 
-    host = hosts.create_host(machine)
     job.run_test('network_WiFi_SuspendStress',
-                 tag=NAME.split('.')[1],
                  host=host,
+                 tag=NAME.split('.')[1],
+                 suspends=5,
                  raw_cmdline_args=args,
                  additional_params=configurations)
 
-
 parallel_simple(run, machines)
diff --git a/server/site_tests/network_WiFi_SuspendStress/control.WEP40 b/server/site_tests/network_WiFi_SuspendStress/control.WEP40
index e1f78d1..9bbf211 100644
--- a/server/site_tests/network_WiFi_SuspendStress/control.WEP40
+++ b/server/site_tests/network_WiFi_SuspendStress/control.WEP40
@@ -4,11 +4,11 @@
 
 AUTHOR = 'krisr, tienchang, bmahadev'
 NAME = 'network_WiFi_SuspendStress.WEP40'
-TIME = 'SHORT'
+TIME = 'MEDIUM'
 TEST_TYPE = 'Server'
+DEPENDENCIES = 'servo, wificell'
 SUITE = ('wifi_matfunc, wifi_matfunc_bcm4356, wifi_matfunc_marvell8897,'
          'wifi_matfunc_intel7265')
-DEPENDENCIES = 'wificell, servo'
 DOC = """
 This test uses servo to simulate lid close and open events and checks that the
 wifi adapter is brought back up and connects to a WEP network.
@@ -17,9 +17,13 @@
 from autotest_lib.client.common_lib.cros.network import xmlrpc_datatypes
 from autotest_lib.client.common_lib.cros.network import xmlrpc_security_types
 from autotest_lib.server.cros.network import hostap_config
+from autotest_lib.server import utils
 
+args_dict = utils.args_to_dict(args)
+servo_args = hosts.CrosHost.get_servo_arguments(args_dict)
 
 def run(machine):
+    host = hosts.create_host(machine, servo_args=servo_args)
     # FYI: D-Bus requires string parameters must be valid UTF-8.
     wep_keys = ['abcde', # Interpretted as ASCII.
                 'fedcba9876',  # Interpretted as hex.
@@ -43,10 +47,10 @@
             assoc_params = xmlrpc_datatypes.AssociationParameters(
                     security_config=wep_config)
             configurations.append((ap_config, assoc_params))
-    host = hosts.create_host(machine)
     job.run_test('network_WiFi_SuspendStress',
-                 tag=NAME.split('.')[1],
                  host=host,
+                 tag=NAME.split('.')[1],
+                 suspends=5,
                  raw_cmdline_args=args,
                  additional_params=configurations)
 
diff --git a/server/site_tests/network_WiFi_SuspendStress/control.WPA2 b/server/site_tests/network_WiFi_SuspendStress/control.WPA2
index 1af2ff3..b7d745b 100644
--- a/server/site_tests/network_WiFi_SuspendStress/control.WPA2
+++ b/server/site_tests/network_WiFi_SuspendStress/control.WPA2
@@ -4,11 +4,11 @@
 
 AUTHOR = 'krisr, tienchang, bmahadev'
 NAME = 'network_WiFi_SuspendStress.WPA2'
-TIME = 'SHORT'
+TIME = 'MEDIUM'
 TEST_TYPE = 'Server'
+DEPENDENCIES = 'servo, wificell'
 SUITE = ('wifi_matfunc, wifi_matfunc_bcm4356, wifi_matfunc_marvell8897,'
          'wifi_matfunc_intel7265')
-DEPENDENCIES = 'wificell, servo'
 DOC = """
 This test uses servo to simulate lid close and open events and checks that the
 wifi adapter is brought back up and connects to a WPA network.
@@ -18,9 +18,13 @@
 from autotest_lib.client.common_lib.cros.network import xmlrpc_datatypes
 from autotest_lib.client.common_lib.cros.network import xmlrpc_security_types
 from autotest_lib.server.cros.network import hostap_config
+from autotest_lib.server import utils
 
+args_dict = utils.args_to_dict(args)
+servo_args = hosts.CrosHost.get_servo_arguments(args_dict)
 
 def run(machine):
+    host = hosts.create_host(machine, servo_args=servo_args)
     wpa_config = xmlrpc_security_types.WPAConfig(
             psk='chromeos',
             wpa_mode=xmlrpc_security_types.WPAConfig.MODE_PURE_WPA2,
@@ -32,12 +36,11 @@
     assoc_params = xmlrpc_datatypes.AssociationParameters()
     assoc_params.security_config = wpa_config
     configurations = [(ap_config, assoc_params)]
-    host = hosts.create_host(machine)
     job.run_test('network_WiFi_SuspendStress',
-                 tag=NAME.split('.')[1],
                  host=host,
+                 tag=NAME.split('.')[1],
+                 suspends=5,
                  raw_cmdline_args=args,
                  additional_params=configurations)
 
-
 parallel_simple(run, machines)