chore(model): deflake TestCompletionEmptyGlobal (#10663)
There was a race condition where using IndexUpdate would trigger a pull, which would sync the delete we are looking for, making the completion 100%. By doing the insert directly into the database we are not triggering these things and get the expected completion percentage always. Signed-off-by: Jakob Borg <jakob@kastelo.net>
This commit is contained in:
@@ -3783,13 +3783,19 @@ func TestIssue6961(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCompletionEmptyGlobal(t *testing.T) {
|
func TestCompletionEmptyGlobal(t *testing.T) {
|
||||||
m, conn, fcfg := setupModelWithConnection(t)
|
m, _, fcfg := setupModelWithConnection(t)
|
||||||
defer cleanupModelAndRemoveDir(m, fcfg.Filesystem().URI())
|
defer cleanupModelAndRemoveDir(m, fcfg.Filesystem().URI())
|
||||||
|
|
||||||
|
// Insert a local file
|
||||||
files := []protocol.FileInfo{{Name: "foo", Version: protocol.Vector{}.Update(myID.Short()), Sequence: 1}}
|
files := []protocol.FileInfo{{Name: "foo", Version: protocol.Vector{}.Update(myID.Short()), Sequence: 1}}
|
||||||
m.sdb.Update(fcfg.ID, protocol.LocalDeviceID, files)
|
must(t, m.sdb.Update(fcfg.ID, protocol.LocalDeviceID, files))
|
||||||
|
|
||||||
|
// A remote announces it deleted
|
||||||
files[0].Deleted = true
|
files[0].Deleted = true
|
||||||
files[0].Version = files[0].Version.Update(device1.Short())
|
files[0].Version = files[0].Version.Update(device1.Short())
|
||||||
must(t, m.IndexUpdate(conn, &protocol.IndexUpdate{Folder: fcfg.ID, Files: files}))
|
must(t, m.sdb.Update(fcfg.ID, device1, files))
|
||||||
|
|
||||||
|
// Our completion should be 95%
|
||||||
comp := m.testCompletion(protocol.LocalDeviceID, fcfg.ID)
|
comp := m.testCompletion(protocol.LocalDeviceID, fcfg.ID)
|
||||||
if comp.CompletionPct != 95 {
|
if comp.CompletionPct != 95 {
|
||||||
t.Error("Expected completion of 95%, got", comp.CompletionPct)
|
t.Error("Expected completion of 95%, got", comp.CompletionPct)
|
||||||
|
|||||||
Reference in New Issue
Block a user