(t *testing.T)
| 1051 | } |
| 1052 | |
| 1053 | func 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) |
nothing calls this directly
no test coverage detected