Esempio n. 1
0
def test():
    """
    Test Redis server, using scenario from POST request.
    """
    if request.method == 'GET':
        return redirect(url_for('home'))

    scenario_type = request.form.get('scenario_type')
    scenario = request.form.get('scenario')

    if not scenario or not scenario_type:
        return render_template('test.html', error='required_field')

    if scenario_type == 'redis':
        try:
            scenario = convert_scenario(scenario)
        except ValueError as e:
            return render_template('test.html', error='convert', exception=e)

    try:
        results = run_scenario(redis, scenario)
    except Exception as e:
        return render_template('test.html', error='exception', exception=e)

    context = {
        'results': results,
        'scenario': scenario,
        'scenario_type': scenario_type,
    }

    return render_template('test.html', **context)
Esempio n. 2
0
def home():
    """
    Show basic information about server and add form to test server.
    """
    context = {
        'info': redis.info(),
        'scenario_python': convert_scenario(SCENARIO),
        'scenario_redis': SCENARIO,
    }

    return render_template('index.html', **context)
Esempio n. 3
0
def home():
    """
    Show basic information about server and add form to test server.
    """
    instance = redis_instance(request.args.get('server', ''))

    context = {
        'info': instance.info(),
        'scenario_python': convert_scenario(SCENARIO),
        'scenario_redis': SCENARIO,
        'server': instance.server,
    }

    return render_template('index.html', **context)
Esempio n. 4
0
def home():
    """
    Show basic information about server and add form to test server.
    """
    instance = redis_instance(request.args.get('server', ''))

    context = {
        'info': instance.info(),
        'scenario_python': convert_scenario(SCENARIO),
        'scenario_redis': SCENARIO,
        'server': instance.server,
    }

    return render_template('index.html', **context)
Esempio n. 5
0
def test():
    """
    Test Redis server, using scenario from POST request.
    """
    if request.method == 'GET':
        return redirect(url_for('home'))

    instance = redis_instance(request.form.get('server', ''))
    scenario_type = request.form.get('scenario_type')
    scenario = request.form.get('scenario')

    if not scenario or not scenario_type:
        return render_template('test.html', error='required_field')

    if scenario_type == 'redis':
        try:
            scenario = convert_scenario(scenario)
        except ValueError as e:
            return render_template('test.html', error='convert', exception=e)

    try:
        results = run_scenario(instance, scenario)
    except Exception as e:
        kwargs = {
            'error': 'exception',
            'exception': e,
            'traceback': traceback.format_exc()
        }
        return render_template('test.html', **kwargs)

    context = {
        'results': results,
        'scenario': scenario,
        'scenario_type': scenario_type,
        'server': instance.server,
    }

    return render_template('test.html', **context)
Esempio n. 6
0
def test():
    """
    Test Redis server, using scenario from POST request.
    """
    if request.method == 'GET':
        return redirect(url_for('home'))

    instance = redis_instance(request.form.get('server', ''))
    scenario_type = request.form.get('scenario_type')
    scenario = request.form.get('scenario')

    if not scenario or not scenario_type:
        return render_template('test.html', error='required_field')

    if scenario_type == 'redis':
        try:
            scenario = convert_scenario(scenario)
        except ValueError as e:
            return render_template('test.html', error='convert', exception=e)

    try:
        results = run_scenario(instance, scenario)
    except Exception as e:
        kwargs = {'error': 'exception',
                  'exception': e,
                  'traceback': traceback.format_exc()}
        return render_template('test.html', **kwargs)

    context = {
        'results': results,
        'scenario': scenario,
        'scenario_type': scenario_type,
        'server': instance.server,
    }

    return render_template('test.html', **context)