27
t *testing.T,
28
factory *sql.Factory,
30
>
return &connectionSuite{
31
>
Assertions: require.New(t),
32
>
factory: factory,
33
>
}
34
>
}
35
37
>
38
>
}
39
41
>
42
>
}
43
45
>
s.Assertions = require.New(s.T())
46
>
}
47
49
>
50
>
}
51
52
// Tests that SQL operations do not panic if the underlying connection has been closed and that the persistence layer
53
// returns a useful error message.
54
// Currently only run against MySQL and Postgresql (SQLite always maintains at least one open connection)
56
>
ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
57
>
defer cancel()
58
>
59
>
shardID := (int32)(1)
60
>
rangeID := rand.Int63()
61
>
shardInfo := RandomShardInfo(shardID, rangeID)
62
>
63
>
store, err := s.factory.NewShardStore()
64
>
s.NoError(err)
65
>
66
>
store.Close() // Connection will be closed by this call
67
>
manager := p.NewShardManager(store, serialization.NewSerializer())
68
>
69
>
resp, err := manager.GetOrCreateShard(ctx, &p.GetOrCreateShardRequest{
70
>
ShardID: shardID,
71
>
InitialShardInfo: shardInfo,
72
>
})
73
>
74
>
s.Nil(resp)
75
>
s.ErrorContains(err, sqlplugin.DatabaseUnavailableError.Error())
76
>
}