Skip to content

Commit 6e24f50

Browse files
committed
tsnet: add tstest.Shard on the slow tests
So they're not all run N times on the sharded oss builders and are only run one time each. Updates tailscale/corp#28679 Change-Id: Ie21e84b06731fdc8ec3212eceb136c8fc26b0115 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
1 parent 8ed6bb3 commit 6e24f50

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

tsnet/packet_filter_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212

1313
"tailscale.com/ipn"
1414
"tailscale.com/tailcfg"
15+
"tailscale.com/tstest"
1516
"tailscale.com/types/ipproto"
1617
"tailscale.com/types/key"
1718
"tailscale.com/types/netmap"
@@ -47,6 +48,7 @@ func waitFor(t testing.TB, ctx context.Context, s *Server, f func(*netmap.Networ
4748
// netmaps and turning them into packet filters together. Only the control-plane
4849
// side is mocked out.
4950
func TestPacketFilterFromNetmap(t *testing.T) {
51+
tstest.Shard(t)
5052
t.Parallel()
5153

5254
var key key.NodePublic

tsnet/tsnet_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ func startServer(t *testing.T, ctx context.Context, controlURL, hostname string)
235235
}
236236

237237
func TestDialBlocks(t *testing.T) {
238+
tstest.Shard(t)
238239
tstest.ResourceCheck(t)
239240
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
240241
defer cancel()
@@ -282,6 +283,7 @@ func TestDialBlocks(t *testing.T) {
282283
// - s2 can dial through the subnet router functionality (getting a synthetic RST
283284
// that we verify we generated & saw)
284285
func TestConn(t *testing.T) {
286+
tstest.Shard(t)
285287
tstest.ResourceCheck(t)
286288
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
287289
defer cancel()
@@ -414,6 +416,7 @@ func TestConn(t *testing.T) {
414416

415417
func TestLoopbackLocalAPI(t *testing.T) {
416418
flakytest.Mark(t, "https://github.com/tailscale/tailscale/issues/8557")
419+
tstest.Shard(t)
417420
tstest.ResourceCheck(t)
418421
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
419422
defer cancel()
@@ -489,6 +492,7 @@ func TestLoopbackLocalAPI(t *testing.T) {
489492

490493
func TestLoopbackSOCKS5(t *testing.T) {
491494
flakytest.Mark(t, "https://github.com/tailscale/tailscale/issues/8198")
495+
tstest.Shard(t)
492496
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
493497
defer cancel()
494498

@@ -539,6 +543,7 @@ func TestLoopbackSOCKS5(t *testing.T) {
539543
}
540544

541545
func TestTailscaleIPs(t *testing.T) {
546+
tstest.Shard(t)
542547
controlURL, _ := startControl(t)
543548

544549
tmp := t.TempDir()
@@ -581,6 +586,7 @@ func TestTailscaleIPs(t *testing.T) {
581586
// TestListenerCleanup is a regression test to verify that s.Close doesn't
582587
// deadlock if a listener is still open.
583588
func TestListenerCleanup(t *testing.T) {
589+
tstest.Shard(t)
584590
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
585591
defer cancel()
586592

@@ -623,6 +629,7 @@ func (wc *closeTrackConn) Close() error {
623629
// tests https://github.com/tailscale/tailscale/issues/6973 -- that we can start a tsnet server,
624630
// stop it, and restart it, even on Windows.
625631
func TestStartStopStartGetsSameIP(t *testing.T) {
632+
tstest.Shard(t)
626633
controlURL, _ := startControl(t)
627634

628635
tmp := t.TempDir()
@@ -672,6 +679,7 @@ func TestStartStopStartGetsSameIP(t *testing.T) {
672679
}
673680

674681
func TestFunnel(t *testing.T) {
682+
tstest.Shard(t)
675683
ctx, dialCancel := context.WithTimeout(context.Background(), 30*time.Second)
676684
defer dialCancel()
677685

@@ -733,6 +741,7 @@ func TestFunnel(t *testing.T) {
733741
}
734742

735743
func TestListenerClose(t *testing.T) {
744+
tstest.Shard(t)
736745
ctx := context.Background()
737746
controlURL, _ := startControl(t)
738747

@@ -812,6 +821,7 @@ func (c *bufferedConn) Read(b []byte) (int, error) {
812821
}
813822

814823
func TestFallbackTCPHandler(t *testing.T) {
824+
tstest.Shard(t)
815825
tstest.ResourceCheck(t)
816826
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
817827
defer cancel()
@@ -854,6 +864,7 @@ func TestFallbackTCPHandler(t *testing.T) {
854864
}
855865

856866
func TestCapturePcap(t *testing.T) {
867+
tstest.Shard(t)
857868
const timeLimit = 120
858869
ctx, cancel := context.WithTimeout(context.Background(), timeLimit*time.Second)
859870
defer cancel()
@@ -907,6 +918,7 @@ func TestCapturePcap(t *testing.T) {
907918
}
908919

909920
func TestUDPConn(t *testing.T) {
921+
tstest.Shard(t)
910922
tstest.ResourceCheck(t)
911923
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
912924
defer cancel()
@@ -1098,6 +1110,7 @@ func sendData(logf func(format string, args ...any), ctx context.Context, bytesC
10981110
}
10991111

11001112
func TestUserMetricsByteCounters(t *testing.T) {
1113+
tstest.Shard(t)
11011114
ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
11021115
defer cancel()
11031116

@@ -1212,6 +1225,7 @@ func TestUserMetricsByteCounters(t *testing.T) {
12121225
}
12131226

12141227
func TestUserMetricsRouteGauges(t *testing.T) {
1228+
tstest.Shard(t)
12151229
// Windows does not seem to support or report back routes when running in
12161230
// userspace via tsnet. So, we skip this check on Windows.
12171231
// TODO(kradalby): Figure out if this is correct.
@@ -1368,6 +1382,7 @@ func mustDirect(t *testing.T, logf logger.Logf, lc1, lc2 *local.Client) {
13681382
}
13691383

13701384
func TestDeps(t *testing.T) {
1385+
tstest.Shard(t)
13711386
deptest.DepChecker{
13721387
GOOS: "linux",
13731388
GOARCH: "amd64",

0 commit comments

Comments
 (0)