|
|
@ -2384,6 +2384,7 @@ func TestDBReadOnly(t *testing.T) {
|
|
|
|
dbDir string
|
|
|
|
dbDir string
|
|
|
|
logger = log.NewLogfmtLogger(log.NewSyncWriter(os.Stderr))
|
|
|
|
logger = log.NewLogfmtLogger(log.NewSyncWriter(os.Stderr))
|
|
|
|
expBlocks []*Block
|
|
|
|
expBlocks []*Block
|
|
|
|
|
|
|
|
expBlock *Block
|
|
|
|
expSeries map[string][]tsdbutil.Sample
|
|
|
|
expSeries map[string][]tsdbutil.Sample
|
|
|
|
expChunks map[string][][]tsdbutil.Sample
|
|
|
|
expChunks map[string][][]tsdbutil.Sample
|
|
|
|
expDBHash []byte
|
|
|
|
expDBHash []byte
|
|
|
@ -2427,6 +2428,7 @@ func TestDBReadOnly(t *testing.T) {
|
|
|
|
require.NoError(t, app.Commit())
|
|
|
|
require.NoError(t, app.Commit())
|
|
|
|
|
|
|
|
|
|
|
|
expBlocks = dbWritable.Blocks()
|
|
|
|
expBlocks = dbWritable.Blocks()
|
|
|
|
|
|
|
|
expBlock = expBlocks[0]
|
|
|
|
expDbSize, err := fileutil.DirSize(dbWritable.Dir())
|
|
|
|
expDbSize, err := fileutil.DirSize(dbWritable.Dir())
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Greater(t, expDbSize, dbSizeBeforeAppend, "db size didn't increase after an append")
|
|
|
|
require.Greater(t, expDbSize, dbSizeBeforeAppend, "db size didn't increase after an append")
|
|
|
@ -2455,7 +2457,22 @@ func TestDBReadOnly(t *testing.T) {
|
|
|
|
require.Equal(t, expBlock.Meta(), blocks[i].Meta(), "block meta mismatch")
|
|
|
|
require.Equal(t, expBlock.Meta(), blocks[i].Meta(), "block meta mismatch")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("block", func(t *testing.T) {
|
|
|
|
|
|
|
|
blockID := expBlock.meta.ULID.String()
|
|
|
|
|
|
|
|
block, err := dbReadOnly.Block(blockID)
|
|
|
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
require.Equal(t, expBlock.Meta(), block.Meta(), "block meta mismatch")
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("invalid block ID", func(t *testing.T) {
|
|
|
|
|
|
|
|
blockID := "01GTDVZZF52NSWB5SXQF0P2PGF"
|
|
|
|
|
|
|
|
_, err := dbReadOnly.Block(blockID)
|
|
|
|
|
|
|
|
require.Error(t, err)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("last block ID", func(t *testing.T) {
|
|
|
|
|
|
|
|
blockID, err := dbReadOnly.LastBlockID()
|
|
|
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
require.Equal(t, expBlocks[2].Meta().ULID.String(), blockID)
|
|
|
|
|
|
|
|
})
|
|
|
|
t.Run("querier", func(t *testing.T) {
|
|
|
|
t.Run("querier", func(t *testing.T) {
|
|
|
|
// Open a read only db and ensure that the API returns the same result as the normal DB.
|
|
|
|
// Open a read only db and ensure that the API returns the same result as the normal DB.
|
|
|
|
q, err := dbReadOnly.Querier(context.TODO(), math.MinInt64, math.MaxInt64)
|
|
|
|
q, err := dbReadOnly.Querier(context.TODO(), math.MinInt64, math.MaxInt64)
|
|
|
|