Add context-aware connection tests, spec events, and workbench env config - #815
Merged
Merged
Conversation
- Replace the global SpecEventChn with a typed SpecEvent sent through the request context, so each spec test run is isolated, cancellable, and reports the request index plus iteration state before and after each request. Legacy wire fields stay for released spec inspectors. - Add Connection.TestWithOptions and ConnEntries.TestWithOptions (endpoints, limit, max requests, context, trace, OnEvent) plus a spec-file overlay that tests a draft spec without mutating the connection entry. Test() still reads the SLING_TEST_* env vars, so the CLI is unchanged. - Emit error events and return context.Canceled promptly on cancellation instead of reporting success. - Add the workbench block to env.yaml, run `sling serve workbench --no-browser` as a brew service, and cover the command with CLI smoke tests.
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.
Problem
sling conns testcan only be configured through process-wideSLING_TEST_*env vars, and spec test events go to a package-global channel (api.SpecEventChn). Two tests running at once share one channel, a test cannot be cancelled, and a server (the workbench) has no way to pass per-run options, receive structured events, or stop a run. There is also no way to test a connection against an edited spec without saving it, and no place inenv.yamlto configuresling serve workbench.Solution
ELI5: instead of settings shouted through global env vars and one global megaphone, every test run now carries its own settings and its own private callback, handed over through the context. Runs can overlap, each can be stopped, and each reports its own progress. A run can also point at a draft spec just for that run, and
env.yamlcan hold workbench settings.Details:
api.SpecEventand typed event constants (endpoint-start,request-complete,records,endpoint-done,error) replace themap[string]anyglobal channel.WithSpecEventHandler/fireSpecEventcarry the handler on the request context, so events are per-run and cancellation propagates. Legacy JSON fields (req_id,timestamp,iter_id,iter_sequence,size_bytes,record_count) are kept for released spec inspectors.request-completeevents now includerequest_index,state_beforeandstate_after(iteration state read underiter.context), plus each request's records.Connection.TestWithOptions(ctx, TestOptions)andConnEntries.TestWithOptions(ctx, name, opts)add endpoints, limit, max requests, context, spec file, trace andOnEvent.Test()keeps its signature and builds its options fromSLING_TEST_*, so the CLI is unchanged.TestOptions.SpecFileoverlays a spec on a copy of the connection entry for one run; the original entries stay untouched.context.Canceledinstead of success, and stops before the next endpoint.env.yamlgains a managedworkbench:block (WorkbenchConfig: host, port, token, projects_root, shell, worker_idle, path_extra, env); command-line flags win over the file.sling serve workbench --no-browser.Testing
core/dbio/connection/connection_test.go: event sequence and payloads (request index, state before/after, legacy wire fields), error event, env-driven test, spec-file overlay, and cancellation via context.tests/suite.cli.yamlcases 620 and 621: workbench--helpoutput, plus a smoke test that starts the server on a free port, checks/healthzreturnsok, and stops it.