From 749c92954c5fcd3a49e6a4b904efffe64616c00a Mon Sep 17 00:00:00 2001 From: Juan Font Alonso Date: Fri, 18 Mar 2022 17:05:28 +0100 Subject: [PATCH 1/7] Add Tailscale unstable channel and repo HEAD to integration tests In preparation for the implementation of the new TS2021 protocol (Tailscale control protocol v2) we are expanding the test infrastructure --- Dockerfile.tailscale | 5 ++-- Dockerfile.tailscale-HEAD | 21 +++++++++++++++ integration_common_test.go | 45 ++++++++++++++++++++++++++++++- integration_embedded_derp_test.go | 12 ++------- integration_test.go | 12 ++------- 5 files changed, 72 insertions(+), 23 deletions(-) create mode 100644 Dockerfile.tailscale-HEAD diff --git a/Dockerfile.tailscale b/Dockerfile.tailscale index 32a8ce7b54..7a3f575af9 100644 --- a/Dockerfile.tailscale +++ b/Dockerfile.tailscale @@ -1,11 +1,12 @@ FROM ubuntu:latest ARG TAILSCALE_VERSION +ARG TAILSCALE_CHANNEL RUN apt-get update \ && apt-get install -y gnupg curl \ - && curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/focal.gpg | apt-key add - \ - && curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/focal.list | tee /etc/apt/sources.list.d/tailscale.list \ + && curl -fsSL https://pkgs.tailscale.com/${TAILSCALE_CHANNEL}/ubuntu/focal.gpg | apt-key add - \ + && curl -fsSL https://pkgs.tailscale.com/${TAILSCALE_CHANNEL}/ubuntu/focal.list | tee /etc/apt/sources.list.d/tailscale.list \ && apt-get update \ && apt-get install -y ca-certificates tailscale=${TAILSCALE_VERSION} dnsutils \ && rm -rf /var/lib/apt/lists/* diff --git a/Dockerfile.tailscale-HEAD b/Dockerfile.tailscale-HEAD new file mode 100644 index 0000000000..2cd0b813ba --- /dev/null +++ b/Dockerfile.tailscale-HEAD @@ -0,0 +1,21 @@ +FROM golang:latest + +RUN apt-get update \ + && apt-get install -y ca-certificates dnsutils git \ + && rm -rf /var/lib/apt/lists/* + + +RUN git clone https://github.com/tailscale/tailscale.git + +WORKDIR tailscale + +RUN sh build_dist.sh tailscale.com/cmd/tailscale +RUN sh build_dist.sh tailscale.com/cmd/tailscaled + +RUN cp tailscale /usr/local/ +RUN cp tailscaled /usr/local/ + +ADD integration_test/etc_embedded_derp/tls/server.crt /usr/local/share/ca-certificates/ +RUN chmod 644 /usr/local/share/ca-certificates/server.crt + +RUN update-ca-certificates diff --git a/integration_common_test.go b/integration_common_test.go index 70285fc4a2..33f3177d91 100644 --- a/integration_common_test.go +++ b/integration_common_test.go @@ -20,7 +20,7 @@ var ( IpPrefix4 = netaddr.MustParseIPPrefix("100.64.0.0/10") IpPrefix6 = netaddr.MustParseIPPrefix("fd7a:115c:a1e0::/48") - tailscaleVersions = []string{"1.22.0", "1.20.4", "1.18.2", "1.16.2", "1.14.3", "1.12.3"} + tailscaleVersions = []string{"HEAD", "unstable", "1.22.0", "1.20.4", "1.18.2", "1.16.2", "1.14.3", "1.12.3"} ) type TestNamespace struct { @@ -128,6 +128,49 @@ func DockerAllowNetworkAdministration(config *docker.HostConfig) { }) } +func getDockerBuildOptions(version string) *dockertest.BuildOptions { + var tailscaleBuildOptions *dockertest.BuildOptions + switch version { + case "HEAD": + tailscaleBuildOptions = &dockertest.BuildOptions{ + Dockerfile: "Dockerfile.tailscale-HEAD", + ContextDir: ".", + BuildArgs: []docker.BuildArg{}, + } + case "unstable": + tailscaleBuildOptions = &dockertest.BuildOptions{ + Dockerfile: "Dockerfile.tailscale", + ContextDir: ".", + BuildArgs: []docker.BuildArg{ + { + Name: "TAILSCALE_VERSION", + Value: "*", // Installs the latest version https://askubuntu.com/a/824926 + }, + { + Name: "TAILSCALE_CHANNEL", + Value: "unstable", + }, + }, + } + default: + tailscaleBuildOptions = &dockertest.BuildOptions{ + Dockerfile: "Dockerfile.tailscale", + ContextDir: ".", + BuildArgs: []docker.BuildArg{ + { + Name: "TAILSCALE_VERSION", + Value: version, + }, + { + Name: "TAILSCALE_CHANNEL", + Value: "stable", + }, + }, + } + } + return tailscaleBuildOptions +} + func getIPs( tailscales map[string]dockertest.Resource, ) (map[string][]netaddr.IP, error) { diff --git a/integration_embedded_derp_test.go b/integration_embedded_derp_test.go index a1737173a8..10ddc9f5ca 100644 --- a/integration_embedded_derp_test.go +++ b/integration_embedded_derp_test.go @@ -245,16 +245,8 @@ func (s *IntegrationDERPTestSuite) Join( func (s *IntegrationDERPTestSuite) tailscaleContainer(identifier, version string, network dockertest.Network, ) (string, *dockertest.Resource) { - tailscaleBuildOptions := &dockertest.BuildOptions{ - Dockerfile: "Dockerfile.tailscale", - ContextDir: ".", - BuildArgs: []docker.BuildArg{ - { - Name: "TAILSCALE_VERSION", - Value: version, - }, - }, - } + tailscaleBuildOptions := getDockerBuildOptions(version) + hostname := fmt.Sprintf( "tailscale-%s-%s", strings.Replace(version, ".", "-", -1), diff --git a/integration_test.go b/integration_test.go index 1649f32284..27b27e988d 100644 --- a/integration_test.go +++ b/integration_test.go @@ -168,16 +168,8 @@ func (s *IntegrationTestSuite) Join( func (s *IntegrationTestSuite) tailscaleContainer( namespace, identifier, version string, ) (string, *dockertest.Resource) { - tailscaleBuildOptions := &dockertest.BuildOptions{ - Dockerfile: "Dockerfile.tailscale", - ContextDir: ".", - BuildArgs: []docker.BuildArg{ - { - Name: "TAILSCALE_VERSION", - Value: version, - }, - }, - } + tailscaleBuildOptions := getDockerBuildOptions(version) + hostname := fmt.Sprintf( "%s-tailscale-%s-%s", namespace, From 0165b89941306a77cd96e55080b4acf9c44bc180 Mon Sep 17 00:00:00 2001 From: Juan Font Alonso Date: Fri, 18 Mar 2022 19:35:09 +0100 Subject: [PATCH 2/7] Fixed paths --- Dockerfile.tailscale-HEAD | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile.tailscale-HEAD b/Dockerfile.tailscale-HEAD index 2cd0b813ba..40c0ad87e8 100644 --- a/Dockerfile.tailscale-HEAD +++ b/Dockerfile.tailscale-HEAD @@ -12,8 +12,8 @@ WORKDIR tailscale RUN sh build_dist.sh tailscale.com/cmd/tailscale RUN sh build_dist.sh tailscale.com/cmd/tailscaled -RUN cp tailscale /usr/local/ -RUN cp tailscaled /usr/local/ +RUN cp tailscale /usr/local/bin/ +RUN cp tailscaled /usr/local/bin/ ADD integration_test/etc_embedded_derp/tls/server.crt /usr/local/share/ca-certificates/ RUN chmod 644 /usr/local/share/ca-certificates/server.crt From a6455653c0d0e499737bcbac728ee9113784b5ae Mon Sep 17 00:00:00 2001 From: Juan Font Alonso Date: Sun, 20 Mar 2022 12:30:08 +0100 Subject: [PATCH 3/7] Added missing package --- Dockerfile.tailscale-HEAD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.tailscale-HEAD b/Dockerfile.tailscale-HEAD index 40c0ad87e8..b62f7e2bf6 100644 --- a/Dockerfile.tailscale-HEAD +++ b/Dockerfile.tailscale-HEAD @@ -1,7 +1,7 @@ FROM golang:latest RUN apt-get update \ - && apt-get install -y ca-certificates dnsutils git \ + && apt-get install -y ca-certificates dnsutils git iptables \ && rm -rf /var/lib/apt/lists/* From f42868f67f9877bb6e51a7a1eea3105f11921507 Mon Sep 17 00:00:00 2001 From: Juan Font Alonso Date: Sun, 20 Mar 2022 12:30:56 +0100 Subject: [PATCH 4/7] Docker requires lowercase for the container names --- integration_common_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration_common_test.go b/integration_common_test.go index 33f3177d91..f7afb807b1 100644 --- a/integration_common_test.go +++ b/integration_common_test.go @@ -20,7 +20,7 @@ var ( IpPrefix4 = netaddr.MustParseIPPrefix("100.64.0.0/10") IpPrefix6 = netaddr.MustParseIPPrefix("fd7a:115c:a1e0::/48") - tailscaleVersions = []string{"HEAD", "unstable", "1.22.0", "1.20.4", "1.18.2", "1.16.2", "1.14.3", "1.12.3"} + tailscaleVersions = []string{"head", "unstable", "1.22.2", "1.20.4", "1.18.2", "1.16.2", "1.14.3", "1.12.3"} ) type TestNamespace struct { @@ -131,7 +131,7 @@ func DockerAllowNetworkAdministration(config *docker.HostConfig) { func getDockerBuildOptions(version string) *dockertest.BuildOptions { var tailscaleBuildOptions *dockertest.BuildOptions switch version { - case "HEAD": + case "head": tailscaleBuildOptions = &dockertest.BuildOptions{ Dockerfile: "Dockerfile.tailscale-HEAD", ContextDir: ".", From a1caa5b45c9e35107d3477e06e158a9239793334 Mon Sep 17 00:00:00 2001 From: Juan Font Alonso Date: Sun, 20 Mar 2022 12:31:18 +0100 Subject: [PATCH 5/7] Minor improvements on logging --- integration_cli_test.go | 2 +- integration_embedded_derp_test.go | 4 ++-- integration_test.go | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/integration_cli_test.go b/integration_cli_test.go index 7ce0758ff1..9644037dd0 100644 --- a/integration_cli_test.go +++ b/integration_cli_test.go @@ -72,7 +72,7 @@ func (s *IntegrationCLITestSuite) SetupTest() { if pheadscale, err := s.pool.BuildAndRunWithBuildOptions(headscaleBuildOptions, headscaleOptions, DockerRestartPolicy); err == nil { s.headscale = *pheadscale } else { - log.Fatalf("Could not start resource: %s", err) + log.Fatalf("Could not start headscale container: %s", err) } fmt.Println("Created headscale container") diff --git a/integration_embedded_derp_test.go b/integration_embedded_derp_test.go index 10ddc9f5ca..54eec804fc 100644 --- a/integration_embedded_derp_test.go +++ b/integration_embedded_derp_test.go @@ -121,7 +121,7 @@ func (s *IntegrationDERPTestSuite) SetupSuite() { if pheadscale, err := s.pool.BuildAndRunWithBuildOptions(headscaleBuildOptions, headscaleOptions, DockerRestartPolicy); err == nil { s.headscale = *pheadscale } else { - log.Fatalf("Could not start resource: %s", err) + log.Fatalf("Could not start headscale container: %s", err) } log.Println("Created headscale container to test DERP") @@ -271,7 +271,7 @@ func (s *IntegrationDERPTestSuite) tailscaleContainer(identifier, version string DockerAllowNetworkAdministration, ) if err != nil { - log.Fatalf("Could not start resource: %s", err) + log.Fatalf("Could not start tailscale container version %s: %s", version, err) } log.Printf("Created %s container\n", hostname) diff --git a/integration_test.go b/integration_test.go index 27b27e988d..52f1765bb1 100644 --- a/integration_test.go +++ b/integration_test.go @@ -192,7 +192,7 @@ func (s *IntegrationTestSuite) tailscaleContainer( DockerAllowNetworkAdministration, ) if err != nil { - log.Fatalf("Could not start resource: %s", err) + log.Fatalf("Could not start tailscale container version %s: %s", version, err) } log.Printf("Created %s container\n", hostname) @@ -241,7 +241,7 @@ func (s *IntegrationTestSuite) SetupSuite() { if pheadscale, err := s.pool.BuildAndRunWithBuildOptions(headscaleBuildOptions, headscaleOptions, DockerRestartPolicy); err == nil { s.headscale = *pheadscale } else { - log.Fatalf("Could not start resource: %s", err) + log.Fatalf("Could not start headscale container: %s", err) } log.Println("Created headscale container") From a8a683d3cccb356dd7c3cd90d39387781d75ae0b Mon Sep 17 00:00:00 2001 From: Juan Font Alonso Date: Sun, 20 Mar 2022 12:33:41 +0100 Subject: [PATCH 6/7] Added default values in Dockerfile.tailscale --- Dockerfile.tailscale | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile.tailscale b/Dockerfile.tailscale index 7a3f575af9..145ab6f7fd 100644 --- a/Dockerfile.tailscale +++ b/Dockerfile.tailscale @@ -1,7 +1,7 @@ FROM ubuntu:latest -ARG TAILSCALE_VERSION -ARG TAILSCALE_CHANNEL +ARG TAILSCALE_VERSION=* +ARG TAILSCALE_CHANNEL=stable RUN apt-get update \ && apt-get install -y gnupg curl \ From af6a47fdd3c16da5d4e861931cff32cf1c88a235 Mon Sep 17 00:00:00 2001 From: Juan Font Alonso Date: Sun, 20 Mar 2022 12:36:30 +0100 Subject: [PATCH 7/7] Changelog updated --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c943940e3..f8872af3f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,7 @@ - Users can now use emails in ACL's groups [#372](https://github.com/juanfont/headscale/issues/372) - Add shorthand aliases for commands and subcommands [#376](https://github.com/juanfont/headscale/pull/376) - Add `/windows` endpoint for Windows configuration instructions + registry file download [#392](https://github.com/juanfont/headscale/pull/392) -- Added embedded DERP server into Headscale [#388](https://github.com/juanfont/headscale/pull/388) +- Added embedded DERP (and STUN) server into Headscale [#388](https://github.com/juanfont/headscale/pull/388) ### Changes @@ -30,6 +30,7 @@ - Reduce the overhead of marshal/unmarshal for Hostinfo, routes and endpoints by using specific types in Machine [#371](https://github.com/juanfont/headscale/pull/371) - Apply normalization function to FQDN on hostnames when hosts registers and retrieve informations [#363](https://github.com/juanfont/headscale/issues/363) - Fix a bug that prevented the use of `tailscale logout` with OIDC [#508](https://github.com/juanfont/headscale/issues/508) +- Added Tailscale repo HEAD and unstable releases channel to the integration tests targets [#513](https://github.com/juanfont/headscale/pull/513) ## 0.14.0 (2022-02-24)