forked from grafana/loki
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Cassandra table options flag (grafana#2575)
* add the cassandra.table-with flag Signed-off-by: Kyeongwon Seo <[email protected]> * update CHANGELOG and docs Signed-off-by: Kyeongwon Seo <[email protected]> * add PR number to CHANGELOG Signed-off-by: Kyeongwon Seo <[email protected]> * remove blacklisted package import Signed-off-by: Kyeongwon Seo <[email protected]> * fix import with goimports Signed-off-by: Kyeongwon Seo <[email protected]> * rename table_with to table_options and improve the flag usage Signed-off-by: Kyeongwon Seo <[email protected]> * add a description about configuring table options to documentation: Running Cortex with Cassandra Signed-off-by: Kyeongwon Seo <[email protected]> * clean white noise Signed-off-by: Kyeongwon Seo <[email protected]>
- Loading branch information
Showing
3 changed files
with
66 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package cassandra | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestTableClient_getCreateTableQuery_default(t *testing.T) { | ||
client := &tableClient{ | ||
cfg: Config{}, | ||
} | ||
desc, _, _ := client.DescribeTable(context.Background(), "test_table") | ||
query := client.getCreateTableQuery(&desc) | ||
assert.Equal( | ||
t, | ||
` | ||
CREATE TABLE IF NOT EXISTS test_table ( | ||
hash text, | ||
range blob, | ||
value blob, | ||
PRIMARY KEY (hash, range) | ||
)`, | ||
query, | ||
) | ||
} | ||
|
||
func TestTableClient_getCreateTableQuery_withOptions(t *testing.T) { | ||
client := &tableClient{ | ||
cfg: Config{ | ||
TableOptions: "CLUSTERING ORDER BY (range DESC) AND compaction = { 'class' : 'LeveledCompactionStrategy' }", | ||
}, | ||
} | ||
desc, _, _ := client.DescribeTable(context.Background(), "test_table") | ||
query := client.getCreateTableQuery(&desc) | ||
assert.Equal( | ||
t, | ||
` | ||
CREATE TABLE IF NOT EXISTS test_table ( | ||
hash text, | ||
range blob, | ||
value blob, | ||
PRIMARY KEY (hash, range) | ||
) WITH CLUSTERING ORDER BY (range DESC) AND compaction = { 'class' : 'LeveledCompactionStrategy' }`, | ||
query, | ||
) | ||
} |