mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-30 02:43:05 +00:00
Merge branch 'main' into oidc-refactoring
This commit is contained in:
commit
fc65ded2d5
7 changed files with 60 additions and 34 deletions
2
.github/workflows/lint.yml
vendored
2
.github/workflows/lint.yml
vendored
|
@ -70,7 +70,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: bufbuild/buf-setup-action@v0.7.0
|
- uses: bufbuild/buf-setup-action@v1.7.0
|
||||||
- uses: bufbuild/buf-lint-action@v1
|
- uses: bufbuild/buf-lint-action@v1
|
||||||
with:
|
with:
|
||||||
input: "proto"
|
input: "proto"
|
||||||
|
|
27
.github/workflows/test-integration.yml
vendored
27
.github/workflows/test-integration.yml
vendored
|
@ -11,6 +11,11 @@ jobs:
|
||||||
with:
|
with:
|
||||||
fetch-depth: 2
|
fetch-depth: 2
|
||||||
|
|
||||||
|
- name: Set Swap Space
|
||||||
|
uses: pierotofy/set-swap-space@master
|
||||||
|
with:
|
||||||
|
swap-size-gb: 10
|
||||||
|
|
||||||
- name: Get changed files
|
- name: Get changed files
|
||||||
id: changed-files
|
id: changed-files
|
||||||
uses: tj-actions/changed-files@v14.1
|
uses: tj-actions/changed-files@v14.1
|
||||||
|
@ -25,11 +30,29 @@ jobs:
|
||||||
- uses: cachix/install-nix-action@v16
|
- uses: cachix/install-nix-action@v16
|
||||||
if: steps.changed-files.outputs.any_changed == 'true'
|
if: steps.changed-files.outputs.any_changed == 'true'
|
||||||
|
|
||||||
- name: Run Integration tests
|
- name: Run CLI integration tests
|
||||||
if: steps.changed-files.outputs.any_changed == 'true'
|
if: steps.changed-files.outputs.any_changed == 'true'
|
||||||
uses: nick-fields/retry@v2
|
uses: nick-fields/retry@v2
|
||||||
with:
|
with:
|
||||||
timeout_minutes: 240
|
timeout_minutes: 240
|
||||||
max_attempts: 5
|
max_attempts: 5
|
||||||
retry_on: error
|
retry_on: error
|
||||||
command: nix develop --command -- make test_integration
|
command: nix develop --command -- make test_integration_cli
|
||||||
|
|
||||||
|
- name: Run Embedded DERP server integration tests
|
||||||
|
if: steps.changed-files.outputs.any_changed == 'true'
|
||||||
|
uses: nick-fields/retry@v2
|
||||||
|
with:
|
||||||
|
timeout_minutes: 240
|
||||||
|
max_attempts: 5
|
||||||
|
retry_on: error
|
||||||
|
command: nix develop --command -- make test_integration_derp
|
||||||
|
|
||||||
|
- name: Run general integration tests
|
||||||
|
if: steps.changed-files.outputs.any_changed == 'true'
|
||||||
|
uses: nick-fields/retry@v2
|
||||||
|
with:
|
||||||
|
timeout_minutes: 240
|
||||||
|
max_attempts: 5
|
||||||
|
retry_on: error
|
||||||
|
command: nix develop --command -- make test_integration_general
|
||||||
|
|
10
Makefile
10
Makefile
|
@ -24,14 +24,16 @@ dev: lint test build
|
||||||
test:
|
test:
|
||||||
@go test -coverprofile=coverage.out ./...
|
@go test -coverprofile=coverage.out ./...
|
||||||
|
|
||||||
test_integration:
|
test_integration: test_integration_cli test_integration_derp test_integration_general
|
||||||
go test -failfast -tags integration -timeout 30m -count=1 ./...
|
|
||||||
|
|
||||||
test_integration_cli:
|
test_integration_cli:
|
||||||
go test -tags integration -v integration_cli_test.go integration_common_test.go
|
go test -failfast -tags integration_cli,integration -timeout 30m -count=1 ./...
|
||||||
|
|
||||||
test_integration_derp:
|
test_integration_derp:
|
||||||
go test -tags integration -v integration_embedded_derp_test.go integration_common_test.go
|
go test -failfast -tags integration_derp,integration -timeout 30m -count=1 ./...
|
||||||
|
|
||||||
|
test_integration_general:
|
||||||
|
go test -failfast -tags integration_general,integration -timeout 30m -count=1 ./...
|
||||||
|
|
||||||
coverprofile_func:
|
coverprofile_func:
|
||||||
go tool cover -func=coverage.out
|
go tool cover -func=coverage.out
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
//go:build integration
|
//go:build integration_cli
|
||||||
// +build integration
|
|
||||||
|
|
||||||
package headscale
|
package headscale
|
||||||
|
|
||||||
|
@ -73,21 +72,22 @@ func (s *IntegrationCLITestSuite) SetupTest() {
|
||||||
s.FailNow(fmt.Sprintf("Could not remove existing container before building test: %s", err), "")
|
s.FailNow(fmt.Sprintf("Could not remove existing container before building test: %s", err), "")
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("Creating headscale container")
|
fmt.Println("Creating headscale container for CLI tests")
|
||||||
if pheadscale, err := s.pool.BuildAndRunWithBuildOptions(headscaleBuildOptions, headscaleOptions, DockerRestartPolicy); err == nil {
|
if pheadscale, err := s.pool.BuildAndRunWithBuildOptions(headscaleBuildOptions, headscaleOptions, DockerRestartPolicy); err == nil {
|
||||||
s.headscale = *pheadscale
|
s.headscale = *pheadscale
|
||||||
} else {
|
} else {
|
||||||
s.FailNow(fmt.Sprintf("Could not start headscale container: %s", err), "")
|
s.FailNow(fmt.Sprintf("Could not start headscale container: %s", err), "")
|
||||||
}
|
}
|
||||||
fmt.Println("Created headscale container")
|
fmt.Println("Created headscale container for CLI tests")
|
||||||
|
|
||||||
fmt.Println("Waiting for headscale to be ready")
|
fmt.Println("Waiting for headscale to be ready for CLI tests")
|
||||||
hostEndpoint := fmt.Sprintf("localhost:%s", s.headscale.GetPort("8080/tcp"))
|
hostEndpoint := fmt.Sprintf("localhost:%s", s.headscale.GetPort("8080/tcp"))
|
||||||
|
|
||||||
if err := s.pool.Retry(func() error {
|
if err := s.pool.Retry(func() error {
|
||||||
url := fmt.Sprintf("http://%s/health", hostEndpoint)
|
url := fmt.Sprintf("http://%s/health", hostEndpoint)
|
||||||
resp, err := http.Get(url)
|
resp, err := http.Get(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Printf("headscale for CLI test is not ready: %s\n", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
@ -102,7 +102,7 @@ func (s *IntegrationCLITestSuite) SetupTest() {
|
||||||
// https://github.com/stretchr/testify/issues/849
|
// https://github.com/stretchr/testify/issues/849
|
||||||
return // fmt.Errorf("Could not connect to headscale: %s", err)
|
return // fmt.Errorf("Could not connect to headscale: %s", err)
|
||||||
}
|
}
|
||||||
fmt.Println("headscale container is ready")
|
fmt.Println("headscale container is ready for CLI tests")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *IntegrationCLITestSuite) TearDownTest() {
|
func (s *IntegrationCLITestSuite) TearDownTest() {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
//go:build integration
|
//go:build integration
|
||||||
// +build integration
|
|
||||||
|
|
||||||
package headscale
|
package headscale
|
||||||
|
|
||||||
|
@ -20,6 +19,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
headscaleHostname = "headscale-derp"
|
||||||
DOCKER_EXECUTE_TIMEOUT = 10 * time.Second
|
DOCKER_EXECUTE_TIMEOUT = 10 * time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -30,9 +30,10 @@ var (
|
||||||
IpPrefix6 = netaddr.MustParseIPPrefix("fd7a:115c:a1e0::/48")
|
IpPrefix6 = netaddr.MustParseIPPrefix("fd7a:115c:a1e0::/48")
|
||||||
|
|
||||||
tailscaleVersions = []string{
|
tailscaleVersions = []string{
|
||||||
"head",
|
// "head",
|
||||||
"unstable",
|
// "unstable",
|
||||||
"1.26.0",
|
"1.28.0",
|
||||||
|
"1.26.2",
|
||||||
"1.24.2",
|
"1.24.2",
|
||||||
"1.22.2",
|
"1.22.2",
|
||||||
"1.20.4",
|
"1.20.4",
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//go:build integration
|
//go:build integration_derp
|
||||||
|
|
||||||
package headscale
|
package headscale
|
||||||
|
|
||||||
|
@ -28,9 +28,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
headscaleHostname = "headscale-derp"
|
namespaceName = "derpnamespace"
|
||||||
namespaceName = "derpnamespace"
|
totalContainers = 3
|
||||||
totalContainers = 3
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type IntegrationDERPTestSuite struct {
|
type IntegrationDERPTestSuite struct {
|
||||||
|
@ -134,15 +133,15 @@ func (s *IntegrationDERPTestSuite) SetupSuite() {
|
||||||
s.FailNow(fmt.Sprintf("Could not remove existing container before building test: %s", err), "")
|
s.FailNow(fmt.Sprintf("Could not remove existing container before building test: %s", err), "")
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println("Creating headscale container")
|
log.Println("Creating headscale container for DERP integration tests")
|
||||||
if pheadscale, err := s.pool.BuildAndRunWithBuildOptions(headscaleBuildOptions, headscaleOptions, DockerRestartPolicy); err == nil {
|
if pheadscale, err := s.pool.BuildAndRunWithBuildOptions(headscaleBuildOptions, headscaleOptions, DockerRestartPolicy); err == nil {
|
||||||
s.headscale = *pheadscale
|
s.headscale = *pheadscale
|
||||||
} else {
|
} else {
|
||||||
s.FailNow(fmt.Sprintf("Could not start headscale container: %s", err), "")
|
s.FailNow(fmt.Sprintf("Could not start headscale container: %s", err), "")
|
||||||
}
|
}
|
||||||
log.Println("Created headscale container to test DERP")
|
log.Println("Created headscale container for embedded DERP tests")
|
||||||
|
|
||||||
log.Println("Creating tailscale containers")
|
log.Println("Creating tailscale containers for embedded DERP tests")
|
||||||
|
|
||||||
for i := 0; i < totalContainers; i++ {
|
for i := 0; i < totalContainers; i++ {
|
||||||
version := tailscaleVersions[i%len(tailscaleVersions)]
|
version := tailscaleVersions[i%len(tailscaleVersions)]
|
||||||
|
@ -154,7 +153,7 @@ func (s *IntegrationDERPTestSuite) SetupSuite() {
|
||||||
s.tailscales[hostname] = *container
|
s.tailscales[hostname] = *container
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println("Waiting for headscale to be ready")
|
log.Println("Waiting for headscale to be ready for embedded DERP tests")
|
||||||
hostEndpoint := fmt.Sprintf("localhost:%s", s.headscale.GetPort("8443/tcp"))
|
hostEndpoint := fmt.Sprintf("localhost:%s", s.headscale.GetPort("8443/tcp"))
|
||||||
|
|
||||||
if err := s.pool.Retry(func() error {
|
if err := s.pool.Retry(func() error {
|
||||||
|
@ -164,6 +163,7 @@ func (s *IntegrationDERPTestSuite) SetupSuite() {
|
||||||
client := &http.Client{Transport: insecureTransport}
|
client := &http.Client{Transport: insecureTransport}
|
||||||
resp, err := client.Get(url)
|
resp, err := client.Get(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Printf("headscale for embedded DERP tests is not ready: %s\n", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ func (s *IntegrationDERPTestSuite) SetupSuite() {
|
||||||
// https://github.com/stretchr/testify/issues/849
|
// https://github.com/stretchr/testify/issues/849
|
||||||
return // fmt.Errorf("Could not connect to headscale: %s", err)
|
return // fmt.Errorf("Could not connect to headscale: %s", err)
|
||||||
}
|
}
|
||||||
log.Println("headscale container is ready")
|
log.Println("headscale container is ready for embedded DERP tests")
|
||||||
|
|
||||||
log.Printf("Creating headscale namespace: %s\n", namespaceName)
|
log.Printf("Creating headscale namespace: %s\n", namespaceName)
|
||||||
result, err := ExecuteCommand(
|
result, err := ExecuteCommand(
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
//go:build integration
|
//go:build integration_general
|
||||||
// +build integration
|
|
||||||
|
|
||||||
package headscale
|
package headscale
|
||||||
|
|
||||||
|
@ -251,15 +250,15 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
||||||
s.FailNow(fmt.Sprintf("Could not remove existing container before building test: %s", err), "")
|
s.FailNow(fmt.Sprintf("Could not remove existing container before building test: %s", err), "")
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println("Creating headscale container")
|
log.Println("Creating headscale container for core integration tests")
|
||||||
if pheadscale, err := s.pool.BuildAndRunWithBuildOptions(headscaleBuildOptions, headscaleOptions, DockerRestartPolicy); err == nil {
|
if pheadscale, err := s.pool.BuildAndRunWithBuildOptions(headscaleBuildOptions, headscaleOptions, DockerRestartPolicy); err == nil {
|
||||||
s.headscale = *pheadscale
|
s.headscale = *pheadscale
|
||||||
} else {
|
} else {
|
||||||
s.FailNow(fmt.Sprintf("Could not start headscale container: %s", err), "")
|
s.FailNow(fmt.Sprintf("Could not start headscale container for core integration tests: %s", err), "")
|
||||||
}
|
}
|
||||||
log.Println("Created headscale container")
|
log.Println("Created headscale container for core integration tests")
|
||||||
|
|
||||||
log.Println("Creating tailscale containers")
|
log.Println("Creating tailscale containers for core integration tests")
|
||||||
for namespace, scales := range s.namespaces {
|
for namespace, scales := range s.namespaces {
|
||||||
for i := 0; i < scales.count; i++ {
|
for i := 0; i < scales.count; i++ {
|
||||||
version := tailscaleVersions[i%len(tailscaleVersions)]
|
version := tailscaleVersions[i%len(tailscaleVersions)]
|
||||||
|
@ -273,7 +272,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println("Waiting for headscale to be ready")
|
log.Println("Waiting for headscale to be ready for core integration tests")
|
||||||
hostEndpoint := fmt.Sprintf("localhost:%s", s.headscale.GetPort("8080/tcp"))
|
hostEndpoint := fmt.Sprintf("localhost:%s", s.headscale.GetPort("8080/tcp"))
|
||||||
|
|
||||||
if err := s.pool.Retry(func() error {
|
if err := s.pool.Retry(func() error {
|
||||||
|
@ -281,6 +280,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
||||||
|
|
||||||
resp, err := http.Get(url)
|
resp, err := http.Get(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Printf("headscale for core integration test is not ready: %s\n", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,7 +296,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
||||||
// https://github.com/stretchr/testify/issues/849
|
// https://github.com/stretchr/testify/issues/849
|
||||||
return // fmt.Errorf("Could not connect to headscale: %s", err)
|
return // fmt.Errorf("Could not connect to headscale: %s", err)
|
||||||
}
|
}
|
||||||
log.Println("headscale container is ready")
|
log.Println("headscale container is ready for core integration tests")
|
||||||
|
|
||||||
for namespace, scales := range s.namespaces {
|
for namespace, scales := range s.namespaces {
|
||||||
log.Printf("Creating headscale namespace: %s\n", namespace)
|
log.Printf("Creating headscale namespace: %s\n", namespace)
|
Loading…
Reference in a new issue