From 36f216cb7cb16958d98b3d77e121198596fd2213 Mon Sep 17 00:00:00 2001 From: Corey Hulen Date: Mon, 19 Jun 2017 08:44:04 -0700 Subject: 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 --- model/cluster_discovery_test.go | 59 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 model/cluster_discovery_test.go (limited to 'model/cluster_discovery_test.go') 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() +} -- cgit v1.2.3-1-g7c22