Skip to content

Issue when trying to use with, assert, and variables together #68

@Kocal

Description

@Kocal

Hi!

I'm trying to combine the usage of with and assert in order to write a single visit url() block which will be driven by configuration (from the with).

Here is our .blackfire.yaml:

scenarios: |
    #!blackfire-player

    scenario
        name "Performance regression"

        with slug, data in \
            { \
                '/a': { name: 'A', maxWallTime: '1s' }, \
                '/b': { name: 'B', maxWallTime: '2s' }, \
                '/c': { name: 'C', maxWallTime: '3s' }
            }

            visit url(slug)
                samples 3
                warmup true
                name "Checking performance for " ~ data['name']
                expect status_code() == 200
                assert main.wall_time < data["maxWallTime"] * var('time_coeff', 1)
                assert percent(main.wall_time) < 10%

The issue is caused by the usage of data["maxWallTime"].
I've tried different syntaxes but it still fails (with different error message tho):

  1. assert main.wall_time < data["maxWallTime"] * var('time_coeff', 1):
Unexpected characters (maxWallTime"]) at line 3 (near "assertions: ["main.wall_time < data["maxWallTime"] * var('time_coeff', 1)"]") in the request configuration (config_yml)
  1. assert main.wall_time < data['maxWallTime'] * var('time_coeff', 1):
Invalid configuration for path "tests._assertion_2.assertions.0.expression": Variable "data" is not valid around position 18 for expression `main.wall_time < data['maxWallTime'] * var('time_coeff', 1)`. Did you forget to prefix your variable with "main.", "metrics.", "runtime.", or "vars."?
  1. assert main.wall_time < data.maxWallTime * var('time_coeff', 1):
Invalid configuration for path "tests._assertion_2.assertions.0.expression": Variable "data" is not valid around position 18 for expression `main.wall_time < data.maxWallTime * var('time_coeff', 1)`. Did you forget to prefix your variable with "main.", "metrics.", "runtime.", or "vars."?

Does someone know how to make things working?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions