Exemplo n.º 1
0
    def test_repositories_cleanup_includes_commits(self):
        self._jens_update()

        self._create_fake_module('electron', ['qa'])
        murdock_path = self._create_fake_hostgroup('murdock', ['qa'])
        commit_id = get_refs(murdock_path + '/.git')['qa']
        override = "{0}{1}".format(COMMIT_PREFIX, commit_id)
        ensure_environment(self.settings, 'test', 'master',
            hostgroups=["murdock:%s" % override])

        repositories_deltas = self._jens_update()

        self.assertTrue('electron' in repositories_deltas['modules']['new'])
        self.assertTrue('murdock' in repositories_deltas['hostgroups']['new'])
        self.assertBare('modules/electron')
        self.assertBare('hostgroups/murdock')
        self.assertClone('hostgroups/murdock/.%s' % commit_id, pointsto=commit_id)
        self.assertEnvironmentOverride("test", 'hostgroups/hg_murdock', override)

        del_repository(self.settings, 'hostgroups', 'murdock')

        repositories_deltas = self._jens_update()

        self.assertTrue('murdock' in repositories_deltas['hostgroups']['deleted'])
        self.assertNotBare('hostgroups/murdock')
        self.assertNotClone('hostgroups/murdock/master')
        self.assertNotClone('hostgroups/murdock/qa')
        self.assertEnvironmentOverrideDoesntExist('test', 'hostgroups/hg_murdock')
Exemplo n.º 2
0
    def test_repositories_add_and_remove_mandatory_expanded_and_cleanup(self):
        self._jens_update()

        self._create_fake_module('electron', ['qa'])
        self._create_fake_hostgroup('aisusie', ['qa'])

        repositories_deltas = self._jens_update()

        self.assertBare('modules/electron')
        self.assertTrue('electron' in repositories_deltas['modules']['new'])
        self.assertBare('hostgroups/aisusie')
        self.assertTrue('aisusie' in repositories_deltas['hostgroups']['new'])
        for branch in MANDATORY_BRANCHES:
            self.assertClone('modules/electron/%s' % branch)
            self.assertClone('hostgroups/aisusie/%s' % branch)
        self.assertEnvironmentLinks("production")
        self.assertEnvironmentLinks("qa")
        self.assertEnvironmentOverride('production', 'modules/electron', 'master')
        self.assertEnvironmentOverride('production', 'hostgroups/hg_aisusie', 'master')

        del_repository(self.settings, 'hostgroups', 'aisusie')

        repositories_deltas = self._jens_update()

        self.assertTrue('aisusie' in repositories_deltas['hostgroups']['deleted'])
        self.assertBare('modules/electron')
        self.assertNotBare('hostgroups/aisusie')
        for branch in MANDATORY_BRANCHES:
            self.assertClone('modules/electron/%s' % branch)
            self.assertNotClone('hostgroups/aisusie/%s' % branch)
        self.assertEnvironmentLinks("production")
        self.assertEnvironmentLinks("qa")
        self.assertEnvironmentOverride('production', 'modules/electron', 'master')
        self.assertEnvironmentOverrideDoesntExist('production', 'hostgroups/hg_aisusie')
        self.assertEnvironmentOverrideDoesntExist('qa', 'hostgroups/hg_aisusie')
Exemplo n.º 3
0
    def test_repositories_cleanup_includes_commits(self):
        self._jens_update()

        self._create_fake_module('electron', ['qa'])
        murdock_path = self._create_fake_hostgroup('murdock', ['qa'])
        commit_id = get_refs(murdock_path + '/.git')['qa']
        override = "{0}{1}".format(COMMIT_PREFIX, commit_id)
        ensure_environment(self.settings, 'test', 'master',
            hostgroups=["murdock:%s" % override])

        repositories_deltas = self._jens_update()

        self.assertTrue('electron' in repositories_deltas['modules']['new'])
        self.assertTrue('murdock' in repositories_deltas['hostgroups']['new'])
        self.assertBare('modules/electron')
        self.assertBare('hostgroups/murdock')
        self.assertClone('hostgroups/murdock/.%s' % commit_id, pointsto=commit_id)
        self.assertEnvironmentOverride("test", 'hostgroups/hg_murdock', override)

        del_repository(self.settings, 'hostgroups', 'murdock')

        repositories_deltas = self._jens_update()

        self.assertTrue('murdock' in repositories_deltas['hostgroups']['deleted'])
        self.assertNotBare('hostgroups/murdock')
        self.assertNotClone('hostgroups/murdock/master')
        self.assertNotClone('hostgroups/murdock/qa')
        self.assertEnvironmentOverrideDoesntExist('test', 'hostgroups/hg_murdock')
Exemplo n.º 4
0
    def test_repositories_add_and_remove_mandatory_expanded_and_cleanup(self):
        self._jens_update()

        self._create_fake_module('electron', ['qa'])
        self._create_fake_hostgroup('aisusie', ['qa'])

        repositories_deltas = self._jens_update()

        self.assertBare('modules/electron')
        self.assertTrue('electron' in repositories_deltas['modules']['new'])
        self.assertBare('hostgroups/aisusie')
        self.assertTrue('aisusie' in repositories_deltas['hostgroups']['new'])
        for branch in MANDATORY_BRANCHES:
            self.assertClone('modules/electron/%s' % branch)
            self.assertClone('hostgroups/aisusie/%s' % branch)
        self.assertEnvironmentLinks("production")
        self.assertEnvironmentLinks("qa")
        self.assertEnvironmentOverride('production', 'modules/electron', 'master')
        self.assertEnvironmentOverride('production', 'hostgroups/hg_aisusie', 'master')

        del_repository(self.settings, 'hostgroups', 'aisusie')

        repositories_deltas = self._jens_update()

        self.assertTrue('aisusie' in repositories_deltas['hostgroups']['deleted'])
        self.assertBare('modules/electron')
        self.assertNotBare('hostgroups/aisusie')
        for branch in MANDATORY_BRANCHES:
            self.assertClone('modules/electron/%s' % branch)
            self.assertNotClone('hostgroups/aisusie/%s' % branch)
        self.assertEnvironmentLinks("production")
        self.assertEnvironmentLinks("qa")
        self.assertEnvironmentOverride('production', 'modules/electron', 'master')
        self.assertEnvironmentOverrideDoesntExist('production', 'hostgroups/hg_aisusie')
        self.assertEnvironmentOverrideDoesntExist('qa', 'hostgroups/hg_aisusie')
Exemplo n.º 5
0
    def test_created_if_new_and_removed_if_gone_regardless_of_hints(self):
        self.settings.MODE = "ONDEMAND"
        murdock_path = self._create_fake_module('murdock', ['qa'])
        steve_path = self._create_fake_hostgroup('steve', ['qa'])
        old_qa = get_refs(murdock_path + '/.git')['qa']
        ensure_environment(self.settings, 'test', 'master',
            modules=["murdock:qa"])

        self._jens_update(hints={'hostgroups': ['foo']})

        self.assertBare('modules/murdock')
        self.assertBare('hostgroups/steve')
        self.assertClone('modules/murdock/master')
        self.assertClone('modules/murdock/qa', pointsto=old_qa)
        self.assertClone('hostgroups/steve/qa')
        self.assertClone('hostgroups/steve/master')
        self.assertEnvironmentNumberOf("test", "modules", 1)
        self.assertEnvironmentNumberOf("test", "hostgroups", 1)
        self.assertEnvironmentOverride("test", 'modules/murdock', 'qa')
        self.assertEnvironmentOverride("test", 'hostgroups/hg_steve', 'master')

        del_repository(self.settings, 'modules', 'murdock')

        repositories_deltas = self._jens_update(hints={'hostgroups': ['foo']})

        self.assertTrue('murdock' in repositories_deltas['modules']['deleted'])
        self.assertEnvironmentLinks("test")
        self.assertEnvironmentNumberOf("test", "modules", 0)
        self.assertEnvironmentNumberOf("test", "hostgroups", 1)
        self.assertEnvironmentOverrideDoesntExist("test", 'modules/murdock')
        self.assertEnvironmentOverride("test", 'hostgroups/hg_steve', 'master')
Exemplo n.º 6
0
    def test_environments_shrink(self):
        guy_path = self._create_fake_module('guy', ['qa'])
        self._create_fake_module('guy2', ['qa'])
        commit_id = get_refs(guy_path + '/.git')['qa']
        override = "{0}{1}".format(COMMIT_PREFIX, commit_id)
        ensure_environment(self.settings, 'test', 'master',
            modules=["guy:%s" % override])
        ensure_environment(self.settings, 'test2', None,
            modules=["guy:%s" % override])

        self._jens_update()

        self.assertBare('modules/guy')
        self.assertClone('modules/guy/.%s' % commit_id)
        self.assertEnvironmentLinks("test")
        self.assertEnvironmentNumberOf("test", "modules", 2)
        self.assertEnvironmentNumberOf("test", "hostgroups", 0)
        self.assertEnvironmentOverride("test", 'modules/guy', override)
        self.assertEnvironmentLinks("test2")
        self.assertEnvironmentNumberOf("test2", "modules", 1)
        self.assertEnvironmentNumberOf("test2", "hostgroups", 0)
        self.assertEnvironmentOverride("test2", 'modules/guy', override)

        # -- The deleted module shouldn't be present in any  env.

        del_repository(self.settings, 'modules', 'guy')

        repositories_deltas = self._jens_update()

        self.assertTrue('guy' in repositories_deltas['modules']['deleted'])
        self.assertEnvironmentLinks("test")
        self.assertEnvironmentNumberOf("test", "modules", 1)
        self.assertEnvironmentNumberOf("test", "hostgroups", 0)
        self.assertEnvironmentOverrideDoesntExist("test", 'modules/guy')

        self.assertEnvironmentLinks("test2")
        self.assertEnvironmentNumberOf("test2", "modules", 0)
        self.assertEnvironmentNumberOf("test2", "hostgroups", 0)
        self.assertEnvironmentOverrideDoesntExist("test2", 'modules/guy')
        self.assertEnvironmentOverrideDoesntExist('production', 'modules/guy')
        self.assertEnvironmentOverrideDoesntExist('qa', 'modules/guy')
Exemplo n.º 7
0
    def test_environments_shrink(self):
        guy_path = self._create_fake_module('guy', ['qa'])
        self._create_fake_module('guy2', ['qa'])
        commit_id = get_refs(guy_path + '/.git')['qa']
        override = "{0}{1}".format(COMMIT_PREFIX, commit_id)
        ensure_environment(self.settings, 'test', 'master',
            modules=["guy:%s" % override])
        ensure_environment(self.settings, 'test2', None,
            modules=["guy:%s" % override])

        self._jens_update()

        self.assertBare('modules/guy')
        self.assertClone('modules/guy/.%s' % commit_id)
        self.assertEnvironmentLinks("test")
        self.assertEnvironmentNumberOf("test", "modules", 2)
        self.assertEnvironmentNumberOf("test", "hostgroups", 0)
        self.assertEnvironmentOverride("test", 'modules/guy', override)
        self.assertEnvironmentLinks("test2")
        self.assertEnvironmentNumberOf("test2", "modules", 1)
        self.assertEnvironmentNumberOf("test2", "hostgroups", 0)
        self.assertEnvironmentOverride("test2", 'modules/guy', override)

        # -- The deleted module shouldn't be present in any  env.

        del_repository(self.settings, 'modules', 'guy')

        repositories_deltas = self._jens_update()

        self.assertTrue('guy' in repositories_deltas['modules']['deleted'])
        self.assertEnvironmentLinks("test")
        self.assertEnvironmentNumberOf("test", "modules", 1)
        self.assertEnvironmentNumberOf("test", "hostgroups", 0)
        self.assertEnvironmentOverrideDoesntExist("test", 'modules/guy')

        self.assertEnvironmentLinks("test2")
        self.assertEnvironmentNumberOf("test2", "modules", 0)
        self.assertEnvironmentNumberOf("test2", "hostgroups", 0)
        self.assertEnvironmentOverrideDoesntExist("test2", 'modules/guy')
        self.assertEnvironmentOverrideDoesntExist('production', 'modules/guy')
        self.assertEnvironmentOverrideDoesntExist('qa', 'modules/guy')