[chromite] Remove the AUTestStage from builders.

We want to stop generating npo control files during AUTest stage.

Generating N to N+1 (npo) control file is not necessary as we already
have sufficient coverage with N to N test as part of the
paygen_au* suites.

So we don't need this stage and its assoicated code.

BUG=chromium:764038
BUG=chromium:758307
TEST=Not sure how best to test this change
CQ-DEPEND=CL:665366

Change-Id: Iadc9904c4e81770896cf02756f0025f87f5b5eb0
Reviewed-on: https://chromium-review.googlesource.com/665170
Commit-Ready: David Haddock <dhaddock@chromium.org>
Tested-by: David Haddock <dhaddock@chromium.org>
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/671455
Reviewed-by: David Haddock <dhaddock@chromium.org>
Trybot-Ready: David Haddock <dhaddock@chromium.org>
diff --git a/cbuildbot/builders/simple_builders.py b/cbuildbot/builders/simple_builders.py
index 52f070d..9d035a5 100644
--- a/cbuildbot/builders/simple_builders.py
+++ b/cbuildbot/builders/simple_builders.py
@@ -111,8 +111,6 @@
         stage_class = None
         if suite_config.async:
           stage_class = test_stages.ASyncHWTestStage
-        elif suite_config.suite == constants.HWTEST_AU_SUITE:
-          stage_class = test_stages.AUTestStage
         else:
           stage_class = test_stages.HWTestStage
 
diff --git a/cbuildbot/commands.py b/cbuildbot/commands.py
index 714d9c3..5620c0f 100644
--- a/cbuildbot/commands.py
+++ b/cbuildbot/commands.py
@@ -2149,53 +2149,6 @@
 
   return matches
 
-def BuildAUTestTarball(buildroot, board, work_dir, version, archive_url):
-  """Tar up the au test artifacts into the tarball_dir.
-
-  Args:
-    buildroot: Root directory where build occurs.
-    board: Board type that was built on this machine.
-    work_dir: Location for doing work.
-    version: Basic version of the build i.e. 3289.23.0.
-    archive_url: GS directory where we uploaded payloads.
-  """
-  au_test_tarball = os.path.join(work_dir, 'au_control.tar.bz2')
-
-  cwd = os.path.join(buildroot, 'src', 'third_party', 'autotest', 'files')
-  control_files_subdir = os.path.join('autotest', 'au_control_files')
-
-  autotest_dir = os.path.join(work_dir, control_files_subdir)
-  os.makedirs(autotest_dir)
-
-  # Get basic version without R*.
-  basic_version = re.search(r'R[0-9]+-([0-9][\w.]+)', version).group(1)
-
-  # Pass in the python paths to the libs full release test needs.
-  env_dict = dict(
-      chromite_path=buildroot,
-      devserver_path=os.path.join(buildroot, 'src', 'platform', 'dev'))
-
-  python_path = '%(chromite_path)s:%(devserver_path)s' % env_dict
-  cmd = ['site_utils/autoupdate/full_release_test.py',
-         '--npo', '--nmo', '--dump',
-         '--dump_dir', autotest_dir, '--archive_url', archive_url,
-         basic_version, board, '--log=debug']
-
-  gs_context_dir = os.path.dirname(gs.GSContext.GetDefaultGSUtilBin())
-  run_env = None
-  if not gs_context_dir in os.environ['PATH']:
-    run_env = os.environ.copy()
-    run_env['PATH'] += ':%s' % gs_context_dir
-  else:
-    run_env = os.environ
-
-  run_env.setdefault('PYTHONPATH', '')
-  run_env['PYTHONPATH'] += ':%s' % python_path
-
-  cros_build_lib.RunCommand(cmd, env=run_env, cwd=cwd)
-  BuildTarball(buildroot, [control_files_subdir], au_test_tarball, cwd=work_dir)
-  return au_test_tarball
-
 
 def BuildAutotestControlFilesTarball(buildroot, cwd, tarball_dir):
   """Tar up the autotest control files.
diff --git a/cbuildbot/commands_unittest.py b/cbuildbot/commands_unittest.py
index 3e5fde8..53ad832 100644
--- a/cbuildbot/commands_unittest.py
+++ b/cbuildbot/commands_unittest.py
@@ -953,25 +953,6 @@
                      constants.AUTOTEST_BUILD_PATH, '..'))
     self._tarball_dir = self.tempdir
 
-  def testBuildAUTestTarball(self):
-    """Tests that our call to generate an au test tarball is correct."""
-    archive_url = 'gs://mytest/path/version'
-    with mock.patch.object(commands, 'BuildTarball') as m:
-      tarball_path = commands.BuildAUTestTarball(
-          self._buildroot, self._board, self._tarball_dir, 'R26-3928.0.0',
-          archive_url)
-      m.assert_called_once_with(self._buildroot, ['autotest/au_control_files'],
-                                os.path.join(self._tarball_dir,
-                                             'au_control.tar.bz2'),
-                                cwd=self._tarball_dir)
-
-      self.assertEquals(os.path.join(self._tarball_dir, 'au_control.tar.bz2'),
-                        tarball_path)
-
-    # Full release test with partial args defined.
-    self.assertCommandContains(['site_utils/autoupdate/full_release_test.py',
-                                '--archive_url', archive_url, '3928.0.0',
-                                self._board])
 
   def testBuildFullAutotestTarball(self):
     """Tests that our call to generate the full autotest tarball is correct."""
diff --git a/cbuildbot/stages/test_stages.py b/cbuildbot/stages/test_stages.py
index 292a5af..6f070ef 100644
--- a/cbuildbot/stages/test_stages.py
+++ b/cbuildbot/stages/test_stages.py
@@ -514,22 +514,6 @@
       raise cmd_result.to_raise
 
 
-class AUTestStage(HWTestStage):
-  """Stage for au hw test suites that requires special pre-processing."""
-
-  stage_name = "AUTest"
-
-  def PerformStage(self):
-    """Uploads its au control files."""
-    with osutils.TempDir() as tempdir:
-      tarball = commands.BuildAUTestTarball(
-          self._build_root, self._current_board, tempdir,
-          self.version, self.upload_url)
-      self.UploadArtifact(tarball)
-
-    super(AUTestStage, self).PerformStage()
-
-
 class ASyncHWTestStage(HWTestStage, generic_stages.ForgivingBuilderStage):
   """Stage that fires and forgets hw test suites to the Autotest lab."""
 
diff --git a/cbuildbot/stages/test_stages_unittest.py b/cbuildbot/stages/test_stages_unittest.py
index 7fc41cf..352b823 100644
--- a/cbuildbot/stages/test_stages_unittest.py
+++ b/cbuildbot/stages/test_stages_unittest.py
@@ -12,16 +12,12 @@
 
 from chromite.cbuildbot import cbuildbot_unittest
 from chromite.cbuildbot import commands
-from chromite.cbuildbot import swarming_lib
-from chromite.cbuildbot import topology
-from chromite.cbuildbot.stages import artifact_stages
 from chromite.cbuildbot.stages import generic_stages_unittest
 from chromite.cbuildbot.stages import test_stages
 from chromite.lib import cgroups
 from chromite.lib import config_lib
 from chromite.lib import constants
 from chromite.lib import cros_build_lib_unittest
-from chromite.lib import cros_test_lib
 from chromite.lib import cros_logging as logging
 from chromite.lib import failures_lib
 from chromite.lib import fake_cidb
@@ -458,94 +454,6 @@
     mock_report.assert_called_once_with(mock.ANY, mock.ANY, mock.ANY)
 
 
-class AUTestStageTest(generic_stages_unittest.AbstractStageTestCase,
-                      cros_build_lib_unittest.RunCommandTestCase,
-                      cbuildbot_unittest.SimpleBuilderTestCase,
-                      cros_test_lib.MockTempDirTestCase):
-  """Test only custom methods in AUTestStageTest."""
-
-  BOT_ID = 'x86-mario-release'
-  RELEASE_TAG = '0.0.1'
-
-  # pylint: disable=W0201
-  def setUp(self):
-    self.PatchObject(commands, 'ArchiveFile', autospec=True,
-                     return_value='foo.txt')
-
-    self.archive_stage = None
-    self.suite_config = None
-    self.suite = None
-
-    self._Prepare()
-
-  def _Prepare(self, bot_id=None, **kwargs):
-    super(AUTestStageTest, self)._Prepare(bot_id, **kwargs)
-
-    self._run.GetArchive().SetupArchivePath()
-    self.archive_stage = artifact_stages.ArchiveStage(self._run,
-                                                      self._current_board)
-    self.suite_config = self.GetHWTestSuite()
-    self.suite = self.suite_config.suite
-
-  def ConstructStage(self):
-    board_runattrs = self._run.GetBoardRunAttrs(self._current_board)
-    board_runattrs.SetParallelDefault('test_artifacts_uploaded', True)
-    return test_stages.AUTestStage(
-        self._run, self._current_board, self._current_board, self.suite_config)
-
-  def _PatchJson(self):
-    """Mock out the code that loads from swarming task summary."""
-    # pylint: disable=protected-access
-    temp_json_path = os.path.join(self.tempdir, 'temp_summary.json')
-    orig_func = commands._CreateSwarmingArgs
-
-    def replacement(*args, **kargs):
-      swarming_args = orig_func(*args, **kargs)
-      swarming_args['temp_json_path'] = temp_json_path
-      return swarming_args
-
-    self.PatchObject(commands, '_CreateSwarmingArgs', side_effect=replacement)
-
-    j = {'shards':[{'name': 'fake_name', 'bot_id': 'chromeos-server990',
-                    'created_ts': '2015-06-12 12:00:00',
-                    'internal_failure': False,
-                    'outputs': ['some fake output']}]}
-    self.PatchObject(swarming_lib.SwarmingCommandResult, 'LoadJsonSummary',
-                     return_value=j)
-
-  def testPerformStage(self):
-    """Tests that we correctly generate a tarball and archive it."""
-    # pylint: disable=protected-access
-
-    topology.FetchTopologyFromCIDB(None)
-    self._PatchJson()
-    stage = self.ConstructStage()
-    stage.PerformStage()
-    cmd = ['site_utils/autoupdate/full_release_test.py', '--npo', '--dump',
-           '--archive_url', self.archive_stage.upload_url,
-           self.archive_stage.release_tag, self._current_board]
-    self.assertCommandContains(cmd)
-    # pylint: disable=W0212
-    self.assertCommandContains([swarming_lib._SWARMING_PROXY_CLIENT,
-                                commands.RUN_SUITE_PATH, self.suite])
-
-  def testPayloadsNotGenerated(self):
-    """Test that we exit early if payloads are not generated."""
-    board_runattrs = self._run.GetBoardRunAttrs(self._current_board)
-    board_runattrs.SetParallel('test_artifacts_uploaded', False)
-    self.warning_mock = self.PatchObject(
-        logging, 'PrintBuildbotStepWarnings')
-    self.run_suite_mock = self.PatchObject(commands, 'RunHWTestSuite')
-
-    self.RunStage()
-
-    # Make sure we make the stage orange.
-    self.warning_mock.assert_called_once()
-    # We exit early, so commands.RunHWTestSuite should not have been
-    # called.
-    self.assertFalse(self.run_suite_mock.called)
-
-
 class ImageTestStageTest(generic_stages_unittest.AbstractStageTestCase,
                          cros_build_lib_unittest.RunCommandTestCase,
                          cbuildbot_unittest.SimpleBuilderTestCase):