tstest/integration/vms: t.Log for VM output (#2007)

Previously we spewed a lot of output to stdout and stderr, even when
`-v` wasn't set. This is sub-optimal for various reasons. This patch
shunts that output to test logs so it only shows up when `-v` is set.

Updates #1988

Signed-off-by: Christine Dodrill <xe@tailscale.com>
pull/2009/head
Christine Dodrill 4 years ago committed by GitHub
parent 6d6cf88d82
commit 4cfaf489ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -12,6 +12,7 @@ import (
"flag" "flag"
"fmt" "fmt"
"io" "io"
"log"
"net" "net"
"net/http" "net/http"
"os" "os"
@ -29,6 +30,7 @@ import (
expect "github.com/google/goexpect" expect "github.com/google/goexpect"
"golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh"
"inet.af/netaddr" "inet.af/netaddr"
"tailscale.com/tstest"
"tailscale.com/tstest/integration/testcontrol" "tailscale.com/tstest/integration/testcontrol"
) )
@ -122,10 +124,11 @@ func fetchDistro(t *testing.T, resultDistro Distro) {
func run(t *testing.T, dir, prog string, args ...string) { func run(t *testing.T, dir, prog string, args ...string) {
t.Helper() t.Helper()
t.Logf("running: %s %s", prog, strings.Join(args, " ")) t.Logf("running: %s %s", prog, strings.Join(args, " "))
tstest.FixLogs(t)
cmd := exec.Command(prog, args...) cmd := exec.Command(prog, args...)
cmd.Stdout = os.Stdout cmd.Stdout = log.Writer()
cmd.Stderr = os.Stderr cmd.Stderr = log.Writer()
cmd.Dir = dir cmd.Dir = dir
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {
t.Fatal(err) t.Fatal(err)
@ -415,6 +418,7 @@ func TestVMIntegrationEndToEnd(t *testing.T) {
for port := range ipMap { for port := range ipMap {
port := port port := port
t.Run(port, func(t *testing.T) { t.Run(port, func(t *testing.T) {
tstest.FixLogs(t)
config := &ssh.ClientConfig{ config := &ssh.ClientConfig{
User: "ts", User: "ts",
Auth: []ssh.AuthMethod{ssh.PublicKeys(signer), ssh.Password("hunter2")}, Auth: []ssh.AuthMethod{ssh.PublicKeys(signer), ssh.Password("hunter2")},
@ -431,7 +435,7 @@ func TestVMIntegrationEndToEnd(t *testing.T) {
t.Logf("about to ssh into 127.0.0.1:%s", port) t.Logf("about to ssh into 127.0.0.1:%s", port)
timeout := 5 * time.Minute timeout := 5 * time.Minute
e, _, err := expect.SpawnSSH(cli, timeout, expect.Verbose(true), expect.VerboseWriter(os.Stdout)) e, _, err := expect.SpawnSSH(cli, timeout, expect.Verbose(true), expect.VerboseWriter(log.Writer()))
if err != nil { if err != nil {
t.Fatalf("%s: can't register a shell session: %v", port, err) t.Fatalf("%s: can't register a shell session: %v", port, err)
} }

Loading…
Cancel
Save