Skip to content

Commit

Permalink
libnetwork: replace consul with boltdb in test
Browse files Browse the repository at this point in the history
Based on randomLocalStore() in libnetwork/ipam/allocator_test.go

Signed-off-by: Sebastiaan van Stijn <[email protected]>
  • Loading branch information
thaJeztah committed Jan 6, 2022
1 parent a7d0f30 commit 25594c3
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions libnetwork/drivers/overlay/overlay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,24 @@ import (
"fmt"
"net"
"os"
"path/filepath"
"syscall"
"testing"
"time"

"golang.org/x/sys/unix"

"github.com/docker/docker/libnetwork/datastore"
"github.com/docker/docker/libnetwork/discoverapi"
"github.com/docker/docker/libnetwork/driverapi"
"github.com/docker/docker/libnetwork/netlabel"
"github.com/docker/docker/pkg/plugingetter"
"github.com/docker/libkv/store/consul"
"github.com/docker/libkv/store"
"github.com/docker/libkv/store/boltdb"
"github.com/vishvananda/netlink/nl"
"golang.org/x/sys/unix"
)

func init() {
consul.Register()
boltdb.Register()
}

type driverTester struct {
Expand All @@ -37,10 +38,25 @@ const testNetworkType = "overlay"
func setupDriver(t *testing.T) *driverTester {
dt := &driverTester{t: t}
config := make(map[string]interface{})

tmp, err := os.CreateTemp(t.TempDir(), "libnetwork-")
if err != nil {
t.Fatalf("Error creating temp file: %v", err)
}
err = tmp.Close()
if err != nil {
t.Fatalf("Error closing temp file: %v", err)
}
defaultPrefix := filepath.Join(os.TempDir(), "libnetwork", "test", "overlay")

config[netlabel.GlobalKVClient] = discoverapi.DatastoreConfigData{
Scope: datastore.GlobalScope,
Provider: "consul",
Address: "127.0.0.01:8500",
Provider: "boltdb",
Address: filepath.Join(defaultPrefix, filepath.Base(tmp.Name())),
Config: &store.Config{
Bucket: "libnetwork",
ConnectionTimeout: 3 * time.Second,
},
}

if err := Init(dt, config); err != nil {
Expand Down

0 comments on commit 25594c3

Please sign in to comment.