feat(cloud): migrate local execution to provisioning API#5881
Draft
feat(cloud): migrate local execution to provisioning API#5881
Conversation
713ef94 to
8c84009
Compare
4547145 to
973ff6f
Compare
736b946 to
c2cb016
Compare
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.
c2cb016 to
0a7c9d2
Compare
17cf82f to
bc0ed49
Compare
bc0ed49 to
72d9a6c
Compare
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.
77c883d to
73e51f2
Compare
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.
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}.
73e51f2 to
9d2e1cd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WIP — description to follow.