Esempio n. 1
0
    def test_clone_and_bare_still_present_if_fetch_fails(self):
        yi_path = self._create_fake_hostgroup('yi', ['qa'])
        yi_path_bare = yi_path.replace('/user/', '/bare/')

        self._jens_update()

        self.assertBare('hostgroups/yi')
        self.assertClone('hostgroups/yi/qa')

        # ---- Make it temporary unavailable
        shutil.move("%s/refs" % yi_path_bare, "%s/goat" % yi_path_bare)

        self._jens_update(errorsExpected=True)

        self.assertBare('hostgroups/yi')
        self.assertClone('hostgroups/yi/qa')


        # ---- Bring it back
        shutil.move("%s/goat" % yi_path_bare, "%s/refs" % yi_path_bare)
        add_branch_to_repo(self.settings, yi_path, 'lol')
        ensure_environment(self.settings, 'test', 'qa',
            hostgroups=['yi:lol'])

        self._jens_update()

        self.assertBare('hostgroups/yi')
        self.assertClone('hostgroups/yi/qa')
        self.assertClone('hostgroups/yi/lol')
        self.assertEnvironmentLinks("test")
Esempio n. 2
0
    def test_broken_link_if_branch_disappears(self):
        ensure_environment(self.settings, 'test', 'master',
            modules=['foo:bar'])
        foo_path = self._create_fake_module('foo', ['qa', 'bar'])

        self._jens_update()

        self.assertClone('modules/foo/bar')
        self.assertEnvironmentLinks("test")
        self.assertEnvironmentOverride("test", 'modules/foo', 'bar')

        # ---- Remove branch (a broken link should be kept)

        remove_branch_from_repo(self.settings, foo_path, 'bar')

        self._jens_update()

        self.assertNotClone('modules/foo/bar')
        self.assertEnvironmentBrokenLinks("test")
        self.assertEnvironmentOverrideExistsButBroken("test", 'modules/foo', 'bar')

        # ---- Add it again (link should be ok again)

        add_branch_to_repo(self.settings, foo_path, 'bar')

        self._jens_update()

        self.assertClone('modules/foo/bar')
        self.assertEnvironmentLinks("test")
        self.assertEnvironmentOverride("test", 'modules/foo', 'bar')
Esempio n. 3
0
    def test_branch_is_added_after_initial_expand_and_removed_if_not_nec(self):
        ensure_environment(self.settings, 'test', 'master')
        murdock_path = self._create_fake_hostgroup('murdock', ['qa'])

        self._jens_update()

        # --- Add override

        add_branch_to_repo(self.settings, murdock_path, 'foo')
        destroy_environment(self.settings, 'test')
        ensure_environment(self.settings, 'test', 'master',
            hostgroups=['murdock:foo'])

        self._jens_update()

        self.assertBare('hostgroups/murdock')
        for branch in MANDATORY_BRANCHES:
            self.assertClone('hostgroups/murdock/%s' % branch)
        self.assertClone('hostgroups/murdock/foo')
        self.assertEnvironmentLinks("test")
        self.assertEnvironmentOverride("test", 'hostgroups/hg_murdock', 'foo')

        # --- Remove it

        destroy_environment(self.settings, 'test')
        ensure_environment(self.settings, 'test', 'master')

        self._jens_update()

        self.assertBare('hostgroups/murdock')
        for branch in MANDATORY_BRANCHES:
            self.assertClone('hostgroups/murdock/%s' % branch)
        self.assertNotClone('hostgroups/murdock/foo')
        self.assertEnvironmentLinks("test")
        self.assertEnvironmentOverride("test", 'hostgroups/hg_murdock', 'master')
Esempio n. 4
0
    def test_clone_and_bare_still_present_if_fetch_fails(self):
        yi_path = self._create_fake_hostgroup('yi', ['qa'])
        yi_path_bare = yi_path.replace('/user/', '/bare/')

        self._jens_update()

        self.assertBare('hostgroups/yi')
        self.assertClone('hostgroups/yi/qa')

        # ---- Make it temporary unavailable
        shutil.move("%s/refs" % yi_path_bare, "%s/goat" % yi_path_bare)

        self._jens_update(errorsExpected=True)

        self.assertBare('hostgroups/yi')
        self.assertClone('hostgroups/yi/qa')


        # ---- Bring it back
        shutil.move("%s/goat" % yi_path_bare, "%s/refs" % yi_path_bare)
        add_branch_to_repo(self.settings, yi_path, 'lol')
        ensure_environment(self.settings, 'test', 'qa',
            hostgroups=['yi:lol'])

        self._jens_update()

        self.assertBare('hostgroups/yi')
        self.assertClone('hostgroups/yi/qa')
        self.assertClone('hostgroups/yi/lol')
        self.assertEnvironmentLinks("test")
Esempio n. 5
0
    def test_broken_link_if_branch_disappears(self):
        ensure_environment(self.settings, 'test', 'master',
            modules=['foo:bar'])
        foo_path = self._create_fake_module('foo', ['qa', 'bar'])

        self._jens_update()

        self.assertClone('modules/foo/bar')
        self.assertEnvironmentLinks("test")
        self.assertEnvironmentOverride("test", 'modules/foo', 'bar')

        # ---- Remove branch (a broken link should be kept)

        remove_branch_from_repo(self.settings, foo_path, 'bar')

        self._jens_update()

        self.assertNotClone('modules/foo/bar')
        self.assertEnvironmentBrokenLinks("test")
        self.assertEnvironmentOverrideExistsButBroken("test", 'modules/foo', 'bar')

        # ---- Add it again (link should be ok again)

        add_branch_to_repo(self.settings, foo_path, 'bar')

        self._jens_update()

        self.assertClone('modules/foo/bar')
        self.assertEnvironmentLinks("test")
        self.assertEnvironmentOverride("test", 'modules/foo', 'bar')
Esempio n. 6
0
    def test_branch_is_added_after_initial_expand_and_removed_if_not_nec(self):
        ensure_environment(self.settings, 'test', 'master')
        murdock_path = self._create_fake_hostgroup('murdock', ['qa'])

        self._jens_update()

        # --- Add override

        add_branch_to_repo(self.settings, murdock_path, 'foo')
        destroy_environment(self.settings, 'test')
        ensure_environment(self.settings, 'test', 'master',
            hostgroups=['murdock:foo'])

        self._jens_update()

        self.assertBare('hostgroups/murdock')
        for branch in MANDATORY_BRANCHES:
            self.assertClone('hostgroups/murdock/%s' % branch)
        self.assertClone('hostgroups/murdock/foo')
        self.assertEnvironmentLinks("test")
        self.assertEnvironmentOverride("test", 'hostgroups/hg_murdock', 'foo')

        # --- Remove it

        destroy_environment(self.settings, 'test')
        ensure_environment(self.settings, 'test', 'master')

        self._jens_update()

        self.assertBare('hostgroups/murdock')
        for branch in MANDATORY_BRANCHES:
            self.assertClone('hostgroups/murdock/%s' % branch)
        self.assertNotClone('hostgroups/murdock/foo')
        self.assertEnvironmentLinks("test")
        self.assertEnvironmentOverride("test", 'hostgroups/hg_murdock', 'master')