MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / waitForMirrorComplete

Function waitForMirrorComplete

sqlchain/mirror/mirror_test.go:184–211  ·  view source on GitHub ↗
(ctx context.Context, dbID string, tick time.Duration, stableDuration time.Duration)

Source from the content-addressed store, hash-verified

182}
183
184func waitForMirrorComplete(ctx context.Context, dbID string, tick time.Duration, stableDuration time.Duration) (err error) {
185 progressFile := FJ(testWorkingDir, "./mirror/node_mirror/"+dbID+progressFileSuffix)
186 lastProgress := 0
187 lastUpdate := time.Now()
188
189 for {
190 select {
191 case <-ctx.Done():
192 return ctx.Err()
193 case <-time.After(tick):
194 progressData, _ := ioutil.ReadFile(progressFile)
195 progressCount, _ := strconv.Atoi(string(progressData))
196 log.WithFields(log.Fields{
197 "lastUpdate": lastUpdate.String(),
198 "stableDuration": stableDuration,
199 "progressCount": progressCount,
200 }).Infof("current mirror count progress")
201 if progressCount > lastProgress {
202 lastProgress = progressCount
203 lastUpdate = time.Now()
204 }
205 if progressCount > 5 || (progressCount > 0 && time.Now().Sub(lastUpdate) > stableDuration) {
206 // mirror synced
207 return
208 }
209 }
210 }
211}
212
213func TestFullProcess(t *testing.T) {
214 log.SetLevel(log.DebugLevel)

Callers 1

TestFullProcessFunction · 0.85

Calls 3

WithFieldsFunction · 0.92
InfofMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected