Пример #1
0
def test_mirror_create():
    """Test if createing mirrors works."""
    with test.clean_and_config(os.path.join(
            _test_base,
            b"mirror-google.yml",
    )) as (tyml, config):
        args = ['-c', config, 'mirror', 'create']
        keys_added = []
        with testfixtures.LogCapture() as l:
            main(args)
            for rec in l.records:
                for arg in rec.args:
                    if isinstance(arg, list):
                        if arg[0] == "gpg":
                            keys_added.append(arg[7])
        assert len(keys_added) > 0
        assert len(keys_added) == len(
            set(keys_added)), ("Key multiple times added")

        expect = set(tyml['mirror'].keys())
        state = SystemStateReader()
        state.read()
        assert state.mirrors == expect
Пример #2
0
def test_publish_snapshot_update_rotating():
    """Test if update rotating publishes via snapshot works."""
    with test.clean_and_config(
            os.path.join(
                _test_base,
                b"publish-current.yml",
            )) as (tyml, config):
        do_publish_create_rotating(config)
        with freezegun.freeze_time("2012-10-11 10:10:10"):
            args = [
                '-c',
                config,
                'snapshot',
                'update',
            ]
            main(args)
            state = SystemStateReader()
            state.read()
            expect = {
                u'fake/current stable': set([u'fake-current']),
                u'fakerepo01/current stable': set([u'fakerepo01-current']),
                u'fakerepo02/current stable': set([u'fakerepo02-current'])
            }
            assert expect == state.publish_map
Пример #3
0
def test_snapshot_update_threetimes_rotating():
    """Test if rotating snapshot update works."""
    with test.clean_and_config(
            os.path.join(
                _test_base,
                b"snapshot-current.yml",
            )) as (tyml, config):
        do_snapshot_update_rotating(config)
        with freezegun.freeze_time("2012-10-11 10:10:10"):
            args = [
                '-c',
                config,
                'snapshot',
                'update',
            ]
            main(args)
            state = SystemStateReader()
            state.read()
            assert set([
                'fake-current',
                'fakerepo01-current-rotated-20121010T1010Z',
                'fakerepo02-current-rotated-20121010T1010Z',
                'fakerepo01-current-rotated-20121011T1010Z',
                'fakerepo02-current-rotated-20121011T1010Z',
            ]).issubset(state.snapshots)
            expected = {
                u'fake-current':
                set([u'fakerepo01-current', u'fakerepo02-current']),
                u'fake-current-rotated-20121010T1010Z':
                set([
                    u'fakerepo01-current-rotated-20121010T1010Z',
                    u'fakerepo02-current-rotated-20121010T1010Z'
                ]),
                u'fake-current-rotated-20121011T1010Z':
                set([
                    u'fakerepo01-current-rotated-20121011T1010Z',
                    u'fakerepo02-current-rotated-20121011T1010Z',
                ]),
                u'fakerepo01-current':
                set([]),
                u'fakerepo01-current-rotated-20121010T1010Z':
                set([]),
                u'fakerepo01-current-rotated-20121011T1010Z':
                set([]),
                u'fakerepo02-current':
                set([]),
                u'fakerepo02-current-rotated-20121010T1010Z':
                set([]),
                u'fakerepo02-current-rotated-20121011T1010Z':
                set([])
            }
            assert state.snapshot_map == expected

        with freezegun.freeze_time("2012-10-12 10:10:10"):
            args = [
                '-c',
                config,
                'snapshot',
                'update',
            ]
            main(args)
            state = SystemStateReader()
            state.read()
            assert set([
                'fake-current',
                'fakerepo01-current-rotated-20121011T1010Z',
                'fakerepo02-current-rotated-20121011T1010Z',
                'fakerepo01-current-rotated-20121012T1010Z',
                'fakerepo02-current-rotated-20121012T1010Z',
            ]).issubset(state.snapshots)
            expected = {
                u'fake-current':
                set([u'fakerepo01-current', u'fakerepo02-current']),
                u'fake-current-rotated-20121010T1010Z':
                set([
                    u'fakerepo01-current-rotated-20121010T1010Z',
                    u'fakerepo02-current-rotated-20121010T1010Z'
                ]),
                u'fake-current-rotated-20121011T1010Z':
                set([
                    u'fakerepo01-current-rotated-20121011T1010Z',
                    u'fakerepo02-current-rotated-20121011T1010Z',
                ]),
                u'fake-current-rotated-20121012T1010Z':
                set([
                    u'fakerepo01-current-rotated-20121012T1010Z',
                    u'fakerepo02-current-rotated-20121012T1010Z',
                ]),
                u'fakerepo01-current':
                set([]),
                u'fakerepo01-current-rotated-20121010T1010Z':
                set([]),
                u'fakerepo01-current-rotated-20121011T1010Z':
                set([]),
                u'fakerepo01-current-rotated-20121012T1010Z':
                set([]),
                u'fakerepo02-current':
                set([]),
                u'fakerepo02-current-rotated-20121010T1010Z':
                set([]),
                u'fakerepo02-current-rotated-20121011T1010Z':
                set([]),
                u'fakerepo02-current-rotated-20121012T1010Z':
                set([]),
            }
            assert state.snapshot_map == expected