Add brillo_PingTest.
This implements the Brillo PTS connectivity test.
BUG=b:25341629
TEST=brillo_test_launcher.py --quickmerge -t brillo_PingTest
Change-Id: Ica99ba13f70eefa20f95cb6a387d3eb2d24e7c9b
Reviewed-on: https://chromium-review.googlesource.com/309561
Commit-Ready: Gilad Arnold <[email protected]>
Tested-by: Gilad Arnold <[email protected]>
Reviewed-by: Dan Shi <[email protected]>
diff --git a/server/site_tests/brillo_PingTest/brillo_PingTest.py b/server/site_tests/brillo_PingTest/brillo_PingTest.py
new file mode 100644
index 0000000..267ed8a
--- /dev/null
+++ b/server/site_tests/brillo_PingTest/brillo_PingTest.py
@@ -0,0 +1,28 @@
+# Copyright 2015 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from autotest_lib.client.common_lib import error
+from autotest_lib.server import test
+
+
+_DEFAULT_PING_HOST = 'www.google.com'
+_DEFAULT_PING_COUNT = 4
+_DEFAULT_PING_TIMEOUT = 4
+
+
+class brillo_PingTest(test.test):
+ """Ping an Internet host."""
+ version = 1
+
+ def run_once(self, host=None, ping_host=_DEFAULT_PING_HOST,
+ ping_count=_DEFAULT_PING_COUNT,
+ ping_timeout=_DEFAULT_PING_TIMEOUT):
+ """Pings an Internet host with given timeout and count values."""
+ cmd = 'ping -q -c %s -W %s %s' % (ping_count, ping_timeout, ping_host)
+ try:
+ host.run(cmd)
+ except error.AutoservRunError:
+ raise error.TestFail(
+ 'Failed to ping %s in %d seconds on all %d attempts' %
+ (ping_host, ping_timeout, ping_count))
diff --git a/server/site_tests/brillo_PingTest/control b/server/site_tests/brillo_PingTest/control
new file mode 100644
index 0000000..34eee6a
--- /dev/null
+++ b/server/site_tests/brillo_PingTest/control
@@ -0,0 +1,30 @@
+# Copyright 2015 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+import logging
+
+from autotest_lib.client.common_lib import utils
+
+
+AUTHOR = 'garnold'
+NAME = 'brillo_PingTest'
+TIME = 'SHORT'
+TEST_CATEGORY = 'Functional'
+TEST_TYPE = 'Server'
+SUITE = ''
+
+DOC = """
+Tests whether a Brillo device can ping the Internet.
+"""
+
+TEST_ARG_NAMES = ('ping_host', 'ping_count', 'ping_timeout')
+args_dict = utils.args_to_dict(args)
+
+def run(machine):
+ test_args = {name: args_dict[name] for name in TEST_ARG_NAMES
+ if name in args_dict}
+ job.run_test('brillo_PingTest', host=hosts.create_host(machine),
+ **test_args)
+
+
+parallel_simple(run, machines)
diff --git a/server/site_tests/sequences/control.brillo_pts b/server/site_tests/sequences/control.brillo_pts
index 10d7f2e..f13086d 100644
--- a/server/site_tests/sequences/control.brillo_pts
+++ b/server/site_tests/sequences/control.brillo_pts
@@ -19,8 +19,7 @@
SERVER_SEQUENCES = [
sequence.SequenceJob('control.brillo_GtestsWhitelist', duration=2000,
fetch_control_file=True),
- sequence.SequenceJob('control.brillo_GtestsWhitelist', duration=2000,
- fetch_control_file=True),
+ sequence.SequenceJob('brillo_PingTest', duration=120),
]
sequence.sequence_schedule(job, machines, SERVER_SEQUENCES)