Exemplo n.º 1
0
 def testStageCIPDUpdate(self):
     with tempfile_ext.NamedTemporaryDirectory() as workDir,\
          tempfile_ext.NamedTemporaryDirectory() as repoRoot,\
          cts_utils.chdir(workDir):
         cts_utils_test.setup_fake_repo(repoRoot)
         cts_utils_test.writefile(
             'n1', os.path.join('filtered', CONFIG_DATA['base11']))
         cts_utils_test.writefile(
             'n3', os.path.join('filtered', CONFIG_DATA['base12']))
         for i in [str(i) for i in range(1, 5)]:
             cts_utils_test.writefile(
                 'o' + i, os.path.join('cipd', CIPD_DATA['file' + i]))
         cts_updater = update_cts.UpdateCTS('.', repoRoot)
         cts_updater.stage_cipd_update()
         self.assertTrue(os.path.isdir('staged'))
         with cts_utils.chdir('staged'):
             self.assertEqual(
                 'n1', cts_utils_test.readfile(CONFIG_DATA['file11']))
             self.assertEqual(
                 'n3', cts_utils_test.readfile(CONFIG_DATA['file12']))
             self.assertEqual(
                 'o2', cts_utils_test.readfile(CONFIG_DATA['file21']))
             self.assertEqual(
                 'o4', cts_utils_test.readfile(CONFIG_DATA['file22']))
             self.assertEqual(CIPD_DATA['yaml'],
                              cts_utils_test.readfile('cipd.yaml'))
Exemplo n.º 2
0
 def testCommitStagedCIPD(self, update_mock):
     with tempfile_ext.NamedTemporaryDirectory() as workDir,\
          tempfile_ext.NamedTemporaryDirectory() as repoRoot,\
          cts_utils.chdir(workDir):
         cts_utils_test.setup_fake_repo(repoRoot)
         cts_updater = update_cts.UpdateCTS('.', repoRoot)
         with self.assertRaises(update_cts.MissingDirError):
             cts_updater.commit_staged_cipd()
         cts_utils_test.writefile(CIPD_DATA['yaml'],
                                  os.path.join('staged', 'cipd.yaml'))
         with cts_utils.chdir('staged'):
             generate_zip_file(CONFIG_DATA['file11'], CONFIG_DATA['apk1'])
             generate_zip_file(CONFIG_DATA['file12'], CONFIG_DATA['apk1'])
             generate_zip_file(CONFIG_DATA['file21'], CONFIG_DATA['apk2a'],
                               CONFIG_DATA['apk2b'])
             with self.assertRaises(update_cts.MissingFileError):
                 cts_updater.commit_staged_cipd()
             generate_zip_file(CONFIG_DATA['file22'], CONFIG_DATA['apk2a'],
                               CONFIG_DATA['apk2b'])
         update_mock.return_value = 'newcipdversion'
         cts_updater.commit_staged_cipd()
         update_mock.assert_called_with(
             os.path.join(workDir, 'staged', 'cipd.yaml'))
         self.assertEqual('newcipdversion',
                          cts_utils_test.readfile('cipd_version.txt'))
Exemplo n.º 3
0
  def _assertCIPDVersionUpdated(self, repo_root, new_version):
    """Check that cts cipd version in DEPS and test suites were updated.

      Args:
        repo_root: Root directory of checkout
        new_version: Expected version of CTS package

      Raises:
        AssertionError: If contents of DEPS and test suite files were not
          expected.
      """
    self.assertEquals(
        DEPS_DATA['template'] % (CIPD_DATA['package'], new_version),
        cts_utils_test.readfile(os.path.join(repo_root, 'DEPS')))
    self.assertEquals(
        cts_utils_test.SUITES_DATA['template'] % (new_version, new_version),
        cts_utils_test.readfile(
            os.path.join(repo_root, 'testing', 'buildbot', 'test_suites.pyl')))
Exemplo n.º 4
0
    def testDownloadCIPD(self, run_mock):
        with tempfile_ext.NamedTemporaryDirectory() as workDir,\
             tempfile_ext.NamedTemporaryDirectory() as repoRoot,\
             cts_utils.chdir(workDir):
            cts_utils_test.setup_fake_repo(repoRoot)
            fake_cipd = cts_utils_test.FakeCIPD()
            fake_cipd.add_package(
                os.path.join(repoRoot, cts_utils.TOOLS_DIR,
                             cts_utils.CIPD_FILE), DEPS_DATA['revision'])
            fake_run_cmd = cts_utils_test.FakeRunCmd(fake_cipd)
            run_mock.side_effect = fake_run_cmd.run_cmd

            cts_updater = update_cts.UpdateCTS('.', repoRoot)
            cts_updater.download_cipd()
            self.assertTrue(os.path.isdir('cipd'))
            for i in [str(x) for x in range(1, 5)]:
                self.assertEqual(
                    CIPD_DATA['file' + i],
                    cts_utils_test.readfile(
                        os.path.join(workDir, 'cipd', CIPD_DATA['file' + i])))