mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-30 13:35:37 +00:00
0e0e53d3b3
this commit changes usermetrics to be non-global, this is a building block for correct metrics if a go process runs multiple tsnets or in tests. Updates #13420 Updates tailscale/corp#22075 Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
45 lines
988 B
Go
45 lines
988 B
Go
// Copyright (c) Tailscale Inc & AUTHORS
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
package wgengine
|
|
|
|
import (
|
|
"runtime"
|
|
"testing"
|
|
"time"
|
|
|
|
"tailscale.com/health"
|
|
"tailscale.com/util/usermetric"
|
|
)
|
|
|
|
func TestWatchdog(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
var maxWaitMultiple time.Duration = 1
|
|
if runtime.GOOS == "darwin" {
|
|
// Work around slow close syscalls on Big Sur with content filter Network Extensions installed.
|
|
// See https://github.com/tailscale/tailscale/issues/1598.
|
|
maxWaitMultiple = 15
|
|
}
|
|
|
|
t.Run("default watchdog does not fire", func(t *testing.T) {
|
|
t.Parallel()
|
|
ht := new(health.Tracker)
|
|
reg := new(usermetric.Registry)
|
|
e, err := NewFakeUserspaceEngine(t.Logf, 0, ht, reg)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
e = NewWatchdog(e)
|
|
e.(*watchdogEngine).maxWait = maxWaitMultiple * 150 * time.Millisecond
|
|
e.(*watchdogEngine).logf = t.Logf
|
|
e.(*watchdogEngine).fatalf = t.Fatalf
|
|
|
|
e.RequestStatus()
|
|
e.RequestStatus()
|
|
e.RequestStatus()
|
|
e.Close()
|
|
})
|
|
}
|