tstest/integration/testcontrol: add experiment.reco implementation

Select the published reco-backed test server with a build tag while
preserving the default implementation and existing caller API. Pin the
public module with its proxy-verified checksums; no workspace is needed.

Accept incremental peer messages in the TSP test. Exercise legacy map
semantics with the default server and version-floor rejection with reco,
including current-version streaming, without manual test skips.

Document GOFLAGS usage so child Go builds inherit the experiment tag.

Updates tailscale/corp#49097

Change-Id: I9b3e086c4c6a9a57a076e76b883422875c843f20
Signed-off-by: Brad Fitzpatrick <[email protected]>
This commit is contained in:
Brad Fitzpatrick authored and Brad Fitzpatrick committed 2026-09-29 10:25:02 -07:00
1 parent cf7d4c6015
commit bcc7e46f42
13 files changed
+98 -10

No files matched your search

+7 -1
View File
@@ -11,6 +11,7 @@ import (
"fmt"
"io"
"net/http/httptest"
"slices"
"strings"
"testing"
"time"
@@ -259,7 +260,7 @@ func TestSendMapUpdateAgainstTestControl(t *testing.T) {
// B should now observe A's new DiscoKey in a subsequent MapResponse.
for {
resp := nextNonKeepalive()
for _, p := range resp.Peers {
for _, p := range slices.Concat(resp.Peers, resp.PeersChanged) {
if p.Key != nodeKeyA.Public() {
continue
}
@@ -267,6 +268,11 @@ func TestSendMapUpdateAgainstTestControl(t *testing.T) {
return // success
}
}
for _, p := range resp.PeersChangedPatch {
if p.NodeID == initialA.ID && p.DiscoKey != nil && *p.DiscoKey == wantDisco {
return // success via a field-level update
}
}
}
}
+1 -1
View File
@@ -173,4 +173,4 @@
});
};
}
# nix-direnv cache busting line: sha256-Kysr52akpXixZ7/zoWaHjqUHQPLCLyHevb4JH+ZJwTw=
# nix-direnv cache busting line: sha256-d8bEjbu413IgbGdDnglZvsoXHjKVrgtA6hWchpYe/Xc=
+2 -2
View File
@@ -4,7 +4,7 @@
"sri": "sha256-qxNiwlI/KJpwx7VZQU9C5puJGMUtN5vBXm3ApNYIolI="
},
"vendor": {
"goModSum": "sha256-+mk46yWJIBkUoh9P7rD+OZcS9e2yhbk2eIWgwnNX4Z8=",
"sri": "sha256-Kysr52akpXixZ7/zoWaHjqUHQPLCLyHevb4JH+ZJwTw="
"goModSum": "sha256-pe7G/m6tu+29a71VnGEIVRS5dP8N8a3gSQjdG1WHjj4=",
"sri": "sha256-d8bEjbu413IgbGdDnglZvsoXHjKVrgtA6hWchpYe/Xc="
}
}
+1
View File
@@ -24,6 +24,7 @@ require (
github.com/bradfitz/go-tool-cache v0.0.0-20260919185303-c660171c910c
github.com/bradfitz/monogok v0.0.0-20260630033929-b1eef977b41f
github.com/bradfitz/qemu-guest-kragent v0.0.0-20240513123539-55a43ea02a03
github.com/bradfitz/reco v0.0.0-20260929154613-b883fbd17e3f
github.com/bramvdbogaerde/go-scp v1.6.1
github.com/chromedp/cdproto v0.0.0-20260714215040-dc233986426f
github.com/chromedp/chromedp v0.16.0
+2
View File
@@ -207,6 +207,8 @@ github.com/bradfitz/monogok v0.0.0-20260630033929-b1eef977b41f h1:voy0korWbg2e1g
github.com/bradfitz/monogok v0.0.0-20260630033929-b1eef977b41f/go.mod h1:TG1HbU9fRVDnNgXncVkKz9GdvjIvqquXjH6QZSEVmY4=
github.com/bradfitz/qemu-guest-kragent v0.0.0-20240513123539-55a43ea02a03 h1:V1gD/xbQZtimHXZ0y19oMgTVBIXQyazG/mG9JIflrIY=
github.com/bradfitz/qemu-guest-kragent v0.0.0-20240513123539-55a43ea02a03/go.mod h1:DFLM0H5mh/gbb8viqnMwZzZ8TU4o3bbXOa5tyknrOQY=
github.com/bradfitz/reco v0.0.0-20260929154613-b883fbd17e3f h1:jdXGSp5Ge5/kzikuxGOw9+6HSStUjkNBJZjGNtpItek=
github.com/bradfitz/reco v0.0.0-20260929154613-b883fbd17e3f/go.mod h1:oiCPXxBoDKSkb/RGEZwAZk8y/fwDlQ1vYlBbNRxPysw=
github.com/bramvdbogaerde/go-scp v1.6.1 h1:HE63uMkmMEB62JwqdRrVqRTBi7H/L/rkTp8TPC7uffY=
github.com/bramvdbogaerde/go-scp v1.6.1/go.mod h1:Lqx75BOgAvQoeBbPuPN/MfU3jf5tlfZVmUqpPbSZkZc=
github.com/breml/bidichk v0.3.3 h1:WSM67ztRusf1sMoqH6/c4OBCUlRVTKq+CbSeo0R17sE=
+1 -1
View File
@@ -16,4 +16,4 @@
) {
src = ./.;
}).shellNix
# nix-direnv cache busting line: sha256-Kysr52akpXixZ7/zoWaHjqUHQPLCLyHevb4JH+ZJwTw=
# nix-direnv cache busting line: sha256-d8bEjbu413IgbGdDnglZvsoXHjKVrgtA6hWchpYe/Xc=
@@ -0,0 +1,9 @@
// Copyright (c) Tailscale Inc & contributors
// SPDX-License-Identifier: BSD-3-Clause
//go:build !experiment.reco
package testcontrol_test
// The original test server also implements legacy map protocol versions.
const minTestControlCapabilityVersion = 0
@@ -0,0 +1,10 @@
// Copyright (c) Tailscale Inc & contributors
// SPDX-License-Identifier: BSD-3-Clause
//go:build experiment.reco
package testcontrol_test
import "github.com/bradfitz/reco/recotestcontrol"
const minTestControlCapabilityVersion = recotestcontrol.MinCapabilityVersion
+5
View File
@@ -0,0 +1,5 @@
// Copyright (c) Tailscale Inc & contributors
// SPDX-License-Identifier: BSD-3-Clause
// Package testcontrol contains a minimal control plane server for testing purposes.
package testcontrol
@@ -0,0 +1,18 @@
// Copyright (c) Tailscale Inc & contributors
// SPDX-License-Identifier: BSD-3-Clause
//go:build experiment.reco
package testcontrol
import "github.com/bradfitz/reco/recotestcontrol"
// Re-export the test server API so callers can select either implementation
// using only a build tag. The reco implementation supports capability 109+.
type Server = recotestcontrol.Server
type AuthPath = recotestcontrol.AuthPath
type MasqueradePair = recotestcontrol.MasqueradePair
type AltMapStreamFunc = recotestcontrol.AltMapStreamFunc
type MapStreamWriter = recotestcontrol.MapStreamWriter
var RejectRequestForPath = recotestcontrol.RejectRequestForPath
+22
View File
@@ -0,0 +1,22 @@
# Experimental reco implementation
By default, this package uses the original in-memory test control server.
The `experiment.reco` build tag substitutes
[`github.com/bradfitz/reco/recotestcontrol`](https://pkg.go.dev/github.com/bradfitz/reco/recotestcontrol)
using type aliases, without changing callers.
Reco is an experimental research prototype, not a production control server or
a stable API. Its test server requires capability version 109 or later. The
protocol tests check both legacy behavior in the default server and rejection
of obsolete versions with the experiment enabled.
For example, from the module root:
```sh
GOWORK=off GOFLAGS=-tags=experiment.reco go test \
./tstest/integration/testcontrol ./control/tsp ./control/controlclient \
./tsnet ./tstest/integration
```
Use `GOFLAGS` so integration tests' child Go builds receive the tag too.
Omit it to exercise the default implementation.
@@ -1,7 +1,8 @@
// Copyright (c) Tailscale Inc & contributors
// SPDX-License-Identifier: BSD-3-Clause
// Package testcontrol contains a minimal control plane server for testing purposes.
//go:build !experiment.reco
package testcontrol
import (
@@ -34,13 +34,18 @@ import (
//
// For older (cap<68) clients, the streaming MapRequest is still a write and
// writes do happen, so DiscoKey=zero in the request does clobber.
// Implementations with a newer protocol floor must reject older versions
// without mutating the node instead.
func TestStreamingMapReqReadOnlyByVersion(t *testing.T) {
tests := []struct {
version tailcfg.CapabilityVersion
wantClobber bool
}{
{67, true}, // pre-cap-68: streaming is a write, DiscoKey=zero clobbers.
{68, false}, // cap>=68: streaming is read-only, DiscoKey unchanged.
{67, true}, // pre-cap-68: streaming is a write, DiscoKey=zero clobbers.
{68, false}, // cap>=68: streaming is read-only, DiscoKey unchanged.
{108, false}, // just below the reco implementation's version floor.
{109, false}, // the reco implementation's oldest supported version.
{tailcfg.CurrentCapabilityVersion, false},
}
for _, tt := range tests {
@@ -115,15 +120,24 @@ func TestStreamingMapReqReadOnlyByVersion(t *testing.T) {
t.Fatalf("nc.Do: %v", err)
}
res.Body.Close() // tears down the streaming session server-side
wantStatus := http.StatusOK
wantClobber := tt.wantClobber
if tt.version < minTestControlCapabilityVersion {
wantStatus = http.StatusBadRequest
wantClobber = false
}
if res.StatusCode != wantStatus {
t.Fatalf("map response status = %d, want %d", res.StatusCode, wantStatus)
}
got := ctrl.Node(nodeKey.Public())
if got == nil {
t.Fatal("node disappeared")
}
switch {
case tt.wantClobber && !got.DiscoKey.IsZero():
case wantClobber && !got.DiscoKey.IsZero():
t.Errorf("v%d: expected DiscoKey clobbered to zero, got %v", tt.version, got.DiscoKey)
case !tt.wantClobber && got.DiscoKey != wantDisco:
case !wantClobber && got.DiscoKey != wantDisco:
t.Errorf("v%d: DiscoKey changed from %v to %v; should have been left alone",
tt.version, wantDisco, got.DiscoKey)
}