Exemple #1
0
    def testDeployEmerge(self):
        """Test that deploy._Emerge is called for each package."""

        _BINPKG = '/path/to/bar-1.2.5.tbz2'

        def FakeIsFile(fname):
            return fname == _BINPKG

        packages = ['some/foo-1.2.3', _BINPKG, 'some/foobar-2.0']
        cpvs = ['some/foo-1.2.3', 'to/bar-1.2.5', 'some/foobar-2.0']
        self.package_scanner.return_value = PackageScannerFake(
            packages, {
                'some/foo-1.2.3': {},
                _BINPKG: {},
                'some/foobar-2.0': {}
            }, cpvs)
        self.PatchObject(os.path, 'isfile', side_effect=FakeIsFile)

        deploy.Deploy(None, ['package'], force=True, clean_binpkg=False)

        # Check that package names were correctly resolved into binary packages.
        self.get_packages_paths.assert_called_once_with(
            [portage_util.SplitCPV(p) for p in cpvs], True, 'sysroot')
        # Check that deploy._Emerge is called the right number of times.
        self.assertEqual(self.emerge.call_count, len(packages))
        self.assertEqual(self.unmerge.call_count, 0)
Exemple #2
0
    def testDeployUnmerge(self):
        """Test that deploy._Unmerge is called for each package."""
        packages = ['foo', 'bar', 'foobar', 'foodlc']
        self.package_scanner.return_value = PackageScannerFake(
            packages, {
                'foo': {},
                'bar': {},
                'foobar': {},
                'foodlc': {
                    deploy._DLC_ID: 'foodlc',
                    deploy._DLC_PACKAGE: 'foopackage'
                }
            })

        deploy.Deploy(None, ['package'],
                      force=True,
                      clean_binpkg=False,
                      emerge=False)

        # Check that deploy._Unmerge is called the right number of times.
        self.assertEqual(self.emerge.call_count, 0)
        self.assertEqual(self.unmerge.call_count, len(packages))

        self.assertEqual(self.device.device.cmds, [[
            'sudo', '-u', 'chronos', 'dlcservice_util', '--uninstall',
            '--dlc_ids=foodlc'
        ], ['restart', 'dlcservice']])
Exemple #3
0
    def testDeployUnmerge(self):
        """Test that deploy._Unmerge is called for each package."""
        packages = ['foo', 'bar', 'foobar']
        self.package_scanner.return_value = PackageScannerFake(packages)

        deploy.Deploy(None, ['package'],
                      force=True,
                      clean_binpkg=False,
                      emerge=False)

        # Check that deploy._Unmerge is called the right number of times.
        self.assertEqual(self.emerge.call_count, 0)
        self.assertEqual(self.unmerge.call_count, len(packages))
Exemple #4
0
    def testDeployMergeWithProgressBar(self):
        """Test that BrilloDeployOperation.Run() is called for merge."""
        packages = ['foo', 'bar', 'foobar']
        self.package_scanner.return_value = PackageScannerFake(packages)

        run = self.PatchObject(deploy.BrilloDeployOperation,
                               'Run',
                               return_value=None)

        self.PatchObject(command, 'UseProgressBar', return_value=True)
        deploy.Deploy(None, ['package'], force=True, clean_binpkg=False)

        # Check that BrilloDeployOperation.Run was called.
        self.assertTrue(run.called)
Exemple #5
0
    def testDeployEmergeDLC(self):
        """Test that deploy._Emerge installs images for DLC packages."""
        packages = ['some/foodlc-1.0', 'some/bardlc-2.0']
        cpvs = ['some/foodlc-1.0', 'some/bardlc-2.0']
        self.package_scanner.return_value = PackageScannerFake(
            packages, {
                'some/foodlc-1.0': {},
                'some/bardlc-2.0': {}
            }, cpvs)
        self.PatchObject(deploy,
                         '_GetDLCInfo',
                         return_value=('foo_id', 'foo_package'))

        deploy.Deploy(None, ['package'], force=True, clean_binpkg=False)
        # Check that dlcservice is restarted (DLC modules are deployed).
        self.assertTrue(['restart', 'dlcservice'] in self.device.device.cmds)
Exemple #6
0
 def Run(self):
     """Run cros deploy."""
     commandline.RunInsideChroot(self)
     self.options.Freeze()
     deploy.Deploy(self.options.device,
                   self.options.packages,
                   board=self.options.board,
                   emerge=self.options.emerge,
                   update=self.options.update,
                   deep=self.options.deep,
                   deep_rev=self.options.deep_rev,
                   clean_binpkg=self.options.clean_binpkg,
                   root=self.options.root,
                   strip=self.options.strip,
                   emerge_args=self.options.emerge_args,
                   ssh_private_key=self.options.private_key,
                   ping=self.options.ping,
                   force=self.options.force,
                   dry_run=self.options.dry_run)
     logging.info('cros deploy completed successfully.')
Exemple #7
0
    def testDeployEmergeSELinux(self):
        """Test deploy progress when the device has SELinux"""

        _BINPKG = '/path/to/bar-1.2.5.tbz2'

        def FakeIsFile(fname):
            return fname == _BINPKG

        def GetRestoreconCommand(pkgfile):
            remote_path = os.path.join('/testdir/packages/to/', pkgfile)
            return [['setenforce', '0'],
                    [
                        'cd', '/', '&&', 'tar', 'tf', remote_path, '|',
                        'restorecon', '-i', '-f', '-'
                    ], ['setenforce', '1']]

        self.device.device.selinux_available = True
        packages = ['some/foo-1.2.3', _BINPKG, 'some/foobar-2.0']
        cpvs = ['some/foo-1.2.3', 'to/bar-1.2.5', 'some/foobar-2.0']
        self.package_scanner.return_value = PackageScannerFake(
            packages, {
                'some/foo-1.2.3': {},
                _BINPKG: {},
                'some/foobar-2.0': {}
            }, cpvs)
        self.PatchObject(os.path, 'isfile', side_effect=FakeIsFile)

        deploy.Deploy(None, ['package'], force=True, clean_binpkg=False)

        # Check that package names were correctly resolved into binary packages.
        self.get_packages_paths.assert_called_once_with(
            [portage_util.SplitCPV(p) for p in cpvs], True, 'sysroot')
        # Check that deploy._Emerge is called the right number of times.
        self.assertEqual(self.emerge.call_count, len(packages))
        self.assertEqual(self.unmerge.call_count, 0)

        self.assertEqual(
            self.device.device.cmds,
            GetRestoreconCommand('foo-1.2.3.tbz2') +
            GetRestoreconCommand('bar-1.2.5.tbz2') +
            GetRestoreconCommand('foobar-2.0.tbz2'))