mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-20 01:47:33 +00:00
tstest/integration/vms: regex-match distros using a flag (#2021)
If you set `-distro-regex` to match a subset of distros, only those distros will be tested. Ex: $ go test -run-vm-tests -distro-regex='opensuse' Signed-off-by: Christine Dodrill <xe@tailscale.com>
This commit is contained in:

committed by
GitHub

parent
e1b994f7ed
commit
36cb69002a
@@ -41,6 +41,11 @@ import (
|
||||
const securePassword = "hunter2"
|
||||
|
||||
var runVMTests = flag.Bool("run-vm-tests", false, "if set, run expensive (10G+ ram) VM based integration tests")
|
||||
var distroRex *regexValue = func() *regexValue {
|
||||
result := ®exValue{r: regexp.MustCompile(`.*`)}
|
||||
flag.Var(result, "distro-regex", "The regex that matches what distros should be run")
|
||||
return result
|
||||
}()
|
||||
|
||||
type Distro struct {
|
||||
name string // amazon-linux
|
||||
@@ -360,6 +365,8 @@ func TestVMIntegrationEndToEnd(t *testing.T) {
|
||||
|
||||
dir := t.TempDir()
|
||||
|
||||
rex := distroRex.Unwrap()
|
||||
|
||||
ln, err := net.Listen("tcp", deriveBindhost(t)+":0")
|
||||
if err != nil {
|
||||
t.Fatalf("can't make TCP listener: %v", err)
|
||||
@@ -417,11 +424,20 @@ func TestVMIntegrationEndToEnd(t *testing.T) {
|
||||
loginServer := fmt.Sprintf("http://%s", ln.Addr())
|
||||
t.Logf("loginServer: %s", loginServer)
|
||||
|
||||
var numDistros = 0
|
||||
|
||||
cancels := make(chan func(), len(distros))
|
||||
|
||||
t.Run("mkvm", func(t *testing.T) {
|
||||
for n, distro := range distros {
|
||||
n, distro := n, distro
|
||||
if rex.MatchString(distro.name) {
|
||||
t.Logf("%s matches %s", distro.name, rex)
|
||||
numDistros++
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
|
||||
t.Run(distro.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -450,13 +466,13 @@ func TestVMIntegrationEndToEnd(t *testing.T) {
|
||||
for {
|
||||
<-waiter.C
|
||||
ipMu.Lock()
|
||||
if len(ipMap) == len(distros) {
|
||||
if len(ipMap) == numDistros {
|
||||
ipMu.Unlock()
|
||||
break
|
||||
} else {
|
||||
if n%30 == 0 {
|
||||
t.Logf("ipMap: %d", len(ipMap))
|
||||
t.Logf("distros: %d", len(distros))
|
||||
t.Logf("distros: %d", numDistros)
|
||||
}
|
||||
}
|
||||
n++
|
||||
|
Reference in New Issue
Block a user