Compare commits

..

1 Commits

Author SHA1 Message Date
Tom DNetto
3425092289 github actions: resume running Nix-based integration tests
These should be back in a good state, and some tests (ie: TestMITMProxy)
are based on nix tooling so we should do these in CI.

Signed-off-by: Tom DNetto <tom@tailscale.com>
2022-04-14 15:46:55 -07:00
3 changed files with 35 additions and 37 deletions

View File

@@ -19,12 +19,16 @@ jobs:
uses: actions/setup-go@v3
with:
go-version: 1.18
- name: Set up Nix
uses: cachix/install-nix-action@v17
with:
nix_path: nixpkgs=channel:nixos-21.11
- name: Checkout Code
uses: actions/checkout@v3
- name: Run VM tests
run: go test ./tstest/integration/vms -v -no-s3 -run-vm-tests -run=TestRunUbuntu2004
run: go test ./tstest/integration/vms -v --timeout=20m --no-s3 --run-vm-tests --distro-regex '(nix|ubuntu)'
env:
HOME: "/tmp"
TMPDIR: "/tmp"

View File

@@ -850,7 +850,7 @@ func (c *Direct) sendMapRequest(ctx context.Context, maxPolls int, cb func(*netm
if pr := resp.PingRequest; pr != nil && c.isUniquePingRequest(pr) {
metricMapResponsePings.Add(1)
go answerPing(c.logf, c.httpc, pr, c.pinger)
go answerPing(c.logf, c.httpc, pr)
}
if u := resp.PopBrowserURL; u != "" && u != sess.lastPopBrowserURL {
sess.lastPopBrowserURL = u
@@ -1181,42 +1181,29 @@ func (c *Direct) isUniquePingRequest(pr *tailcfg.PingRequest) bool {
return true
}
func answerPing(logf logger.Logf, c *http.Client, pr *tailcfg.PingRequest, pinger Pinger) {
func answerPing(logf logger.Logf, c *http.Client, pr *tailcfg.PingRequest) {
if pr.URL == "" {
logf("invalid PingRequest with no URL")
return
}
if pr.Types == "" {
answerHeadPing(logf, c, pr)
return
}
for _, t := range strings.Split(pr.Types, ",") {
switch t {
case "TSMP":
go tsmpPing(logf, c, pr, pinger)
}
}
}
func answerHeadPing(logf logger.Logf, c *http.Client, pr *tailcfg.PingRequest) {
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel()
req, err := http.NewRequestWithContext(ctx, "HEAD", pr.URL, nil)
if err != nil {
logf("answerHeadPing: NewRequestWithContext: %v", err)
logf("http.NewRequestWithContext(%q): %v", pr.URL, err)
return
}
if pr.Log {
logf("answerHeadPing: sending HEAD ping to %v ...", pr.URL)
logf("answerPing: sending ping to %v ...", pr.URL)
}
t0 := time.Now()
_, err = c.Do(req)
d := time.Since(t0).Round(time.Millisecond)
if err != nil {
logf("answerHeadPing error: %v to %v (after %v)", err, pr.URL, d)
logf("answerPing error: %v to %v (after %v)", err, pr.URL, d)
} else if pr.Log {
logf("answerHeadPing complete to %v (after %v)", pr.URL, d)
logf("answerPing complete to %v (after %v)", pr.URL, d)
}
}
@@ -1391,25 +1378,33 @@ func (c *Direct) DoNoiseRequest(req *http.Request) (*http.Response, error) {
// tsmpPing sends a Ping to pr.IP, and sends an http request back to pr.URL
// with ping response data.
func tsmpPing(logf logger.Logf, c *http.Client, pr *tailcfg.PingRequest, pinger Pinger) {
if pr.URL == "" || pr.IP.IsZero() || pinger == nil {
return
func tsmpPing(logf logger.Logf, c *http.Client, pr *tailcfg.PingRequest, pinger Pinger) error {
var err error
if pr.URL == "" {
return errors.New("invalid PingRequest with no URL")
}
start := time.Now()
if pr.IP.IsZero() {
return errors.New("PingRequest without IP")
}
if !strings.Contains(pr.Types, "TSMP") {
return fmt.Errorf("PingRequest with no TSMP in Types, got %q", pr.Types)
}
now := time.Now()
pinger.Ping(pr.IP, true, func(res *ipnstate.PingResult) {
// Currently does not check for error since we just return if it fails.
postPingResult(start, logf, c, pr, res)
err = postPingResult(now, logf, c, pr, res)
})
return err
}
func postPingResult(start time.Time, logf logger.Logf, c *http.Client, pr *tailcfg.PingRequest, res *ipnstate.PingResult) error {
duration := time.Since(start).Round(time.Millisecond)
func postPingResult(now time.Time, logf logger.Logf, c *http.Client, pr *tailcfg.PingRequest, res *ipnstate.PingResult) error {
if res.Err != "" {
return errors.New(res.Err)
}
duration := time.Since(now)
if pr.Log {
if res.Err == "" {
logf("TSMP ping to %v completed in %v. pinger.Ping took %v seconds", pr.IP, res.LatencySeconds, duration)
} else {
logf("TSMP ping to %v failed after %v: %v", pr.IP, duration, res.Err)
}
logf("TSMP ping to %v completed in %v seconds. pinger.Ping took %v seconds", pr.IP, res.LatencySeconds, duration.Seconds())
}
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel()
@@ -1419,7 +1414,7 @@ func postPingResult(start time.Time, logf logger.Logf, c *http.Client, pr *tailc
return err
}
// Send the results of the Ping, back to control URL.
req, err := http.NewRequestWithContext(ctx, "POST", pr.URL, bytes.NewReader(jsonPingRes))
req, err := http.NewRequestWithContext(ctx, "POST", pr.URL, bytes.NewBuffer(jsonPingRes))
if err != nil {
return fmt.Errorf("http.NewRequestWithContext(%q): %w", pr.URL, err)
}
@@ -1430,9 +1425,9 @@ func postPingResult(start time.Time, logf logger.Logf, c *http.Client, pr *tailc
_, err = c.Do(req)
d := time.Since(t0).Round(time.Millisecond)
if err != nil {
return fmt.Errorf("postPingResult error: %w to %v (after %v)", err, pr.URL, d)
return fmt.Errorf("tsmpPing error: %w to %v (after %v)", err, pr.URL, d)
} else if pr.Log {
logf("postPingResult complete to %v (after %v)", pr.URL, d)
logf("tsmpPing complete to %v (after %v)", pr.URL, d)
}
return nil
}

View File

@@ -67,8 +67,7 @@ type CapabilityVersion int
// 28: 2022-03-09: client can communicate over Noise.
// 29: 2022-03-21: MapResponse.PopBrowserURL
// 30: 2022-03-22: client can request id tokens.
// 31: 2022-04-15: PingRequest TSMP support
const CurrentCapabilityVersion CapabilityVersion = 31
const CurrentCapabilityVersion CapabilityVersion = 30
type StableID string