Skip to content

Commit 9ce6b57

Browse files
committed
add test
1 parent 0073413 commit 9ce6b57

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import org.awaitility.Awaitility
2+
3+
import static java.util.concurrent.TimeUnit.SECONDS
4+
5+
suite("test_index_change_after_mv") {
6+
def tableName = "test_index_change_after_mv"
7+
sql """ DROP TABLE IF EXISTS ${test_index_change_after_mv} """
8+
sql """
9+
CREATE TABLE IF NOT EXISTS ${tableName} (
10+
name varchar(50),
11+
age int NOT NULL,
12+
grade int NOT NULL,
13+
studentInfo char(100),
14+
tearchComment string,
15+
INDEX age_idx_1(age) USING INVERTED COMMENT 'age index'
16+
)
17+
DUPLICATE KEY(`name`)
18+
DISTRIBUTED BY HASH(`name`) BUCKETS 10
19+
properties("replication_num" = "1");
20+
"""
21+
22+
def mvName = "${test_index_change_after_mv}_1"
23+
24+
sql """ INSERT INTO ${tableName} VALUES("steve", 0, 2, "xxx", "xxx") """
25+
26+
sql """
27+
CREATE MATERIALIZED VIEW ${test_index_change_after_mv} AS SELECT name, age, grade FROM ${tableName} WHERE name = "steve" AND age = 0
28+
"""
29+
30+
def getJobState = { tblName ->
31+
def jobStateResult = sql """ SHOW ALTER TABLE MATERIALIZED VIEW WHERE TableName='${tblName}' ORDER BY CreateTime DESC LIMIT 1; """
32+
return jobStateResult[0][8]
33+
}
34+
35+
def max_try_secs = 60
36+
Awaitility.await().atMost(max_try_secs, SECONDS).pollInterval(2, SECONDS).until{
37+
String res = getJobState(tableName)
38+
if (res == "FINISHED" || res == "CANCELLED") {
39+
assertEquals("FINISHED", res)
40+
sleep(3000)
41+
return true
42+
}
43+
return false
44+
}
45+
46+
sql """
47+
CREATE INDEX ${tableName}_idx ON ${tableName}(age) USING INVERTED COMMENT 'inverted index age_idx_1'
48+
"""
49+
50+
waitForSchemaChangeDone({
51+
sql " SHOW ALTER TABLE COLUMN WHERE TableName='${tableName}' ORDER BY createtime DESC LIMIT 1 "
52+
})
53+
54+
qt_sql """
55+
SHOW CREATE materialized MATERIALIZED VIEW ${test_index_change_after_mv} on ${tableName};
56+
"""
57+
}

0 commit comments

Comments
 (0)