MCPcopy
hub / github.com/grafana/dskit / TestJoinMembersWithRetryBackoff

Function TestJoinMembersWithRetryBackoff

kv/memberlist/memberlist_client_test.go:1053–1194  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1051}
1052
1053func TestJoinMembersWithRetryBackoff(t *testing.T) {
1054
1055 c := dataCodec{}
1056
1057 const members = 3
1058 const key = "ring"
1059
1060 tests := map[string]struct {
1061 dnsDelayForFirstKV int
1062 startDelayForRest time.Duration
1063 queryType string
1064 }{
1065 "Test late start of members with fast join": {
1066 dnsDelayForFirstKV: 0,
1067 startDelayForRest: 1 * time.Second,
1068 queryType: "",
1069 },
1070 "Test late start of members with DNS lookup": {
1071 dnsDelayForFirstKV: 0,
1072 startDelayForRest: 1 * time.Second,
1073 queryType: "dns+",
1074 },
1075 "Test late start of DNS service": {
1076 dnsDelayForFirstKV: 5, // fail DNS lookup for 5 times (fast join and first couple of normal join DNS lookups)
1077 startDelayForRest: 0,
1078 queryType: "dns+",
1079 },
1080 }
1081
1082 for testName, testData := range tests {
1083 testData := testData
1084
1085 t.Run(testName, func(t *testing.T) {
1086 t.Parallel()
1087
1088 var clients []*Client
1089
1090 stop := make(chan struct{})
1091 start := make(chan struct{})
1092
1093 ports, err := getFreePorts(members)
1094 require.NoError(t, err)
1095
1096 watcher := services.NewFailureWatcher()
1097 go func() {
1098 for {
1099 select {
1100 case err := <-watcher.Chan():
1101 t.Errorf("service reported error: %v", err)
1102 case <-stop:
1103 return
1104 }
1105 }
1106 }()
1107
1108 kvsStarted := &sync.WaitGroup{}
1109 for i, port := range ports {
1110 id := fmt.Sprintf("Member-%d", i)

Callers

nothing calls this directly

Calls 15

ChanMethod · 0.95
WatchServiceMethod · 0.95
NewFailureWatcherFunction · 0.92
DefaultValuesFunction · 0.92
StartAndAwaitRunningFunction · 0.92
getFreePortsFunction · 0.85
getLocalhostAddrsFunction · 0.85
NewKVFunction · 0.85
RunMethod · 0.80
ErrorfMethod · 0.80
getAllTokensMethod · 0.80
NewClientFunction · 0.70

Tested by

no test coverage detected