Skip to content

Commit

Permalink
Extend table manager test with multi-section schema config
Browse files Browse the repository at this point in the history
Signed-off-by: Bryan Boreham <bryan@weave.works>
  • Loading branch information
bboreham committed Oct 19, 2018
1 parent ae5dca7 commit 2d5a0c1
Showing 1 changed file with 61 additions and 19 deletions.
80 changes: 61 additions & 19 deletions table_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,30 @@ import (
)

const (
baseTableName = "cortex_base"
tablePrefix = "cortex_"
chunkTablePrefix = "chunks_"
tablePeriod = 7 * 24 * time.Hour
gracePeriod = 15 * time.Minute
maxChunkAge = 12 * time.Hour
inactiveWrite = 1
inactiveRead = 2
write = 200
read = 100
autoScaleLastN = 2
autoScaleMin = 50
autoScaleMax = 500
autoScaleTarget = 80
baseTableName = "cortex_base"
tablePrefix = "cortex_"
table2Prefix = "cortex2_"
chunkTablePrefix = "chunks_"
chunkTable2Prefix = "chunks2_"
tablePeriod = 7 * 24 * time.Hour
gracePeriod = 15 * time.Minute
maxChunkAge = 12 * time.Hour
inactiveWrite = 1
inactiveRead = 2
write = 200
read = 100
autoScaleLastN = 2
autoScaleMin = 50
autoScaleMax = 500
autoScaleTarget = 80
)

var (
baseTableStart = time.Unix(0, 0)
weeklyTableStart = baseTableStart.Add(tablePeriod * 3)
week1Suffix = "3"
week2Suffix = "4"
baseTableStart = time.Unix(0, 0)
weeklyTableStart = baseTableStart.Add(tablePeriod * 3)
weeklyTable2Start = baseTableStart.Add(tablePeriod * 5)
week1Suffix = "3"
week2Suffix = "4"
)

type mockTableClient struct {
Expand Down Expand Up @@ -147,6 +150,29 @@ func TestTableManager(t *testing.T) {
InactiveReadThroughput: inactiveRead,
},
},
{
From: model.TimeFromUnix(weeklyTable2Start.Unix()),
IndexTables: PeriodicTableConfig{
Prefix: table2Prefix,
Period: tablePeriod,
ProvisionedWriteThroughput: write,
ProvisionedReadThroughput: read,
InactiveWriteThroughput: inactiveWrite,
InactiveReadThroughput: inactiveRead,
WriteScale: activeScalingConfig,
InactiveWriteScale: inactiveScalingConfig,
InactiveWriteScaleLastN: autoScaleLastN,
},

ChunkTables: PeriodicTableConfig{
Prefix: chunkTable2Prefix,
Period: tablePeriod,
ProvisionedWriteThroughput: write,
ProvisionedReadThroughput: read,
InactiveWriteThroughput: inactiveWrite,
InactiveReadThroughput: inactiveRead,
},
},
},
}
tbmConfig := TableManagerConfig{
Expand Down Expand Up @@ -214,7 +240,7 @@ func TestTableManager(t *testing.T) {
// Fast forward table period - grace period, check we add another weekly table
tmTest(t, client, tableManager,
"Move forward by table period - grace period",
weeklyTableStart.Add(tablePeriod).Add(-gracePeriod),
weeklyTableStart.Add(tablePeriod).Add(-gracePeriod+time.Second),
[]TableDesc{
{Name: baseTableName, ProvisionedRead: inactiveRead, ProvisionedWrite: inactiveWrite},
{Name: tablePrefix + week1Suffix, ProvisionedRead: read, ProvisionedWrite: write, WriteScale: activeScalingConfig},
Expand Down Expand Up @@ -262,6 +288,22 @@ func TestTableManager(t *testing.T) {
{Name: chunkTablePrefix + week2Suffix, ProvisionedRead: read, ProvisionedWrite: write},
},
)

// Move to the next section of the config
tmTest(t, client, tableManager,
"Move forward to next section of schema config",
weeklyTable2Start,
[]TableDesc{
{Name: baseTableName, ProvisionedRead: inactiveRead, ProvisionedWrite: inactiveWrite},
{Name: tablePrefix + week1Suffix, ProvisionedRead: inactiveRead, ProvisionedWrite: inactiveWrite, WriteScale: inactiveScalingConfig},
{Name: tablePrefix + week2Suffix, ProvisionedRead: read, ProvisionedWrite: write, WriteScale: activeScalingConfig},
{Name: table2Prefix + "5", ProvisionedRead: read, ProvisionedWrite: write, WriteScale: activeScalingConfig},
{Name: chunkTablePrefix + week1Suffix, ProvisionedRead: inactiveRead, ProvisionedWrite: inactiveWrite},
{Name: chunkTablePrefix + week2Suffix, ProvisionedRead: read, ProvisionedWrite: write},
{Name: chunkTable2Prefix + "5", ProvisionedRead: read, ProvisionedWrite: write},
},
)

}

func TestTableManagerAutoscaleInactiveOnly(t *testing.T) {
Expand Down

0 comments on commit 2d5a0c1

Please sign in to comment.