etcd: Rewrite embed etcd implementation

This is a giant cleanup of the etcd code. The earlier version was
written when I was less experienced with golang.

This is still not perfect, and does contain some races, but at least
it's a decent base to start from. The automatic elastic clustering
should be considered an experimental feature. If you need a more
battle-tested cluster, then you should manage etcd manually and point
mgmt at your existing cluster.
This commit is contained in:
James Shubin
2018-05-05 17:35:08 -04:00
parent fb275d9537
commit a5842a41b2
56 changed files with 5459 additions and 2654 deletions

View File

@@ -21,31 +21,19 @@ package etcd
import (
"testing"
etcdtypes "github.com/coreos/etcd/pkg/types"
)
func TestNewEmbdEtcd(t *testing.T) {
// should return a new etcd object
noServer := false
var flags Flags
obj := NewEmbdEtcd("", nil, nil, nil, nil, nil, noServer, false, 0, flags, "", nil)
if obj == nil {
t.Fatal("failed to create server object")
}
}
func TestNewEmbdEtcdConfigValidation(t *testing.T) {
// running --no-server with no --seeds specified should fail early
seeds := make(etcdtypes.URLs, 0)
noServer := true
var flags Flags
obj := NewEmbdEtcd("", seeds, nil, nil, nil, nil, noServer, false, 0, flags, "", nil)
if obj != nil {
t.Fatal("server initialization should fail on invalid configuration")
func TestValidation1(t *testing.T) {
// running --no-server with no --seeds should not validate at the moment
embdEtcd := &EmbdEtcd{
//Seeds: etcdtypes.URLs{},
NoServer: true,
}
if err := embdEtcd.Validate(); err == nil {
t.Errorf("expected validation err, got nil")
}
if err := embdEtcd.Init(); err == nil {
t.Errorf("expected init err, got nil")
defer embdEtcd.Close()
}
}