Some general cleanup
This commit is contained in:
parent
71bc182ab4
commit
010c53e5c7
@ -138,7 +138,6 @@ func New(
|
||||
d.networks[id], err = network.Load(
|
||||
ctx,
|
||||
logger.WithNamespace("network"),
|
||||
id,
|
||||
networkConfig,
|
||||
d.envBinDirPath,
|
||||
networkStateDir,
|
||||
|
@ -176,7 +176,6 @@ type network struct {
|
||||
// been initialized.
|
||||
func instatiateNetwork(
|
||||
logger *mlog.Logger,
|
||||
networkID string,
|
||||
networkConfig daecommon.NetworkConfig,
|
||||
envBinDirPath string,
|
||||
stateDir toolkit.Dir,
|
||||
@ -224,7 +223,6 @@ func LoadCreationParams(
|
||||
func Load(
|
||||
ctx context.Context,
|
||||
logger *mlog.Logger,
|
||||
networkID string,
|
||||
networkConfig daecommon.NetworkConfig,
|
||||
envBinDirPath string,
|
||||
stateDir toolkit.Dir,
|
||||
@ -235,7 +233,6 @@ func Load(
|
||||
) {
|
||||
n := instatiateNetwork(
|
||||
logger,
|
||||
networkID,
|
||||
networkConfig,
|
||||
envBinDirPath,
|
||||
stateDir,
|
||||
@ -281,7 +278,6 @@ func Join(
|
||||
) {
|
||||
n := instatiateNetwork(
|
||||
logger,
|
||||
joiningBootstrap.Bootstrap.NetworkCreationParams.ID,
|
||||
networkConfig,
|
||||
envBinDirPath,
|
||||
stateDir,
|
||||
@ -348,7 +344,6 @@ func Create(
|
||||
|
||||
n := instatiateNetwork(
|
||||
logger,
|
||||
creationParams.ID,
|
||||
networkConfig,
|
||||
envBinDirPath,
|
||||
stateDir,
|
||||
@ -597,9 +592,7 @@ func withCurrBootstrap[Res any](
|
||||
return fn(currBootstrap)
|
||||
}
|
||||
|
||||
func (n *network) getBootstrap(
|
||||
ctx context.Context,
|
||||
) (
|
||||
func (n *network) getBootstrap() (
|
||||
bootstrap.Bootstrap, error,
|
||||
) {
|
||||
return withCurrBootstrap(n, func(
|
||||
@ -612,7 +605,7 @@ func (n *network) getBootstrap(
|
||||
}
|
||||
|
||||
func (n *network) GetHosts(ctx context.Context) ([]bootstrap.Host, error) {
|
||||
b, err := n.getBootstrap(ctx)
|
||||
b, err := n.getBootstrap()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("retrieving bootstrap: %w", err)
|
||||
}
|
||||
@ -644,7 +637,7 @@ func (n *network) GetNebulaCAPublicCredentials(
|
||||
) (
|
||||
nebula.CAPublicCredentials, error,
|
||||
) {
|
||||
b, err := n.getBootstrap(ctx)
|
||||
b, err := n.getBootstrap()
|
||||
if err != nil {
|
||||
return nebula.CAPublicCredentials{}, fmt.Errorf(
|
||||
"retrieving bootstrap: %w", err,
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
|
||||
@ -18,13 +19,13 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
envBinDirPath = func() string {
|
||||
getEnvBinDirPath = sync.OnceValue(func() string {
|
||||
appDirPath := os.Getenv("APPDIR")
|
||||
if appDirPath == "" {
|
||||
panic("APPDIR not set")
|
||||
}
|
||||
return filepath.Join(appDirPath, "bin")
|
||||
}()
|
||||
})
|
||||
|
||||
ipNetCounter uint64
|
||||
)
|
||||
@ -82,6 +83,8 @@ func (h *harness) mkDir(t *testing.T, name string) toolkit.Dir {
|
||||
}
|
||||
|
||||
func TestCreate(t *testing.T) {
|
||||
toolkit.MarkIntegrationTest(t)
|
||||
|
||||
var (
|
||||
h = newHarness(t)
|
||||
creationParams = bootstrap.NewCreationParams("test", "test.localnet")
|
||||
@ -119,7 +122,7 @@ func TestCreate(t *testing.T) {
|
||||
h.ctx,
|
||||
h.logger.WithNamespace("network"),
|
||||
networkConfig,
|
||||
envBinDirPath,
|
||||
getEnvBinDirPath(),
|
||||
stateDir,
|
||||
runtimeDir,
|
||||
creationParams,
|
@ -6,7 +6,6 @@ require (
|
||||
code.betamike.com/micropelago/pmux v0.0.0-20240719134913-f5fce902e8c4
|
||||
dev.mediocregopher.com/mediocre-go-lib.git v0.0.0-20240511135822-4ab1176672d7
|
||||
github.com/adrg/xdg v0.4.0
|
||||
github.com/imdario/mergo v0.3.12
|
||||
github.com/jxskiss/base62 v1.1.0
|
||||
github.com/minio/minio-go/v7 v7.0.28
|
||||
github.com/slackhq/nebula v1.6.1
|
||||
|
@ -18,8 +18,6 @@ github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
|
||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gopherjs/gopherjs v1.17.2 h1:fQnZVsXk8uxXIStYb0N4bGk7jeyTalG/wsZjQ25dO0g=
|
||||
github.com/gopherjs/gopherjs v1.17.2/go.mod h1:pRRIvn/QzFLrKfvEz3qUuEhtE/zLCWfreZ6J5gM2i+k=
|
||||
github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=
|
||||
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
|
||||
@ -92,9 +90,6 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/ini.v1 v1.57.0 h1:9unxIsFcTt4I55uWluz+UmL95q4kdJ0buvQ1ZIqVQww=
|
||||
gopkg.in/ini.v1 v1.57.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
@ -13,5 +13,5 @@ nix-shell -A testShell ../default.nix --run "
|
||||
--user=\"$this_user\" \\
|
||||
--addamb=cap_net_admin \\
|
||||
--addamb=cap_net_bind_service \\
|
||||
-- -c 'go test $*'
|
||||
-- -c 'ISLE_INTEGRATION_TEST=1 go test $*'
|
||||
"
|
14
go/toolkit/testutils.go
Normal file
14
go/toolkit/testutils.go
Normal file
@ -0,0 +1,14 @@
|
||||
package toolkit
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// MarkIntegrationTest marks a test as being an integration test. It will be
|
||||
// skipped if the ISLE_INTEGRATION_TEST envvar isn't set.
|
||||
func MarkIntegrationTest(t *testing.T) {
|
||||
if os.Getenv("ISLE_INTEGRATION_TEST") == "" {
|
||||
t.Skip("Skipped because ISLE_INTEGRATION_TEST isn't set")
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user