libnetwork: replace consul with boltdb in test
Based on randomLocalStore() in libnetwork/ipam/allocator_test.go
@@ -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 {
@@ -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 {
