Skip to content

Commit

Permalink
[Enhancement]use awaitility in partial update testcases (#38900)
Browse files Browse the repository at this point in the history
## Proposed changes

Issue Number: close #xxx
#37817

use awaitility to replace thread.sleep in partial update regression
testcases
  • Loading branch information
Vallishp authored Aug 6, 2024
1 parent c12d0d4 commit a7e586f
Show file tree
Hide file tree
Showing 4 changed files with 203 additions and 270 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
// 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("test_partial_update_insert_light_schema_change", "p0") {

Expand Down Expand Up @@ -56,16 +58,15 @@ suite("test_partial_update_insert_light_schema_change", "p0") {

// schema change
sql " ALTER table ${tableName} add column c10 INT DEFAULT '0' "
def try_times=100
while(true){
def try_times=12000
// if timeout awaitility will raise exception
Awaitility.await().atMost(try_times, TimeUnit.SECONDS).with().pollDelay(100, TimeUnit.MILLISECONDS).await().until(() -> {
def res = sql " SHOW ALTER TABLE COLUMN WHERE TableName = '${tableName}' ORDER BY CreateTime DESC LIMIT 1 "
Thread.sleep(1200)
if(res[0][9].toString() == "FINISHED"){
break;
return true;
}
assert(try_times>0)
try_times--
}
return false;
});
sql "sync"

// test insert data without new column
Expand Down Expand Up @@ -116,16 +117,14 @@ suite("test_partial_update_insert_light_schema_change", "p0") {

// schema change
sql " ALTER table ${tableName} DROP COLUMN c8 "
try_times=100
while(true){
// if timeout awaitility will raise exception
Awaitility.await().atMost(try_times, TimeUnit.SECONDS).with().pollDelay(100, TimeUnit.MILLISECONDS).await().until(() -> {
def res = sql " SHOW ALTER TABLE COLUMN WHERE TableName = '${tableName}' ORDER BY CreateTime DESC LIMIT 1 "
Thread.sleep(1200)
if(res[0][9].toString() == "FINISHED"){
break;
return true;
}
assert(try_times>0)
try_times--
}
return false;
});
sql "sync"

// test insert data without delete column
Expand Down Expand Up @@ -194,16 +193,14 @@ suite("test_partial_update_insert_light_schema_change", "p0") {

// schema change
sql " ALTER table ${tableName} MODIFY COLUMN c2 double "
try_times=100
while(true){
// if timeout awaitility will raise exception
Awaitility.await().atMost(try_times, TimeUnit.SECONDS).with().pollDelay(100, TimeUnit.MILLISECONDS).await().until(() -> {
def res = sql " SHOW ALTER TABLE COLUMN WHERE TableName = '${tableName}' ORDER BY CreateTime DESC LIMIT 1 "
Thread.sleep(1200)
if(res[0][9].toString() == "FINISHED"){
break;
return true;
}
assert(try_times>0)
try_times--
}
return false;
});
sql "sync"

// test insert data with update column
Expand Down Expand Up @@ -234,42 +231,36 @@ suite("test_partial_update_insert_light_schema_change", "p0") {

// schema change
sql """ ALTER table ${tableName} ADD COLUMN c1 int key default "0"; """
try_times=100
while(true){
// if timeout awaitility will raise exception
Awaitility.await().atMost(try_times, TimeUnit.SECONDS).with().pollDelay(100, TimeUnit.MILLISECONDS).await().until(() -> {
def res = sql " SHOW ALTER TABLE COLUMN WHERE TableName = '${tableName}' ORDER BY CreateTime DESC LIMIT 1 "
Thread.sleep(1200)
if(res[0][9].toString() == "FINISHED"){
break;
return true;
}
assert(try_times>0)
try_times--
}
return false;
});
sql "sync"

sql " ALTER table ${tableName} ADD COLUMN c2 int null "
try_times=100
while(true){
// if timeout awaitility will raise exception
Awaitility.await().atMost(try_times, TimeUnit.SECONDS).with().pollDelay(100, TimeUnit.MILLISECONDS).await().until(() -> {
def res = sql " SHOW ALTER TABLE COLUMN WHERE TableName = '${tableName}' ORDER BY CreateTime DESC LIMIT 1 "
Thread.sleep(1200)
if(res[0][9].toString() == "FINISHED"){
break;
return true;
}
assert(try_times>0)
try_times--
}
return false;
});
sql "sync"

sql " ALTER table ${tableName} ADD COLUMN c3 int null "
try_times=100
while(true){
// if timeout awaitility will raise exception
Awaitility.await().atMost(try_times, TimeUnit.SECONDS).with().pollDelay(100, TimeUnit.MILLISECONDS).await().until(() -> {
def res = sql " SHOW ALTER TABLE COLUMN WHERE TableName = '${tableName}' ORDER BY CreateTime DESC LIMIT 1 "
Thread.sleep(1200)
if(res[0][9].toString() == "FINISHED"){
break;
return true;
}
assert(try_times>0)
try_times--
}
return false;
});
sql "sync"

// test insert data with all key column, should fail because
Expand Down Expand Up @@ -315,16 +306,14 @@ suite("test_partial_update_insert_light_schema_change", "p0") {


sql " CREATE INDEX test ON ${tableName} (c1) USING BITMAP "
try_times=100
while(true){
// if timeout awaitility will raise exception
Awaitility.await().atMost(try_times, TimeUnit.SECONDS).with().pollDelay(100, TimeUnit.MILLISECONDS).await().until(() -> {
def res = sql " SHOW ALTER TABLE COLUMN WHERE TableName = '${tableName}' ORDER BY CreateTime DESC LIMIT 1 "
Thread.sleep(1200)
if(res[0][9].toString() == "FINISHED"){
break;
return true;
}
assert(try_times>0)
try_times--
}
return false;
});
sql "sync"

//test insert data with create index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
// 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("test_partial_update_insert_schema_change", "p0") {

Expand Down Expand Up @@ -47,16 +49,15 @@ suite("test_partial_update_insert_schema_change", "p0") {

// schema change
sql " ALTER table ${tableName} add column c10 INT DEFAULT '0' "
def try_times=100
while(true){
def try_times=12000
// if timeout awaitility will raise exception
Awaitility.await().atMost(try_times, TimeUnit.SECONDS).with().pollDelay(100, TimeUnit.MILLISECONDS).await().until(() -> {
def res = sql " SHOW ALTER TABLE COLUMN WHERE TableName = '${tableName}' ORDER BY CreateTime DESC LIMIT 1 "
Thread.sleep(1200)
if(res[0][9].toString() == "FINISHED"){
break;
return true;
}
assert(try_times>0)
try_times--
}
return false;
});
sql "sync"

// test insert data without new column
Expand Down Expand Up @@ -106,16 +107,14 @@ suite("test_partial_update_insert_schema_change", "p0") {

// schema change
sql " ALTER table ${tableName} DROP COLUMN c8 "
try_times=100
while(true){
// if timeout awaitility will raise exception
Awaitility.await().atMost(try_times, TimeUnit.SECONDS).with().pollDelay(100, TimeUnit.MILLISECONDS).await().until(() -> {
def res = sql " SHOW ALTER TABLE COLUMN WHERE TableName = '${tableName}' ORDER BY CreateTime DESC LIMIT 1 "
Thread.sleep(1200)
if(res[0][9].toString() == "FINISHED"){
break;
return true;
}
assert(try_times>0)
try_times--
}
return false;
});
sql "sync"

// test insert data without delete column
Expand Down Expand Up @@ -181,16 +180,14 @@ suite("test_partial_update_insert_schema_change", "p0") {

// schema change
sql " ALTER table ${tableName} MODIFY COLUMN c2 double "
try_times=100
while(true){
// if timeout awaitility will raise exception
Awaitility.await().atMost(try_times, TimeUnit.SECONDS).with().pollDelay(100, TimeUnit.MILLISECONDS).await().until(() -> {
def res = sql " SHOW ALTER TABLE COLUMN WHERE TableName = '${tableName}' ORDER BY CreateTime DESC LIMIT 1 "
Thread.sleep(1200)
if(res[0][9].toString() == "FINISHED"){
break;
return true;
}
assert(try_times>0)
try_times--
}
return false;
});
sql "sync"

// test insert data with update column
Expand Down Expand Up @@ -219,42 +216,36 @@ suite("test_partial_update_insert_schema_change", "p0") {

// schema change
sql """ ALTER table ${tableName} ADD COLUMN c1 int key default "0"; """
try_times=100
while(true){
// if timeout awaitility will raise exception
Awaitility.await().atMost(try_times, TimeUnit.SECONDS).with().pollDelay(100, TimeUnit.MILLISECONDS).await().until(() -> {
def res = sql " SHOW ALTER TABLE COLUMN WHERE TableName = '${tableName}' ORDER BY CreateTime DESC LIMIT 1 "
Thread.sleep(1200)
if(res[0][9].toString() == "FINISHED"){
break;
return true;
}
assert(try_times>0)
try_times--
}
return false;
});
sql "sync"

sql " ALTER table ${tableName} ADD COLUMN c2 int null "
try_times=100
while(true){
// if timeout awaitility will raise exception
Awaitility.await().atMost(try_times, TimeUnit.SECONDS).with().pollDelay(100, TimeUnit.MILLISECONDS).await().until(() -> {
def res = sql " SHOW ALTER TABLE COLUMN WHERE TableName = '${tableName}' ORDER BY CreateTime DESC LIMIT 1 "
Thread.sleep(1200)
if(res[0][9].toString() == "FINISHED"){
break;
return true;
}
assert(try_times>0)
try_times--
}
return false;
});
sql "sync"

sql " ALTER table ${tableName} ADD COLUMN c3 int null "
try_times=100
while(true){
// if timeout awaitility will raise exception
Awaitility.await().atMost(try_times, TimeUnit.SECONDS).with().pollDelay(100, TimeUnit.MILLISECONDS).await().until(() -> {
def res = sql " SHOW ALTER TABLE COLUMN WHERE TableName = '${tableName}' ORDER BY CreateTime DESC LIMIT 1 "
Thread.sleep(1200)
if(res[0][9].toString() == "FINISHED"){
break;
return true;
}
assert(try_times>0)
try_times--
}
return false;
});
sql "sync"

// test insert data with all key column, should fail because
Expand Down Expand Up @@ -300,16 +291,14 @@ suite("test_partial_update_insert_schema_change", "p0") {


sql " CREATE INDEX test ON ${tableName} (c1) USING BITMAP "
try_times=100
while(true){
// if timeout awaitility will raise exception
Awaitility.await().atMost(try_times, TimeUnit.SECONDS).with().pollDelay(100, TimeUnit.MILLISECONDS).await().until(() -> {
def res = sql " SHOW ALTER TABLE COLUMN WHERE TableName = '${tableName}' ORDER BY CreateTime DESC LIMIT 1 "
Thread.sleep(1200)
if(res[0][9].toString() == "FINISHED"){
break;
return true;
}
assert(try_times>0)
try_times--
}
return false;
});
sql "sync"

//test insert data with create index
Expand Down
Loading

0 comments on commit a7e586f

Please sign in to comment.