Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions pkgs/mcpx/internal/e2e/effect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ var implementedEffectProbes = map[string]string{
"protoTasks.maxPerRequestor": "TestProtoTasksMaxPerRequestorCapsUnfinishedTasksFromTheEnvironment",
"protoTasks.perMinute": "TestProtoTasksPerMinuteWindowsTaskReadsFromTheEnvironment",
"events.history": "TestEventsHistoryBoundsTheReplay",
"daemon.leaseTTL": "TestDaemonLeaseTTLForgetsASilentCallerFromTheEnvironment",
"elicit.disambiguate": "TestElicitDisambiguateAsksWhichInstanceFromTheEnvironment",
"elicit.disambiguateDefault": "TestElicitDisambiguateDefaultPicksTheRecentInstanceFromTheEnvironment",
"elicit.ttl": "TestElicitTTLSetsAnUpstreamQuestionsDeadlineFromTheEnvironment",
Expand Down Expand Up @@ -281,6 +282,7 @@ var effectProbeFuncs = map[string]func(*testing.T){
"TestProtoTasksMaxPerRequestorCapsUnfinishedTasksFromTheEnvironment": TestProtoTasksMaxPerRequestorCapsUnfinishedTasksFromTheEnvironment,
"TestProtoTasksPerMinuteWindowsTaskReadsFromTheEnvironment": TestProtoTasksPerMinuteWindowsTaskReadsFromTheEnvironment,
"TestEventsHistoryBoundsTheReplay": TestEventsHistoryBoundsTheReplay,
"TestDaemonLeaseTTLForgetsASilentCallerFromTheEnvironment": TestDaemonLeaseTTLForgetsASilentCallerFromTheEnvironment,
"TestElicitDisambiguateAsksWhichInstanceFromTheEnvironment": TestElicitDisambiguateAsksWhichInstanceFromTheEnvironment,
"TestElicitDisambiguateDefaultPicksTheRecentInstanceFromTheEnvironment": TestElicitDisambiguateDefaultPicksTheRecentInstanceFromTheEnvironment,
"TestElicitTTLSetsAnUpstreamQuestionsDeadlineFromTheEnvironment": TestElicitTTLSetsAnUpstreamQuestionsDeadlineFromTheEnvironment,
Expand Down Expand Up @@ -3692,6 +3694,43 @@ func TestElicitDisambiguateDefaultPicksTheRecentInstanceFromTheEnvironment(t *te
}
}

// liveAfterASilentCaller makes one call to a call-scoped demo under a
// fixed caller id that never releases, waits 1.5s with the reaper
// sweeping every 100ms, and returns ls's LIVE column for demo.
func liveAfterASilentCaller(t *testing.T, env ...string) string {
t.Helper()
e := newEnv(t, `{"mcpServers":{"demo":{"command":"FAKE","mcpx":{"sharing":"exclusive","scope":"call","max":4}}}}`)
e.setenv(append([]string{"MCPX_DAEMON_REAP_INTERVAL=100ms"}, env...)...)
e.run("ls")
req, err := http.NewRequest(http.MethodPost, "http://mcpx/v1/call",
strings.NewReader(`{"server":"demo","tool":"echo","args":{"message":"held"}}`))
if err != nil {
t.Fatal(err)
}
req.Header.Set("X-Mcpx-Call", "silent-caller")
resp, err := e.socketClient(t).Do(req)
if err != nil {
t.Fatal(err)
}
_ = resp.Body.Close()
time.Sleep(1500 * time.Millisecond)
return lsDemoRow(t, e.run("ls"))[4]
}

// TestDaemonLeaseTTLForgetsASilentCallerFromTheEnvironment is the effect
// probe for daemon.leaseTTL. A caller that never says it has finished
// keeps its call-scoped instance live under the default 30m retention;
// with daemon.leaseTTL=500ms the lease is forgotten and the reaper
// releases the instance.
func TestDaemonLeaseTTLForgetsASilentCallerFromTheEnvironment(t *testing.T) {
if live := liveAfterASilentCaller(t); live == "0" {
t.Fatal("oracle: under the default lease retention the silent caller's instance should stay live")
}
if live := liveAfterASilentCaller(t, "MCPX_DAEMON_LEASE_TTL=500ms"); live != "0" {
t.Fatalf("with daemon.leaseTTL=500ms the silent caller's instance should be released, LIVE=%s", live)
}
}

// TestDaemonAddressIsReachableFromTheEnvironment is the effect probe
// for daemon.address (#8468 chain 1). The exemption it replaced said
// a bind address is a network identity the harness cannot vary
Expand Down
1 change: 0 additions & 1 deletion pkgs/mcpx/internal/e2e/feature_coverage_exemptions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ cli supervise no integration-test exercise yet; burn-down #8461 (cli daemon grou
cli upgrade no integration-test exercise yet; burn-down #8461 (cli daemon group)
setting daemon.idleExit no integration-test exercise yet; burn-down #8468 (settings daemon family); needs an EffectProbes entry + e2e test
setting daemon.inlineStartPoll no integration-test exercise yet; burn-down #8468 (settings daemon family); needs an EffectProbes entry + e2e test
setting daemon.leaseTTL no integration-test exercise yet; burn-down #8468 (settings daemon family); needs an EffectProbes entry + e2e test
setting daemon.port no integration-test exercise yet; burn-down #8468 (settings daemon family); needs an EffectProbes entry + e2e test
setting daemon.roots no integration-test exercise yet; burn-down #8468 (settings daemon family); needs an EffectProbes entry + e2e test
setting daemon.saveInterval no integration-test exercise yet; burn-down #8468 (settings daemon family); needs an EffectProbes entry + e2e test
Expand Down
Loading