mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-03 02:21:58 +00:00
tstest/integration/vms: test DNS configuration
This uses a neat little tool to dump the output of DNS queries to standard out. This is the first end-to-end test of DNS that runs against actual linux systems. The /etc/resolv.conf test may look superflous, however this will help for correlating system state if one of the DNS tests fails. Signed-off-by: Christine Dodrill <xe@tailscale.com>
This commit is contained in:
committed by
David Crawshaw
parent
00b3c1c042
commit
0b9e938152
@@ -624,6 +624,48 @@ func (h *Harness) testDistro(t *testing.T, d Distro, ipm ipMapping) {
|
||||
t.Fatalf("wanted %q from vm, got: %q", securePassword, msg)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("dns-test", func(t *testing.T) {
|
||||
t.Run("etc-resolv-conf", func(t *testing.T) {
|
||||
sess := getSession(t, cli)
|
||||
sess.Stdout = logger.FuncWriter(t.Logf)
|
||||
sess.Stderr = logger.FuncWriter(t.Errorf)
|
||||
if err := sess.Run("cat /etc/resolv.conf"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
})
|
||||
|
||||
cwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
t.Fatalf("can't get working directory: %v", err)
|
||||
}
|
||||
dir := t.TempDir()
|
||||
run(t, cwd, "go", "build", "-o", filepath.Join(dir, "dns_tester"), "./dns_tester.go")
|
||||
|
||||
sftpCli, err := sftp.NewClient(cli)
|
||||
if err != nil {
|
||||
t.Fatalf("can't connect over sftp to copy binaries: %v", err)
|
||||
}
|
||||
defer sftpCli.Close()
|
||||
|
||||
copyFile(t, sftpCli, filepath.Join(dir, "dns_tester"), "/dns_tester")
|
||||
|
||||
for _, record := range []string{"extratest.record", "extratest"} {
|
||||
t.Run(record, func(t *testing.T) {
|
||||
sess := getSession(t, cli)
|
||||
sess.Stderr = logger.FuncWriter(t.Errorf)
|
||||
msg, err := sess.Output("/dns_tester " + record)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
msg = bytes.TrimSpace(msg)
|
||||
if want := []byte("1.2.3.4"); !bytes.Contains(msg, want) {
|
||||
t.Fatalf("got: %q, want: %q", msg, want)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func runTestCommands(t *testing.T, timeout time.Duration, cli *ssh.Client, batch []expect.Batcher) {
|
||||
|
||||
Reference in New Issue
Block a user