diff options
author | Corey Hulen <corey@hulen.com> | 2017-06-19 08:44:04 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-19 08:44:04 -0700 |
commit | 36f216cb7cb16958d98b3d77e121198596fd2213 (patch) | |
tree | ac2a5b79494749b3dffc2f5778092f2529c98d1a /model/cluster_discovery_test.go | |
parent | fe48987a32fbd600458edd4e81318071ae558ba4 (diff) | |
download | chat-36f216cb7cb16958d98b3d77e121198596fd2213.tar.gz chat-36f216cb7cb16958d98b3d77e121198596fd2213.tar.bz2 chat-36f216cb7cb16958d98b3d77e121198596fd2213.zip |
PLT-6080 moving clustering to memberlist (#6499)
* PLT-6080 adding cluster discovery service
* Adding memberlist lib
* Adding memberlist lib
* WIP
* WIP
* WIP
* WIP
* Rolling back config changes
* Fixing make file
* Fixing config for cluster
* WIP
* Fixing system console for clustering
* Fixing default config
* Fixing config
* Fixing system console for clustering
* Tweaking hub setting
* Bumping up time
* merging vendor dir
* Updating vendor dir
* Fixing unit test
* Fixing bad merge
* Remove some testing code
* Moving comment
* PLT-6868 adding db ping retry
* Removing unused loc strings
* Adding defer to cancel
Diffstat (limited to 'model/cluster_discovery_test.go')
-rw-r--r-- | model/cluster_discovery_test.go | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/model/cluster_discovery_test.go b/model/cluster_discovery_test.go new file mode 100644 index 000000000..bfbdbd303 --- /dev/null +++ b/model/cluster_discovery_test.go @@ -0,0 +1,59 @@ +// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +package model + +import ( + "strings" + "testing" +) + +func TestClusterDiscovery(t *testing.T) { + o := ClusterDiscovery{ + Type: "test_type", + ClusterName: "cluster_name", + Hostname: "test_hostname", + } + + json := o.ToJson() + result1 := ClusterDiscoveryFromJson(strings.NewReader(json)) + + if result1.ClusterName != "cluster_name" { + t.Fatal("should be set") + } + + result2 := ClusterDiscoveryFromJson(strings.NewReader(json)) + result3 := ClusterDiscoveryFromJson(strings.NewReader(json)) + + o.Id = "0" + result1.Id = "1" + result2.Id = "2" + result3.Id = "3" + result3.Hostname = "something_diff" + + if !o.IsEqual(result1) { + t.Fatal("Should be equal") + } + + list := make([]*ClusterDiscovery, 0) + list = append(list, &o) + list = append(list, result1) + list = append(list, result2) + list = append(list, result3) + + rlist := FilterClusterDiscovery(list, func(in *ClusterDiscovery) bool { + return !o.IsEqual(in) + }) + + if len(rlist) != 1 { + t.Fatal("should only have 1 result") + } + + o.AutoFillHostname() + o.Hostname = "" + o.AutoFillHostname() + + o.AutoFillIpAddress() + o.Hostname = "" + o.AutoFillIpAddress() +} |