mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 00:55:55 +00:00
We had two different, incompatible-with-each-other, and both individually broken, partial implementations of resizing logic. There's the original pre-etcd resize, and then the etcd resize, and neither works, but there's conflicts between the ways they don't work. No attempt to fix this is likely to yield decent results, so instead, we yank them both out entirely, so if we decide to implement resizing (which we will) we won't be confused by stray code pertaining to resizing that's not really hooked up to anything. We're leaving the resize messages in protobuf to avoid renumbering protobuf messages. We rename some of our message types to UNUSED0, etcetera, so that any code still using the old names won't compile, to make sure we get rid of it, but we can't just drop the numbers without breaking rolling restart. The Resize_AddNode tests are removed not just because we don't have resizing, but because they were completely broken anyway and never worked at all. But there's no reason to fix them because they exist to fix the functionality we didn't have and are now removing the vestigial remains of. We also drop the one usage of the AddNode function of Noder, because it was used only by one test code fragment that was creatincg clusters, and that can be done more correctly. There were no other call sites at all. We mark the monitorAntiEntropy function to be ignored by code coverage because it's not actually being covered. There's a separate ticket for removing that entirely.
84 lines
2.1 KiB
Go
84 lines
2.1 KiB
Go
package etcd
|
|
|
|
import (
|
|
"context"
|
|
"net/url"
|
|
"testing"
|
|
"time"
|
|
|
|
pilosa "github.com/molecula/featurebase/v3"
|
|
"github.com/molecula/featurebase/v3/disco"
|
|
"github.com/molecula/featurebase/v3/logger"
|
|
"go.etcd.io/etcd/server/v3/embed"
|
|
)
|
|
|
|
func TestRestartEtcd(t *testing.T) {
|
|
cfg := embed.NewConfig()
|
|
cfg.Dir = "default.etcd"
|
|
curl, _ := url.Parse(pilosa.EtcdUnixSocket(t))
|
|
cfg.LPUrls = append(cfg.LPUrls, *curl)
|
|
curl, _ = url.Parse(pilosa.EtcdUnixSocket(t))
|
|
cfg.LCUrls = append(cfg.LCUrls, *curl)
|
|
e, err := embed.StartEtcd(cfg)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
select {
|
|
case <-e.Server.ReadyNotify():
|
|
t.Logf("Server is ready!")
|
|
case <-time.After(60 * time.Second):
|
|
e.Server.Stop() // trigger a shutdown
|
|
t.Logf("Server took too long to start!")
|
|
}
|
|
e.Server.Stop()
|
|
e.Close()
|
|
|
|
e, err = embed.StartEtcd(cfg)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
select {
|
|
case <-e.Server.ReadyNotify():
|
|
t.Logf("Server is ready!")
|
|
case <-time.After(60 * time.Second):
|
|
e.Server.Stop() // trigger a shutdown
|
|
t.Logf("Server took too long to start!")
|
|
}
|
|
e.Close()
|
|
}
|
|
|
|
func TestParseOptions(t *testing.T) {
|
|
var e = &Etcd{options: Options{ClusterURL: "http://foo"}, logger: logger.NewLogfLogger(t)}
|
|
curl, _ := url.Parse(pilosa.EtcdUnixSocket(t))
|
|
e.options.LClientURL = curl.String()
|
|
curl, _ = url.Parse(pilosa.EtcdUnixSocket(t))
|
|
e.options.LPeerURL = curl.String()
|
|
|
|
e.options.ClusterURL = "http://foo"
|
|
_, err := e.parseOptions()
|
|
if err == nil {
|
|
t.Fatalf("cluster URL should be rejected")
|
|
}
|
|
e.options.ClusterURL = ""
|
|
e.options.InitCluster = "a,b"
|
|
_, err = e.parseOptions()
|
|
if AllowCluster() {
|
|
if err != nil {
|
|
t.Fatalf("expect options parsing to succeed")
|
|
}
|
|
} else {
|
|
t.Logf("no-allow: %v", err)
|
|
if err == nil {
|
|
t.Fatalf("should have failed to parse a multi-node cluster in non-clustered build")
|
|
}
|
|
}
|
|
|
|
// verify failure on start with invalid options
|
|
state, err := e.Start(context.Background())
|
|
if err == nil {
|
|
t.Fatalf("should have gotten error starting etcd with invalid options")
|
|
}
|
|
if state != disco.InitialClusterStateNew {
|
|
t.Fatalf("expected cluster state of %q, got %q", disco.InitialClusterStateNew, state)
|
|
}
|
|
}
|