From 2d5a0c19c0a71e5c01b727b803c5f5d20d1beb7e Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Wed, 17 Oct 2018 13:10:26 +0000 Subject: [PATCH] Extend table manager test with multi-section schema config Signed-off-by: Bryan Boreham --- table_manager_test.go | 80 +++++++++++++++++++++++++++++++++---------- 1 file changed, 61 insertions(+), 19 deletions(-) diff --git a/table_manager_test.go b/table_manager_test.go index 894ac0acb1284..d8d2691f78772 100644 --- a/table_manager_test.go +++ b/table_manager_test.go @@ -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 { @@ -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{ @@ -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}, @@ -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) {