Add Google Docs and MS Office CUJs to Performance CUJ Experimental suite.

BUG=b:185195343
TEST=test_that --board=${BOARD} ip:port suite:performance_cuj_experimental

Change-Id: I872bf507c1ae4a0bea9a81d46ba3e7638c1c5c40
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/3334056
Commit-Queue: Alex Bergman <abergman@google.com>
Tested-by: Alex Bergman <abergman@google.com>
Auto-Submit: Alex Bergman <abergman@google.com>
Reviewed-by: Afshin Sadrieh <asadrieh@google.com>
Commit-Queue: Afshin Sadrieh <asadrieh@google.com>
diff --git a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_EverydayMultiTaskingCUJ_basic_ytmusic b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_EverydayMultiTaskingCUJ_basic_ytmusic
index dfb62a5..6e27dc5 100644
--- a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_EverydayMultiTaskingCUJ_basic_ytmusic
+++ b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_EverydayMultiTaskingCUJ_basic_ytmusic
@@ -94,7 +94,10 @@
       stage_config(host)
 
       # Writing all test arguments to yaml file.
-      yaml.dump(test_args, stream=temp_file, default_flow_style=False)
+      yaml.safe_dump(test_args,
+                    stream=temp_file,
+                    default_flow_style=False,
+                    allow_unicode=True)
       job.run_test('tast',
                   host=host,
                   test_exprs=['ui.EverydayMultiTaskingCUJ.basic_ytmusic'],
diff --git a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_EverydayMultiTaskingCUJ_plus_ytmusic b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_EverydayMultiTaskingCUJ_plus_ytmusic
index 8a26a7d..a50dc0f 100644
--- a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_EverydayMultiTaskingCUJ_plus_ytmusic
+++ b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_EverydayMultiTaskingCUJ_plus_ytmusic
@@ -94,7 +94,10 @@
       stage_config(host)
 
       # Writing all test arguments to yaml file.
-      yaml.dump(test_args, stream=temp_file, default_flow_style=False)
+      yaml.safe_dump(test_args,
+                    stream=temp_file,
+                    default_flow_style=False,
+                    allow_unicode=True)
       job.run_test('tast',
                   host=host,
                   test_exprs=['ui.EverydayMultiTaskingCUJ.plus_ytmusic'],
diff --git a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_ExtendedDisplayCUJ_premium_meet_large b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_ExtendedDisplayCUJ_premium_meet_large
index 6e6ad5b..a94cc3c 100644
--- a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_ExtendedDisplayCUJ_premium_meet_large
+++ b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_ExtendedDisplayCUJ_premium_meet_large
@@ -94,7 +94,10 @@
       stage_config(host)
 
       # Writing all test arguments to yaml file.
-      yaml.dump(test_args, stream=temp_file, default_flow_style=False)
+      yaml.safe_dump(test_args,
+                    stream=temp_file,
+                    default_flow_style=False,
+                    allow_unicode=True)
       job.run_test('tast',
                   host=host,
                   test_exprs=['ui.ExtendedDisplayCUJ.premium_meet_large'],
diff --git a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_GoogleDocsWebCUJ_basic b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_GoogleDocsWebCUJ_basic
new file mode 100644
index 0000000..a3eda25
--- /dev/null
+++ b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_GoogleDocsWebCUJ_basic
@@ -0,0 +1,109 @@
+# Copyright 2021 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.
+
+AUTHOR = 'abergman, chromeos-engprod-platform-syd'
+NAME = 'ui_GoogleDocsWebCUJ_basic'
+ATTRIBUTES = 'suite:performance_cuj_experimental'
+TIME = 'long'
+TEST_CATEGORY = 'Stress'
+TEST_CLASS = 'Hardware'
+TEST_TYPE = 'Server'
+PRIORITY = 4974
+MAX_RESULT_SIZE_KB = 1024 * 1024
+JOB_RETRIES = 5
+REQUIRE_SSP = True
+DEPENDENCIES = ''
+
+DOC = '''
+Run the Tast-based MTBF performance CUJ test.
+
+Tast is an integration-testing framework analogous to the test-running portion
+of Autotest. See https://chromium.googlesource.com/chromiumos/platform/tast/ for
+more information.
+
+See http://go/tast-failures for information about investigating failures.
+'''
+
+import common
+import json
+import logging
+import tempfile
+from six.moves import urllib
+import yaml
+
+from autotest_lib.client.common_lib import utils
+from autotest_lib.client.common_lib.cros import dev_server
+from autotest_lib.site_utils.deployment.prepare import dut
+from autotest_lib.utils import labellib
+
+test_args = dict()
+test_args['test_version'] = 1
+
+def report_host_info(host):
+  labels = labellib.LabelsMapping(host.host_info_store.get().labels)
+  labels['test'] = 'ui.GoogleDocsWebCUJ.basic'
+  labels['test_iteration'] = '1'
+  utils.write_keyval(job.resultdir, labels)
+  # Try to retrieve and report DUT HWID and serial number.
+  try:
+    dut.setup_hwid_and_serialnumber(host)
+    logging.info("Host info store: %s", host.host_info_store.get())
+    utils.write_keyval(job.resultdir, host.host_info_store.get().attributes)
+  except Exception as e:
+    logging.warning("Failed retrieving DUT host info: %s", e)
+
+def parse_config(config_url):
+  response = urllib.request.urlopen(config_url)
+  vars = json.loads(response.read())
+  for key in vars:
+    test_args[key] = vars[key]
+  logging.info('Read %d values from remote configuration.', len(vars))
+
+def stage_config(host):
+  devservers = dev_server.ImageServer.get_available_devservers()
+  devserver_url = devservers[0][0]
+  if devserver_url:
+    logging.info('Using devserver: %s', devserver_url)
+    labels = host.host_info_store.get().labels
+    build = labellib.LabelsMapping(labels).get(labellib.Key.CROS_VERSION)
+    if not build:
+      # Not able to detect build, means not running on Moblab.
+      return
+    ds = dev_server.ImageServer(devserver_url)
+    gs_bucket = dev_server._get_image_storage_server()
+    if gs_bucket:
+      config_path = 'config/perf_cuj/'
+      config_file = 'perf_cuj.config'
+      archive_url = gs_bucket + config_path
+      logging.info('Staging configuration from %s.', gs_bucket)
+      try:
+        ds.stage_artifacts(build,
+                          archive_url = archive_url,
+                          files = [config_file])
+      except Exception as e:
+          logging.error('Staging artifacts failed: %s', str(e))
+      else:
+        logging.info('Parsing configuration from %s.', archive_url)
+        parse_config(devserver_url + '/static/' + config_path + config_file)
+
+def run(machine):
+  with tempfile.NamedTemporaryFile(suffix='.yaml') as temp_file:
+      host=hosts.create_host(machine)
+      report_host_info(host)
+      stage_config(host)
+
+      # Writing all test arguments to yaml file.
+      yaml.safe_dump(test_args,
+                    stream=temp_file,
+                    default_flow_style=False,
+                    allow_unicode=True)
+      job.run_test('tast',
+                  host=host,
+                  test_exprs=['ui.GoogleDocsWebCUJ.basic'],
+                  ignore_test_failures=False,
+                  max_run_sec=3600,
+                  command_args=args,
+                  varsfiles=[temp_file.name])
+
+parallel_simple(run, machines)
diff --git a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_GoogleDocsWebCUJ_premium b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_GoogleDocsWebCUJ_premium
new file mode 100644
index 0000000..cce629d
--- /dev/null
+++ b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_GoogleDocsWebCUJ_premium
@@ -0,0 +1,109 @@
+# Copyright 2021 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.
+
+AUTHOR = 'abergman, chromeos-engprod-platform-syd'
+NAME = 'ui_GoogleDocsWebCUJ_premium'
+ATTRIBUTES = 'suite:performance_cuj_experimental'
+TIME = 'long'
+TEST_CATEGORY = 'Stress'
+TEST_CLASS = 'Hardware'
+TEST_TYPE = 'Server'
+PRIORITY = 4973
+MAX_RESULT_SIZE_KB = 1024 * 1024
+JOB_RETRIES = 5
+REQUIRE_SSP = True
+DEPENDENCIES = ''
+
+DOC = '''
+Run the Tast-based MTBF performance CUJ test.
+
+Tast is an integration-testing framework analogous to the test-running portion
+of Autotest. See https://chromium.googlesource.com/chromiumos/platform/tast/ for
+more information.
+
+See http://go/tast-failures for information about investigating failures.
+'''
+
+import common
+import json
+import logging
+import tempfile
+from six.moves import urllib
+import yaml
+
+from autotest_lib.client.common_lib import utils
+from autotest_lib.client.common_lib.cros import dev_server
+from autotest_lib.site_utils.deployment.prepare import dut
+from autotest_lib.utils import labellib
+
+test_args = dict()
+test_args['test_version'] = 1
+
+def report_host_info(host):
+  labels = labellib.LabelsMapping(host.host_info_store.get().labels)
+  labels['test'] = 'ui.GoogleDocsWebCUJ.premium'
+  labels['test_iteration'] = '1'
+  utils.write_keyval(job.resultdir, labels)
+  # Try to retrieve and report DUT HWID and serial number.
+  try:
+    dut.setup_hwid_and_serialnumber(host)
+    logging.info("Host info store: %s", host.host_info_store.get())
+    utils.write_keyval(job.resultdir, host.host_info_store.get().attributes)
+  except Exception as e:
+    logging.warning("Failed retrieving DUT host info: %s", e)
+
+def parse_config(config_url):
+  response = urllib.request.urlopen(config_url)
+  vars = json.loads(response.read())
+  for key in vars:
+    test_args[key] = vars[key]
+  logging.info('Read %d values from remote configuration.', len(vars))
+
+def stage_config(host):
+  devservers = dev_server.ImageServer.get_available_devservers()
+  devserver_url = devservers[0][0]
+  if devserver_url:
+    logging.info('Using devserver: %s', devserver_url)
+    labels = host.host_info_store.get().labels
+    build = labellib.LabelsMapping(labels).get(labellib.Key.CROS_VERSION)
+    if not build:
+      # Not able to detect build, means not running on Moblab.
+      return
+    ds = dev_server.ImageServer(devserver_url)
+    gs_bucket = dev_server._get_image_storage_server()
+    if gs_bucket:
+      config_path = 'config/perf_cuj/'
+      config_file = 'perf_cuj.config'
+      archive_url = gs_bucket + config_path
+      logging.info('Staging configuration from %s.', gs_bucket)
+      try:
+        ds.stage_artifacts(build,
+                          archive_url = archive_url,
+                          files = [config_file])
+      except Exception as e:
+          logging.error('Staging artifacts failed: %s', str(e))
+      else:
+        logging.info('Parsing configuration from %s.', archive_url)
+        parse_config(devserver_url + '/static/' + config_path + config_file)
+
+def run(machine):
+  with tempfile.NamedTemporaryFile(suffix='.yaml') as temp_file:
+      host=hosts.create_host(machine)
+      report_host_info(host)
+      stage_config(host)
+
+      # Writing all test arguments to yaml file.
+      yaml.safe_dump(test_args,
+                    stream=temp_file,
+                    default_flow_style=False,
+                    allow_unicode=True)
+      job.run_test('tast',
+                  host=host,
+                  test_exprs=['ui.GoogleDocsWebCUJ.premium'],
+                  ignore_test_failures=False,
+                  max_run_sec=3600,
+                  command_args=args,
+                  varsfiles=[temp_file.name])
+
+parallel_simple(run, machines)
diff --git a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_GoogleMeetCUJ_basic_class b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_GoogleMeetCUJ_basic_class
index cc9516c..196b71e 100644
--- a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_GoogleMeetCUJ_basic_class
+++ b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_GoogleMeetCUJ_basic_class
@@ -94,7 +94,10 @@
       stage_config(host)
 
       # Writing all test arguments to yaml file.
-      yaml.dump(test_args, stream=temp_file, default_flow_style=False)
+      yaml.safe_dump(test_args,
+                    stream=temp_file,
+                    default_flow_style=False,
+                    allow_unicode=True)
       job.run_test('tast',
                   host=host,
                   test_exprs=['ui.GoogleMeetCUJ.basic_class'],
diff --git a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_GoogleMeetCUJ_basic_large b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_GoogleMeetCUJ_basic_large
index 2505241..5346e58 100644
--- a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_GoogleMeetCUJ_basic_large
+++ b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_GoogleMeetCUJ_basic_large
@@ -94,7 +94,10 @@
       stage_config(host)
 
       # Writing all test arguments to yaml file.
-      yaml.dump(test_args, stream=temp_file, default_flow_style=False)
+      yaml.safe_dump(test_args,
+                    stream=temp_file,
+                    default_flow_style=False,
+                    allow_unicode=True)
       job.run_test('tast',
                   host=host,
                   test_exprs=['ui.GoogleMeetCUJ.basic_large'],
diff --git a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_GoogleMeetCUJ_basic_small b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_GoogleMeetCUJ_basic_small
index 60e9fbe..13ec1da 100644
--- a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_GoogleMeetCUJ_basic_small
+++ b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_GoogleMeetCUJ_basic_small
@@ -94,7 +94,10 @@
       stage_config(host)
 
       # Writing all test arguments to yaml file.
-      yaml.dump(test_args, stream=temp_file, default_flow_style=False)
+      yaml.safe_dump(test_args,
+                    stream=temp_file,
+                    default_flow_style=False,
+                    allow_unicode=True)
       job.run_test('tast',
                   host=host,
                   test_exprs=['ui.GoogleMeetCUJ.basic_small'],
diff --git a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_GoogleMeetCUJ_basic_two b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_GoogleMeetCUJ_basic_two
index 17150f3..b18c2d9 100644
--- a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_GoogleMeetCUJ_basic_two
+++ b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_GoogleMeetCUJ_basic_two
@@ -94,7 +94,10 @@
       stage_config(host)
 
       # Writing all test arguments to yaml file.
-      yaml.dump(test_args, stream=temp_file, default_flow_style=False)
+      yaml.safe_dump(test_args,
+                    stream=temp_file,
+                    default_flow_style=False,
+                    allow_unicode=True)
       job.run_test('tast',
                   host=host,
                   test_exprs=['ui.GoogleMeetCUJ.basic_two'],
diff --git a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_GoogleMeetCUJ_plus_class b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_GoogleMeetCUJ_plus_class
index 91c81b6..7720da8 100644
--- a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_GoogleMeetCUJ_plus_class
+++ b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_GoogleMeetCUJ_plus_class
@@ -94,7 +94,10 @@
       stage_config(host)
 
       # Writing all test arguments to yaml file.
-      yaml.dump(test_args, stream=temp_file, default_flow_style=False)
+      yaml.safe_dump(test_args,
+                    stream=temp_file,
+                    default_flow_style=False,
+                    allow_unicode=True)
       job.run_test('tast',
                   host=host,
                   test_exprs=['ui.GoogleMeetCUJ.plus_class'],
diff --git a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_GoogleMeetCUJ_plus_large b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_GoogleMeetCUJ_plus_large
index a098acf..00704e1 100644
--- a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_GoogleMeetCUJ_plus_large
+++ b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_GoogleMeetCUJ_plus_large
@@ -94,7 +94,10 @@
       stage_config(host)
 
       # Writing all test arguments to yaml file.
-      yaml.dump(test_args, stream=temp_file, default_flow_style=False)
+      yaml.safe_dump(test_args,
+                    stream=temp_file,
+                    default_flow_style=False,
+                    allow_unicode=True)
       job.run_test('tast',
                   host=host,
                   test_exprs=['ui.GoogleMeetCUJ.plus_large'],
diff --git a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_GoogleMeetCUJ_premium_large b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_GoogleMeetCUJ_premium_large
index 3071033..34fe83e 100644
--- a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_GoogleMeetCUJ_premium_large
+++ b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_GoogleMeetCUJ_premium_large
@@ -94,7 +94,10 @@
       stage_config(host)
 
       # Writing all test arguments to yaml file.
-      yaml.dump(test_args, stream=temp_file, default_flow_style=False)
+      yaml.safe_dump(test_args,
+                    stream=temp_file,
+                    default_flow_style=False,
+                    allow_unicode=True)
       job.run_test('tast',
                   host=host,
                   test_exprs=['ui.GoogleMeetCUJ.premium_large'],
diff --git a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_MicrosoftOfficeWebCUJ_basic b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_MicrosoftOfficeWebCUJ_basic
new file mode 100644
index 0000000..d49d8a2
--- /dev/null
+++ b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_MicrosoftOfficeWebCUJ_basic
@@ -0,0 +1,109 @@
+# Copyright 2021 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.
+
+AUTHOR = 'abergman, chromeos-engprod-platform-syd'
+NAME = 'ui_MicrosoftOfficeWebCUJ_basic'
+ATTRIBUTES = 'suite:performance_cuj_experimental'
+TIME = 'long'
+TEST_CATEGORY = 'Stress'
+TEST_CLASS = 'Hardware'
+TEST_TYPE = 'Server'
+PRIORITY = 4972
+MAX_RESULT_SIZE_KB = 1024 * 1024
+JOB_RETRIES = 5
+REQUIRE_SSP = True
+DEPENDENCIES = ''
+
+DOC = '''
+Run the Tast-based MTBF performance CUJ test.
+
+Tast is an integration-testing framework analogous to the test-running portion
+of Autotest. See https://chromium.googlesource.com/chromiumos/platform/tast/ for
+more information.
+
+See http://go/tast-failures for information about investigating failures.
+'''
+
+import common
+import json
+import logging
+import tempfile
+from six.moves import urllib
+import yaml
+
+from autotest_lib.client.common_lib import utils
+from autotest_lib.client.common_lib.cros import dev_server
+from autotest_lib.site_utils.deployment.prepare import dut
+from autotest_lib.utils import labellib
+
+test_args = dict()
+test_args['test_version'] = 1
+
+def report_host_info(host):
+  labels = labellib.LabelsMapping(host.host_info_store.get().labels)
+  labels['test'] = 'ui.MicrosoftOfficeWebCUJ.basic'
+  labels['test_iteration'] = '1'
+  utils.write_keyval(job.resultdir, labels)
+  # Try to retrieve and report DUT HWID and serial number.
+  try:
+    dut.setup_hwid_and_serialnumber(host)
+    logging.info("Host info store: %s", host.host_info_store.get())
+    utils.write_keyval(job.resultdir, host.host_info_store.get().attributes)
+  except Exception as e:
+    logging.warning("Failed retrieving DUT host info: %s", e)
+
+def parse_config(config_url):
+  response = urllib.request.urlopen(config_url)
+  vars = json.loads(response.read())
+  for key in vars:
+    test_args[key] = vars[key]
+  logging.info('Read %d values from remote configuration.', len(vars))
+
+def stage_config(host):
+  devservers = dev_server.ImageServer.get_available_devservers()
+  devserver_url = devservers[0][0]
+  if devserver_url:
+    logging.info('Using devserver: %s', devserver_url)
+    labels = host.host_info_store.get().labels
+    build = labellib.LabelsMapping(labels).get(labellib.Key.CROS_VERSION)
+    if not build:
+      # Not able to detect build, means not running on Moblab.
+      return
+    ds = dev_server.ImageServer(devserver_url)
+    gs_bucket = dev_server._get_image_storage_server()
+    if gs_bucket:
+      config_path = 'config/perf_cuj/'
+      config_file = 'perf_cuj.config'
+      archive_url = gs_bucket + config_path
+      logging.info('Staging configuration from %s.', gs_bucket)
+      try:
+        ds.stage_artifacts(build,
+                          archive_url = archive_url,
+                          files = [config_file])
+      except Exception as e:
+          logging.error('Staging artifacts failed: %s', str(e))
+      else:
+        logging.info('Parsing configuration from %s.', archive_url)
+        parse_config(devserver_url + '/static/' + config_path + config_file)
+
+def run(machine):
+  with tempfile.NamedTemporaryFile(suffix='.yaml') as temp_file:
+      host=hosts.create_host(machine)
+      report_host_info(host)
+      stage_config(host)
+
+      # Writing all test arguments to yaml file.
+      yaml.safe_dump(test_args,
+                    stream=temp_file,
+                    default_flow_style=False,
+                    allow_unicode=True)
+      job.run_test('tast',
+                  host=host,
+                  test_exprs=['ui.MicrosoftOfficeWebCUJ.basic'],
+                  ignore_test_failures=False,
+                  max_run_sec=3600,
+                  command_args=args,
+                  varsfiles=[temp_file.name])
+
+parallel_simple(run, machines)
diff --git a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_MicrosoftOfficeWebCUJ_premium b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_MicrosoftOfficeWebCUJ_premium
new file mode 100644
index 0000000..32646f3
--- /dev/null
+++ b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_MicrosoftOfficeWebCUJ_premium
@@ -0,0 +1,109 @@
+# Copyright 2021 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.
+
+AUTHOR = 'abergman, chromeos-engprod-platform-syd'
+NAME = 'ui_MicrosoftOfficeWebCUJ_premium'
+ATTRIBUTES = 'suite:performance_cuj_experimental'
+TIME = 'long'
+TEST_CATEGORY = 'Stress'
+TEST_CLASS = 'Hardware'
+TEST_TYPE = 'Server'
+PRIORITY = 4971
+MAX_RESULT_SIZE_KB = 1024 * 1024
+JOB_RETRIES = 5
+REQUIRE_SSP = True
+DEPENDENCIES = ''
+
+DOC = '''
+Run the Tast-based MTBF performance CUJ test.
+
+Tast is an integration-testing framework analogous to the test-running portion
+of Autotest. See https://chromium.googlesource.com/chromiumos/platform/tast/ for
+more information.
+
+See http://go/tast-failures for information about investigating failures.
+'''
+
+import common
+import json
+import logging
+import tempfile
+from six.moves import urllib
+import yaml
+
+from autotest_lib.client.common_lib import utils
+from autotest_lib.client.common_lib.cros import dev_server
+from autotest_lib.site_utils.deployment.prepare import dut
+from autotest_lib.utils import labellib
+
+test_args = dict()
+test_args['test_version'] = 1
+
+def report_host_info(host):
+  labels = labellib.LabelsMapping(host.host_info_store.get().labels)
+  labels['test'] = 'ui.MicrosoftOfficeWebCUJ.premium'
+  labels['test_iteration'] = '1'
+  utils.write_keyval(job.resultdir, labels)
+  # Try to retrieve and report DUT HWID and serial number.
+  try:
+    dut.setup_hwid_and_serialnumber(host)
+    logging.info("Host info store: %s", host.host_info_store.get())
+    utils.write_keyval(job.resultdir, host.host_info_store.get().attributes)
+  except Exception as e:
+    logging.warning("Failed retrieving DUT host info: %s", e)
+
+def parse_config(config_url):
+  response = urllib.request.urlopen(config_url)
+  vars = json.loads(response.read())
+  for key in vars:
+    test_args[key] = vars[key]
+  logging.info('Read %d values from remote configuration.', len(vars))
+
+def stage_config(host):
+  devservers = dev_server.ImageServer.get_available_devservers()
+  devserver_url = devservers[0][0]
+  if devserver_url:
+    logging.info('Using devserver: %s', devserver_url)
+    labels = host.host_info_store.get().labels
+    build = labellib.LabelsMapping(labels).get(labellib.Key.CROS_VERSION)
+    if not build:
+      # Not able to detect build, means not running on Moblab.
+      return
+    ds = dev_server.ImageServer(devserver_url)
+    gs_bucket = dev_server._get_image_storage_server()
+    if gs_bucket:
+      config_path = 'config/perf_cuj/'
+      config_file = 'perf_cuj.config'
+      archive_url = gs_bucket + config_path
+      logging.info('Staging configuration from %s.', gs_bucket)
+      try:
+        ds.stage_artifacts(build,
+                          archive_url = archive_url,
+                          files = [config_file])
+      except Exception as e:
+          logging.error('Staging artifacts failed: %s', str(e))
+      else:
+        logging.info('Parsing configuration from %s.', archive_url)
+        parse_config(devserver_url + '/static/' + config_path + config_file)
+
+def run(machine):
+  with tempfile.NamedTemporaryFile(suffix='.yaml') as temp_file:
+      host=hosts.create_host(machine)
+      report_host_info(host)
+      stage_config(host)
+
+      # Writing all test arguments to yaml file.
+      yaml.safe_dump(test_args,
+                    stream=temp_file,
+                    default_flow_style=False,
+                    allow_unicode=True)
+      job.run_test('tast',
+                  host=host,
+                  test_exprs=['ui.MicrosoftOfficeWebCUJ.premium'],
+                  ignore_test_failures=False,
+                  max_run_sec=3600,
+                  command_args=args,
+                  varsfiles=[temp_file.name])
+
+parallel_simple(run, machines)
diff --git a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_QuickCheckCUJ2_basic_unlock b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_QuickCheckCUJ2_basic_unlock
index 74a4c74..88504ba 100644
--- a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_QuickCheckCUJ2_basic_unlock
+++ b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_QuickCheckCUJ2_basic_unlock
@@ -94,7 +94,10 @@
       stage_config(host)
 
       # Writing all test arguments to yaml file.
-      yaml.dump(test_args, stream=temp_file, default_flow_style=False)
+      yaml.safe_dump(test_args,
+                    stream=temp_file,
+                    default_flow_style=False,
+                    allow_unicode=True)
       job.run_test('tast',
                   host=host,
                   test_exprs=['ui.QuickCheckCUJ2.basic_unlock'],
diff --git a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_QuickCheckCUJ2_basic_wakeup b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_QuickCheckCUJ2_basic_wakeup
index a77bf6a..69f98bc 100644
--- a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_QuickCheckCUJ2_basic_wakeup
+++ b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_QuickCheckCUJ2_basic_wakeup
@@ -94,7 +94,10 @@
       stage_config(host)
 
       # Writing all test arguments to yaml file.
-      yaml.dump(test_args, stream=temp_file, default_flow_style=False)
+      yaml.safe_dump(test_args,
+                    stream=temp_file,
+                    default_flow_style=False,
+                    allow_unicode=True)
       job.run_test('tast',
                   host=host,
                   test_exprs=['ui.QuickCheckCUJ2.basic_wakeup'],
diff --git a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_TabSwitchCUJ2_basic_noproxy b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_TabSwitchCUJ2_basic_noproxy
index 6500e14..531bec5 100644
--- a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_TabSwitchCUJ2_basic_noproxy
+++ b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_TabSwitchCUJ2_basic_noproxy
@@ -94,7 +94,10 @@
       stage_config(host)
 
       # Writing all test arguments to yaml file.
-      yaml.dump(test_args, stream=temp_file, default_flow_style=False)
+      yaml.safe_dump(test_args,
+                    stream=temp_file,
+                    default_flow_style=False,
+                    allow_unicode=True)
       job.run_test('tast',
                   host=host,
                   test_exprs=['ui.TabSwitchCUJ2.basic_noproxy'],
diff --git a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_TabSwitchCUJ2_plus_noproxy b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_TabSwitchCUJ2_plus_noproxy
index ae31ac0..4c022f7 100644
--- a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_TabSwitchCUJ2_plus_noproxy
+++ b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_TabSwitchCUJ2_plus_noproxy
@@ -94,7 +94,10 @@
       stage_config(host)
 
       # Writing all test arguments to yaml file.
-      yaml.dump(test_args, stream=temp_file, default_flow_style=False)
+      yaml.safe_dump(test_args,
+                    stream=temp_file,
+                    default_flow_style=False,
+                    allow_unicode=True)
       job.run_test('tast',
                   host=host,
                   test_exprs=['ui.TabSwitchCUJ2.plus_noproxy'],
diff --git a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_TabSwitchCUJ2_premium_noproxy b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_TabSwitchCUJ2_premium_noproxy
index 60cb26c..2d37503 100644
--- a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_TabSwitchCUJ2_premium_noproxy
+++ b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_TabSwitchCUJ2_premium_noproxy
@@ -94,7 +94,10 @@
       stage_config(host)
 
       # Writing all test arguments to yaml file.
-      yaml.dump(test_args, stream=temp_file, default_flow_style=False)
+      yaml.safe_dump(test_args,
+                    stream=temp_file,
+                    default_flow_style=False,
+                    allow_unicode=True)
       job.run_test('tast',
                   host=host,
                   test_exprs=['ui.TabSwitchCUJ2.premium_noproxy'],
diff --git a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_VideoCUJ2_basic_youtube_app b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_VideoCUJ2_basic_youtube_app
index 8ef2eaf..52e4f42 100644
--- a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_VideoCUJ2_basic_youtube_app
+++ b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_VideoCUJ2_basic_youtube_app
@@ -94,7 +94,10 @@
       stage_config(host)
 
       # Writing all test arguments to yaml file.
-      yaml.dump(test_args, stream=temp_file, default_flow_style=False)
+      yaml.safe_dump(test_args,
+                    stream=temp_file,
+                    default_flow_style=False,
+                    allow_unicode=True)
       job.run_test('tast',
                   host=host,
                   test_exprs=['ui.VideoCUJ2.basic_youtube_app'],
diff --git a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_VideoCUJ2_basic_youtube_web b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_VideoCUJ2_basic_youtube_web
index eabbef2..24b7b62 100644
--- a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_VideoCUJ2_basic_youtube_web
+++ b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_VideoCUJ2_basic_youtube_web
@@ -94,7 +94,10 @@
       stage_config(host)
 
       # Writing all test arguments to yaml file.
-      yaml.dump(test_args, stream=temp_file, default_flow_style=False)
+      yaml.safe_dump(test_args,
+                    stream=temp_file,
+                    default_flow_style=False,
+                    allow_unicode=True)
       job.run_test('tast',
                   host=host,
                   test_exprs=['ui.VideoCUJ2.basic_youtube_web'],
diff --git a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_VideoCUJ2_plus_youtube_app b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_VideoCUJ2_plus_youtube_app
index ae2d7ed..7389a95 100644
--- a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_VideoCUJ2_plus_youtube_app
+++ b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_VideoCUJ2_plus_youtube_app
@@ -94,7 +94,10 @@
       stage_config(host)
 
       # Writing all test arguments to yaml file.
-      yaml.dump(test_args, stream=temp_file, default_flow_style=False)
+      yaml.safe_dump(test_args,
+                    stream=temp_file,
+                    default_flow_style=False,
+                    allow_unicode=True)
       job.run_test('tast',
                   host=host,
                   test_exprs=['ui.VideoCUJ2.plus_youtube_app'],
diff --git a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_VideoCUJ2_plus_youtube_web b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_VideoCUJ2_plus_youtube_web
index c428bb9..6b95b98 100644
--- a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_VideoCUJ2_plus_youtube_web
+++ b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_VideoCUJ2_plus_youtube_web
@@ -94,7 +94,10 @@
       stage_config(host)
 
       # Writing all test arguments to yaml file.
-      yaml.dump(test_args, stream=temp_file, default_flow_style=False)
+      yaml.safe_dump(test_args,
+                    stream=temp_file,
+                    default_flow_style=False,
+                    allow_unicode=True)
       job.run_test('tast',
                   host=host,
                   test_exprs=['ui.VideoCUJ2.plus_youtube_web'],
diff --git a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_ZoomConfCUJ_basic_class b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_ZoomConfCUJ_basic_class
index 59d41f0..e47c5d9 100644
--- a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_ZoomConfCUJ_basic_class
+++ b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_ZoomConfCUJ_basic_class
@@ -94,7 +94,10 @@
       stage_config(host)
 
       # Writing all test arguments to yaml file.
-      yaml.dump(test_args, stream=temp_file, default_flow_style=False)
+      yaml.safe_dump(test_args,
+                    stream=temp_file,
+                    default_flow_style=False,
+                    allow_unicode=True)
       job.run_test('tast',
                   host=host,
                   test_exprs=['ui.ZoomConfCUJ.basic_class'],
diff --git a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_ZoomConfCUJ_basic_large b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_ZoomConfCUJ_basic_large
index 277f80e..2531e87 100644
--- a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_ZoomConfCUJ_basic_large
+++ b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_ZoomConfCUJ_basic_large
@@ -94,7 +94,10 @@
       stage_config(host)
 
       # Writing all test arguments to yaml file.
-      yaml.dump(test_args, stream=temp_file, default_flow_style=False)
+      yaml.safe_dump(test_args,
+                    stream=temp_file,
+                    default_flow_style=False,
+                    allow_unicode=True)
       job.run_test('tast',
                   host=host,
                   test_exprs=['ui.ZoomConfCUJ.basic_large'],
diff --git a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_ZoomConfCUJ_basic_small b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_ZoomConfCUJ_basic_small
index 85c1292..08011bc 100644
--- a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_ZoomConfCUJ_basic_small
+++ b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_ZoomConfCUJ_basic_small
@@ -94,7 +94,10 @@
       stage_config(host)
 
       # Writing all test arguments to yaml file.
-      yaml.dump(test_args, stream=temp_file, default_flow_style=False)
+      yaml.safe_dump(test_args,
+                    stream=temp_file,
+                    default_flow_style=False,
+                    allow_unicode=True)
       job.run_test('tast',
                   host=host,
                   test_exprs=['ui.ZoomConfCUJ.basic_small'],
diff --git a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_ZoomConfCUJ_basic_two b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_ZoomConfCUJ_basic_two
index 3d7face..6fc28c8 100644
--- a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_ZoomConfCUJ_basic_two
+++ b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_ZoomConfCUJ_basic_two
@@ -94,7 +94,10 @@
       stage_config(host)
 
       # Writing all test arguments to yaml file.
-      yaml.dump(test_args, stream=temp_file, default_flow_style=False)
+      yaml.safe_dump(test_args,
+                    stream=temp_file,
+                    default_flow_style=False,
+                    allow_unicode=True)
       job.run_test('tast',
                   host=host,
                   test_exprs=['ui.ZoomConfCUJ.basic_two'],
diff --git a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_ZoomConfCUJ_plus_class b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_ZoomConfCUJ_plus_class
index 7e07b72..b8f28a7 100644
--- a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_ZoomConfCUJ_plus_class
+++ b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_ZoomConfCUJ_plus_class
@@ -94,7 +94,10 @@
       stage_config(host)
 
       # Writing all test arguments to yaml file.
-      yaml.dump(test_args, stream=temp_file, default_flow_style=False)
+      yaml.safe_dump(test_args,
+                    stream=temp_file,
+                    default_flow_style=False,
+                    allow_unicode=True)
       job.run_test('tast',
                   host=host,
                   test_exprs=['ui.ZoomConfCUJ.plus_class'],
diff --git a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_ZoomConfCUJ_plus_large b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_ZoomConfCUJ_plus_large
index 2b86d0c..aca67fe 100644
--- a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_ZoomConfCUJ_plus_large
+++ b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_ZoomConfCUJ_plus_large
@@ -94,7 +94,10 @@
       stage_config(host)
 
       # Writing all test arguments to yaml file.
-      yaml.dump(test_args, stream=temp_file, default_flow_style=False)
+      yaml.safe_dump(test_args,
+                    stream=temp_file,
+                    default_flow_style=False,
+                    allow_unicode=True)
       job.run_test('tast',
                   host=host,
                   test_exprs=['ui.ZoomConfCUJ.plus_large'],
diff --git a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_ZoomConfCUJ_premium_large b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_ZoomConfCUJ_premium_large
index 726e2e3..f197094 100644
--- a/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_ZoomConfCUJ_premium_large
+++ b/server/site_tests/platform_MTBF/control.performance_cuj_experimental_ui_ZoomConfCUJ_premium_large
@@ -94,7 +94,10 @@
       stage_config(host)
 
       # Writing all test arguments to yaml file.
-      yaml.dump(test_args, stream=temp_file, default_flow_style=False)
+      yaml.safe_dump(test_args,
+                    stream=temp_file,
+                    default_flow_style=False,
+                    allow_unicode=True)
       job.run_test('tast',
                   host=host,
                   test_exprs=['ui.ZoomConfCUJ.premium_large'],
diff --git a/server/site_tests/platform_MTBF/spera_config.json b/server/site_tests/platform_MTBF/spera_config.json
index 00a9fc2..e1c6ce9 100644
--- a/server/site_tests/platform_MTBF/spera_config.json
+++ b/server/site_tests/platform_MTBF/spera_config.json
@@ -170,6 +170,30 @@
       "deps": ["premium"]
     },
     {
+      "name": "gdocs-basic",
+      "tool": "tast",
+      "test_expr": "ui.GoogleDocsWebCUJ.basic",
+      "attributes": ["basic"]
+    },
+    {
+      "name": "gdocs-premium",
+      "tool": "tast",
+      "test_expr": "ui.GoogleDocsWebCUJ.premium",
+      "attributes": ["premium"]
+    },
+    {
+      "name": "msoffice-basic",
+      "tool": "tast",
+      "test_expr": "ui.MicrosoftOfficeWebCUJ.basic",
+      "attributes": ["basic"]
+    },
+    {
+      "name": "msoffice-premium",
+      "tool": "tast",
+      "test_expr": "ui.MicrosoftOfficeWebCUJ.premium",
+      "attributes": ["premium"]
+    },
+    {
       "name": "geekbench-public-android",
       "tool": "tast",
       "test_expr": "ui.GeekbenchPublicAndroidApp",
@@ -218,7 +242,11 @@
         {"test": "zoom-basic-class", "repeats": 1},
         {"test": "zoom-plus-large", "repeats": 1},
         {"test": "zoom-plus-class", "repeats": 1},
-        {"test": "zoom-premium-large", "repeats": 1}
+        {"test": "zoom-premium-large", "repeats": 1},
+        {"test": "gdocs-basic", "repeats": 1},
+        {"test": "gdocs-premium", "repeats": 1},
+        {"test": "msoffice-basic", "repeats": 1},
+        {"test": "msoffice-premium", "repeats": 1}
       ]
     },
     {