示例#1
0
文件: dev.py 项目: DarumasLegs/alba
    def _inner():
        alba.demo_kill()
        alba.demo_setup()
        cmd = [
            env['alba_bin'],
            'create-preset', 'preset_no_compression',
            '--config', arakoon_config_file,

        ]
        tls = env['alba_tls']
        if is_true(tls):
            alba._extend_alba_tls(cmd)

        cmd.append('< ./cfg/preset_no_compression.json')
        # create the preset in albamgr
        local(" ".join(cmd))

        cmd = [
            env['alba_bin'],
            'create-namespace', 'big', 'preset_no_compression',
            '--config', arakoon_config_file
        ]
        if is_true(tls):
            alba._extend_alba_tls(cmd)
        # create new namespace with this preset
        local(" ".join(cmd))

        object_file = "%s/obj" % ALBA_BASE_PATH
        # upload a big object
        local("truncate -s 2G %s" % object_file)
        local(" ".join([
            'time', env['alba_bin'],
            'proxy-upload-object',
            "-h 127.0.0.1 ",
            'big', object_file, 'bigobj'
        ]))
        # note this may fail with NoSatisfiablePolicy from time to time

        local(" ".join([
            'time', env['alba_bin'],
            'proxy-download-object',
            "-h 127.0.0.1 ",
            'big', 'bigobj', '%s/obj_download' % ALBA_BASE_PATH
        ]))
        local("rm %s/obj_download" % ALBA_BASE_PATH)

        # policy says we can lose a node,
        # so stop and decommission osd 0 to 3
        for i in range(0,4):
            port = alba.get_osd_port(i)
            alba.osd_stop(port)
            long_id = "%i_%i_%s" % (port, 2000, alba.local_nodeid_prefix)
            cmd = [
                env['alba_bin'],
                'decommission-osd', '--long-id', long_id,
                '--config', arakoon_config_file
            ]
            if is_true(tls):
                alba._extend_alba_tls(cmd)
            local(" ".join(cmd))
示例#2
0
文件: dev.py 项目: DarumasLegs/alba
def run_tests_voldrv_tests(xml=False, kind = default_kind, dump = None):
    alba.demo_kill()
    alba.demo_setup(kind)
    time.sleep(1)
    where = local
    cmd = "%s --skip-backend-setup 1 --backend-config-file ./cfg/backend.json --gtest_filter=SimpleVolumeTests/SimpleVolumeTest* --loglevel=error" % env['voldrv_tests']
    if xml:
        cmd = cmd + " --gtest_output=xml:gtestresults.xml"
    if dump:
        cmd = cmd + " 2> %s" % dump # in this case, we need sterr
    where(cmd)
示例#3
0
文件: dev.py 项目: DarumasLegs/alba
def run_test_asd_start(xml=False):
    alba.demo_kill()
    alba.demo_setup()

    object_location = "%s/obj" % ALBA_BASE_PATH
    local("dd if=/dev/urandom of=%s bs=1M count=1" % object_location)

    for i in xrange(0, 1000):
        cmd = [
            env['alba_bin'],
            'proxy-upload-object',
            "-h 127.0.0.1 ",
            'demo', object_location,
            str(i)
        ]
        local(" ".join(cmd))

    for i in xrange(0, N):
        alba.osd_stop(alba.get_osd_port(i))

    alba.start_osds(default_kind, N, True, restart = True)
    time.sleep(2)

    cmd = [
        env['alba_bin'],
        'proxy-upload-object',
        "-h 127.0.0.1 ",
        'demo', object_location,
        "fdskii", "--allow-overwrite"
    ]
    with warn_only():
        # this clears the borked connections from the
        # asd connection pools
        local(" ".join(cmd))
        local(" ".join(cmd))
        local(" ".join(cmd))
        time.sleep(2)
        local(" ".join(cmd))

    r = local(" ".join(cmd))
    print r

    local(" ".join([
        env['alba_bin'],
        'proxy-download-object',
        "-h 127.0.0.1 ",
        'demo', '1', '%s/obj2' % ALBA_BASE_PATH
    ]))

    alba.smoke_test()

    if xml:
        alba.dump_junit_xml()
示例#4
0
文件: dev.py 项目: DarumasLegs/alba
def run_tests_stress(kind = default_kind, xml = False):
    alba.demo_kill()
    alba.demo_setup(kind = kind)
    time.sleep(1)
    where = local
    #
    n = 3000
    def build_cmd(command):
        cmd = [
        env['alba_bin'],
            command
        ]
        return cmd

    def create_namespace_cmd(name):
        cmd = build_cmd('proxy-create-namespace')
        cmd.append(name)
        cmd.append("-h 127.0.0.1 ")
        cmd_s = ' '.join(cmd)
        return cmd_s

    def list_namespaces_cmd():
        cmd = build_cmd('list-namespaces')
        tls = env['alba_tls']
        if is_true(tls):
            alba._extend_alba_tls(cmd)

        cmd.append('--to-json')
        cmd.append('2> /dev/null')
        cmd_s = ' '.join(cmd)
        return cmd_s

    template = "%20i"

    for i in xrange(n):
        name = template % i
        cmd_s = create_namespace_cmd(name)
        where (cmd_s)
    # they exist?
    v = where(list_namespaces_cmd(),
              capture = True)
    parsed = json.loads(v)
    print parsed
    assert parsed["success"] == True
    ns = parsed["result"]
    print len(ns)
    assert (len(ns) == n+1)

    if xml:
        alba.dump_junit_xml()
示例#5
0
文件: dev.py 项目: DarumasLegs/alba
    def fresh():
        alba.demo_kill()
        alba.demo_setup()

        # deliver osd & nsm messages
        time.sleep(1)
        cmd = [
            env['alba_bin'],
            'deliver-messages',
            '--config', arakoon_config_file
        ]
        local(' '.join(cmd))

        # stop asd 0
        alba.osd_stop(alba.get_osd_port(0))
示例#6
0
文件: dev.py 项目: DarumasLegs/alba
def run_tests_disk_failures(xml=False):
    alba.demo_kill()
    alba.demo_setup()
    time.sleep(1)
    where = local
    cmd = [env['failure_tester']]
    if xml:
        cmd.append(" --xml=true")

    tls = env['alba_tls']
    if is_true(tls):
        alba._extend_alba_tls(cmd)

    cmd_s = " ".join(cmd)
    where(cmd_s)
示例#7
0
文件: dev.py 项目: DarumasLegs/alba
def run_tests_voldrv_backend(xml=False, kind = default_kind,
                             filter = None, dump = None):
    alba.demo_kill()
    alba.demo_setup(kind)
    time.sleep(1)
    where = local
    cmd0 = ""
    #cmd0 = "valgrind -v --track-origins=yes --leak-check=full --leak-resolution=high "
    cmd = cmd0 + "%s --skip-backend-setup 1 --backend-config-file ./cfg/backend.json" % env['voldrv_backend_test']
    if filter:
        cmd = cmd + " --gtest_filter=%s" % filter
    if xml:
        cmd = cmd + " --gtest_output=xml:gtestresults.xml"
    if dump:
        cmd = cmd + " > %s 2>&1" % dump
    where(cmd)
示例#8
0
文件: dev.py 项目: DarumasLegs/alba
    def _inner():
        alba.demo_kill ()
        alba.demo_setup(acf = arakoon_config_file_2)
        # 2 node cluster, and arakoon_0 will be master.
        def stop_node(node_name):
            r = local("pgrep -a arakoon | grep '%s'" % node_name, capture = True)
            info = r.split()
            pid = info[0]
            local("kill %s" % pid)

        def start_node(node_name, cfg):
            inner = [
                env['arakoon_bin'],
                "--node", node_name,
                "-config", cfg
            ]
            cmd_line = alba._detach(inner)
            local(cmd_line)

        def upload_albamgr_cfg(cfg):
            local(' '.join([
                env['alba_bin'], 'update-abm-client-config',
                '--attempts', '5',
                '--config', cfg
            ]))

        def signal_alba(process_name,signal):
            r = local("pgrep -a alba | grep %s" % process_name, capture = True)
            info = r.split()
            pid = info[0]
            local("kill -s %s %s" % (signal, pid))

        def wait_for(delay):
            n = int(delay)
            print "sleeping %i" % n
            while n:
                print "\t%i" % n
                time.sleep(1)
                n = n - 1

        # 2 node cluster, and arakoon_0 is master.
        wait_for(10)
        # expand the cluster
        stop_node('arakoon_0')
        stop_node('witness_0')
        # restart them with other config

        start_node('arakoon_1', arakoon_config_file)
        start_node('witness_0', arakoon_config_file)

        wait_for(20)
        start_node('arakoon_0', arakoon_config_file)

        maintenance_home = "%s/maintenance" % ALBA_BASE_PATH
        maintenance_cfg = maintenance_home + "/albamgr.cfg"
        local("cp %s %s" % (arakoon_config_file, maintenance_cfg))
        signal_alba('maintenance', 'USR1')
        wait_for(120)
        cfg_s = local("%s proxy-client-cfg | grep port | wc" % env['alba_bin'], capture=True)
        c = cfg_s.split()[0]
        assert (c == '3') # 3 nodes in config

        # shrink the cluster
        stop_node('arakoon_0')
        stop_node('arakoon_1')
        stop_node('witness_0')

        start_node('arakoon_0', arakoon_config_file_2)
        start_node('witness_0', arakoon_config_file_2)

        local("cp %s %s" % (arakoon_config_file_2, maintenance_cfg))
        upload_albamgr_cfg(arakoon_config_file_2)
        wait_for(120)
        cfg_s = local("%s proxy-client-cfg | grep port | wc" % env['alba_bin'], capture=True)
        c = cfg_s.split()[0]
        assert (c == '2') # 2 nodes in config
示例#9
0
文件: dev.py 项目: DarumasLegs/alba
def setup_demo_alba(kind = default_kind):
    alba.demo_kill()
    alba.demo_setup()
示例#10
0
文件: dev.py 项目: DarumasLegs/alba
def run_tests_cli():
    alba.demo_kill()
    alba.demo_setup()
    tls = env['alba_tls']
    port = '8501' if is_true(tls) else '8001'
    host = '127.0.0.1'
    where = local

    def _asd( what, extra, tls = tls):
        cmd = [env['alba_bin'],
               what,
               '-h', host,
               '-p', port]
        cmd.extend(extra)
        if is_true(tls):
            alba._extend_alba_tls(cmd)
        return cmd

    def _rough_compare_string(x,y):
        if x.find(y) < 0:
            msg = "expected %s to contain '%s'" % (v_s,v)
            print msg
            raise Exception(msg)

    def _run(cmd):
        cmd_line = ' '.join(cmd)
        result = where(cmd_line, capture = True)
        return result

    def test_asd_get_version():
        cmd = _asd('asd-get-version', [] )
        result = _run(cmd)
        t = eval(result)
        print t
        assert (len(t) == 4)
        print "ok"

    def test_asd_get_statistics():
        cmd = _asd('asd-statistics',['--to-json'])
        result = _run(cmd)
        t = json.loads(result)

    def test_asd_crud():
        k = 'the_key'
        v = 'the_value'
        asd_set = _asd('asd-set', [k,v])
        _run(asd_set)

        asd_get = _asd('asd-multi-get',[k])
        v_s = _run(asd_get)
        _rough_compare_string(v_s,v)

        asd_delete = _asd('asd-delete',[k])
        _run(asd_delete)
        v_s2 = _run(asd_get)
        print v_s2
        assert (v_s2 == '[None]')

    def test_asd_cli_env():
        print "test_asd_cli_env"
        if is_true(env['alba_tls']):
            cmd = _asd('asd-get-version', [], tls = False)
            x = alba._my_client_tls()
            with shell_env(ALBA_CLI_TLS='%s,%s,%s' % x):
                cmd_line = ' ' . join(cmd)
                result = where(cmd_line, capture=True)
                print result

    def create_example_preset():
        cmd = [ env['alba_bin'],
                'create-preset', 'example',
                '--config', './cfg/albamgr_example_arakoon_cfg.ini',
                '< cfg/preset.json'
        ]
        tls = env['arakoon_tls']

        if is_true(tls):
            _extend_alba_tls(cmd)

        cmd_line = ' '.join(cmd)
        local (cmd_line)

    suite_name = "run_tests_cli"
    results = []
    tests = [
        ("asd_get_version", test_asd_get_version),
        ("asd_cli_env", test_asd_cli_env),
        ("asd_get_statistics", test_asd_get_statistics),
        ("asd_crud", test_asd_crud)
    ]

    for test_name, test  in tests:
        r = timed_test(test_name,test)
        results.append(r)
    return "cli", results


    test_asd_crud()