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
38 changes: 38 additions & 0 deletions pkgs/mcpx/internal/e2e/effect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"os/exec"
"path/filepath"
"sort"
"strconv"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -101,6 +102,7 @@ var implementedEffectProbes = map[string]string{
"protoTasks.maxPerRequestor": "TestProtoTasksMaxPerRequestorCapsUnfinishedTasksFromTheEnvironment",
"protoTasks.perMinute": "TestProtoTasksPerMinuteWindowsTaskReadsFromTheEnvironment",
"events.history": "TestEventsHistoryBoundsTheReplay",
"daemon.port": "TestDaemonPortBindsTheChosenPortFromTheEnvironment",
"daemon.saveInterval": "TestDaemonSaveIntervalWritesTheLeaseTableFromTheEnvironment",
"autostart.pollInterval": "TestAutostartPollIntervalPacesTheReadinessPollFromTheEnvironment",
"daemon.leaseTTL": "TestDaemonLeaseTTLForgetsASilentCallerFromTheEnvironment",
Expand Down Expand Up @@ -284,6 +286,7 @@ var effectProbeFuncs = map[string]func(*testing.T){
"TestProtoTasksMaxPerRequestorCapsUnfinishedTasksFromTheEnvironment": TestProtoTasksMaxPerRequestorCapsUnfinishedTasksFromTheEnvironment,
"TestProtoTasksPerMinuteWindowsTaskReadsFromTheEnvironment": TestProtoTasksPerMinuteWindowsTaskReadsFromTheEnvironment,
"TestEventsHistoryBoundsTheReplay": TestEventsHistoryBoundsTheReplay,
"TestDaemonPortBindsTheChosenPortFromTheEnvironment": TestDaemonPortBindsTheChosenPortFromTheEnvironment,
"TestDaemonSaveIntervalWritesTheLeaseTableFromTheEnvironment": TestDaemonSaveIntervalWritesTheLeaseTableFromTheEnvironment,
"TestAutostartPollIntervalPacesTheReadinessPollFromTheEnvironment": TestAutostartPollIntervalPacesTheReadinessPollFromTheEnvironment,
"TestDaemonLeaseTTLForgetsASilentCallerFromTheEnvironment": TestDaemonLeaseTTLForgetsASilentCallerFromTheEnvironment,
Expand Down Expand Up @@ -3800,6 +3803,41 @@ func TestDaemonSaveIntervalWritesTheLeaseTableFromTheEnvironment(t *testing.T) {
}
}

// TestDaemonPortBindsTheChosenPortFromTheEnvironment is the effect probe
// for daemon.port. By default the daemon binds an ephemeral port; with
// daemon.port set to a port the test just found free, the daemon
// reports that exact endpoint, and it answers there.
func TestDaemonPortBindsTheChosenPortFromTheEnvironment(t *testing.T) {
l, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
t.Fatal(err)
}
port := strconv.Itoa(l.Addr().(*net.TCPAddr).Port)
_ = l.Close()
want := "http://127.0.0.1:" + port

def := newEnv(t, oneServer)
def.run("ls")
if got := endpointOf(t, def); got == want || !strings.HasPrefix(got, "http://127.0.0.1:") {
t.Fatalf("oracle: by default the daemon should bind some other loopback port, got %s", got)
}

e := newEnv(t, oneServer)
e.setenv("MCPX_DAEMON_PORT=" + port)
e.run("ls")
if got := endpointOf(t, e); got != want {
t.Fatalf("with daemon.port=%s the daemon should report %s, got %s", port, want, got)
}
resp, err := http.Get(want + "/v1/health")
if err != nil {
t.Fatalf("the chosen port should answer: %v", err)
}
defer func() { _ = resp.Body.Close() }()
if resp.StatusCode != http.StatusOK {
t.Fatalf("the chosen port answered %d, want 200", resp.StatusCode)
}
}

// 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.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.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
Expand Down
Loading