1
0
Fork 0

E2E testing of DNS clustering with non-voters

master
Philip O'Toole 9 months ago
parent 3d8ee9fc0f
commit b7892539ac

@ -137,7 +137,8 @@ func (b *Bootstrapper) SetCredentials(creds *Credentials) {
// - joining an existing cluster by explicitly joining it through a node returned
// by the AddressProvider, or
// - if it's a Voting node, notifying all nodes returned by the AddressProvider
// that it exists, allowing a cluster-wide bootstrap take place.
// that it exists, potentially allowing a cluster-wide bootstrap take place
// which will include this node.
//
// Returns nil if the boot operation was successful, or if done() ever returns
// true. done() is periodically polled by the boot process. Returns an error

@ -322,8 +322,8 @@ func (c *Config) Validate() error {
return fmt.Errorf("bootstrapping not applicable when using %s", c.DiscoMode)
}
case DiscoModeDNS, DiscoModeDNSSRV:
if c.BootstrapExpect == 0 {
return fmt.Errorf("bootstrap-expect value required when using %s", c.DiscoMode)
if c.BootstrapExpect == 0 && !c.RaftNonVoter {
return fmt.Errorf("bootstrap-expect value required when using %s with a voting node", c.DiscoMode)
}
default:
return fmt.Errorf("disco mode must be one of %s, %s, %s, or %s",

@ -26,7 +26,6 @@ import (
"github.com/rqlite/rqlite/v8/cmd"
"github.com/rqlite/rqlite/v8/db"
"github.com/rqlite/rqlite/v8/disco"
"github.com/rqlite/rqlite/v8/http"
httpd "github.com/rqlite/rqlite/v8/http"
"github.com/rqlite/rqlite/v8/rtls"
"github.com/rqlite/rqlite/v8/store"
@ -559,7 +558,7 @@ func createCluster(cfg *Config, hasPeers bool, client *cluster.Client, str *stor
func networkCheckJoinAddrs(joinAddrs []string) error {
log.Println("checking that any supplied join addresses don't serve HTTP(S)")
if addr, ok := http.AnyServingHTTP(joinAddrs); ok {
if addr, ok := httpd.AnyServingHTTP(joinAddrs); ok {
return fmt.Errorf("join address %s appears to be serving HTTP when it should be Raft", addr)
}
return nil

@ -132,7 +132,7 @@ class TestBootstrappingRestartLeaveOnRemove(unittest.TestCase):
deprovision_node(n2)
class TestAutoClusteringDNS(unittest.TestCase):
def test(self):
def test_3_voters(self):
os.environ['RQLITE_DISCO_DNS_HOSTS'] = 'localhost:4002,localhost:4004,localhost:4006'
filename = write_random_file('{"name":"rqlite.cluster"}') # Anything, doesn't matter.
@ -151,6 +151,25 @@ class TestAutoClusteringDNS(unittest.TestCase):
deprovision_node(n1)
deprovision_node(n2)
def test_3_voters_1_nonvoter(self):
os.environ['RQLITE_DISCO_DNS_HOSTS'] = 'localhost:4002,localhost:4004,localhost:4006'
filename = write_random_file('{"name":"rqlite.cluster"}') # Anything, doesn't matter.
n0 = Node(RQLITED_PATH, '0', raft_addr='localhost:4002', bootstrap_expect=3)
n1 = Node(RQLITED_PATH, '1', raft_addr='localhost:4004', bootstrap_expect=3)
n2 = Node(RQLITED_PATH, '2', raft_addr='localhost:4006', bootstrap_expect=3)
n0.start(disco_mode='dns', disco_config=filename)
n1.start(disco_mode='dns', disco_config=filename)
n2.start(disco_mode='dns', disco_config=filename)
self.assertEqual(n0.wait_for_leader(), n1.wait_for_leader())
self.assertEqual(n0.wait_for_leader(), n2.wait_for_leader())
n3 = Node(RQLITED_PATH, '3', raft_voter=False)
n3.start(disco_mode='dns', disco_config=filename)
self.assertEqual(n0.wait_for_leader(), n3.wait_for_leader())
def tearDown(self):
del os.environ['RQLITE_DISCO_DNS_HOSTS']

Loading…
Cancel
Save