944332d12d
* Update Go client libraries for etcd * Added etcd server container to run etcd3 tests automatically. * Removed etcd2 test case: it fails the backend tests but the failure is unrelated to the uplift. The etcd2 backend implementation does not remove empty nested nodes when removing leaf (see comments in #11980).
44 lines
1 KiB
Go
44 lines
1 KiB
Go
package etcd
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
"time"
|
|
|
|
log "github.com/hashicorp/go-hclog"
|
|
"github.com/hashicorp/vault/helper/testhelpers/etcd"
|
|
"github.com/hashicorp/vault/sdk/helper/logging"
|
|
"github.com/hashicorp/vault/sdk/physical"
|
|
)
|
|
|
|
func TestEtcd3Backend(t *testing.T) {
|
|
cleanup, config := etcd.PrepareTestContainer(t, "v3.5.0")
|
|
defer cleanup()
|
|
|
|
logger := logging.NewVaultLogger(log.Debug)
|
|
configMap := map[string]string{
|
|
"address": config.URL().String(),
|
|
"path": fmt.Sprintf("/vault-%d", time.Now().Unix()),
|
|
"etcd_api": "3",
|
|
"username": "root",
|
|
"password": "insecure",
|
|
|
|
// Syncing adverticed client urls should be disabled since docker port mapping confuses the client.
|
|
"sync": "false",
|
|
}
|
|
|
|
b, err := NewEtcdBackend(configMap, logger)
|
|
if err != nil {
|
|
t.Fatalf("err: %s", err)
|
|
}
|
|
|
|
b2, err := NewEtcdBackend(configMap, logger)
|
|
if err != nil {
|
|
t.Fatalf("err: %s", err)
|
|
}
|
|
|
|
physical.ExerciseBackend(t, b)
|
|
physical.ExerciseBackend_ListPrefix(t, b)
|
|
physical.ExerciseHABackend(t, b.(physical.HABackend), b2.(physical.HABackend))
|
|
}
|