Merge pull request #865 from kradalby/integration-no-build-tags
Do not use build tags for running integration tests
This commit is contained in:
commit
a39504510a
14
Makefile
14
Makefile
|
@ -22,7 +22,7 @@ build:
|
|||
dev: lint test build
|
||||
|
||||
test:
|
||||
@go test -coverprofile=coverage.out ./...
|
||||
@go test -short -coverprofile=coverage.out ./...
|
||||
|
||||
test_integration: test_integration_cli test_integration_derp test_integration_oidc test_integration_general
|
||||
|
||||
|
@ -31,36 +31,40 @@ test_integration_cli:
|
|||
docker network create headscale-test || true
|
||||
docker run -t --rm \
|
||||
--network headscale-test \
|
||||
-v ~/.cache/hs-integration-go:/go \
|
||||
-v $$PWD:$$PWD -w $$PWD \
|
||||
-v /var/run/docker.sock:/var/run/docker.sock golang:1 \
|
||||
go test -failfast -tags integration_cli,integration -timeout 30m -count=1 ./...
|
||||
go test -failfast -timeout 30m -count=1 -run IntegrationCLI ./...
|
||||
|
||||
test_integration_derp:
|
||||
docker network rm $$(docker network ls --filter name=headscale --quiet) || true
|
||||
docker network create headscale-test || true
|
||||
docker run -t --rm \
|
||||
--network headscale-test \
|
||||
-v ~/.cache/hs-integration-go:/go \
|
||||
-v $$PWD:$$PWD -w $$PWD \
|
||||
-v /var/run/docker.sock:/var/run/docker.sock golang:1 \
|
||||
go test -failfast -tags integration_derp,integration -timeout 30m -count=1 ./...
|
||||
go test -failfast -timeout 30m -count=1 -run IntegrationDERP ./...
|
||||
|
||||
test_integration_general:
|
||||
docker network rm $$(docker network ls --filter name=headscale --quiet) || true
|
||||
docker network create headscale-test || true
|
||||
docker run -t --rm \
|
||||
--network headscale-test \
|
||||
-v ~/.cache/hs-integration-go:/go \
|
||||
-v $$PWD:$$PWD -w $$PWD \
|
||||
-v /var/run/docker.sock:/var/run/docker.sock golang:1 \
|
||||
go test -failfast -tags integration_general,integration -timeout 30m -count=1 ./...
|
||||
go test -failfast -timeout 30m -count=1 -run IntegrationGeneral ./...
|
||||
|
||||
test_integration_oidc:
|
||||
docker network rm $$(docker network ls --filter name=headscale --quiet) || true
|
||||
docker network create headscale-test || true
|
||||
docker run -t --rm \
|
||||
--network headscale-test \
|
||||
-v ~/.cache/hs-integration-go:/go \
|
||||
-v $$PWD:$$PWD -w $$PWD \
|
||||
-v /var/run/docker.sock:/var/run/docker.sock golang:1 \
|
||||
go test -failfast -tags integration_oidc,integration -timeout 30m -count=1 ./...
|
||||
go test -failfast -timeout 30m -count=1 -run IntegrationOIDC ./...
|
||||
|
||||
coverprofile_func:
|
||||
go tool cover -func=coverage.out
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
version = headscaleVersion;
|
||||
src = pkgs.lib.cleanSource self;
|
||||
|
||||
# Only run unit tests when testing a build
|
||||
checkFlags = ["-short"];
|
||||
|
||||
# When updating go.mod or go.sum, a new sha will need to be calculated,
|
||||
# update this if you have a mismatch after doing a change to thos files.
|
||||
vendorSha256 = "sha256-DosFCSiQ5FURbIrt4NcPGkExc84t2MGMqe9XLxNHdIM=";
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
//go:build integration_cli
|
||||
|
||||
//nolint
|
||||
package headscale
|
||||
|
||||
import (
|
||||
|
@ -28,7 +27,11 @@ type IntegrationCLITestSuite struct {
|
|||
env []string
|
||||
}
|
||||
|
||||
func TestCLIIntegrationTestSuite(t *testing.T) {
|
||||
func TestIntegrationCLITestSuite(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping integration tests due to short flag")
|
||||
}
|
||||
|
||||
s := new(IntegrationCLITestSuite)
|
||||
|
||||
suite.Run(t, s)
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
//go:build integration
|
||||
|
||||
//nolint
|
||||
package headscale
|
||||
|
||||
import (
|
||||
|
@ -328,7 +327,6 @@ func GetEnvBool(key string) (bool, error) {
|
|||
func GetFirstOrCreateNetwork(pool *dockertest.Pool, name string) (dockertest.Network, error) {
|
||||
networks, err := pool.NetworksByName(name)
|
||||
if err != nil || len(networks) == 0 {
|
||||
|
||||
if _, err := pool.CreateNetwork(name); err == nil {
|
||||
// Create does not give us an updated version of the resource, so we need to
|
||||
// get it again.
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
//go:build integration_derp
|
||||
|
||||
//nolint
|
||||
package headscale
|
||||
|
||||
import (
|
||||
|
@ -17,13 +16,12 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/ccding/go-stun/stun"
|
||||
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
|
||||
"github.com/ory/dockertest/v3"
|
||||
"github.com/ory/dockertest/v3/docker"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/ccding/go-stun/stun"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -46,7 +44,11 @@ type IntegrationDERPTestSuite struct {
|
|||
joinWaitGroup sync.WaitGroup
|
||||
}
|
||||
|
||||
func TestDERPIntegrationTestSuite(t *testing.T) {
|
||||
func TestIntegrationDERPTestSuite(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping integration tests due to short flag")
|
||||
}
|
||||
|
||||
saveLogs, err := GetEnvBool("HEADSCALE_INTEGRATION_SAVE_LOG")
|
||||
if err != nil {
|
||||
saveLogs = false
|
||||
|
@ -120,7 +122,6 @@ func (s *IntegrationDERPTestSuite) SetupSuite() {
|
|||
}
|
||||
|
||||
headscaleOptions := &dockertest.RunOptions{
|
||||
|
||||
Name: headscaleDerpHostname,
|
||||
Mounts: []string{
|
||||
fmt.Sprintf(
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
//go:build integration_general
|
||||
|
||||
//nolint
|
||||
package headscale
|
||||
|
||||
import (
|
||||
|
@ -41,7 +40,11 @@ type IntegrationTestSuite struct {
|
|||
joinWaitGroup sync.WaitGroup
|
||||
}
|
||||
|
||||
func TestIntegrationTestSuite(t *testing.T) {
|
||||
func TestIntegrationGeneralTestSuite(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping integration tests due to short flag")
|
||||
}
|
||||
|
||||
saveLogs, err := GetEnvBool("HEADSCALE_INTEGRATION_SAVE_LOG")
|
||||
if err != nil {
|
||||
saveLogs = false
|
||||
|
@ -504,7 +507,7 @@ func getIPsfromIPNstate(status ipnstate.Status) []netip.Addr {
|
|||
return ips
|
||||
}
|
||||
|
||||
// TODO: Adopt test for cross communication between namespaces
|
||||
// TODO: Adopt test for cross communication between namespaces.
|
||||
func (s *IntegrationTestSuite) TestPingAllPeersByAddress() {
|
||||
for _, scales := range s.namespaces {
|
||||
ips, err := getIPs(scales.tailscales)
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
//go:build integration_oidc
|
||||
|
||||
//nolint
|
||||
package headscale
|
||||
|
||||
import (
|
||||
|
@ -45,7 +44,11 @@ type IntegrationOIDCTestSuite struct {
|
|||
joinWaitGroup sync.WaitGroup
|
||||
}
|
||||
|
||||
func TestOIDCIntegrationTestSuite(t *testing.T) {
|
||||
func TestIntegrationOIDCTestSuite(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping integration tests due to short flag")
|
||||
}
|
||||
|
||||
saveLogs, err := GetEnvBool("HEADSCALE_INTEGRATION_SAVE_LOG")
|
||||
if err != nil {
|
||||
saveLogs = false
|
||||
|
@ -197,7 +200,7 @@ oidc:
|
|||
log.Println(config)
|
||||
|
||||
configPath := path.Join(currentPath, "integration_test/etc_oidc/config.yaml")
|
||||
err = os.WriteFile(configPath, []byte(config), 0644)
|
||||
err = os.WriteFile(configPath, []byte(config), 0o644)
|
||||
if err != nil {
|
||||
s.FailNow(fmt.Sprintf("Could not write config: %s", err), "")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue