def test_deployment_path_should_return_path_after_setting_name(self):
        cfg = Config(Source.url('url'), 'ref', stateroot='test-stateroot')
        cfg.set_deployment_name('deployment-name')

        self.assertEqual(
            cfg.deployment_dir,
            os.path.join('/ostree', 'deploy', 'test-stateroot', 'deploy',
                         'deployment-name'))
    def test_deployment_dir_should_include_sysroot(self):
        sysroot = os.path.join('/mnt', 'rootfs')
        cfg = Config(Source.url('url'), 'ref', sysroot=sysroot)
        cfg.set_deployment_name('0123deployment.0')

        self.assertEqual(
            cfg.deployment_dir,
            os.path.join(sysroot, 'ostree', 'deploy', cfg.stateroot, 'deploy',
                         '0123deployment.0'))
Beispiel #3
0
    def test_should_unmount_on_cleanup(self, run_mock: mock.Mock):
        cfg = Config(Source.url('url'), 'ref', stateroot='test')
        cfg.set_deployment_name('test-deploy.0')

        MountVar(cfg).cleanup()

        run_mock.assert_called_once_with([
            'umount',
            '-l',
            os.path.join('/ostree', 'deploy', 'test', 'deploy',
                         'test-deploy.0', 'var'),
        ],
                                         check=True)
Beispiel #4
0
    def test_should_bind_mount_var_into_deployment(self, run_mock: mock.Mock):
        cfg = Config(Source.url('url'), 'ref', stateroot='test')
        cfg.set_deployment_name('test-deploy.0')

        MountVar(cfg).run()

        run_mock.assert_called_once_with([
            'mount',
            '-o',
            'bind',
            os.path.join('/ostree', 'deploy', 'test', 'var'),
            os.path.join('/ostree', 'deploy', 'test', 'deploy',
                         'test-deploy.0', 'var'),
        ],
                                         check=True)
Beispiel #5
0
    def test_should_mount_with_specified_sysroot(self, run_mock: mock.Mock):
        sysroot = os.path.join('/mnt', 'rootfs')
        cfg = Config(Source.url('url'),
                     'ref',
                     stateroot='test',
                     sysroot=sysroot)
        cfg.set_deployment_name('test-deploy.0')

        MountVar(cfg).run()

        run_mock.assert_called_once_with([
            'mount',
            '-o',
            'bind',
            os.path.join(sysroot, 'ostree', 'deploy', 'test', 'var'),
            os.path.join(sysroot, 'ostree', 'deploy', 'test', 'deploy',
                         'test-deploy.0', 'var'),
        ],
                                         check=True)
    def test_should_run_provisioner_script_with_specified_sysroot(
            self, run_mock: mock.Mock):
        sysroot = os.path.join('/mnt', 'rootfs')
        cfg = Config(Source.url('url'),
                     'ref',
                     stateroot='test',
                     sysroot=sysroot)
        cfg.set_deployment_name('test-deploy.0')
        provisioner = ProvisionerConfig('etc-fstab', {})

        BuiltinProvisioner(cfg, provisioner).run()

        run_mock.assert_called_once_with([
            os.path.join(PROVISIONERS_DIR, 'etc-fstab'),
            os.path.join(sysroot, 'ostree', 'deploy', 'test', 'deploy',
                         'test-deploy.0')
        ],
                                         check=True,
                                         env={})