-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
K8SPSMDB-1002: add crd preferer primary node
Add crd parameter to prefer primary node in cluster.
- Loading branch information
1 parent
c2b95d9
commit 46d7983
Showing
11 changed files
with
182 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package perconaservermongodb | ||
|
||
import ( | ||
"testing" | ||
|
||
api "github.com/percona/percona-server-mongodb-operator/pkg/apis/psmdb/v1" | ||
"github.com/percona/percona-server-mongodb-operator/pkg/psmdb/mongo" | ||
) | ||
|
||
func TestCompareTags(t *testing.T) { | ||
t.Parallel() | ||
|
||
tests := []struct { | ||
name string | ||
mongoTags mongo.ReplsetTags | ||
selectorTags api.PrimaryPreferTagSelectorSpec | ||
expected bool | ||
}{ | ||
{ | ||
name: "empty tags", | ||
mongoTags: mongo.ReplsetTags{}, | ||
selectorTags: api.PrimaryPreferTagSelectorSpec{}, | ||
expected: false, | ||
}, | ||
{ | ||
name: "selector with podName", | ||
mongoTags: mongo.ReplsetTags{}, | ||
selectorTags: api.PrimaryPreferTagSelectorSpec{"podName": "test"}, | ||
expected: false, | ||
}, | ||
{ | ||
name: "match selector with podName", | ||
mongoTags: mongo.ReplsetTags{"podName": "test"}, | ||
selectorTags: api.PrimaryPreferTagSelectorSpec{"podName": "test"}, | ||
expected: true, | ||
}, | ||
{ | ||
name: "match selector with podName and other tags", | ||
mongoTags: mongo.ReplsetTags{"podName": "test", "other": "tag"}, | ||
selectorTags: api.PrimaryPreferTagSelectorSpec{"podName": "test"}, | ||
expected: true, | ||
}, | ||
{ | ||
name: "match two selectors with podName and other tags", | ||
mongoTags: mongo.ReplsetTags{"podName": "test", "other": "tag"}, | ||
selectorTags: api.PrimaryPreferTagSelectorSpec{"podName": "test", "other": "tag"}, | ||
expected: true, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := compareTags(tt.mongoTags, tt.selectorTags); got != tt.expected { | ||
t.Errorf("compareTags() = %v, want %v", got, tt.expected) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters