MCPcopy Create free account
hub / github.com/cortexproject/cortex / Test_resolveConflicts

Function Test_resolveConflicts

pkg/ring/model_test.go:749–825  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

747}
748
749func Test_resolveConflicts(t *testing.T) {
750 tests := []struct {
751 name string
752 args map[string]InstanceDesc
753 want map[string]InstanceDesc
754 }{
755 {
756 name: "Empty input",
757 args: map[string]InstanceDesc{},
758 want: map[string]InstanceDesc{},
759 },
760 {
761 name: "No conflicts",
762 args: map[string]InstanceDesc{
763 "ing1": {State: ACTIVE, Tokens: []uint32{1, 2, 3}},
764 "ing2": {State: ACTIVE, Tokens: []uint32{4, 5, 6}},
765 },
766 want: map[string]InstanceDesc{
767 "ing1": {State: ACTIVE, Tokens: []uint32{1, 2, 3}},
768 "ing2": {State: ACTIVE, Tokens: []uint32{4, 5, 6}},
769 },
770 },
771 {
772 name: "Conflict resolution with LEFT state",
773 args: map[string]InstanceDesc{
774 "ing1": {State: ACTIVE, Tokens: []uint32{1, 2, 3}},
775 "ing2": {State: LEFT, Tokens: []uint32{1, 2, 3, 4}},
776 },
777 want: map[string]InstanceDesc{
778 "ing1": {State: ACTIVE, Tokens: []uint32{1, 2, 3}},
779 "ing2": {State: LEFT, Tokens: nil},
780 },
781 },
782 {
783 name: "Conflict resolution with LEAVING state",
784 args: map[string]InstanceDesc{
785 "ing1": {State: LEAVING, Tokens: []uint32{1, 2, 3}},
786 "ing2": {State: PENDING, Tokens: []uint32{1, 2, 3, 4}},
787 },
788 want: map[string]InstanceDesc{
789 "ing1": {State: LEAVING, Tokens: nil},
790 "ing2": {State: PENDING, Tokens: []uint32{1, 2, 3, 4}},
791 },
792 },
793 {
794 name: "Conflict resolution with JOINING state",
795 args: map[string]InstanceDesc{
796 "ing1": {State: ACTIVE, Tokens: []uint32{1, 2, 3}},
797 "ing2": {State: JOINING, Tokens: []uint32{1, 2, 3, 4}},
798 },
799 want: map[string]InstanceDesc{
800 "ing1": {State: ACTIVE, Tokens: []uint32{1, 2, 3}},
801 "ing2": {State: JOINING, Tokens: []uint32{4}},
802 },
803 },
804 {
805 name: "Conflict resolution with same state",
806 args: map[string]InstanceDesc{

Callers

nothing calls this directly

Calls 3

resolveConflictsFunction · 0.85
RunMethod · 0.65
EqualMethod · 0.65

Tested by

no test coverage detected