Skip to content

PLZ: refine env vars and add new CLI arguments #742

@yorugac

Description

@yorugac

Feature Description

Current definition and capabilities of PLZ test runs are minimal in comparison to public GCk6 tests. We're going to polish it a bit, so that PLZ becomes more similar to other kinds of tests. Specifically:

  1. The .spec.arguments definition should be expanded with some additional flags to k6 CLI: --no-summary, --verbose (TODO: clarify this one)
  2. User-defined env vars must be passed with -e CLI flag
  3. The call to /loadtests/v4/test_runs(%s)?$select=id,run_status,k8s_load_zones_config,k6_runtime_config must also include ,load_zone_distribution and the format of expected response is now this:
    {
      "k8s_load_zones_config": {
        "instance_count": <int>,
        "k6_archive_temp_public_url": <str>,
        "load_runner_image": <str>,
    
        "environment": <map>, # user-defined
    
        "cli_flags": { # user-defined
          "tags": <map>,
          "user_agent": <str>,
          "blacklist_ips": [<str>], 
          "blocked_hostnames": [<str>],
          "include_system_env_variables": bool,
        },
        "gck6_env_vars": { # defined by GCk6
          "K6_CLOUD_TOKEN": "token",
          "K6_LOG_OUTPUT": "value", 
        },
      },
      load_zone_distribution: {
            "label": {"loadZone": <str>, "percent": <int>}
      }
  4. cli_flags must all be passed to the .spec.arguments as k6 tags, --user-agent, --blacklist-ip and --block-hostnames CLI args respectively.
  5. gck6_env_vars must be set as env vars for the runner
    • NOTE: K6_LOG_OUTPUT format is pending; we need to ensure we don't have a degradation here.
  6. As described here, we need to set 4 additional env vars as part of user-defined env vars, via -e tag.
    • three of them can be set as part of .spec.arguments: K6_CLOUDRUN_LOAD_ZONE (taken from distribution field), K6_CLOUDRUN_DISTRIBUTION (also from distribution field?), K6_CLOUDRUN_TEST_RUN_ID.
      • Additionally pass load zone value as "load_zone" tag to .spec.arguments.
    • the 4th env var, K6_CLOUDRUN_INSTANCE_ID must be set at the level of k6 runner definition, because its value is not known until then. Consider the best implementation there + potential refactoring.
    • Theses vars must be added on top of user-defined env vars: they have higher priority and should overwrite the values from the user if any.

Major change: K6_CLOUD_TOKEN added in the endpoint brings a new type of token to a PLZ - a test run specific token.

Suggested Solution (optional)

Most is self-explanatory. But as mentioned, there might also be small ways to improve / refactor some bits of code on the way.

Additionally, change with the token must be confirmed to be non-breaking for PLZ, as there wasn't a hard guarantee of it being non-breaking from GCk6 side.

Already existing or connected issues / PRs (optional)

No response

Metadata

Metadata

Assignees

Labels

GCk6pertaining to cloud test runs and communication between k6-operator and GCk6PLZenhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions