Skip to content

Commit

Permalink
Revert "Change docker networking stuff"
Browse files Browse the repository at this point in the history
This reverts commit 29ed903.
  • Loading branch information
TotoTheDragon committed Feb 16, 2024
1 parent 29ed903 commit 6728dc7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
2 changes: 1 addition & 1 deletion integration/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type ControlServer interface {
SaveLog(string) error
SaveProfile(string) error
Execute(command []string) (string, error)
ConnectToNetwork(network *dockertest.Network) error
GetHealthEndpoint() string
GetEndpoint() string
WaitForRunning() error
Expand All @@ -19,5 +20,4 @@ type ControlServer interface {
GetCert() []byte
GetHostname() string
GetIP() string
GetNetwork() *dockertest.Network
}
23 changes: 21 additions & 2 deletions integration/embedded_derp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"testing"

"github.com/juanfont/headscale/hscontrol/util"
"github.com/juanfont/headscale/integration/dockertestutil"
"github.com/juanfont/headscale/integration/hsic"
"github.com/juanfont/headscale/integration/tsic"
"github.com/ory/dockertest/v3"
Expand Down Expand Up @@ -227,10 +228,28 @@ func (s *EmbeddedDERPServerScenario) CreateTailscaleIsolatedNodesInUser(
return err
}

network := hsServer.GetNetwork()

if user, ok := s.users[userStr]; ok {
for clientN := 0; clientN < count; clientN++ {
networkName := fmt.Sprintf("tsnet-%s-%s-%d",
hash,
userStr,
clientN,
)
network, err := dockertestutil.GetFirstOrCreateNetwork(
s.pool,
networkName,
)
if err != nil {
return fmt.Errorf("failed to create or get %s network: %w", networkName, err)
}

s.tsicNetworks[networkName] = network

err = hsServer.ConnectToNetwork(network)
if err != nil {
return fmt.Errorf("failed to connect headscale to %s network: %w", networkName, err)
}

version := requestedVersion
if requestedVersion == "all" {
version = MustTestVersions[clientN%len(MustTestVersions)]
Expand Down
9 changes: 4 additions & 5 deletions integration/hsic/hsic.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,10 @@ func New(
return hsic, nil
}

func (t *HeadscaleInContainer) ConnectToNetwork(network *dockertest.Network) error {
return t.container.ConnectToNetwork(network)
}

func (t *HeadscaleInContainer) hasTLS() bool {
return len(t.tlsCert) != 0 && len(t.tlsKey) != 0
}
Expand Down Expand Up @@ -469,11 +473,6 @@ func (t *HeadscaleInContainer) GetEndpoint() string {
return fmt.Sprintf("http://%s", hostEndpoint)
}

// GetEndpoint returns the Headscale endpoint for the HeadscaleInContainer.
func (t *HeadscaleInContainer) GetNetwork() *dockertest.Network {
return t.network
}

// GetCert returns the public certificate of the HeadscaleInContainer.
func (t *HeadscaleInContainer) GetCert() []byte {
return t.tlsCert
Expand Down

0 comments on commit 6728dc7

Please sign in to comment.