mirror of
https://github.com/datarhei/core.git
synced 2025-10-16 04:50:44 +08:00

Replace CORE_CLUSTER_JOIN_ADDRESS with CORE_CLUSTER_PEERS. This is a comma separated list of cluster members with their IDs of the form ID@host:port On startup the node tries to connect to all the peers. In case of sudden deaths of a node this will allow to find back into the cluster. The list in CLUSTER_PEERS is a starting point of known peers. Other node that are not in that list can still join the cluster. File and stream proxy has been moved to the Proxy type.
80 lines
1.7 KiB
Go
80 lines
1.7 KiB
Go
package value
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestClusterAddressValue(t *testing.T) {
|
|
var x string
|
|
|
|
val := NewClusterAddress(&x, "foobar:8080")
|
|
|
|
require.Equal(t, "foobar:8080", val.String())
|
|
require.Equal(t, nil, val.Validate())
|
|
require.Equal(t, false, val.IsEmpty())
|
|
|
|
x = "foobaz:9090"
|
|
|
|
require.Equal(t, "foobaz:9090", val.String())
|
|
require.Equal(t, nil, val.Validate())
|
|
require.Equal(t, false, val.IsEmpty())
|
|
|
|
val.Set("fooboz:7070")
|
|
|
|
require.Equal(t, "fooboz:7070", x)
|
|
|
|
err := val.Set(":7070")
|
|
require.Error(t, err)
|
|
}
|
|
|
|
func TestClusterPeerValue(t *testing.T) {
|
|
var x string
|
|
|
|
val := NewClusterPeer(&x, "abc@foobar:8080")
|
|
|
|
require.Equal(t, "abc@foobar:8080", val.String())
|
|
require.Equal(t, nil, val.Validate())
|
|
require.Equal(t, false, val.IsEmpty())
|
|
|
|
x = "xyz@foobaz:9090"
|
|
|
|
require.Equal(t, "xyz@foobaz:9090", val.String())
|
|
require.Equal(t, nil, val.Validate())
|
|
require.Equal(t, false, val.IsEmpty())
|
|
|
|
val.Set("mno@fooboz:7070")
|
|
|
|
require.Equal(t, "mno@fooboz:7070", x)
|
|
|
|
err := val.Set("foobar:7070")
|
|
require.Error(t, err)
|
|
}
|
|
|
|
func TestClusterPeerListValue(t *testing.T) {
|
|
var x []string
|
|
|
|
val := NewClusterPeerList(&x, []string{"abc@foobar:8080"}, ",")
|
|
|
|
require.Equal(t, "abc@foobar:8080", val.String())
|
|
require.Equal(t, nil, val.Validate())
|
|
require.Equal(t, false, val.IsEmpty())
|
|
|
|
x = []string{"abc@foobar:8080", "xyz@foobaz:9090"}
|
|
|
|
require.Equal(t, "abc@foobar:8080,xyz@foobaz:9090", val.String())
|
|
require.Equal(t, nil, val.Validate())
|
|
require.Equal(t, false, val.IsEmpty())
|
|
|
|
val.Set("mno@fooboz:8080,rst@foobax:9090")
|
|
|
|
require.Equal(t, []string{"mno@fooboz:8080", "rst@foobax:9090"}, x)
|
|
|
|
err := val.Set("mno@:8080")
|
|
require.Error(t, err)
|
|
|
|
err = val.Set("foobax:9090")
|
|
require.Error(t, err)
|
|
}
|