You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tailscale/tstest/integration/vms
Joe Tsai c299a96624 all: apply consistent imports of "json" packages
This runs:

        go run ./cmd/jsonimports -update -ignore=tempfork/

which applies the following rules:

  * Until the Go standard library formally accepts "encoding/json/v2"
    and "encoding/json/jsontext" into the standard library
    (i.e., they are no longer considered experimental),
    we forbid any code from directly importing those packages.
    Go code should instead import "github.com/go-json-experiment/json"
    and "github.com/go-json-experiment/json/jsontext".
    The latter packages contain aliases to the standard library
    if built on Go 1.25 with the goexperiment.jsonv2 tag specified.

  * Imports of "encoding/json" or "github.com/go-json-experiment/json/v1"
    must be explicitly imported under the package name "jsonv1".
    If both packages need to be imported, then
    the former should be imported under the package name "jsonv1std".

  * Imports of "github.com/go-json-experiment/json"
    must be explicitly imported under the package name "jsonv2".

The latter two rules exist to provide clarity when reading code.
Without them, it is unclear whether "json.Marshal" refers to v1 or v2.
With them, however, it is clear that "jsonv1.Marshal" is calling v1 and
that "jsonv2.Marshal" is calling v2.

Updates tailscale/corp#791

Signed-off-by: Joe Tsai <joetsai@digital-static.net>
1 month ago
..
README.md tstest/integration/vms,.github/workflows: bump Ubuntu and NixOS for VM tests + cleanup (#16098) 2 months ago
derive_bindhost_test.go net/{interfaces,netmon}, all: merge net/interfaces package into net/netmon 2 years ago
distros.go all: apply consistent imports of "json" packages 1 month ago
distros.hujson tstest/integration/vms,.github/workflows: bump Ubuntu and NixOS for VM tests + cleanup (#16098) 2 months ago
distros_test.go all: update copyright and license headers 3 years ago
dns_tester.go all: apply consistent imports of "json" packages 1 month ago
doc.go all: update copyright and license headers 3 years ago
harness_test.go tstest/integration: don't require TestMake, stop leaking binaries in /tmp 7 months ago
nixos_test.go tstest/integration/vms,.github/workflows: bump Ubuntu and NixOS for VM tests + cleanup (#16098) 2 months ago
runner.nix all: fix spelling mistakes 4 years ago
squid.conf tstest/integration/vms: smoke test derphttp through mitm proxies 4 years ago
top_level_test.go tstest/integration/vms,.github/workflows: bump Ubuntu and NixOS for VM tests + cleanup (#16098) 2 months ago
udp_tester.go all: update copyright and license headers 3 years ago
vm_setup_test.go all: use Go 1.22 range-over-int 2 years ago
vms_steps_test.go all: use Go 1.22 range-over-int 2 years ago
vms_test.go tstest/integration/vms,.github/workflows: bump Ubuntu and NixOS for VM tests + cleanup (#16098) 2 months ago

README.md

End-to-End VM-based Integration Testing

These tests spin up a Tailscale client in a Linux VM and try to connect it to testcontrol server.

Running

This test currently only runs on Linux.

This test depends on the following command line tools:

This test also requires the following:

  • about 10 GB of temporary storage
  • about 10 GB of cached VM images
  • at least 4 GB of ram for virtual machines
  • hardware virtualization support (KVM) enabled in the BIOS
  • the kvm module to be loaded (modprobe kvm)
  • the user running these tests must have access to /dev/kvm (being in the kvm group should suffice)

The --no-s3 flag is needed to disable downloads from S3, which require credentials. However keep in mind that some distributions do not use stable URLs for each individual image artifact, so there may be spurious test failures as a result.

If you are using Nix, you can run all of the tests with the correct command line tools using this command:

$ nix-shell -p nixos-generators -p openssh -p go -p qemu -p cdrkit --run "go test . --run-vm-tests --v --timeout 30m --no-s3"

Keep the timeout high for the first run, especially if you are not downloading VM images from S3. The mirrors we pull images from have download rate limits and will take a while to download.

Because of the hardware requirements of this test, this test will not run without the --run-vm-tests flag set.

Other Fun Flags

This test's behavior is customized with command line flags.

Don't Download Images From S3

If you pass the -no-s3 flag to go test, the S3 step will be skipped in favor of downloading the images directly from upstream sources, which may cause the test to fail in odd places.

Ram Limiting

This test uses a lot of memory. In order to avoid making machines run out of memory running this test, a semaphore is used to limit how many megabytes of ram are being used at once. By default this semaphore is set to 4096 MB of ram (about 4 gigabytes). You can customize this with the --ram-limit flag:

$ go test --run-vm-tests --ram-limit 2048
$ go test --run-vm-tests --ram-limit 65536

The first example will set the limit to 2048 MB of ram (about 2 gigabytes). The second example will set the limit to 65536 MB of ram (about 65 gigabytes). Please be careful with this flag, improper usage of it is known to cause the Linux out-of-memory killer to engage. Try to keep it within 50-75% of your machine's available ram (there is some overhead involved with the virtualization) to be on the safe side.