Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration tests v2 #856

Merged
merged 23 commits into from
Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
fa8b02a
tsic: Tailscale in Container abstraction
kradalby Oct 13, 2022
308b9e7
Defince control server interface
kradalby Oct 13, 2022
b331e3f
hsic: ControlServer implementation of headscale in docker
kradalby Oct 13, 2022
f68ba75
Move some helper functions into dockertestutil package
kradalby Oct 13, 2022
a9c3b14
Define a "scenario", which is a controlserver with nodes
kradalby Oct 13, 2022
eda4321
Skip integration tests on short or lack of docker
kradalby Oct 14, 2022
f109b54
Join test suite container to network, allowing seperate networks
kradalby Oct 14, 2022
25e39d9
Add get ips command to scenario
kradalby Oct 14, 2022
b0a4ee4
test login with one node
kradalby Oct 14, 2022
13aa845
Add comment about scenario test
kradalby Oct 14, 2022
aef77a1
use variable for namespace
kradalby Oct 14, 2022
84f9f60
go mod tidy
kradalby Oct 18, 2022
c90d0dd
remove the need to bind host port
kradalby Oct 18, 2022
3951f39
Add wait for peers and status to tsic
kradalby Oct 18, 2022
0db608a
Add tailscale versions, waiters and helpers for scenario
kradalby Oct 18, 2022
39bc6f7
Port PingAll test to new test suite
kradalby Oct 18, 2022
2bf50bc
Add new integration tests to ci
kradalby Oct 18, 2022
4cb7d63
Set better names for different integration tests
kradalby Oct 18, 2022
36ad000
golangci-lint --fix
kradalby Oct 18, 2022
8502a0a
dont request tty
kradalby Oct 18, 2022
12ee9bc
Fix golangcilint
kradalby Oct 18, 2022
6d8c18d
Fix golangcilint
kradalby Oct 18, 2022
b2bca2a
Only run integration tests from dir in new tests
kradalby Oct 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions integration/hsic/hsic.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ import (
"github.com/ory/dockertest/v3"
)

const hsicHashLength = 6
const dockerContextPath = "../."
const (
hsicHashLength = 6
dockerContextPath = "../."
)

var errHeadscaleStatusCodeNotOk = errors.New("headscale status code not ok")

Expand All @@ -32,7 +34,8 @@ type HeadscaleInContainer struct {
func New(
pool *dockertest.Pool,
port int,
network *dockertest.Network) (*HeadscaleInContainer, error) {
network *dockertest.Network,
) (*HeadscaleInContainer, error) {
hash, err := headscale.GenerateRandomStringDNSSafe(hsicHashLength)
if err != nil {
return nil, err
Expand Down
46 changes: 24 additions & 22 deletions integration/scenario.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,29 @@ import (

const scenarioHashLength = 6

var errNoHeadscaleAvailable = errors.New("no headscale available")
var errNoNamespaceAvailable = errors.New("no namespace available")
var TailscaleVersions = []string{
"head",
"unstable",
"1.32.0",
"1.30.2",
"1.28.0",
"1.26.2",
"1.24.2",
"1.22.2",
"1.20.4",
"1.18.2",
"1.16.2",

// These versions seem to fail when fetching from apt.
// "1.14.6",
// "1.12.4",
// "1.10.2",
// "1.8.7",
}
var (
errNoHeadscaleAvailable = errors.New("no headscale available")
juanfont marked this conversation as resolved.
Show resolved Hide resolved
errNoNamespaceAvailable = errors.New("no namespace available")
TailscaleVersions = []string{
"head",
"unstable",
"1.32.0",
"1.30.2",
"1.28.0",
"1.26.2",
"1.24.2",
"1.22.2",
"1.20.4",
"1.18.2",
"1.16.2",

// These versions seem to fail when fetching from apt.
// "1.14.6",
// "1.12.4",
// "1.10.2",
// "1.8.7",
}
)

type Namespace struct {
Clients map[string]*tsic.TailscaleInContainer
Expand Down Expand Up @@ -272,7 +274,7 @@ func (s *Scenario) WaitForTailscaleSync() error {

// CreateHeadscaleEnv is a conventient method returning a set up Headcale
// test environment with nodes of all versions, joined to the server with X
// namespaces
// namespaces.
func (s *Scenario) CreateHeadscaleEnv(namespaces map[string]int) error {
err := s.StartHeadscale()
if err != nil {
Expand Down
2 changes: 0 additions & 2 deletions integration/scenario_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ func TestHeadscale(t *testing.T) {
if err != nil {
t.Errorf("headscale failed to become ready: %s", err)
}

})

t.Run("create-namespace", func(t *testing.T) {
Expand Down Expand Up @@ -129,7 +128,6 @@ func TestTailscaleNodesJoiningHeadcale(t *testing.T) {
if err != nil {
t.Errorf("headscale failed to become ready: %s", err)
}

})

t.Run("create-namespace", func(t *testing.T) {
Expand Down
20 changes: 12 additions & 8 deletions integration/tsic/tsic.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@ import (
"tailscale.com/ipn/ipnstate"
)

const tsicHashLength = 6
const dockerContextPath = "../."
const (
tsicHashLength = 6
dockerContextPath = "../."
)

var errTailscalePingFailed = errors.New("ping failed")
var errTailscaleNotLoggedIn = errors.New("tailscale not logged in")
var (
errTailscalePingFailed = errors.New("ping failed")
errTailscaleNotLoggedIn = errors.New("tailscale not logged in")
)

type TailscaleInContainer struct {
version string
Expand All @@ -34,7 +38,8 @@ type TailscaleInContainer struct {
func New(
pool *dockertest.Pool,
version string,
network *dockertest.Network) (*TailscaleInContainer, error) {
network *dockertest.Network,
) (*TailscaleInContainer, error) {
hash, err := headscale.GenerateRandomStringDNSSafe(tsicHashLength)
if err != nil {
return nil, err
Expand Down Expand Up @@ -130,7 +135,7 @@ func (t *TailscaleInContainer) Up(
return nil
}

// TODO(kradalby): Make cached/lazy
// TODO(kradalby): Make cached/lazy.
func (t *TailscaleInContainer) IPs() ([]netip.Addr, error) {
ips := make([]netip.Addr, 0)

Expand Down Expand Up @@ -213,7 +218,7 @@ func (t *TailscaleInContainer) WaitForPeers(expected int) error {
})
}

// TODO(kradalby): Make multiping, go routine magic
// TODO(kradalby): Make multiping, go routine magic.
func (t *TailscaleInContainer) Ping(ip netip.Addr) error {
return t.pool.Retry(func() error {
command := []string{
Expand Down Expand Up @@ -245,7 +250,6 @@ func (t *TailscaleInContainer) Ping(ip netip.Addr) error {

return nil
})

}

func createTailscaleBuildOptions(version string) *dockertest.BuildOptions {
Expand Down