From e9cf3b4d3f36949f308b131d8446ee794e2f61d6 Mon Sep 17 00:00:00 2001 From: ginuerzh Date: Thu, 16 Jul 2026 17:22:05 +0800 Subject: [PATCH] e2e: add cmd probe failover test with true/false command nodes --- tests/e2e/probe_test.go | 15 +++++++++++ tests/e2e/testdata/probe/cmd.yaml | 43 +++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 tests/e2e/testdata/probe/cmd.yaml diff --git a/tests/e2e/probe_test.go b/tests/e2e/probe_test.go index 7db11bf..d211d4a 100644 --- a/tests/e2e/probe_test.go +++ b/tests/e2e/probe_test.go @@ -85,6 +85,21 @@ func (s *ProbeSuite) TestLowestLatencyProbe() { } } +// TestCmdProbeFailover verifies that the cmd probe detects a dead node via +// shell exit code and marks it before real traffic, so FailFilter excludes it. +func (s *ProbeSuite) TestCmdProbeFailover() { + gostC, err := RunGostContainerWithPorts(s.ctx, SharedNetworkName, "testdata/probe/cmd.yaml", "8080/tcp") + s.Require().NoError(err) + defer gostC.Terminate(s.ctx) + + // The probe fires at startup; the dead node is already marked. + for range 10 { + code, body := s.proxyRequest(gostC, "8080") + s.Require().Equal(0, code, "all requests must succeed; dead cmd node pre-marked") + s.Require().Contains(body, "hello-gost") + } +} + func TestProbeSuite(t *testing.T) { suite.Run(t, new(ProbeSuite)) } diff --git a/tests/e2e/testdata/probe/cmd.yaml b/tests/e2e/testdata/probe/cmd.yaml new file mode 100644 index 0000000..549bda5 --- /dev/null +++ b/tests/e2e/testdata/probe/cmd.yaml @@ -0,0 +1,43 @@ +services: +- name: proxy + addr: :8080 + handler: + type: http + chain: my-chain + listener: + type: tcp + +# Live relay: forwards to the echo server. +- name: relay + addr: 127.0.0.1:18081 + handler: + type: http + listener: + type: tcp + +chains: +- name: my-chain + hops: + - name: hop-1 + selector: + strategy: round + maxFails: 1 + failTimeout: 10s + nodes: + - name: node-live + addr: 127.0.0.1:18081 + connector: + type: http + probe: + type: cmd + command: "true" + interval: 5s + # This node's probe always fails → pre-marked dead → FailFilter excludes it. + - name: node-dead + addr: 127.0.0.1:18082 + connector: + type: http + probe: + type: cmd + command: "false" + interval: 5s