routing: introduce missionControlDB abstraction

So that `missionControlStore` can be unaware of the backing DB structure
it is writing to. In an upcoming commit when we change mission control
to write to namespaced buckets instead, we then only need to update the
`namespacedDB` implementation.
This commit is contained in:
Elle Mouton
2024-08-13 18:00:55 +02:00
parent 75eaaf7c5c
commit 2dd9046622
3 changed files with 105 additions and 28 deletions

View File

@@ -62,7 +62,9 @@ func newMCStoreTestHarness(t testing.TB, maxRecords int,
require.NoError(t, db.Close())
})
store, err := newMissionControlStore(db, maxRecords, flushInterval)
store, err := newMissionControlStore(
newNamespacedDB(db), maxRecords, flushInterval,
)
require.NoError(t, err)
return mcStoreTestHarness{db: db, store: store}
@@ -115,7 +117,9 @@ func TestMissionControlStore(t *testing.T) {
require.Equal(t, &result2, results[1])
// Recreate store to test pruning.
store, err = newMissionControlStore(db, testMaxRecords, time.Second)
store, err = newMissionControlStore(
newNamespacedDB(db), testMaxRecords, time.Second,
)
require.NoError(t, err)
// Add a newer result which failed due to mpp timeout.
@@ -213,7 +217,9 @@ func TestMissionControlStoreFlushing(t *testing.T) {
store.stop()
// Recreate store.
store, err := newMissionControlStore(db, testMaxRecords, flushInterval)
store, err := newMissionControlStore(
newNamespacedDB(db), testMaxRecords, flushInterval,
)
require.NoError(t, err)
store.run()
defer store.stop()