lib/model: Unflake folder restart with blocking conn test (ref #5707) (#5744)

This commit is contained in:
Simon Frei 2019-05-27 11:58:09 +02:00 committed by Audrius Butkevicius
parent 486230768e
commit 129df0613b
1 changed files with 10 additions and 4 deletions

View File

@ -3273,6 +3273,12 @@ func TestConnCloseOnRestart(t *testing.T) {
br := &testutils.BlockingRW{}
nw := &testutils.NoopRW{}
m.AddConnection(newFakeProtoConn(protocol.NewConnection(device1, br, nw, m, "testConn", protocol.CompressNever)), protocol.HelloResult{})
m.pmut.RLock()
if len(m.closed) != 1 {
t.Fatalf("Expected just one conn (len(m.conn) == %v)", len(m.conn))
}
closed := m.closed[device1]
m.pmut.RUnlock()
newFcfg := fcfg.Copy()
newFcfg.Paused = true
@ -3286,9 +3292,9 @@ func TestConnCloseOnRestart(t *testing.T) {
case <-time.After(5 * time.Second):
t.Fatal("Timed out before folder restart returned")
}
m.pmut.RLock()
defer m.pmut.RUnlock()
if len(m.conn) != 0 {
t.Errorf("Conn wasn't removed on restart (len(m.conn) == %v)", len(m.conn))
select {
case <-closed:
case <-time.After(5 * time.Second):
t.Fatal("Timed out before connection was closed")
}
}