mirror of https://github.com/tailscale/tailscale/
tstest/integration/vms: codegen for top level tests (#2441)
This moves the distribution definitions into a maintainable hujson file instead of just existing as constants in `distros.go`. Comments are maintained from the inline definitions. This uses jennifer[1] for hygenic source tree creation. This allows us to generate a unique top-level test for each VM run. This should hopefully help make the output of `go test` easier to read. This also separates each test out into its own top-level test so that we can better track the time that each distro takes. I really wish there was a way to have the `test_codegen.go` file _always_ run as a part of the compile process instead of having to rely on people remembering to run `go generate`, but I am limited by my tools. This will let us remove the `-distro-regex` flag and use `go test -run` to pick which distros are run. Signed-off-by: Christine Dodrill <xe@tailscale.com>pull/2445/head
parent
391207bbcf
commit
798b0da470
@ -0,0 +1,208 @@
|
||||
// NOTE(Xe): If you run into issues getting the autoconfig to work, run
|
||||
// this test with the flag `--distro-regex=alpine-edge`. Connect with a VNC
|
||||
// client with a command like this:
|
||||
//
|
||||
// $ vncviewer :0
|
||||
//
|
||||
// On NixOS you can get away with something like this:
|
||||
//
|
||||
// $ env NIXPKGS_ALLOW_UNFREE=1 nix-shell -p tigervnc --run 'vncviewer :0'
|
||||
//
|
||||
// Login as root with the password root. Then look in
|
||||
// /var/log/cloud-init-output.log for what you messed up.
|
||||
[
|
||||
// NOTE(Xe): These images are not official images created by the Alpine Linux
|
||||
// cloud team because the cloud team hasn't created any official images yet.
|
||||
// These images were created under the guidance of the cloud team and contain
|
||||
// few notable differences from what they would end up shipping. The Alpine
|
||||
// Linux cloud team probably won't have official images up until a year or so
|
||||
// after this comment is written (2021-06-11), but overall they will be
|
||||
// compatible with these images. These images were created using the setup in
|
||||
// this repo: https://github.com/Xe/alpine-image. I hereby promise to not break
|
||||
// these links.
|
||||
{
|
||||
"Name": "alpine-3-13-5",
|
||||
"URL": "https://xena.greedo.xeserv.us/pkg/alpine/img/alpine-3.13.5-cloud-init-within.qcow2",
|
||||
"SHA256Sum": "a2665c16724e75899723e81d81126bd0254a876e5de286b0b21553734baec287",
|
||||
"MemoryMegs": 256,
|
||||
"PackageManager": "apk",
|
||||
"InitSystem": "openrc"
|
||||
},
|
||||
{
|
||||
"Name": "alpine-edge",
|
||||
"URL": "https://xena.greedo.xeserv.us/pkg/alpine/img/alpine-edge-2021-05-18-cloud-init-within.qcow2",
|
||||
"SHA256Sum": "b3bb15311c0bd3beffa1b554f022b75d3b7309b5fdf76fb146fe7c72b83b16d0",
|
||||
"MemoryMegs": 256,
|
||||
"PackageManager": "apk",
|
||||
"InitSystem": "openrc"
|
||||
},
|
||||
|
||||
// NOTE(Xe): All of the following images are official images straight from each
|
||||
// distribution's official documentation.
|
||||
{
|
||||
"Name": "amazon-linux",
|
||||
"URL": "https://cdn.amazonlinux.com/os-images/2.0.20210427.0/kvm/amzn2-kvm-2.0.20210427.0-x86_64.xfs.gpt.qcow2",
|
||||
"SHA256Sum": "6ef9daef32cec69b2d0088626ec96410cd24afc504d57278bbf2f2ba2b7e529b",
|
||||
"MemoryMegs": 512,
|
||||
"PackageManager": "yum",
|
||||
"InitSystem": "systemd"
|
||||
},
|
||||
{
|
||||
"Name": "arch",
|
||||
"URL": "https://mirror.pkgbuild.com/images/v20210515.22945/Arch-Linux-x86_64-cloudimg-20210515.22945.qcow2",
|
||||
"SHA256Sum": "e4077f5ba3c5d545478f64834bc4852f9f7a2e05950fce8ecd0df84193162a27",
|
||||
"MemoryMegs": 512,
|
||||
"PackageManager": "pacman",
|
||||
"InitSystem": "systemd"
|
||||
},
|
||||
{
|
||||
"Name": "centos-7",
|
||||
"URL": "https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-2003.qcow2c",
|
||||
"SHA256Sum": "b7555ecf90b24111f2efbc03c1e80f7b38f1e1fc7e1b15d8fee277d1a4575e87",
|
||||
"MemoryMegs": 512,
|
||||
"PackageManager": "yum",
|
||||
"InitSystem": "systemd"
|
||||
},
|
||||
{
|
||||
"Name": "centos-8",
|
||||
"URL": "https://cloud.centos.org/centos/8/x86_64/images/CentOS-8-GenericCloud-8.3.2011-20201204.2.x86_64.qcow2",
|
||||
"SHA256Sum": "7ec97062618dc0a7ebf211864abf63629da1f325578868579ee70c495bed3ba0",
|
||||
"MemoryMegs": 768,
|
||||
"PackageManager": "dnf",
|
||||
"InitSystem": "systemd"
|
||||
},
|
||||
{
|
||||
"Name": "debian-9",
|
||||
"URL": "http://cloud.debian.org/images/cloud/OpenStack/9.13.22-20210531/debian-9.13.22-20210531-openstack-amd64.qcow2",
|
||||
"SHA256Sum": "c36e25f2ab0b5be722180db42ed9928476812f02d053620e1c287f983e9f6f1d",
|
||||
"MemoryMegs": 512,
|
||||
"PackageManager": "apt",
|
||||
"InitSystem": "systemd"
|
||||
},
|
||||
{
|
||||
"Name": "debian-10",
|
||||
"URL": "https://cdimage.debian.org/images/cloud/buster/20210329-591/debian-10-generic-amd64-20210329-591.qcow2",
|
||||
"SHA256Sum": "70c61956095870c4082103d1a7a1cb5925293f8405fc6cb348588ec97e8611b0",
|
||||
"MemoryMegs": 768,
|
||||
"PackageManager": "apt",
|
||||
"InitSystem": "systemd"
|
||||
},
|
||||
{
|
||||
"Name": "fedora-34",
|
||||
"URL": "https://download.fedoraproject.org/pub/fedora/linux/releases/34/Cloud/x86_64/images/Fedora-Cloud-Base-34-1.2.x86_64.qcow2",
|
||||
"SHA256Sum": "b9b621b26725ba95442d9a56cbaa054784e0779a9522ec6eafff07c6e6f717ea",
|
||||
"MemoryMegs": 768,
|
||||
"PackageManager": "dnf",
|
||||
"InitSystem": "systemd"
|
||||
},
|
||||
{
|
||||
"Name": "opensuse-leap-15-1",
|
||||
"URL": "https://download.opensuse.org/repositories/Cloud:/Images:/Leap_15.1/images/openSUSE-Leap-15.1-OpenStack.x86_64.qcow2",
|
||||
"SHA256Sum": "40bc72b8ee143364fc401f2c9c9a11ecb7341a29fa84c6f7bf42fc94acf19a02",
|
||||
"MemoryMegs": 512,
|
||||
"PackageManager": "zypper",
|
||||
"InitSystem": "systemd"
|
||||
},
|
||||
{
|
||||
"Name": "opensuse-leap-15-2",
|
||||
"URL": "https://download.opensuse.org/repositories/Cloud:/Images:/Leap_15.2/images/openSUSE-Leap-15.2-OpenStack.x86_64.qcow2",
|
||||
"SHA256Sum": "4df9cee9281d1f57d20f79dc65d76e255592b904760e73c0dd44ac753a54330f",
|
||||
"MemoryMegs": 512,
|
||||
"PackageManager": "zypper",
|
||||
"InitSystem": "systemd"
|
||||
},
|
||||
{
|
||||
"Name": "opensuse-leap-15-3",
|
||||
"URL": "http://mirror.its.dal.ca/opensuse/distribution/leap/15.3/appliances/openSUSE-Leap-15.3-JeOS.x86_64-OpenStack-Cloud.qcow2",
|
||||
"SHA256Sum": "22e0392e4d0becb523d1bc5f709366140b7ee20d6faf26de3d0f9046d1ee15d5",
|
||||
"MemoryMegs": 512,
|
||||
"PackageManager": "zypper",
|
||||
"InitSystem": "systemd"
|
||||
},
|
||||
{
|
||||
"Name": "opensuse-tumbleweed",
|
||||
"URL": "https://download.opensuse.org/tumbleweed/appliances/openSUSE-Tumbleweed-JeOS.x86_64-OpenStack-Cloud.qcow2",
|
||||
"SHA256Sum": "79e610bba3ed116556608f031c06e4b9260e3be2b193ce1727914ba213afac3f",
|
||||
"MemoryMegs": 512,
|
||||
"PackageManager": "zypper",
|
||||
"InitSystem": "systemd"
|
||||
},
|
||||
{
|
||||
"Name": "oracle-linux-7",
|
||||
"URL": "https://yum.oracle.com/templates/OracleLinux/OL7/u9/x86_64/OL7U9_x86_64-olvm-b86.qcow2",
|
||||
"SHA256Sum": "2ef4c10c0f6a0b17844742adc9ede7eb64a2c326e374068b7175f2ecbb1956fb",
|
||||
"MemoryMegs": 512,
|
||||
"PackageManager": "yum",
|
||||
"InitSystem": "systemd"
|
||||
},
|
||||
{
|
||||
"Name": "oracle-linux-8",
|
||||
"URL": "https://yum.oracle.com/templates/OracleLinux/OL8/u4/x86_64/OL8U4_x86_64-olvm-b85.qcow2",
|
||||
"SHA256Sum": "b86e1f1ea8fc904ed763a85ba12e9f12f4291c019c8435d0e4e6133392182b0b",
|
||||
"MemoryMegs": 768,
|
||||
"PackageManager": "dnf",
|
||||
"InitSystem": "systemd"
|
||||
},
|
||||
{
|
||||
"Name": "ubuntu-16-04",
|
||||
"URL": "https://cloud-images.ubuntu.com/xenial/20210429/xenial-server-cloudimg-amd64-disk1.img",
|
||||
"SHA256Sum": "50a21bc067c05e0c73bf5d8727ab61152340d93073b3dc32eff18b626f7d813b",
|
||||
"MemoryMegs": 512,
|
||||
"PackageManager": "apt",
|
||||
"InitSystem": "systemd"
|
||||
},
|
||||
{
|
||||
"Name": "ubuntu-18-04",
|
||||
"URL": "https://cloud-images.ubuntu.com/bionic/20210526/bionic-server-cloudimg-amd64.img",
|
||||
"SHA256Sum": "389ffd5d36bbc7a11bf384fd217cda9388ccae20e5b0cb7d4516733623c96022",
|
||||
"MemoryMegs": 512,
|
||||
"PackageManager": "apt",
|
||||
"InitSystem": "systemd"
|
||||
},
|
||||
{
|
||||
"Name": "ubuntu-20-04",
|
||||
"URL": "https://cloud-images.ubuntu.com/focal/20210603/focal-server-cloudimg-amd64.img",
|
||||
"SHA256Sum": "1c0969323b058ba8b91fec245527069c2f0502fc119b9138b213b6bfebd965cb",
|
||||
"MemoryMegs": 512,
|
||||
"PackageManager": "apt",
|
||||
"InitSystem": "systemd"
|
||||
},
|
||||
{
|
||||
"Name": "ubuntu-20-10",
|
||||
"URL": "https://cloud-images.ubuntu.com/groovy/20210604/groovy-server-cloudimg-amd64.img",
|
||||
"SHA256Sum": "2196df5f153faf96443e5502bfdbcaa0baaefbaec614348fec344a241855b0ef",
|
||||
"MemoryMegs": 512,
|
||||
"PackageManager": "apt",
|
||||
"InitSystem": "systemd"
|
||||
},
|
||||
{
|
||||
"Name": "ubuntu-21-04",
|
||||
"URL": "https://cloud-images.ubuntu.com/hirsute/20210603/hirsute-server-cloudimg-amd64.img",
|
||||
"SHA256Sum": "bf07f36fc99ff521d3426e7d257e28f0c81feebc9780b0c4f4e25ae594ff4d3b",
|
||||
"MemoryMegs": 512,
|
||||
"PackageManager": "apt",
|
||||
"InitSystem": "systemd"
|
||||
},
|
||||
|
||||
// NOTE(Xe): We build fresh NixOS images for every test run, so the URL being
|
||||
// used here is actually the URL of the NixOS channel being built from and the
|
||||
// shasum is meaningless. This `channel:name` syntax is documented at [1].
|
||||
//
|
||||
// [1]: https://nixos.org/manual/nix/unstable/command-ref/env-common.html
|
||||
{
|
||||
"Name": "nixos-21-05",
|
||||
"URL": "channel:nixos-21.05",
|
||||
"SHA256Sum": "lolfakesha",
|
||||
"MemoryMegs": 512,
|
||||
"PackageManager": "nix",
|
||||
"InitSystem": "systemd"
|
||||
},
|
||||
{
|
||||
"Name": "nixos-unstable",
|
||||
"URL": "channel:nixos-unstable",
|
||||
"SHA256Sum": "lolfakesha",
|
||||
"MemoryMegs": 512,
|
||||
"PackageManager": "nix",
|
||||
"InitSystem": "systemd"
|
||||
}
|
||||
]
|
@ -0,0 +1,17 @@
|
||||
// Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build linux
|
||||
|
||||
package vms
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDistrosGotLoaded(t *testing.T) {
|
||||
if len(Distros) == 0 {
|
||||
t.Fatal("no distros were loaded")
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
// Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// build ignore
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/dave/jennifer/jen"
|
||||
"github.com/iancoleman/strcase"
|
||||
"tailscale.com/tstest/integration/vms"
|
||||
)
|
||||
|
||||
func main() {
|
||||
f := jen.NewFile("vms")
|
||||
f.Comment("Code generated by tstest/integration/vms/gen/test_codegen.go DO NOT EDIT.")
|
||||
|
||||
ptr := jen.Op("*")
|
||||
|
||||
for i, d := range vms.Distros {
|
||||
f.Func().
|
||||
Id("TestRun" + strcase.ToCamel(d.Name)).
|
||||
Params(jen.Id("t").Add(ptr).Qual("testing", "T")).
|
||||
BlockFunc(func(g *jen.Group) {
|
||||
g.Id("t").Dot("Parallel").Call()
|
||||
g.Id("setupTests").Call(jen.Id("t"))
|
||||
g.Id("testOneDistribution").Call(jen.Id("t"), jen.Lit(i), jen.Id("Distros").Index(jen.Lit(i)))
|
||||
})
|
||||
}
|
||||
|
||||
os.Remove("top_level_test.go")
|
||||
fout, err := os.Create("top_level_test.go")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer fout.Close()
|
||||
|
||||
fmt.Fprintf(fout, "// Copyright (c) %d Tailscale Inc & AUTHORS All rights reserved.\n", time.Now().Year())
|
||||
fout.WriteString("// Use of this source code is governed by a BSD-style\n")
|
||||
fout.WriteString("// license that can be found in the LICENSE file.\n")
|
||||
fout.WriteString("\n")
|
||||
fout.WriteString("// +build linux\n\n")
|
||||
|
||||
err = f.Render(fout)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
@ -0,0 +1,121 @@
|
||||
// Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build linux
|
||||
|
||||
package vms
|
||||
|
||||
import "testing"
|
||||
|
||||
// Code generated by tstest/integration/vms/gen/test_codegen.go DO NOT EDIT.
|
||||
func TestRunAlpine3135(t *testing.T) {
|
||||
t.Parallel()
|
||||
setupTests(t)
|
||||
testOneDistribution(t, 0, Distros[0])
|
||||
}
|
||||
func TestRunAlpineEdge(t *testing.T) {
|
||||
t.Parallel()
|
||||
setupTests(t)
|
||||
testOneDistribution(t, 1, Distros[1])
|
||||
}
|
||||
func TestRunAmazonLinux(t *testing.T) {
|
||||
t.Parallel()
|
||||
setupTests(t)
|
||||
testOneDistribution(t, 2, Distros[2])
|
||||
}
|
||||
func TestRunArch(t *testing.T) {
|
||||
t.Parallel()
|
||||
setupTests(t)
|
||||
testOneDistribution(t, 3, Distros[3])
|
||||
}
|
||||
func TestRunCentos7(t *testing.T) {
|
||||
t.Parallel()
|
||||
setupTests(t)
|
||||
testOneDistribution(t, 4, Distros[4])
|
||||
}
|
||||
func TestRunCentos8(t *testing.T) {
|
||||
t.Parallel()
|
||||
setupTests(t)
|
||||
testOneDistribution(t, 5, Distros[5])
|
||||
}
|
||||
func TestRunDebian9(t *testing.T) {
|
||||
t.Parallel()
|
||||
setupTests(t)
|
||||
testOneDistribution(t, 6, Distros[6])
|
||||
}
|
||||
func TestRunDebian10(t *testing.T) {
|
||||
t.Parallel()
|
||||
setupTests(t)
|
||||
testOneDistribution(t, 7, Distros[7])
|
||||
}
|
||||
func TestRunFedora34(t *testing.T) {
|
||||
t.Parallel()
|
||||
setupTests(t)
|
||||
testOneDistribution(t, 8, Distros[8])
|
||||
}
|
||||
func TestRunOpensuseLeap151(t *testing.T) {
|
||||
t.Parallel()
|
||||
setupTests(t)
|
||||
testOneDistribution(t, 9, Distros[9])
|
||||
}
|
||||
func TestRunOpensuseLeap152(t *testing.T) {
|
||||
t.Parallel()
|
||||
setupTests(t)
|
||||
testOneDistribution(t, 10, Distros[10])
|
||||
}
|
||||
func TestRunOpensuseLeap153(t *testing.T) {
|
||||
t.Parallel()
|
||||
setupTests(t)
|
||||
testOneDistribution(t, 11, Distros[11])
|
||||
}
|
||||
func TestRunOpensuseTumbleweed(t *testing.T) {
|
||||
t.Parallel()
|
||||
setupTests(t)
|
||||
testOneDistribution(t, 12, Distros[12])
|
||||
}
|
||||
func TestRunOracleLinux7(t *testing.T) {
|
||||
t.Parallel()
|
||||
setupTests(t)
|
||||
testOneDistribution(t, 13, Distros[13])
|
||||
}
|
||||
func TestRunOracleLinux8(t *testing.T) {
|
||||
t.Parallel()
|
||||
setupTests(t)
|
||||
testOneDistribution(t, 14, Distros[14])
|
||||
}
|
||||
func TestRunUbuntu1604(t *testing.T) {
|
||||
t.Parallel()
|
||||
setupTests(t)
|
||||
testOneDistribution(t, 15, Distros[15])
|
||||
}
|
||||
func TestRunUbuntu1804(t *testing.T) {
|
||||
t.Parallel()
|
||||
setupTests(t)
|
||||
testOneDistribution(t, 16, Distros[16])
|
||||
}
|
||||
func TestRunUbuntu2004(t *testing.T) {
|
||||
t.Parallel()
|
||||
setupTests(t)
|
||||
testOneDistribution(t, 17, Distros[17])
|
||||
}
|
||||
func TestRunUbuntu2010(t *testing.T) {
|
||||
t.Parallel()
|
||||
setupTests(t)
|
||||
testOneDistribution(t, 18, Distros[18])
|
||||
}
|
||||
func TestRunUbuntu2104(t *testing.T) {
|
||||
t.Parallel()
|
||||
setupTests(t)
|
||||
testOneDistribution(t, 19, Distros[19])
|
||||
}
|
||||
func TestRunNixos2105(t *testing.T) {
|
||||
t.Parallel()
|
||||
setupTests(t)
|
||||
testOneDistribution(t, 20, Distros[20])
|
||||
}
|
||||
func TestRunNixosUnstable(t *testing.T) {
|
||||
t.Parallel()
|
||||
setupTests(t)
|
||||
testOneDistribution(t, 21, Distros[21])
|
||||
}
|
Loading…
Reference in New Issue