From f1b5e51369e2c418db51f85a7d8383d5447eb4b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus=20Lensb=C3=B8l?= Date: Wed, 18 Nov 2026 11:17:00 -0500 Subject: [PATCH] tstest/natlab/vmtest: make ssh tests run across Linux test matrix (#22491) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updates #21817 Signed-off-by: Claus Lensbøl --- tstest/natlab/vmtest/matrix_generated_test.go | 3 ++ tstest/natlab/vmtest/ssh_test.go | 29 +++++++++++-------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/tstest/natlab/vmtest/matrix_generated_test.go b/tstest/natlab/vmtest/matrix_generated_test.go index 9276de681..620ad8c85 100644 --- a/tstest/natlab/vmtest/matrix_generated_test.go +++ b/tstest/natlab/vmtest/matrix_generated_test.go @@ -17,6 +17,9 @@ var testMatrix = []struct { {name: "testPeerAPINotReachableFromLAN_Ubuntu2404", fn: func(t *testing.T) { testPeerAPINotReachableFromLAN(t, vmtest.Ubuntu2404) }}, {name: "testPeerAPINotReachableFromLAN_Fedora43", fn: func(t *testing.T) { testPeerAPINotReachableFromLAN(t, vmtest.Fedora43) }}, {name: "testPeerAPINotReachableFromLAN_Debian13", fn: func(t *testing.T) { testPeerAPINotReachableFromLAN(t, vmtest.Debian13) }}, + {name: "testTailscaleSSHForOS_Ubuntu2404", fn: func(t *testing.T) { testTailscaleSSHForOS(t, vmtest.Ubuntu2404) }}, + {name: "testTailscaleSSHForOS_Fedora43", fn: func(t *testing.T) { testTailscaleSSHForOS(t, vmtest.Fedora43) }}, + {name: "testTailscaleSSHForOS_Debian13", fn: func(t *testing.T) { testTailscaleSSHForOS(t, vmtest.Debian13) }}, {name: "testSubnetRouterForOS_Ubuntu2404", fn: func(t *testing.T) { testSubnetRouterForOS(t, vmtest.Ubuntu2404) }}, {name: "testSubnetRouterForOS_Fedora43", fn: func(t *testing.T) { testSubnetRouterForOS(t, vmtest.Fedora43) }}, {name: "testSubnetRouterForOS_Debian13", fn: func(t *testing.T) { testSubnetRouterForOS(t, vmtest.Debian13) }}, diff --git a/tstest/natlab/vmtest/ssh_test.go b/tstest/natlab/vmtest/ssh_test.go index 8f332922e..8616c7a32 100644 --- a/tstest/natlab/vmtest/ssh_test.go +++ b/tstest/natlab/vmtest/ssh_test.go @@ -18,29 +18,34 @@ import ( "tailscale.com/tstest/natlab/vnet" ) -// TestTailscaleSSH_Ubuntu exercises the Tailscale SSH server ("tailscale up -// --ssh", not a system sshd) on an Ubuntu node, with an Ubuntu node as the SSH -// client. It tests logging in as both root and a non-root user, which -// exercises the incubator's su-based login path. +// TestTailscaleSSH_Ubuntu exercises the Tailscale SSH server on Ubuntu. +// See testTailscaleSSHForOS for what is verified. func TestTailscaleSSH_Ubuntu(t *testing.T) { - testSuite := newTestSuite(t, "ubuntu", vmtest.Ubuntu2404) + testTailscaleSSHForOS(t, vmtest.Ubuntu2404) +} - ubuntu := testSuite.server +// testTailscaleSSHForOS exercises the Tailscale SSH server ("tailscale up +// --ssh", not a system sshd) on a Linux node of the given distribution, with +// an Ubuntu node as the SSH client. It tests logging in as both root and a +// non-root user, which exercises the incubator's su-based login path. +func testTailscaleSSHForOS(t *testing.T, serverOS vmtest.OSImageLinux) { + testSuite := newTestSuite(t, serverOS.Name, serverOS) + server := testSuite.server - if out, err := testSuite.env.SSHExec(ubuntu, "useradd -m -s /bin/bash tsuser"); err != nil { + if out, err := testSuite.env.SSHExec(server, "useradd -m -s /bin/bash tsuser"); err != nil { t.Fatalf("useradd: %v\n%s", err, out) } - testSuite.waitSSH(t, "ubuntu", "root") + testSuite.waitSSH(t, serverOS.Name, "root") - testSuite.check(t, "ubuntu root login", "root", "id -un && pwd", "root\n/root") - testSuite.check(t, "ubuntu non-root login", "tsuser", "id -un && pwd", "tsuser\n/home/tsuser") + testSuite.check(t, serverOS.Name+" root login", "root", "id -un && pwd", "root\n/root") + testSuite.check(t, serverOS.Name+" non-root login", "tsuser", "id -un && pwd", "tsuser\n/home/tsuser") if out, code := testSuite.ssh(t, "nosuchuser", "true"); code == 0 { - t.Errorf("ubuntu nonexistent user: ssh succeeded, want failure:\n%s", out) + t.Errorf("%s nonexistent user: ssh succeeded, want failure:\n%s", serverOS.Name, out) } - testSuite.checkAutogroupNonroot(t, "ubuntu") + testSuite.checkAutogroupNonroot(t, serverOS.Name) } // TestTailscaleSSH_FreeBSD exercises the Tailscale SSH server ("tailscale up