cmd/vet: add subtestnames analyzer; fix all existing violations
Add a new vet analyzer that checks t.Run subtest names don't contain characters requiring quoting when re-running via "go test -run". This enforces the style guide rule: don't use spaces or punctuation in subtest names. The analyzer flags: - Direct t.Run calls with string literal names containing spaces, regex metacharacters, quotes, or other problematic characters - Table-driven t.Run(tt.name, ...) calls where tt ranges over a slice/map literal with bad name field values Also fix all 978 existing violations across 81 test files, replacing spaces with hyphens and shortening long sentence-like names to concise hyphenated forms. Updates #19242 Change-Id: Ib0ad96a111bd8e764582d1d4902fe2599454ab65 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
0f02c20c5e
commit
5ef3713c9f
@@ -180,7 +180,7 @@ func Test_endpoint_maybeProbeUDPLifetimeLocked(t *testing.T) {
|
||||
wantMaybe bool
|
||||
}{
|
||||
{
|
||||
name: "nil probeUDPLifetime",
|
||||
name: "nil-probeUDPLifetime",
|
||||
localDisco: higher,
|
||||
remoteDisco: &lower,
|
||||
probeUDPLifetimeFn: func() *probeUDPLifetime {
|
||||
@@ -189,28 +189,28 @@ func Test_endpoint_maybeProbeUDPLifetimeLocked(t *testing.T) {
|
||||
bestAddr: addr,
|
||||
},
|
||||
{
|
||||
name: "local higher disco key",
|
||||
name: "local-higher-disco-key",
|
||||
localDisco: higher,
|
||||
remoteDisco: &lower,
|
||||
probeUDPLifetimeFn: newProbeUDPLifetime,
|
||||
bestAddr: addr,
|
||||
},
|
||||
{
|
||||
name: "remote no disco key",
|
||||
name: "remote-no-disco-key",
|
||||
localDisco: higher,
|
||||
remoteDisco: nil,
|
||||
probeUDPLifetimeFn: newProbeUDPLifetime,
|
||||
bestAddr: addr,
|
||||
},
|
||||
{
|
||||
name: "invalid bestAddr",
|
||||
name: "invalid-bestAddr",
|
||||
localDisco: lower,
|
||||
remoteDisco: &higher,
|
||||
probeUDPLifetimeFn: newProbeUDPLifetime,
|
||||
bestAddr: addrQuality{},
|
||||
},
|
||||
{
|
||||
name: "cycle started too recently",
|
||||
name: "cycle-started-too-recently",
|
||||
localDisco: lower,
|
||||
remoteDisco: &higher,
|
||||
probeUDPLifetimeFn: func() *probeUDPLifetime {
|
||||
@@ -222,7 +222,7 @@ func Test_endpoint_maybeProbeUDPLifetimeLocked(t *testing.T) {
|
||||
bestAddr: addr,
|
||||
},
|
||||
{
|
||||
name: "maybe cliff 0 cycle not active",
|
||||
name: "maybe-cliff-0-cycle-not-active",
|
||||
localDisco: lower,
|
||||
remoteDisco: &higher,
|
||||
probeUDPLifetimeFn: func() *probeUDPLifetime {
|
||||
@@ -238,7 +238,7 @@ func Test_endpoint_maybeProbeUDPLifetimeLocked(t *testing.T) {
|
||||
wantMaybe: true,
|
||||
},
|
||||
{
|
||||
name: "maybe cliff 0",
|
||||
name: "maybe-cliff-0",
|
||||
localDisco: lower,
|
||||
remoteDisco: &higher,
|
||||
probeUDPLifetimeFn: func() *probeUDPLifetime {
|
||||
@@ -254,7 +254,7 @@ func Test_endpoint_maybeProbeUDPLifetimeLocked(t *testing.T) {
|
||||
wantMaybe: true,
|
||||
},
|
||||
{
|
||||
name: "maybe cliff 1",
|
||||
name: "maybe-cliff-1",
|
||||
localDisco: lower,
|
||||
remoteDisco: &higher,
|
||||
probeUDPLifetimeFn: func() *probeUDPLifetime {
|
||||
@@ -270,7 +270,7 @@ func Test_endpoint_maybeProbeUDPLifetimeLocked(t *testing.T) {
|
||||
wantMaybe: true,
|
||||
},
|
||||
{
|
||||
name: "maybe cliff 2",
|
||||
name: "maybe-cliff-2",
|
||||
localDisco: lower,
|
||||
remoteDisco: &higher,
|
||||
probeUDPLifetimeFn: func() *probeUDPLifetime {
|
||||
@@ -341,13 +341,13 @@ func Test_epAddr_isDirectUDP(t *testing.T) {
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "false derp magic addr",
|
||||
name: "false-derp-magic-addr",
|
||||
ap: netip.AddrPortFrom(tailcfg.DerpMagicIPAddr, 0),
|
||||
vni: packet.VirtualNetworkID{},
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "false vni set",
|
||||
name: "false-vni-set",
|
||||
ap: netip.MustParseAddrPort("192.0.2.1:7"),
|
||||
vni: vni,
|
||||
want: false,
|
||||
@@ -397,42 +397,42 @@ func Test_endpoint_udpRelayEndpointReady(t *testing.T) {
|
||||
wantBestAddr addrQuality
|
||||
}{
|
||||
{
|
||||
name: "bestAddr trusted direct",
|
||||
name: "bestAddr-trusted-direct",
|
||||
curBestAddr: directAddrQuality,
|
||||
trustBestAddrUntil: mono.Now().Add(1 * time.Hour),
|
||||
maybeBest: peerRelayAddrQuality,
|
||||
wantBestAddr: directAddrQuality,
|
||||
},
|
||||
{
|
||||
name: "bestAddr untrusted direct",
|
||||
name: "bestAddr-untrusted-direct",
|
||||
curBestAddr: directAddrQuality,
|
||||
trustBestAddrUntil: mono.Now().Add(-1 * time.Hour),
|
||||
maybeBest: peerRelayAddrQuality,
|
||||
wantBestAddr: peerRelayAddrQuality,
|
||||
},
|
||||
{
|
||||
name: "maybeBest same relay server higher latency bestAddr trusted",
|
||||
name: "maybeBest-same-relay-higher-latency-trusted",
|
||||
curBestAddr: peerRelayAddrQuality,
|
||||
trustBestAddrUntil: mono.Now().Add(1 * time.Hour),
|
||||
maybeBest: peerRelayAddrQualityHigherLatencySameServer,
|
||||
wantBestAddr: peerRelayAddrQualityHigherLatencySameServer,
|
||||
},
|
||||
{
|
||||
name: "maybeBest diff relay server higher latency bestAddr trusted",
|
||||
name: "maybeBest-diff-relay-higher-latency-trusted",
|
||||
curBestAddr: peerRelayAddrQuality,
|
||||
trustBestAddrUntil: mono.Now().Add(1 * time.Hour),
|
||||
maybeBest: peerRelayAddrQualityHigherLatencyDiffServer,
|
||||
wantBestAddr: peerRelayAddrQuality,
|
||||
},
|
||||
{
|
||||
name: "maybeBest diff relay server lower latency bestAddr trusted",
|
||||
name: "maybeBest-diff-relay-lower-latency-trusted",
|
||||
curBestAddr: peerRelayAddrQuality,
|
||||
trustBestAddrUntil: mono.Now().Add(1 * time.Hour),
|
||||
maybeBest: peerRelayAddrQualityLowerLatencyDiffServer,
|
||||
wantBestAddr: peerRelayAddrQualityLowerLatencyDiffServer,
|
||||
},
|
||||
{
|
||||
name: "maybeBest diff relay server equal latency bestAddr trusted",
|
||||
name: "maybeBest-diff-relay-equal-latency-trusted",
|
||||
curBestAddr: peerRelayAddrQuality,
|
||||
trustBestAddrUntil: mono.Now().Add(1 * time.Hour),
|
||||
maybeBest: peerRelayAddrQualityEqualLatencyDiffServer,
|
||||
|
||||
@@ -184,19 +184,19 @@ func TestBpfDiscardV4(t *testing.T) {
|
||||
accept bool
|
||||
}{
|
||||
{
|
||||
name: "base accepted datagram",
|
||||
name: "base-accepted-datagram",
|
||||
replace: map[int]byte{},
|
||||
accept: true,
|
||||
},
|
||||
{
|
||||
name: "more fragments",
|
||||
name: "more-fragments",
|
||||
replace: map[int]byte{
|
||||
6: 0x20,
|
||||
},
|
||||
accept: false,
|
||||
},
|
||||
{
|
||||
name: "some fragment",
|
||||
name: "some-fragment",
|
||||
replace: map[int]byte{
|
||||
7: 0x01,
|
||||
},
|
||||
|
||||
@@ -1217,7 +1217,7 @@ func testTwoDevicePing(t *testing.T, d *devices) {
|
||||
}
|
||||
|
||||
outerT := t
|
||||
t.Run("ping 1.0.0.1", func(t *testing.T) {
|
||||
t.Run("ping-1_0_0_1", func(t *testing.T) {
|
||||
setT(t)
|
||||
defer setT(outerT)
|
||||
ping1(t)
|
||||
@@ -1225,7 +1225,7 @@ func testTwoDevicePing(t *testing.T, d *devices) {
|
||||
checkStats(t, m2, m2Conns)
|
||||
})
|
||||
|
||||
t.Run("ping 1.0.0.2", func(t *testing.T) {
|
||||
t.Run("ping-1_0_0_2", func(t *testing.T) {
|
||||
setT(t)
|
||||
defer setT(outerT)
|
||||
ping2(t)
|
||||
@@ -1233,7 +1233,7 @@ func testTwoDevicePing(t *testing.T, d *devices) {
|
||||
checkStats(t, m2, m2Conns)
|
||||
})
|
||||
|
||||
t.Run("ping 1.0.0.2 via SendPacket", func(t *testing.T) {
|
||||
t.Run("ping-1_0_0_2-via-SendPacket", func(t *testing.T) {
|
||||
setT(t)
|
||||
defer setT(outerT)
|
||||
msg1to2 := tuntest.Ping(netip.MustParseAddr("1.0.0.2"), netip.MustParseAddr("1.0.0.1"))
|
||||
@@ -1251,7 +1251,7 @@ func testTwoDevicePing(t *testing.T, d *devices) {
|
||||
checkStats(t, m2, m2Conns)
|
||||
})
|
||||
|
||||
t.Run("no-op dev1 reconfig", func(t *testing.T) {
|
||||
t.Run("no-op-dev1-reconfig", func(t *testing.T) {
|
||||
setT(t)
|
||||
defer setT(outerT)
|
||||
if err := m1.Reconfig(m1cfg); err != nil {
|
||||
@@ -2731,7 +2731,7 @@ func TestAddrForSendLockedForWireGuardOnly(t *testing.T) {
|
||||
want epAddr
|
||||
}{
|
||||
{
|
||||
name: "no endpoints",
|
||||
name: "no-endpoints",
|
||||
sendInitialPing: false,
|
||||
validAddr: false,
|
||||
sendFollowUpPing: false,
|
||||
@@ -2740,7 +2740,7 @@ func TestAddrForSendLockedForWireGuardOnly(t *testing.T) {
|
||||
want: epAddr{},
|
||||
},
|
||||
{
|
||||
name: "singular endpoint does not request ping",
|
||||
name: "singular-endpoint-no-ping-request",
|
||||
sendInitialPing: false,
|
||||
validAddr: true,
|
||||
sendFollowUpPing: false,
|
||||
@@ -2754,7 +2754,7 @@ func TestAddrForSendLockedForWireGuardOnly(t *testing.T) {
|
||||
want: epAddr{ap: netip.MustParseAddrPort("1.1.1.1:111")},
|
||||
},
|
||||
{
|
||||
name: "ping sent within wireguardPingInterval should not request ping",
|
||||
name: "ping-within-wireguardPingInterval-no-request",
|
||||
sendInitialPing: true,
|
||||
validAddr: true,
|
||||
sendFollowUpPing: false,
|
||||
@@ -2772,7 +2772,7 @@ func TestAddrForSendLockedForWireGuardOnly(t *testing.T) {
|
||||
want: epAddr{ap: netip.MustParseAddrPort("1.1.1.1:111")},
|
||||
},
|
||||
{
|
||||
name: "ping sent outside of wireguardPingInterval should request ping",
|
||||
name: "ping-outside-wireguardPingInterval-requests-ping",
|
||||
sendInitialPing: true,
|
||||
validAddr: true,
|
||||
sendFollowUpPing: true,
|
||||
@@ -2790,7 +2790,7 @@ func TestAddrForSendLockedForWireGuardOnly(t *testing.T) {
|
||||
want: epAddr{ap: netip.MustParseAddrPort("1.1.1.1:111")},
|
||||
},
|
||||
{
|
||||
name: "choose lowest latency for useable IPv4 and IPv6",
|
||||
name: "choose-lowest-latency-v4-and-v6",
|
||||
sendInitialPing: true,
|
||||
validAddr: true,
|
||||
sendFollowUpPing: false,
|
||||
@@ -2808,7 +2808,7 @@ func TestAddrForSendLockedForWireGuardOnly(t *testing.T) {
|
||||
want: epAddr{ap: netip.MustParseAddrPort("[2345:0425:2CA1:0000:0000:0567:5673:23b5]:222")},
|
||||
},
|
||||
{
|
||||
name: "choose IPv6 address when latency is the same for v4 and v6",
|
||||
name: "choose-IPv6-when-equal-latency",
|
||||
sendInitialPing: true,
|
||||
validAddr: true,
|
||||
sendFollowUpPing: false,
|
||||
@@ -3378,73 +3378,73 @@ func Test_packetLooksLike(t *testing.T) {
|
||||
wantIsGeneveEncap bool
|
||||
}{
|
||||
{
|
||||
name: "STUN binding success response",
|
||||
name: "STUN-binding-success-response",
|
||||
msg: stun.Response(stun.NewTxID(), netip.MustParseAddrPort("127.0.0.1:1")),
|
||||
wantPacketLooksLikeType: packetLooksLikeSTUNBinding,
|
||||
wantIsGeneveEncap: false,
|
||||
},
|
||||
{
|
||||
name: "naked disco",
|
||||
name: "naked-disco",
|
||||
msg: nakedDisco,
|
||||
wantPacketLooksLikeType: packetLooksLikeDisco,
|
||||
wantIsGeneveEncap: false,
|
||||
},
|
||||
{
|
||||
name: "geneve encap disco",
|
||||
name: "geneve-encap-disco",
|
||||
msg: geneveEncapDisco,
|
||||
wantPacketLooksLikeType: packetLooksLikeDisco,
|
||||
wantIsGeneveEncap: true,
|
||||
},
|
||||
{
|
||||
name: "geneve encap too short disco",
|
||||
name: "geneve-encap-too-short-disco",
|
||||
msg: geneveEncapDisco[:len(geneveEncapDisco)-key.DiscoPublicRawLen],
|
||||
wantPacketLooksLikeType: packetLooksLikeWireGuard,
|
||||
wantIsGeneveEncap: false,
|
||||
},
|
||||
{
|
||||
name: "geneve encap disco nonzero geneve version",
|
||||
name: "geneve-encap-disco-nonzero-geneve-version",
|
||||
msg: geneveEncapDiscoNonZeroGeneveVersion,
|
||||
wantPacketLooksLikeType: packetLooksLikeWireGuard,
|
||||
wantIsGeneveEncap: false,
|
||||
},
|
||||
{
|
||||
name: "geneve encap disco nonzero geneve reserved bits",
|
||||
name: "geneve-encap-disco-nonzero-geneve-reserved-bits",
|
||||
msg: geneveEncapDiscoNonZeroGeneveReservedBits,
|
||||
wantPacketLooksLikeType: packetLooksLikeWireGuard,
|
||||
wantIsGeneveEncap: false,
|
||||
},
|
||||
{
|
||||
name: "geneve encap disco nonzero geneve vni lsb",
|
||||
name: "geneve-encap-disco-nonzero-geneve-vni-lsb",
|
||||
msg: geneveEncapDiscoNonZeroGeneveVNILSB,
|
||||
wantPacketLooksLikeType: packetLooksLikeWireGuard,
|
||||
wantIsGeneveEncap: false,
|
||||
},
|
||||
{
|
||||
name: "geneve encap wireguard",
|
||||
name: "geneve-encap-wireguard",
|
||||
msg: geneveEncapWireGuard,
|
||||
wantPacketLooksLikeType: packetLooksLikeWireGuard,
|
||||
wantIsGeneveEncap: true,
|
||||
},
|
||||
{
|
||||
name: "naked WireGuard Initiation type",
|
||||
name: "naked-WireGuard-Initiation-type",
|
||||
msg: nakedWireGuardInitiation,
|
||||
wantPacketLooksLikeType: packetLooksLikeWireGuard,
|
||||
wantIsGeneveEncap: false,
|
||||
},
|
||||
{
|
||||
name: "naked WireGuard Response type",
|
||||
name: "naked-WireGuard-Response-type",
|
||||
msg: nakedWireGuardResponse,
|
||||
wantPacketLooksLikeType: packetLooksLikeWireGuard,
|
||||
wantIsGeneveEncap: false,
|
||||
},
|
||||
{
|
||||
name: "naked WireGuard Cookie Reply type",
|
||||
name: "naked-WireGuard-Cookie-Reply-type",
|
||||
msg: nakedWireGuardCookieReply,
|
||||
wantPacketLooksLikeType: packetLooksLikeWireGuard,
|
||||
wantIsGeneveEncap: false,
|
||||
},
|
||||
{
|
||||
name: "naked WireGuard Transport type",
|
||||
name: "naked-WireGuard-Transport-type",
|
||||
msg: nakedWireGuardTransport,
|
||||
wantPacketLooksLikeType: packetLooksLikeWireGuard,
|
||||
wantIsGeneveEncap: false,
|
||||
@@ -3481,22 +3481,22 @@ func Test_looksLikeInitiationMsg(t *testing.T) {
|
||||
want bool
|
||||
}{
|
||||
{
|
||||
name: "valid initiation",
|
||||
name: "valid-initiation",
|
||||
b: initMsg,
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "invalid message type field",
|
||||
name: "invalid-message-type-field",
|
||||
b: initMsgSizeTransportType,
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "too small",
|
||||
name: "too-small",
|
||||
b: initMsg[:device.MessageInitiationSize-1],
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "too big",
|
||||
name: "too-big",
|
||||
b: append(initMsg, 0),
|
||||
want: false,
|
||||
},
|
||||
@@ -3538,7 +3538,7 @@ func Test_nodeHasCap(t *testing.T) {
|
||||
want bool
|
||||
}{
|
||||
{
|
||||
name: "match v4",
|
||||
name: "match-v4",
|
||||
filt: filter.New([]filtertype.Match{
|
||||
{
|
||||
Srcs: []netip.Prefix{netip.MustParsePrefix("2.2.2.2/32")},
|
||||
@@ -3556,7 +3556,7 @@ func Test_nodeHasCap(t *testing.T) {
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "match v6",
|
||||
name: "match-v6",
|
||||
filt: filter.New([]filtertype.Match{
|
||||
{
|
||||
Srcs: []netip.Prefix{netip.MustParsePrefix("::2/128")},
|
||||
@@ -3574,7 +3574,7 @@ func Test_nodeHasCap(t *testing.T) {
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "no match CapMatch Dst",
|
||||
name: "no-match-CapMatch-Dst",
|
||||
filt: filter.New([]filtertype.Match{
|
||||
{
|
||||
Srcs: []netip.Prefix{netip.MustParsePrefix("::2/128")},
|
||||
@@ -3592,7 +3592,7 @@ func Test_nodeHasCap(t *testing.T) {
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "no match peer cap",
|
||||
name: "no-match-peer-cap",
|
||||
filt: filter.New([]filtertype.Match{
|
||||
{
|
||||
Srcs: []netip.Prefix{netip.MustParsePrefix("::2/128")},
|
||||
@@ -3610,7 +3610,7 @@ func Test_nodeHasCap(t *testing.T) {
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "nil src",
|
||||
name: "nil-src",
|
||||
filt: filter.New([]filtertype.Match{
|
||||
{
|
||||
Srcs: []netip.Prefix{netip.MustParsePrefix("2.2.2.2/32")},
|
||||
@@ -3628,7 +3628,7 @@ func Test_nodeHasCap(t *testing.T) {
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "nil dst",
|
||||
name: "nil-dst",
|
||||
filt: filter.New([]filtertype.Match{
|
||||
{
|
||||
Srcs: []netip.Prefix{netip.MustParsePrefix("2.2.2.2/32")},
|
||||
@@ -3706,7 +3706,7 @@ func TestConn_SetNetworkMap_updateRelayServersSet(t *testing.T) {
|
||||
wantRelayClientEnabled bool
|
||||
}{
|
||||
{
|
||||
name: "candidate relay server",
|
||||
name: "candidate-relay-server",
|
||||
filt: filter.New([]filtertype.Match{
|
||||
{
|
||||
Srcs: peerNodeCandidateRelay.Addresses,
|
||||
@@ -3730,7 +3730,7 @@ func TestConn_SetNetworkMap_updateRelayServersSet(t *testing.T) {
|
||||
wantRelayClientEnabled: true,
|
||||
},
|
||||
{
|
||||
name: "no candidate relay server because self has tailcfg.NodeAttrDisableRelayClient",
|
||||
name: "no-candidate-self-has-DisableRelayClient", // self has tailcfg.NodeAttrDisableRelayClient
|
||||
filt: filter.New([]filtertype.Match{
|
||||
{
|
||||
Srcs: peerNodeCandidateRelay.Addresses,
|
||||
@@ -3748,7 +3748,7 @@ func TestConn_SetNetworkMap_updateRelayServersSet(t *testing.T) {
|
||||
wantRelayClientEnabled: false,
|
||||
},
|
||||
{
|
||||
name: "no candidate relay server because self has tailcfg.NodeAttrOnlyTCP443",
|
||||
name: "no-candidate-self-has-OnlyTCP443", // self has tailcfg.NodeAttrOnlyTCP443
|
||||
filt: filter.New([]filtertype.Match{
|
||||
{
|
||||
Srcs: peerNodeCandidateRelay.Addresses,
|
||||
@@ -3766,7 +3766,7 @@ func TestConn_SetNetworkMap_updateRelayServersSet(t *testing.T) {
|
||||
wantRelayClientEnabled: false,
|
||||
},
|
||||
{
|
||||
name: "self candidate relay server",
|
||||
name: "self-candidate-relay-server",
|
||||
filt: filter.New([]filtertype.Match{
|
||||
{
|
||||
Srcs: selfNode.Addresses,
|
||||
@@ -3790,7 +3790,7 @@ func TestConn_SetNetworkMap_updateRelayServersSet(t *testing.T) {
|
||||
wantRelayClientEnabled: true,
|
||||
},
|
||||
{
|
||||
name: "no candidate relay server",
|
||||
name: "no-candidate-relay-server",
|
||||
filt: filter.New([]filtertype.Match{
|
||||
{
|
||||
Srcs: peerNodeNotCandidateRelayCapVer.Addresses,
|
||||
@@ -3911,7 +3911,7 @@ func TestConn_receiveIP(t *testing.T) {
|
||||
wantNoteRecvActivityCalled bool
|
||||
}{
|
||||
{
|
||||
name: "naked disco",
|
||||
name: "naked-disco",
|
||||
b: looksLikeNakedDisco,
|
||||
ipp: netip.MustParseAddrPort("127.0.0.1:7777"),
|
||||
cache: &epAddrEndpointCache{},
|
||||
@@ -3923,7 +3923,7 @@ func TestConn_receiveIP(t *testing.T) {
|
||||
wantNoteRecvActivityCalled: false,
|
||||
},
|
||||
{
|
||||
name: "geneve encap disco",
|
||||
name: "geneve-encap-disco",
|
||||
b: looksLikeGeneveDisco,
|
||||
ipp: netip.MustParseAddrPort("127.0.0.1:7777"),
|
||||
cache: &epAddrEndpointCache{},
|
||||
@@ -3935,7 +3935,7 @@ func TestConn_receiveIP(t *testing.T) {
|
||||
wantNoteRecvActivityCalled: false,
|
||||
},
|
||||
{
|
||||
name: "STUN binding",
|
||||
name: "STUN-binding",
|
||||
b: looksLikeSTUNBinding,
|
||||
ipp: netip.MustParseAddrPort("127.0.0.1:7777"),
|
||||
cache: &epAddrEndpointCache{},
|
||||
@@ -3947,7 +3947,7 @@ func TestConn_receiveIP(t *testing.T) {
|
||||
wantNoteRecvActivityCalled: false,
|
||||
},
|
||||
{
|
||||
name: "naked WireGuard init lazyEndpoint empty peerMap",
|
||||
name: "naked-WireGuard-init-lazyEndpoint-empty-peerMap",
|
||||
b: looksLikeNakedWireGuardInit,
|
||||
ipp: netip.MustParseAddrPort("127.0.0.1:7777"),
|
||||
cache: &epAddrEndpointCache{},
|
||||
@@ -3959,7 +3959,7 @@ func TestConn_receiveIP(t *testing.T) {
|
||||
wantNoteRecvActivityCalled: false,
|
||||
},
|
||||
{
|
||||
name: "naked WireGuard init endpoint matching peerMap entry",
|
||||
name: "naked-WireGuard-init-endpoint-matching-peerMap-entry",
|
||||
b: looksLikeNakedWireGuardInit,
|
||||
ipp: netip.MustParseAddrPort("127.0.0.1:7777"),
|
||||
cache: &epAddrEndpointCache{},
|
||||
@@ -3973,7 +3973,7 @@ func TestConn_receiveIP(t *testing.T) {
|
||||
wantNoteRecvActivityCalled: true,
|
||||
},
|
||||
{
|
||||
name: "geneve WireGuard init lazyEndpoint empty peerMap",
|
||||
name: "geneve-WireGuard-init-lazyEndpoint-empty-peerMap",
|
||||
b: looksLikeGeneveWireGuardInit,
|
||||
ipp: netip.MustParseAddrPort("127.0.0.1:7777"),
|
||||
cache: &epAddrEndpointCache{},
|
||||
@@ -3985,7 +3985,7 @@ func TestConn_receiveIP(t *testing.T) {
|
||||
wantNoteRecvActivityCalled: false,
|
||||
},
|
||||
{
|
||||
name: "geneve WireGuard init lazyEndpoint matching peerMap activity noted",
|
||||
name: "geneve-WireGuard-init-lazyEndpoint-matching-peerMap-activity-noted",
|
||||
b: looksLikeGeneveWireGuardInit,
|
||||
ipp: netip.MustParseAddrPort("127.0.0.1:7777"),
|
||||
cache: &epAddrEndpointCache{},
|
||||
@@ -4001,7 +4001,7 @@ func TestConn_receiveIP(t *testing.T) {
|
||||
wantNoteRecvActivityCalled: true,
|
||||
},
|
||||
{
|
||||
name: "geneve WireGuard init lazyEndpoint matching peerMap no activity noted",
|
||||
name: "geneve-WireGuard-init-lazyEndpoint-matching-peerMap-no-activity-noted",
|
||||
b: looksLikeGeneveWireGuardInit,
|
||||
ipp: netip.MustParseAddrPort("127.0.0.1:7777"),
|
||||
cache: &epAddrEndpointCache{},
|
||||
@@ -4151,25 +4151,25 @@ func Test_lazyEndpoint_InitiationMessagePublicKey(t *testing.T) {
|
||||
wantNoteRecvActivityCalled bool
|
||||
}{
|
||||
{
|
||||
name: "noteRecvActivity called",
|
||||
name: "noteRecvActivity-called",
|
||||
callWithPeerMapKey: true,
|
||||
maybeEPMatchingKey: false,
|
||||
wantNoteRecvActivityCalled: true,
|
||||
},
|
||||
{
|
||||
name: "maybeEP early return",
|
||||
name: "maybeEP-early-return",
|
||||
callWithPeerMapKey: true,
|
||||
maybeEPMatchingKey: true,
|
||||
wantNoteRecvActivityCalled: false,
|
||||
},
|
||||
{
|
||||
name: "not in peerMap early return",
|
||||
name: "not-in-peerMap-early-return",
|
||||
callWithPeerMapKey: false,
|
||||
maybeEPMatchingKey: false,
|
||||
wantNoteRecvActivityCalled: false,
|
||||
},
|
||||
{
|
||||
name: "not in peerMap maybeEP early return",
|
||||
name: "not-in-peerMap-maybeEP-early-return",
|
||||
callWithPeerMapKey: false,
|
||||
maybeEPMatchingKey: true,
|
||||
wantNoteRecvActivityCalled: false,
|
||||
@@ -4232,25 +4232,25 @@ func Test_lazyEndpoint_FromPeer(t *testing.T) {
|
||||
wantEpAddrInPeerMap bool
|
||||
}{
|
||||
{
|
||||
name: "epAddr in peerMap",
|
||||
name: "epAddr-in-peerMap",
|
||||
callWithPeerMapKey: true,
|
||||
maybeEPMatchingKey: false,
|
||||
wantEpAddrInPeerMap: true,
|
||||
},
|
||||
{
|
||||
name: "maybeEP early return",
|
||||
name: "maybeEP-early-return",
|
||||
callWithPeerMapKey: true,
|
||||
maybeEPMatchingKey: true,
|
||||
wantEpAddrInPeerMap: false,
|
||||
},
|
||||
{
|
||||
name: "not in peerMap early return",
|
||||
name: "not-in-peerMap-early-return",
|
||||
callWithPeerMapKey: false,
|
||||
maybeEPMatchingKey: false,
|
||||
wantEpAddrInPeerMap: false,
|
||||
},
|
||||
{
|
||||
name: "not in peerMap maybeEP early return",
|
||||
name: "not-in-peerMap-maybeEP-early-return",
|
||||
callWithPeerMapKey: false,
|
||||
maybeEPMatchingKey: true,
|
||||
wantEpAddrInPeerMap: false,
|
||||
|
||||
@@ -141,7 +141,7 @@ func TestRelayManager_handleNewServerEndpointRunLoop(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
// Test for http://go/corp/32978
|
||||
name: "eq server+ep neq VNI higher lamport",
|
||||
name: "eq-server-ep-neq-VNI-higher-lamport",
|
||||
events: []newRelayServerEndpointEvent{
|
||||
serverAendpointALamport1VNI1,
|
||||
serverAendpointALamport2VNI2,
|
||||
@@ -151,7 +151,7 @@ func TestRelayManager_handleNewServerEndpointRunLoop(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "eq server+ep neq VNI lower lamport",
|
||||
name: "eq-server-ep-neq-VNI-lower-lamport",
|
||||
events: []newRelayServerEndpointEvent{
|
||||
serverAendpointALamport2VNI2,
|
||||
serverAendpointALamport1VNI1,
|
||||
@@ -161,7 +161,7 @@ func TestRelayManager_handleNewServerEndpointRunLoop(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "eq server+vni neq ep lower lamport",
|
||||
name: "eq-server-vni-neq-ep-lower-lamport",
|
||||
events: []newRelayServerEndpointEvent{
|
||||
serverAendpointALamport2VNI2,
|
||||
serverAendpointBLamport1VNI2,
|
||||
@@ -171,7 +171,7 @@ func TestRelayManager_handleNewServerEndpointRunLoop(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "eq server+vni neq ep higher lamport",
|
||||
name: "eq-server-vni-neq-ep-higher-lamport",
|
||||
events: []newRelayServerEndpointEvent{
|
||||
serverAendpointBLamport1VNI2,
|
||||
serverAendpointALamport2VNI2,
|
||||
@@ -181,7 +181,7 @@ func TestRelayManager_handleNewServerEndpointRunLoop(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "eq server+endpoint+vni higher lamport",
|
||||
name: "eq-server-endpoint-vni-higher-lamport",
|
||||
events: []newRelayServerEndpointEvent{
|
||||
serverAendpointALamport1VNI1,
|
||||
serverAendpointALamport2VNI1,
|
||||
@@ -191,7 +191,7 @@ func TestRelayManager_handleNewServerEndpointRunLoop(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "eq server+endpoint+vni lower lamport",
|
||||
name: "eq-server-endpoint-vni-lower-lamport",
|
||||
events: []newRelayServerEndpointEvent{
|
||||
serverAendpointALamport2VNI1,
|
||||
serverAendpointALamport1VNI1,
|
||||
@@ -201,7 +201,7 @@ func TestRelayManager_handleNewServerEndpointRunLoop(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "eq endpoint+vni+lamport neq server",
|
||||
name: "eq-endpoint-vni-lamport-neq-server",
|
||||
events: []newRelayServerEndpointEvent{
|
||||
serverAendpointALamport1VNI1,
|
||||
serverBendpointALamport1VNI1,
|
||||
@@ -212,7 +212,7 @@ func TestRelayManager_handleNewServerEndpointRunLoop(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "trusted last best with matching server",
|
||||
name: "trusted-last-best-with-matching-server",
|
||||
events: []newRelayServerEndpointEvent{
|
||||
serverAendpointALamport1VNI1LastBestMatching,
|
||||
},
|
||||
|
||||
@@ -54,13 +54,13 @@ ip rule add -6 pref 5270 table 52
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "no config",
|
||||
name: "no-config",
|
||||
in: nil,
|
||||
want: `
|
||||
up` + basic,
|
||||
},
|
||||
{
|
||||
name: "local addr only",
|
||||
name: "local-addr-only",
|
||||
in: &Config{
|
||||
LocalAddrs: mustCIDRs("100.101.102.103/10"),
|
||||
NetfilterMode: netfilterOff,
|
||||
@@ -71,7 +71,7 @@ ip addr add 100.101.102.103/10 dev tailscale0` + basic,
|
||||
},
|
||||
|
||||
{
|
||||
name: "addr and routes",
|
||||
name: "addr-and-routes",
|
||||
in: &Config{
|
||||
LocalAddrs: mustCIDRs("100.101.102.103/10"),
|
||||
Routes: mustCIDRs("100.100.100.100/32", "192.168.16.0/24"),
|
||||
@@ -85,7 +85,7 @@ ip route add 192.168.16.0/24 dev tailscale0 table 52` + basic,
|
||||
},
|
||||
|
||||
{
|
||||
name: "addr and routes and subnet routes",
|
||||
name: "addr-routes-and-subnet-routes",
|
||||
in: &Config{
|
||||
LocalAddrs: mustCIDRs("100.101.102.103/10"),
|
||||
Routes: mustCIDRs("100.100.100.100/32", "192.168.16.0/24"),
|
||||
@@ -100,7 +100,7 @@ ip route add 192.168.16.0/24 dev tailscale0 table 52` + basic,
|
||||
},
|
||||
|
||||
{
|
||||
name: "addr and routes and subnet routes with netfilter",
|
||||
name: "addr-routes-subnet-routes-with-netfilter",
|
||||
in: &Config{
|
||||
LocalAddrs: mustCIDRs("100.101.102.104/10"),
|
||||
Routes: mustCIDRs("100.100.100.100/32", "10.0.0.0/8"),
|
||||
@@ -141,7 +141,7 @@ v6/nat/ts-postrouting -m mark --mark 0x40000/0xff0000 -j MASQUERADE
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "addr and routes and subnet routes with netfilter but no stateful filtering",
|
||||
name: "addr-routes-subnet-routes-netfilter-no-stateful",
|
||||
in: &Config{
|
||||
LocalAddrs: mustCIDRs("100.101.102.104/10"),
|
||||
Routes: mustCIDRs("100.100.100.100/32", "10.0.0.0/8"),
|
||||
@@ -180,7 +180,7 @@ v6/nat/ts-postrouting -m mark --mark 0x40000/0xff0000 -j MASQUERADE
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "addr and routes with netfilter",
|
||||
name: "addr-and-routes-with-netfilter",
|
||||
in: &Config{
|
||||
LocalAddrs: mustCIDRs("100.101.102.104/10"),
|
||||
Routes: mustCIDRs("100.100.100.100/32", "10.0.0.0/8"),
|
||||
@@ -215,7 +215,7 @@ v6/nat/POSTROUTING -j ts-postrouting
|
||||
},
|
||||
|
||||
{
|
||||
name: "addr and routes and subnet routes with netfilter but no SNAT",
|
||||
name: "addr-routes-subnet-routes-netfilter-no-SNAT",
|
||||
in: &Config{
|
||||
LocalAddrs: mustCIDRs("100.101.102.104/10"),
|
||||
Routes: mustCIDRs("100.100.100.100/32", "10.0.0.0/8"),
|
||||
@@ -251,7 +251,7 @@ v6/nat/POSTROUTING -j ts-postrouting
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "addr and routes with netfilter",
|
||||
name: "addr-and-routes-with-netfilter-2",
|
||||
in: &Config{
|
||||
LocalAddrs: mustCIDRs("100.101.102.104/10"),
|
||||
Routes: mustCIDRs("100.100.100.100/32", "10.0.0.0/8"),
|
||||
@@ -286,7 +286,7 @@ v6/nat/POSTROUTING -j ts-postrouting
|
||||
},
|
||||
|
||||
{
|
||||
name: "addr and routes with half netfilter",
|
||||
name: "addr-and-routes-with-half-netfilter",
|
||||
in: &Config{
|
||||
LocalAddrs: mustCIDRs("100.101.102.104/10"),
|
||||
Routes: mustCIDRs("100.100.100.100/32", "10.0.0.0/8"),
|
||||
@@ -310,7 +310,7 @@ v6/filter/ts-forward -o tailscale0 -j ACCEPT
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "addr and routes with netfilter2",
|
||||
name: "addr-and-routes-with-netfilter2",
|
||||
in: &Config{
|
||||
LocalAddrs: mustCIDRs("100.101.102.104/10"),
|
||||
Routes: mustCIDRs("100.100.100.100/32", "10.0.0.0/8"),
|
||||
@@ -344,7 +344,7 @@ v6/nat/POSTROUTING -j ts-postrouting
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "addr, routes, and local routes with netfilter",
|
||||
name: "addr-routes-local-routes-with-netfilter",
|
||||
in: &Config{
|
||||
LocalAddrs: mustCIDRs("100.101.102.104/10"),
|
||||
Routes: mustCIDRs("100.100.100.100/32", "0.0.0.0/0"),
|
||||
@@ -380,7 +380,7 @@ v6/nat/POSTROUTING -j ts-postrouting
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "addr, routes, and local routes with no netfilter",
|
||||
name: "addr-routes-local-routes-no-netfilter",
|
||||
in: &Config{
|
||||
LocalAddrs: mustCIDRs("100.101.102.104/10"),
|
||||
Routes: mustCIDRs("100.100.100.100/32", "0.0.0.0/0"),
|
||||
@@ -396,7 +396,7 @@ ip route add throw 10.0.0.0/8 table 52
|
||||
ip route add throw 192.168.0.0/24 table 52` + basic,
|
||||
},
|
||||
{
|
||||
name: "subnet routes with connmark for rp_filter",
|
||||
name: "subnet-routes-connmark-for-rp_filter",
|
||||
in: &Config{
|
||||
LocalAddrs: mustCIDRs("100.101.102.104/10"),
|
||||
Routes: mustCIDRs("100.100.100.100/32"),
|
||||
@@ -433,7 +433,7 @@ v6/nat/ts-postrouting -m mark --mark 0x40000/0xff0000 -j MASQUERADE
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "subnet routes (connmark always enabled)",
|
||||
name: "subnet-routes-connmark-always-enabled",
|
||||
in: &Config{
|
||||
LocalAddrs: mustCIDRs("100.101.102.104/10"),
|
||||
Routes: mustCIDRs("100.100.100.100/32"),
|
||||
@@ -470,7 +470,7 @@ v6/nat/ts-postrouting -m mark --mark 0x40000/0xff0000 -j MASQUERADE
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "connmark with stateful filtering",
|
||||
name: "connmark-with-stateful-filtering",
|
||||
in: &Config{
|
||||
LocalAddrs: mustCIDRs("100.101.102.104/10"),
|
||||
Routes: mustCIDRs("100.100.100.100/32"),
|
||||
|
||||
@@ -26,7 +26,7 @@ func TestWatchdog(t *testing.T) {
|
||||
maxWaitMultiple = 15
|
||||
}
|
||||
|
||||
t.Run("default watchdog does not fire", func(t *testing.T) {
|
||||
t.Run("default-watchdog-does-not-fire", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
bus := eventbustest.NewBus(t)
|
||||
ht := health.NewTracker(bus)
|
||||
@@ -55,7 +55,7 @@ func TestWatchdogMetrics(t *testing.T) {
|
||||
wantCounts map[watchdogEvent]int64
|
||||
}{
|
||||
{
|
||||
name: "single event types",
|
||||
name: "single-event-types",
|
||||
events: []watchdogEvent{RequestStatus, PeerForIPEvent, Ping},
|
||||
wantCounts: map[watchdogEvent]int64{
|
||||
RequestStatus: 1,
|
||||
@@ -64,7 +64,7 @@ func TestWatchdogMetrics(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "repeated events",
|
||||
name: "repeated-events",
|
||||
events: []watchdogEvent{RequestStatus, RequestStatus, Ping, RequestStatus},
|
||||
wantCounts: map[watchdogEvent]int64{
|
||||
RequestStatus: 3,
|
||||
|
||||
@@ -90,14 +90,14 @@ func TestDeviceConfig(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
t.Run("device1 config", func(t *testing.T) {
|
||||
t.Run("device1-config", func(t *testing.T) {
|
||||
if err := ReconfigDevice(device1, cfg1, t.Logf); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cmp(t, device1, cfg1)
|
||||
})
|
||||
|
||||
t.Run("device2 config", func(t *testing.T) {
|
||||
t.Run("device2-config", func(t *testing.T) {
|
||||
if err := ReconfigDevice(device2, cfg2, t.Logf); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -105,7 +105,7 @@ func TestDeviceConfig(t *testing.T) {
|
||||
})
|
||||
|
||||
// This is only to test that Config and Reconfig are properly synchronized.
|
||||
t.Run("device2 config/reconfig", func(t *testing.T) {
|
||||
t.Run("device2-config-reconfig", func(t *testing.T) {
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(2)
|
||||
|
||||
@@ -122,7 +122,7 @@ func TestDeviceConfig(t *testing.T) {
|
||||
wg.Wait()
|
||||
})
|
||||
|
||||
t.Run("device1 modify peer", func(t *testing.T) {
|
||||
t.Run("device1-modify-peer", func(t *testing.T) {
|
||||
cfg1.Peers[0].DiscoKey = key.DiscoPublicFromRaw32(mem.B([]byte{0: 1, 31: 0}))
|
||||
if err := ReconfigDevice(device1, cfg1, t.Logf); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -130,7 +130,7 @@ func TestDeviceConfig(t *testing.T) {
|
||||
cmp(t, device1, cfg1)
|
||||
})
|
||||
|
||||
t.Run("device1 replace endpoint", func(t *testing.T) {
|
||||
t.Run("device1-replace-endpoint", func(t *testing.T) {
|
||||
cfg1.Peers[0].DiscoKey = key.DiscoPublicFromRaw32(mem.B([]byte{0: 2, 31: 0}))
|
||||
if err := ReconfigDevice(device1, cfg1, t.Logf); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -138,7 +138,7 @@ func TestDeviceConfig(t *testing.T) {
|
||||
cmp(t, device1, cfg1)
|
||||
})
|
||||
|
||||
t.Run("device1 add new peer", func(t *testing.T) {
|
||||
t.Run("device1-add-new-peer", func(t *testing.T) {
|
||||
cfg1.Peers = append(cfg1.Peers, Peer{
|
||||
PublicKey: k3,
|
||||
AllowedIPs: []netip.Prefix{ip3},
|
||||
@@ -178,7 +178,7 @@ func TestDeviceConfig(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("device1 remove peer", func(t *testing.T) {
|
||||
t.Run("device1-remove-peer", func(t *testing.T) {
|
||||
removeKey := cfg1.Peers[len(cfg1.Peers)-1].PublicKey
|
||||
cfg1.Peers = cfg1.Peers[:len(cfg1.Peers)-1]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user