2017-08-03 17:24:27 +00:00
|
|
|
package etcd
|
2017-01-03 19:43:46 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
2018-04-03 00:46:59 +00:00
|
|
|
log "github.com/hashicorp/go-hclog"
|
|
|
|
"github.com/hashicorp/vault/helper/logging"
|
2017-08-03 17:24:27 +00:00
|
|
|
"github.com/hashicorp/vault/physical"
|
2017-01-03 19:43:46 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestEtcd3Backend(t *testing.T) {
|
|
|
|
addr := os.Getenv("ETCD_ADDR")
|
|
|
|
if addr == "" {
|
|
|
|
t.Skipf("Skipped. No etcd3 server found")
|
|
|
|
}
|
|
|
|
|
2018-04-03 00:46:59 +00:00
|
|
|
logger := logging.NewVaultLogger(log.Debug)
|
2018-11-01 17:31:09 +00:00
|
|
|
config := map[string]string{
|
2017-01-03 19:43:46 +00:00
|
|
|
"path": fmt.Sprintf("/vault-%d", time.Now().Unix()),
|
|
|
|
"etcd_api": "3",
|
2018-11-01 17:31:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
b, err := NewEtcdBackend(config, logger)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
b2, err := NewEtcdBackend(config, logger)
|
2017-01-03 19:43:46 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
}
|
|
|
|
|
2017-08-03 17:24:27 +00:00
|
|
|
physical.ExerciseBackend(t, b)
|
|
|
|
physical.ExerciseBackend_ListPrefix(t, b)
|
2018-11-01 17:31:09 +00:00
|
|
|
physical.ExerciseHABackend(t, b.(physical.HABackend), b2.(physical.HABackend))
|
2017-01-03 19:43:46 +00:00
|
|
|
}
|