Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor browser options #876

Merged
merged 22 commits into from
May 18, 2023
Merged

Refactor browser options #876

merged 22 commits into from
May 18, 2023

Commits on May 18, 2023

  1. Rename LaunchOptions to BrowserOptions

    LaunchOptions struct serves also for browser options when using connect
    method, therefore it makes sense to rename it to a more generic naming
    that defines its purpose.
    
    Co-authored-by: ankur22 <ankur.agarwal@grafana.com>
    ka3de and ankur22 committed May 18, 2023
    Configuration menu
    Copy the full SHA
    b6e94cc View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    5b9f567 View commit details
    Browse the repository at this point in the history
  3. Upgrade k6 version

    ka3de committed May 18, 2023
    Configuration menu
    Copy the full SHA
    a320ea1 View commit details
    Browse the repository at this point in the history
  4. Move IsRemoteBrowser to new env package

    A new env package is a better fit for the current implementation of
    IsRemoteBrowser than the k6ext package. In this new env package we can
    define a lookupper function type to be used across the rest of the
    codebase as a reference for environment variables lookup functions.
    ka3de committed May 18, 2023
    Configuration menu
    Copy the full SHA
    1456191 View commit details
    Browse the repository at this point in the history
  5. Export env.LookupFunc

    This will allow to have a common environment variable lookupper function
    definition across the codebase.
    
    Co-authored-by: İnanç Gümüş <inanc.gumus@grafana.com>
    ka3de and inancgumus committed May 18, 2023
    Configuration menu
    Copy the full SHA
    2a953fc View commit details
    Browse the repository at this point in the history
  6. Add k6ext.GetScenarioOpts

    This function allows to retrieve the scenario options associated with
    the given VU context. It is required in order to validate the browser
    options defined at the scenario.options.browser level.
    ka3de committed May 18, 2023
    Configuration menu
    Copy the full SHA
    33a765c View commit details
    Browse the repository at this point in the history
  7. Refactor test browser args option

    Change its type from []any to []string to match the actual browser
    options struct. There is no need for it to be a slice of 'any'. Making
    it a string slice will also ease the set up as environment variable
    moving browser options to be parsed from ENV.
    ka3de committed May 18, 2023
    Configuration menu
    Copy the full SHA
    359028b View commit details
    Browse the repository at this point in the history
  8. Move options parsing methods to browser_options.go

    These methods are only used in the browser options parsing method,
    therefore, by now, it makes more sense to keep them in the same file
    instead than in a separate generic options implementation.
    ka3de committed May 18, 2023
    Configuration menu
    Copy the full SHA
    bdee6e2 View commit details
    Browse the repository at this point in the history
  9. Do not expose browser opts through Goja

    Avoid reading browser options defined at the JS layer for
    BrowserType.Launch and BrowserType.Connect methods. These options will
    be parsed from scenario options and environment variables.
    ka3de committed May 18, 2023
    Configuration menu
    Copy the full SHA
    e8e8157 View commit details
    Browse the repository at this point in the history
  10. Read browser options from scenario options

    This commit changes the way browser options are currently parsed in
    order to read them browser options field defined at the scenario level
    and also from environment variables.
    ka3de committed May 18, 2023
    Configuration menu
    Copy the full SHA
    7982241 View commit details
    Browse the repository at this point in the history
  11. Add unit test for browser type option

    The unit test should verify that any browser type set with a value
    different than 'chromium', currently the only supported browser type,
    returns an error. No browser type set also returns an error as this
    field is now mandatory.
    ka3de committed May 18, 2023
    Configuration menu
    Copy the full SHA
    9a1ddbf View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    ab5d5a7 View commit details
    Browse the repository at this point in the history
  13. Add envLookupper to BrowserType

    This allows to define a default env.Lookupper function at the
    BrowserType level, which will be the one passed into browser options
    parsing function, and that can be overwritten from tests (e.g.: test
    browser) in order to be able to run tests that depend on environment
    browser options in parallel.
    ka3de committed May 18, 2023
    Configuration menu
    Copy the full SHA
    c0360c9 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    f1c9309 View commit details
    Browse the repository at this point in the history
  15. Add test scenario config to mock VU

    Because browser type option is now a mandatory field to be able to run
    k6 browser tests, we have to modify our mock VU implementation in order
    to add this field. This is done through the definition of a default
    scenario and a mock executor implementation for testing purposes.
    ka3de committed May 18, 2023
    Configuration menu
    Copy the full SHA
    b7619d7 View commit details
    Browse the repository at this point in the history
  16. Fix testbrowser custom ctx does not wrap VU state

    Test browser had support for withContext option, which allowed to pass a
    custom context to test browser, which would be the one set as VU
    context. Usually this context was used in order to control from the test
    the cancellation of the test browser.
    The problem is that this context passed from the test implementation,
    was "divergent" from the test runtime context set up when calling
    setupHTTPTestModuleInstance() from test browser, which sets up all the
    VU related mock data, including the mandatory browser type field inside
    scenario options. Because this option is not mandatory, tests that were
    using a custom context were failing due to scenario options not being
    present in this context.
    
    This has been fixed by not allowing custom contexts to be set for test
    browser, and instead expose this component's context and context
    cancelling function so they can be handled from tests implementation.
    
    This commit also fixes the tests affected by this issue.
    ka3de committed May 18, 2023
    Configuration menu
    Copy the full SHA
    dae4788 View commit details
    Browse the repository at this point in the history
  17. Do not expose browser slowMo option

    Based on #857, a decision
    was made to not expose slowMo browser option by now, and try to move it
    to the browser context level instead, which will provide more
    flexibility.
    ka3de committed May 18, 2023
    Configuration menu
    Copy the full SHA
    b812369 View commit details
    Browse the repository at this point in the history
  18. Update examples

    Modify JS examples removing browser options that now should be set as
    ENV variables and setting browser type option inside scenario options,
    which is now a mandatory field for any browser test.
    Also browser_args.js example is removed as it does not provide any value
    beyond showing how to set a browser arg in the previous implementation;
    and evaluate.js is modified in order to showcase 'evaluate' method
    functionality without requiring the usage of 'ignoreBrowserArgs' option.
    ka3de committed May 18, 2023
    Configuration menu
    Copy the full SHA
    185bd18 View commit details
    Browse the repository at this point in the history
  19. Add tests package godoc

    ka3de committed May 18, 2023
    Configuration menu
    Copy the full SHA
    64407fc View commit details
    Browse the repository at this point in the history
  20. Add common package godoc

    ka3de committed May 18, 2023
    Configuration menu
    Copy the full SHA
    e827f38 View commit details
    Browse the repository at this point in the history
  21. Add k6test package godoc

    ka3de committed May 18, 2023
    Configuration menu
    Copy the full SHA
    25346e2 View commit details
    Browse the repository at this point in the history
  22. Tidy up dependencies

    ka3de committed May 18, 2023
    Configuration menu
    Copy the full SHA
    a6b5b60 View commit details
    Browse the repository at this point in the history