open-vault/physical/etcd/etcd3_test.go

39 lines
762 B
Go
Raw Normal View History

package etcd
2017-01-03 19:43:46 +00:00
import (
"fmt"
"os"
"testing"
"time"
"github.com/hashicorp/vault/helper/logformat"
"github.com/hashicorp/vault/physical"
2017-01-03 19:43:46 +00:00
log "github.com/mgutz/logxi/v1"
)
func TestEtcd3Backend(t *testing.T) {
addr := os.Getenv("ETCD_ADDR")
if addr == "" {
t.Skipf("Skipped. No etcd3 server found")
}
logger := logformat.NewVaultLogger(log.LevelTrace)
b, err := NewEtcdBackend(map[string]string{
2017-01-03 19:43:46 +00:00
"path": fmt.Sprintf("/vault-%d", time.Now().Unix()),
"etcd_api": "3",
}, logger)
2017-01-03 19:43:46 +00:00
if err != nil {
t.Fatalf("err: %s", err)
}
physical.ExerciseBackend(t, b)
physical.ExerciseBackend_ListPrefix(t, b)
2017-01-03 19:43:46 +00:00
ha, ok := b.(physical.HABackend)
2017-01-03 19:43:46 +00:00
if !ok {
t.Fatalf("etcd3 does not implement HABackend")
}
physical.ExerciseHABackend(t, ha, ha)
2017-01-03 19:43:46 +00:00
}