Пример #1
0
def main():
    user = os.environ['USER']
    subprocess.check_call(
        ['sudo', 'yum', 'install', '-y', 'mz_bench', 'mz_bench_dev'])
    with util.chdir(os.path.join(dirname, '..')):

        if '--local' in sys.argv:
            run_command = ['mz-bench-dev', 'run-local']
        else:
            run_command =\
                ['mz-bench'
                , 'run'
                , '--user_repo=' + user 
                , '--exclusive_node_usage=false'
                ]

        with server.background_server():
            subprocess.check_call(
                run_command +
                [ 'examples/http_post.erl'
                , '--env=host=' + hostname
                , '--env=port=' + str(server.port)
                , '--env=max_rps=2'
                , '--env=endpoint=/update-db'
                ])
            subprocess.check_call(
                run_command +
                [ 'examples/http_get.erl'
                , '--env=host=' + hostname
                , '--env=port=' + str(server.port)
                , '--env=max_rps=2'
                , '--env=endpoint=/index.html'
                ])
Пример #2
0
def main():

    with util.chdir(os.path.join(dirname, '../')):
        serverStatus = checkServer()

        if '--local' in sys.argv:
            if serverStatus == 1:
                print("Please stop MZBench server before running local mode")
                sys.exit()
            run_command = ['../../bin/mzbench', 'run_local']
        else:
            if serverStatus == -1:
                print("Non-MZBench server is listening on 4800")
                sys.exit()
            if serverStatus == 0:
                if 'MZBENCH_REPO' in  os.environ:
                    mzbench_git_param = '{{mzbench_git, "{0}"}}'.format(os.environ['MZBENCH_REPO'])
                else:
                    mzbench_git_param = ''

                with open(dirname + '/mzbench_server.config', 'w') as config:
                    config.write('[{{mzbench_api, [{0}]}}].'.format(mzbench_git_param))

                subprocess.check_call(['../../bin/mzbench', 'start_server', '--config', dirname + '/mzbench_server.config'])

            run_command = ['../../bin/mzbench', 'run']

        with server.background_server():
            subprocess.check_call(
                run_command +
                [ 'examples/http_post.erl'
                , '--env=host=' + hostname
                , '--env=port=' + str(server.port)
                , '--env=max_rps=2'
                , '--env=endpoint=/update-db'
                ])
            subprocess.check_call(
                run_command +
                [ 'examples/http_get.erl'
                , '--env=host=' + hostname
                , '--env=port=' + str(server.port)
                , '--env=max_rps=2'
                , '--env=endpoint=/index.html'
                ])
        if ('--local' not in sys.argv) and (serverStatus == 0):
            subprocess.check_call(['../../bin/mzbench', 'stop_server'])
Пример #3
0
def main():

    with util.chdir(os.path.join(dirname, '../')):
        serverStatus = checkServer()

        if '--local' in sys.argv:
            if serverStatus == 1:
                print("Please stop MZBench server before running local mode")
                sys.exit()
            run_command = ['../../bin/mzbench', 'run_local']
        else:
            if serverStatus == -1:
                print("Non-MZBench server is listening on 4800")
                sys.exit()
            if serverStatus == 0:
                if 'MZBENCH_REPO' in os.environ:
                    mzbench_git_param = '{{mzbench_git, "{0}"}}'.format(
                        os.environ['MZBENCH_REPO'])
                else:
                    mzbench_git_param = ''

                with open(dirname + '/mzbench_server.config', 'w') as config:
                    config.write(
                        '[{{mzbench_api, [{0}]}}].'.format(mzbench_git_param))

                subprocess.check_call([
                    '../../bin/mzbench', 'start_server', '--config',
                    dirname + '/mzbench_server.config'
                ])

            run_command = ['../../bin/mzbench', 'run']

        with server.background_server():
            subprocess.check_call(run_command + [
                'examples/http_post.erl', '--env=host=' +
                hostname, '--env=port=' + str(server.port), '--env=max_rps=2',
                '--env=endpoint=/update-db'
            ])
            subprocess.check_call(run_command + [
                'examples/http_get.erl', '--env=host=' +
                hostname, '--env=port=' + str(server.port), '--env=max_rps=2',
                '--env=endpoint=/index.html'
            ])
        if ('--local' not in sys.argv) and (serverStatus == 0):
            subprocess.check_call(['../../bin/mzbench', 'stop_server'])