Fix for failing RLZ tests.

RLZ autotests have been failing due to the RLZ ping not being sent
properly. The RLZ ping is sent after a delay prescribed by the
--rlz_ping_delay flag, which is set in /etc/chrome_dev.conf. However,
inspecting chrome://version during test execution showed that the flag
was not set, even though it was properly set before the device rebooted
and logged in as the test user. If the flag is not set, I think the default
delay is 24 hours, and the test times out after 2 minutes. Furthermore,
the contents of /etc/chrome_dev.conf during test execution are different
from what was set by the test in rlz_CheckPing.py. It seems that the
test runner modifies this file to contain only the flag
CHROME_HEADLESS=1. I worked around this by setting the --rlz_ping_delay
flag through chrome.Chrome()'s extra_browser_args optional parameter.

BUG=chromium:1045615
TEST=rlz_CheckPing, rlz_CheckPing.guest locally

Change-Id: I035fe87eb84c3e19b259d322b545d07d0a4f1bf8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/2021022
Reviewed-by: David Haddock <dhaddock@chromium.org>
Tested-by: Kyle Shimabukuro <kyleshima@chromium.org>
Commit-Queue: David Haddock <dhaddock@chromium.org>
diff --git a/client/site_tests/desktopui_CheckRlzPingSent/desktopui_CheckRlzPingSent.py b/client/site_tests/desktopui_CheckRlzPingSent/desktopui_CheckRlzPingSent.py
index 6a3cf1e..980a063 100644
--- a/client/site_tests/desktopui_CheckRlzPingSent/desktopui_CheckRlzPingSent.py
+++ b/client/site_tests/desktopui_CheckRlzPingSent/desktopui_CheckRlzPingSent.py
@@ -80,20 +80,25 @@
             raise error.TestFail('Timed out trying to lock the device')
 
 
-    def run_once(self, logged_in=True):
+    def run_once(self, ping_timeout=30, logged_in=True):
         """
         Main entry to the test.
 
-        @param logged_in: True for real login or guest mode.
+        @param logged_in: True for real login or False for guest mode.
+        @param ping_timeout: Delay time (seconds) before rlz ping is sent.
 
         """
+        # Browser arg to make DUT send rlz ping after a short delay.
+        rlz_flag = '--rlz-ping-delay=%d' % ping_timeout
+
         # If we are testing the ping is sent in guest mode (logged_in=False),
         # we need to first do a real login and wait for the DUT to become
         # 'locked' for rlz. Then logout and enter guest mode.
         if not logged_in:
-            with chrome.Chrome(logged_in=True):
+            with chrome.Chrome(logged_in=True, extra_browser_args=rlz_flag):
                 self._wait_for_rlz_lock()
 
-        with chrome.Chrome(logged_in=logged_in) as cr:
+        with chrome.Chrome(logged_in=logged_in,
+                           extra_browser_args=rlz_flag) as cr:
             self._check_url_for_rlz(cr)
             self._verify_rlz_data()
diff --git a/server/site_tests/rlz_CheckPing/rlz_CheckPing.py b/server/site_tests/rlz_CheckPing/rlz_CheckPing.py
index a9f6394..40b6286 100644
--- a/server/site_tests/rlz_CheckPing/rlz_CheckPing.py
+++ b/server/site_tests/rlz_CheckPing/rlz_CheckPing.py
@@ -54,15 +54,6 @@
                                          '%s' % e.result_obj.stderr)
 
 
-    def _make_rootfs_writable(self):
-        """ Remove rootfs verification on DUT."""
-        logging.info('Disabling rootfs on the DUT.')
-        cmd = ('/usr/share/vboot/bin/make_dev_ssd.sh '
-               '--remove_rootfs_verification --force')
-        self._host.run(cmd)
-        self._host.reboot()
-
-
     def _check_rlz_vpd_settings_post_ping(self):
         """Checks that rlz related vpd settings are correct after the test."""
         def should_send_rlz_ping():
@@ -79,15 +70,6 @@
             raise error.TestFail('rlz_embargo_end_date still present in vpd.')
 
 
-    def _reduce_rlz_ping_delay(self, ping_timeout):
-        """Changes the rlz ping delay so we can test it quickly."""
-
-        # Removes any old rlz ping delays in the file.
-        self._host.run('sed -i /--rlz-ping-delay/d /etc/chrome_dev.conf')
-        self._host.run('echo --rlz-ping-delay=%d >> /etc/chrome_dev.conf' %
-                       ping_timeout)
-
-
     def run_once(self, host, ping_timeout=30, logged_in=True):
         """Main test logic"""
         self._host = host
@@ -101,8 +83,6 @@
 
         # Setup DUT to send rlz ping after a short timeout.
         self._set_vpd_values()
-        self._make_rootfs_writable()
-        self._reduce_rlz_ping_delay(ping_timeout)
         self._host.reboot()
 
         # Login, do a Google search, check for CAF event in RLZ Data file.