Skip to content

Commit

Permalink
[Enhancement]use awaitility.await() replace thread.sleep(), neredis p…
Browse files Browse the repository at this point in the history
…art (#38816)

## Proposed changes

Issue Number: close #xxx
#37817
replace thread.sleep with awaitility util in some of neredis_syntax test
cases.
  • Loading branch information
Vallishp authored and dataroaring committed Aug 11, 2024
1 parent 780c9ff commit 558951a
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 75 deletions.
40 changes: 17 additions & 23 deletions regression-test/suites/nereids_syntax_p0/rollup/agg.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
import java.util.concurrent.TimeUnit
import org.awaitility.Awaitility

suite("agg") {

sql """set enable_nereids_planner=true"""
Expand Down Expand Up @@ -43,37 +46,28 @@ suite("agg") {
"""
sql """ALTER TABLE ${tbName} ADD ROLLUP rollup_city(citycode, pv);"""
int max_try_secs = 60
while (max_try_secs--) {
String res = getJobRollupState(tbName)
String res = "NOT_FINISHED"
Awaitility.await().atMost(max_try_secs, TimeUnit.SECONDS).with().pollDelay(100, TimeUnit.MILLISECONDS).await().until(() -> {
res = getJobRollupState(tbName)
if (res == "FINISHED" || res == "CANCELLED") {
assertEquals("FINISHED", res)
sleep(3000)
break
} else {
Thread.sleep(2000)
if (max_try_secs < 1) {
println "test timeout," + "state:" + res
assertEquals("FINISHED",res)
}
return true;
}
}
Thread.sleep(2000)
return false;
});
assertEquals("FINISHED",res)

sql "ALTER TABLE ${tbName} ADD COLUMN vv BIGINT SUM NULL DEFAULT '0' TO rollup_city;"
max_try_secs = 60
while (max_try_secs--) {
String res = getJobColumnState(tbName)
Awaitility.await().atMost(max_try_secs, TimeUnit.SECONDS).with().pollDelay(100, TimeUnit.MILLISECONDS).await().until(() -> {
res = getJobColumnState(tbName)
if (res == "FINISHED" || res == "CANCELLED") {
assertEquals("FINISHED", res)
sleep(3000)
break
} else {
Thread.sleep(2000)
if (max_try_secs < 1) {
println "test timeout," + "state:" + res
assertEquals("FINISHED",res)
}
return true;
}
}
return false;
});
assertEquals("FINISHED",res)
sql "SHOW ALTER TABLE ROLLUP WHERE TableName='${tbName}';"
qt_sql "DESC ${tbName} ALL;"
sql "insert into ${tbName} values(1, 1, 'test1', 100,100,100);"
Expand Down
84 changes: 32 additions & 52 deletions regression-test/suites/nereids_syntax_p0/rollup/date.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
import java.util.concurrent.TimeUnit
import org.awaitility.Awaitility

suite("date", "rollup") {

sql """set enable_nereids_planner=true"""
Expand Down Expand Up @@ -43,72 +46,49 @@ suite("date", "rollup") {

int max_try_secs = 120
sql "CREATE materialized VIEW amt_max1 AS SELECT store_id, max(sale_date1) FROM ${tbName1} GROUP BY store_id;"
while (max_try_secs--) {
String res = getJobState(tbName1)
String res = "NOT_FINISHED"
Awaitility.await().atMost(max_try_secs, TimeUnit.SECONDS).with().pollDelay(100, TimeUnit.MILLISECONDS).await().until(() -> {
res = getJobState(tbName1)
if (res == "FINISHED" || res == "CANCELLED") {
assertEquals("FINISHED", res)
sleep(3000)
break
} else {
Thread.sleep(2000)
if (max_try_secs < 1) {
println "test timeout," + "state:" + res
assertEquals("FINISHED",res)
}
return true;
}
}
Thread.sleep(2000)
max_try_secs = 120
return false;
});
assertEquals("FINISHED",res)

sql "CREATE materialized VIEW amt_max2 AS SELECT store_id, max(sale_datetime1) FROM ${tbName1} GROUP BY store_id;"
while (max_try_secs--) {
String res = getJobState(tbName1)
Awaitility.await().atMost(max_try_secs, TimeUnit.SECONDS).with().pollDelay(100, TimeUnit.MILLISECONDS).await().until(() -> {
res = getJobState(tbName1)
if (res == "FINISHED" || res == "CANCELLED") {
assertEquals("FINISHED", res)
sleep(3000)
break
} else {
Thread.sleep(2000)
if (max_try_secs < 1) {
println "test timeout," + "state:" + res
assertEquals("FINISHED",res)
}
}
}
Thread.sleep(2000)
max_try_secs = 120
return true;
}
return false;
});
assertEquals("FINISHED",res)

sql "CREATE materialized VIEW amt_max3 AS SELECT store_id, max(sale_datetime2) FROM ${tbName1} GROUP BY store_id;"
while (max_try_secs--) {
String res = getJobState(tbName1)
Awaitility.await().atMost(max_try_secs, TimeUnit.SECONDS).with().pollDelay(100, TimeUnit.MILLISECONDS).await().until(() -> {
res = getJobState(tbName1)
if (res == "FINISHED" || res == "CANCELLED") {
assertEquals("FINISHED", res)
sleep(3000)
break
} else {
Thread.sleep(2000)
if (max_try_secs < 1) {
println "test timeout," + "state:" + res
assertEquals("FINISHED",res)
}
return true;
}
}
Thread.sleep(2000)
max_try_secs = 120
return false;
});
assertEquals("FINISHED",res)

sql "CREATE materialized VIEW amt_max4 AS SELECT store_id, max(sale_datetime3) FROM ${tbName1} GROUP BY store_id;"
while (max_try_secs--) {
String res = getJobState(tbName1)
Awaitility.await().atMost(max_try_secs, TimeUnit.SECONDS).with().pollDelay(100, TimeUnit.MILLISECONDS).await().until(() -> {
res = getJobState(tbName1)
if (res == "FINISHED" || res == "CANCELLED") {
assertEquals("FINISHED", res)
sleep(3000)
break
} else {
Thread.sleep(2000)
if (max_try_secs < 1) {
println "test timeout," + "state:" + res
assertEquals("FINISHED",res)
}
return true;
}
}

return false;
});
assertEquals("FINISHED",res)

sql "SHOW ALTER TABLE MATERIALIZED VIEW WHERE TableName='${tbName1}';"
sql "insert into ${tbName1} values(1, 1, 1, '2020-05-30', '2020-05-30', '2020-05-30 11:11:11.111111', '2020-05-30 11:11:11.111111', '2020-05-30 11:11:11.111111',100);"
Expand Down

0 comments on commit 558951a

Please sign in to comment.