Example #1
0
def test_mapping(metasync, opts):
    "test mapping strategies"

    opts.notree = True

    m = DetMap([(1, 2*GB), (2, 5*GB), (3, 3*GB)])

    def __do_check(m):
        assert len([n for n in m.distrib if n == 1]) == len(m.distrib)/10*2
        assert len([n for n in m.distrib if n == 2]) == len(m.distrib)/10*5
        assert len([n for n in m.distrib if n == 3]) == len(m.distrib)/10*3

        copyset = set()
        for i in range(len(m.distrib)):
            c = m.get_mapping(i)
            assert len(c) == m.replica
            copyset.add(tuple(c))

        assert len(copyset) < len(m.distrib)

        dbg.info("mapping: %s ..." % str(m.distrib)[:30])
        dbg.info("copyset: %s" % str(list(copyset)))

    __do_check(m)
    __do_check(DetMap.restore(m.store()))

    # small_test
    m = DetMap([(2, 2*GB), (1, 5*GB)])
    assert m.mapinfo[0].config[0][0] == 1 
Example #2
0
def test_mapping_reconfig(metasync, opts):
    "test reconfiguration/versioning of mapping strategies"

    opts.notree = True

    m = DetMap([(1, 2 * GB), (2, 5 * GB), (3, 2 * GB)])
    m.reconfig([(1, 2 * GB), (2, 5 * GB)])

    # two version of mapping info
    assert len(m.mapinfo) == 2
    for (ver, conf) in m.mapinfo.iteritems():
        dbg.info("%s -> %s" % (ver, conf.store()))

    # where to remap of hash value: 0
    #  0: [1,2] -> [1,2]
    #  1: [2,3] -> [2,1]
    assert m.get_remmaping(0) == []
    assert m.get_remmaping(1) == [1]
Example #3
0
def test_mapping_reconfig(metasync, opts):
    "test reconfiguration/versioning of mapping strategies"

    opts.notree = True

    m = DetMap([(1, 2*GB), (2, 5*GB), (3, 2*GB)])
    m.reconfig([(1, 2*GB), (2, 5*GB)])

    # two version of mapping info
    assert len(m.mapinfo) == 2
    for (ver, conf) in m.mapinfo.iteritems():
        dbg.info("%s -> %s"  % (ver, conf.store()))

    # where to remap of hash value: 0
    #  0: [1,2] -> [1,2]
    #  1: [2,3] -> [2,1]
    assert m.get_remmaping(0) == []
    assert m.get_remmaping(1) == [1]
Example #4
0
def test_mapping(metasync, opts):
    "test mapping strategies"

    opts.notree = True

    m = DetMap([(1, 2 * GB), (2, 5 * GB), (3, 3 * GB)])

    def __do_check(m):
        assert len([n for n in m.distrib if n == 1]) == len(m.distrib) / 10 * 2
        assert len([n for n in m.distrib if n == 2]) == len(m.distrib) / 10 * 5
        assert len([n for n in m.distrib if n == 3]) == len(m.distrib) / 10 * 3

        copyset = set()
        for i in range(len(m.distrib)):
            c = m.get_mapping(i)
            assert len(c) == m.replica
            copyset.add(tuple(c))

        assert len(copyset) < len(m.distrib)

        dbg.info("mapping: %s ..." % str(m.distrib)[:30])
        dbg.info("copyset: %s" % str(list(copyset)))

    __do_check(m)
    __do_check(DetMap.restore(m.store()))

    # small_test
    m = DetMap([(2, 2 * GB), (1, 5 * GB)])
    assert m.mapinfo[0].config[0][0] == 1