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
40 changes: 40 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.saveInterval": "TestDaemonSaveIntervalWritesTheLeaseTableFromTheEnvironment",
"autostart.pollInterval": "TestAutostartPollIntervalPacesTheReadinessPollFromTheEnvironment",
"daemon.leaseTTL": "TestDaemonLeaseTTLForgetsASilentCallerFromTheEnvironment",
"elicit.disambiguate": "TestElicitDisambiguateAsksWhichInstanceFromTheEnvironment",
Expand Down Expand Up @@ -283,6 +284,7 @@ var effectProbeFuncs = map[string]func(*testing.T){
"TestProtoTasksMaxPerRequestorCapsUnfinishedTasksFromTheEnvironment": TestProtoTasksMaxPerRequestorCapsUnfinishedTasksFromTheEnvironment,
"TestProtoTasksPerMinuteWindowsTaskReadsFromTheEnvironment": TestProtoTasksPerMinuteWindowsTaskReadsFromTheEnvironment,
"TestEventsHistoryBoundsTheReplay": TestEventsHistoryBoundsTheReplay,
"TestDaemonSaveIntervalWritesTheLeaseTableFromTheEnvironment": TestDaemonSaveIntervalWritesTheLeaseTableFromTheEnvironment,
"TestAutostartPollIntervalPacesTheReadinessPollFromTheEnvironment": TestAutostartPollIntervalPacesTheReadinessPollFromTheEnvironment,
"TestDaemonLeaseTTLForgetsASilentCallerFromTheEnvironment": TestDaemonLeaseTTLForgetsASilentCallerFromTheEnvironment,
"TestElicitDisambiguateAsksWhichInstanceFromTheEnvironment": TestElicitDisambiguateAsksWhichInstanceFromTheEnvironment,
Expand Down Expand Up @@ -3760,6 +3762,44 @@ func TestAutostartPollIntervalPacesTheReadinessPollFromTheEnvironment(t *testing
}
}

// leaseSavedWithin makes one call under a fixed caller id and reports
// whether the daemon's sessions.json names that caller 1.5s later,
// while the daemon is still running.
func leaseSavedWithin(t *testing.T, env ...string) bool {
t.Helper()
e := newEnv(t, oneServer)
e.setenv(env...)
e.run("ls")
req, err := http.NewRequest(http.MethodPost, "http://mcpx/v1/call",
strings.NewReader(`{"server":"demo","tool":"echo","args":{"message":"saved"}}`))
if err != nil {
t.Fatal(err)
}
req.Header.Set("X-Mcpx-Call", "periodically-saved-caller")
resp, err := e.socketClient(t).Do(req)
if err != nil {
t.Fatal(err)
}
_ = resp.Body.Close()
time.Sleep(1500 * time.Millisecond)
b, _ := os.ReadFile(filepath.Join(e.dir, "state", "sessions.json"))
return strings.Contains(string(b), "periodically-saved-caller")
}

// TestDaemonSaveIntervalWritesTheLeaseTableFromTheEnvironment is the
// effect probe for daemon.saveInterval. A caller's lease reaches
// sessions.json only when the daemon saves: not within 1.5s under the
// default five-minute interval, and within it at
// daemon.saveInterval=200ms.
func TestDaemonSaveIntervalWritesTheLeaseTableFromTheEnvironment(t *testing.T) {
if leaseSavedWithin(t) {
t.Fatal("oracle: under the default save interval the lease should not be on disk yet")
}
if !leaseSavedWithin(t, "MCPX_DAEMON_SAVE_INTERVAL=200ms") {
t.Fatal("with daemon.saveInterval=200ms the lease should have been saved to sessions.json")
}
}

// 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 @@ -22,7 +22,6 @@ setting daemon.idleExit no integration-test exercise yet; burn-down #8468 (setti
setting daemon.inlineStartPoll 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
setting daemon.socketProbeTimeout no integration-test exercise yet; burn-down #8468 (settings daemon family); needs an EffectProbes entry + e2e test
setting daemon.takeoverTimeout no integration-test exercise yet; burn-down #8468 (settings daemon family); needs an EffectProbes entry + e2e test
setting daemon.tsnet.hostname no integration-test exercise yet; burn-down #8468 (settings daemon family); needs an EffectProbes entry + e2e test
Expand Down
Loading