Skip to content

feat(cloud): migrate local execution to provisioning API#5881

Draft
ankur22 wants to merge 10 commits intomasterfrom
provisioning-local-exec
Draft

feat(cloud): migrate local execution to provisioning API#5881
ankur22 wants to merge 10 commits intomasterfrom
provisioning-local-exec

Conversation

@ankur22
Copy link
Copy Markdown
Contributor

@ankur22 ankur22 commented Apr 24, 2026

WIP — description to follow.

@ankur22 ankur22 force-pushed the provisioning-local-exec branch from 713ef94 to 8c84009 Compare April 24, 2026 19:53
@ankur22 ankur22 temporarily deployed to azure-trusted-signing April 24, 2026 19:59 — with GitHub Actions Inactive
@ankur22 ankur22 temporarily deployed to azure-trusted-signing April 24, 2026 20:01 — with GitHub Actions Inactive
@ankur22 ankur22 temporarily deployed to azure-trusted-signing April 24, 2026 20:13 — with GitHub Actions Inactive
@ankur22 ankur22 force-pushed the provisioning-local-exec branch from 4547145 to 973ff6f Compare April 24, 2026 20:14
@ankur22 ankur22 temporarily deployed to azure-trusted-signing April 24, 2026 20:20 — with GitHub Actions Inactive
@ankur22 ankur22 temporarily deployed to azure-trusted-signing April 24, 2026 20:22 — with GitHub Actions Inactive
@ankur22 ankur22 temporarily deployed to azure-trusted-signing April 24, 2026 20:46 — with GitHub Actions Inactive
@ankur22 ankur22 temporarily deployed to azure-trusted-signing April 24, 2026 20:48 — with GitHub Actions Inactive
@ankur22 ankur22 force-pushed the provisioning-local-exec branch from 736b946 to c2cb016 Compare April 24, 2026 20:57
@ankur22 ankur22 temporarily deployed to azure-trusted-signing April 24, 2026 21:03 — with GitHub Actions Inactive
@ankur22 ankur22 temporarily deployed to azure-trusted-signing April 24, 2026 21:04 — with GitHub Actions Inactive
Creates a load test by name only (no script/archive) via
POST /cloud/v6/projects/{id}/load_tests. On 409 conflict,
falls back to find the existing test by name.

First step of the new provisioning local-execution flow:
obtain a load_test_id before start_local_execution.
@ankur22 ankur22 force-pushed the provisioning-local-exec branch from c2cb016 to 0a7c9d2 Compare April 24, 2026 21:10
@ankur22 ankur22 temporarily deployed to azure-trusted-signing April 24, 2026 21:16 — with GitHub Actions Inactive
@ankur22 ankur22 temporarily deployed to azure-trusted-signing April 24, 2026 21:19 — with GitHub Actions Inactive
@ankur22 ankur22 temporarily deployed to azure-trusted-signing April 24, 2026 22:45 — with GitHub Actions Inactive
@ankur22 ankur22 temporarily deployed to azure-trusted-signing April 24, 2026 22:47 — with GitHub Actions Inactive
@ankur22 ankur22 force-pushed the provisioning-local-exec branch from 17cf82f to bc0ed49 Compare April 24, 2026 22:55
@ankur22 ankur22 temporarily deployed to azure-trusted-signing April 24, 2026 23:01 — with GitHub Actions Inactive
@ankur22 ankur22 temporarily deployed to azure-trusted-signing April 24, 2026 23:03 — with GitHub Actions Inactive
@ankur22 ankur22 force-pushed the provisioning-local-exec branch from bc0ed49 to 72d9a6c Compare April 24, 2026 23:04
@ankur22 ankur22 temporarily deployed to azure-trusted-signing April 24, 2026 23:10 — with GitHub Actions Inactive
@ankur22 ankur22 temporarily deployed to azure-trusted-signing April 24, 2026 23:12 — with GitHub Actions Inactive
@ankur22 ankur22 temporarily deployed to azure-trusted-signing April 24, 2026 23:28 — with GitHub Actions Inactive
@ankur22 ankur22 temporarily deployed to azure-trusted-signing April 24, 2026 23:30 — with GitHub Actions Inactive
ankur22 added 2 commits April 25, 2026 00:33
Hand-written HTTP POST to /provisioning/v1/load_tests/{id}/
start_local_execution with Bearer auth and idempotency key.
Adds request/response types (RuntimeConfig, MetricsRuntimeConfig,
TracesRuntimeConfig, etc.) and retry on 5xx errors.
Serializes a lib.Archive to bytes.Buffer once, then PUTs the
buffer to the given presigned URL with Content-Type:
application/octet-stream. No Authorization header is set
(presigned URL embeds credentials). Returns serialized size.
@ankur22 ankur22 force-pushed the provisioning-local-exec branch from 77c883d to 73e51f2 Compare April 24, 2026 23:39
Polls GET /cloud/v6/test_runs/{id} every 2s until the run leaves
pre-run states. Waits on {created, queued, initializing}; fails
on aborted (includes status history message); warns-and-proceeds
on unexpected {processing_metrics, completed}; logs a status line
on each state transition (wait states only).
Poll interval is a parameter so tests can run fast.
ankur22 added 6 commits April 25, 2026 00:43
Change newMetricsClient to accept an explicit pushURL and
testRunToken. When pushURL is non-empty it is used verbatim,
bypassing the /v1 trim. When testRunToken is non-empty the
metrics push sets Authorization: Bearer {token}; prepareHeaders
guards against clobbering a pre-set Authorization header.

Empty pushURL/testRunToken preserves the existing behavior
for the PushRefID code path.
Add POST /provisioning/v1/test_runs/{id}/notify call with Bearer
auth and retry-on-5xx (3×500ms). mapTestErrorToNotification maps
errext abort reasons to numeric error codes.
Orchestrates the 4-step local execution provisioning flow:
create-or-find load test, start_local_execution, optional S3
archive upload + poll for ready. Archive is pre-serialised to
obtain the byte-length for the start_local_execution body.
NotifyTestRunCompleted is the caller's responsibility.
Replace v1 CreateTestRun in Output.Start (k6 run --out cloud)
with ProvisionLocalExecution. PushRefID/testRunID paths are
preserved unchanged. testFinished uses NotifyTestRunCompleted
via v6Client when provisioning path was taken; falls back to
v1 TestFinished otherwise.
Replace v1 CreateTestRun with ProvisionLocalExecution in Path A
(k6 cloud run --local-execution). Stack ID is now required (hard
error instead of deprecation warning). Test run ID stored as
strconv.FormatInt; MetricsPushURL and TestRunToken propagated
from RuntimeConfig into Collectors[cloud] config.
Add TestCloudRunLocalExecutionProvisioning_DefaultArchiveUpload
(header assertions: Bearer auth, X-Stack-Id, no auth on S3 PUT,
scoped metrics token, no v1 calls) and _NameConflict409 (409
fallback to GET by name). Add TestRunOutCloudProvisioning for
Path B (k6 run --out cloud). Extend v6test.Config with
ConflictOnCreateLoadTest, ArchiveUploadEnabled, InspectRequest.

Fix Output.Start() to create a v6 client when testRunID is
externally pre-set and StackID is valid, so testFinished() uses
NotifyTestRunCompleted instead of legacy POST /v1/tests/{id}.
@ankur22 ankur22 force-pushed the provisioning-local-exec branch from 73e51f2 to 9d2e1cd Compare April 24, 2026 23:44
@ankur22 ankur22 temporarily deployed to azure-trusted-signing April 24, 2026 23:50 — with GitHub Actions Inactive
@ankur22 ankur22 temporarily deployed to azure-trusted-signing April 24, 2026 23:52 — with GitHub Actions Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant