Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[regression-test](fix) Fix the incorrect invocation of Awaitility.await.untilAsserted #45605

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions regression-test/plugins/plugin_compaction.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import org.codehaus.groovy.runtime.IOGroovyMethods
import org.awaitility.Awaitility

Suite.metaClass.checkComactionStatus = { String backendIP, String backendPort, String tabletID ->
def (code, out, err) = be_get_compaction_status(backendIP, backendPort, tabletID)
logger.info("Get compaction status: code=" + code + ", out=" + out + ", err=" + err)
if (code != 0) {
return false
}

def compactionStatus = parseJson(out.trim())
if ("success" == compactionStatus.status.toLowerCase()) {
return compactionStatus.run_status
} else {
return false
}
}

Suite.metaClass.assertCompactionStatus = { String backendIP, String backendPort, String tabletID ->
Awaitility.await().untilAsserted({
assert checkComactionStatus(backendIP, backendPort, tabletID)
})
}

Suite.metaClass.assertCompactionStatusAtMost = { String backendIP, String backendPort, String tabletID, long t, TimeUnit tu ->
Awaitility.await().atMost(t, tu).untilAsserted({
assert checkComactionStatus(backendIP, backendPort, tabletID)
})
}
33 changes: 3 additions & 30 deletions regression-test/suites/compaction/test_base_compaction.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -148,16 +148,7 @@ suite("test_base_compaction", "p2") {

// wait for all compactions done
for (def tablet in tablets) {
Awaitility.await().untilAsserted(() -> {
String tablet_id = tablet.TabletId
backend_id = tablet.BackendId
(code, out, err) = be_get_compaction_status(backendId_to_backendIP.get(backend_id), backendId_to_backendHttpPort.get(backend_id), tablet_id)
logger.info("Get compaction status: code=" + code + ", out=" + out + ", err=" + err)
assertEquals(code, 0)
def compactionStatus = parseJson(out.trim())
assertEquals("success", compactionStatus.status.toLowerCase())
return compactionStatus.run_status;
});
assertCompactionStatus(backendId_to_backendIP.get(tablet.BackendId), backendId_to_backendHttpPort.get(tablet.BackendId), tablet.TabletId)
}

streamLoad {
Expand Down Expand Up @@ -208,16 +199,7 @@ suite("test_base_compaction", "p2") {

// wait for all compactions done
for (def tablet in tablets) {
Awaitility.await().untilAsserted(() -> {
String tablet_id = tablet.TabletId
backend_id = tablet.BackendId
(code, out, err) = be_get_compaction_status(backendId_to_backendIP.get(backend_id), backendId_to_backendHttpPort.get(backend_id), tablet_id)
logger.info("Get compaction status: code=" + code + ", out=" + out + ", err=" + err)
assertEquals(code, 0)
def compactionStatus = parseJson(out.trim())
assertEquals("success", compactionStatus.status.toLowerCase())
return compactionStatus.run_status;
});
assertCompactionStatus(backendId_to_backendIP.get(tablet.BackendId), backendId_to_backendHttpPort.get(tablet.BackendId), tablet.TabletId)
}

qt_select_default """ SELECT count(*) FROM ${tableName} """
Expand All @@ -237,16 +219,7 @@ suite("test_base_compaction", "p2") {

// wait for all compactions done
for (def tablet in tablets) {
Awaitility.await().untilAsserted(() -> {
String tablet_id = tablet.TabletId
backend_id = tablet.BackendId
(code, out, err) = be_get_compaction_status(backendId_to_backendIP.get(backend_id), backendId_to_backendHttpPort.get(backend_id), tablet_id)
logger.info("Get compaction status: code=" + code + ", out=" + out + ", err=" + err)
assertEquals(code, 0)
def compactionStatus = parseJson(out.trim())
assertEquals("success", compactionStatus.status.toLowerCase())
return compactionStatus.run_status;
});
assertCompactionStatus(backendId_to_backendIP.get(tablet.BackendId), backendId_to_backendHttpPort.get(tablet.BackendId), tablet.TabletId)
}

def replicaNum = get_table_replica_num(tableName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
// under the License.

import org.codehaus.groovy.runtime.IOGroovyMethods
import org.awaitility.Awaitility

suite("test_base_compaction_no_value", "p2") {
def tableName = "base_compaction_uniq_keys_no_value"
Expand Down Expand Up @@ -148,16 +147,7 @@ suite("test_base_compaction_no_value", "p2") {

// wait for all compactions done
for (def tablet in tablets) {
Awaitility.await().untilAsserted(() -> {
String tablet_id = tablet.TabletId
backend_id = tablet.BackendId
(code, out, err) = be_get_compaction_status(backendId_to_backendIP.get(backend_id), backendId_to_backendHttpPort.get(backend_id), tablet_id)
logger.info("Get compaction status: code=" + code + ", out=" + out + ", err=" + err)
assertEquals(code, 0)
def compactionStatus = parseJson(out.trim())
assertEquals("success", compactionStatus.status.toLowerCase())
return compactionStatus.run_status;
});
assertCompactionStatus(backendId_to_backendIP.get(tablet.BackendId), backendId_to_backendHttpPort.get(tablet.BackendId), tablet.TabletId)
}

streamLoad {
Expand Down Expand Up @@ -208,16 +198,7 @@ suite("test_base_compaction_no_value", "p2") {

// wait for all compactions done
for (def tablet in tablets) {
Awaitility.await().untilAsserted(() -> {
String tablet_id = tablet.TabletId
backend_id = tablet.BackendId
(code, out, err) = be_get_compaction_status(backendId_to_backendIP.get(backend_id), backendId_to_backendHttpPort.get(backend_id), tablet_id)
logger.info("Get compaction status: code=" + code + ", out=" + out + ", err=" + err)
assertEquals(code, 0)
def compactionStatus = parseJson(out.trim())
assertEquals("success", compactionStatus.status.toLowerCase())
return compactionStatus.run_status;
});
assertCompactionStatus(backendId_to_backendIP.get(tablet.BackendId), backendId_to_backendHttpPort.get(tablet.BackendId), tablet.TabletId)
}

qt_select_default """ SELECT count(*) FROM ${tableName} """
Expand All @@ -237,16 +218,7 @@ suite("test_base_compaction_no_value", "p2") {

// wait for all compactions done
for (def tablet in tablets) {
Awaitility.await().untilAsserted(() -> {
String tablet_id = tablet.TabletId
backend_id = tablet.BackendId
(code, out, err) = be_get_compaction_status(backendId_to_backendIP.get(backend_id), backendId_to_backendHttpPort.get(backend_id), tablet_id)
logger.info("Get compaction status: code=" + code + ", out=" + out + ", err=" + err)
assertEquals(code, 0)
def compactionStatus = parseJson(out.trim())
assertEquals("success", compactionStatus.status.toLowerCase())
return compactionStatus.run_status;
});
assertCompactionStatus(backendId_to_backendIP.get(tablet.BackendId), backendId_to_backendHttpPort.get(tablet.BackendId), tablet.TabletId)
}

def replicaNum = get_table_replica_num(tableName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,7 @@ suite("test_compaction_agg_keys") {

// wait for all compactions done
for (def tablet in tablets) {
Awaitility.await().untilAsserted(() -> {
String tablet_id = tablet.TabletId
backend_id = tablet.BackendId
(code, out, err) = be_get_compaction_status(backendId_to_backendIP.get(backend_id), backendId_to_backendHttpPort.get(backend_id), tablet_id)
logger.info("Get compaction status: code=" + code + ", out=" + out + ", err=" + err)
assertEquals(code, 0)

def compactionStatus = parseJson(out.trim())
assertEquals("success", compactionStatus.status.toLowerCase())
return compactionStatus.run_status;

});
assertCompactionStatus(backendId_to_backendIP.get(tablet.BackendId), backendId_to_backendHttpPort.get(tablet.BackendId), tablet.TabletId)
}

def replicaNum = get_table_replica_num(tableName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,7 @@ suite("test_compaction_uniq_keys") {

// wait for all compactions done
for (def tablet in tablets) {
Awaitility.await().untilAsserted(() -> {
String tablet_id = tablet.TabletId
backend_id = tablet.BackendId
(code, out, err) = be_get_compaction_status(backendId_to_backendIP.get(backend_id), backendId_to_backendHttpPort.get(backend_id), tablet_id)
logger.info("Get compaction status: code=" + code + ", out=" + out + ", err=" + err)
assertEquals(code, 0)
def compactionStatus = parseJson(out.trim())
assertEquals("success", compactionStatus.status.toLowerCase())
return compactionStatus.run_status;
});
assertCompactionStatus(backendId_to_backendIP.get(tablet.BackendId), backendId_to_backendHttpPort.get(tablet.BackendId), tablet.TabletId)
}

def replicaNum = get_table_replica_num(tableName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,7 @@ suite("test_variant_bloom_filter", "nonConcurrent") {

// wait for all compactions done
for (def tablet in tablets) {
Awaitility.await().atMost(3, TimeUnit.MINUTES).untilAsserted(() -> {
String tablet_id = tablet.TabletId
backend_id = tablet.BackendId
(code, out, err) = be_get_compaction_status(backendId_to_backendIP.get(backend_id), backendId_to_backendHttpPort.get(backend_id), tablet_id)
logger.info("Get compaction status: code=" + code + ", out=" + out + ", err=" + err)
assertEquals(code, 0)
def compactionStatus = parseJson(out.trim())
assertEquals("compaction task for this tablet is not running", compactionStatus.msg.toLowerCase())
return compactionStatus.run_status;
});
assertCompactionStatusAtMost(backendId_to_backendIP.get(tablet.BackendId), backendId_to_backendHttpPort.get(tablet.BackendId), tablet.TabletId, 3, TimeUnit.MINUTES)
}

for (def tablet in tablets) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,7 @@ suite("test_index_compaction_empty_segments", "p0, nonConcurrent") {

// wait for all compactions done
for (def tablet in tablets) {
Awaitility.await().atMost(10, TimeUnit.MINUTES).untilAsserted(() -> {
String tablet_id = tablet.TabletId
backend_id = tablet.BackendId
(code, out, err) = be_get_compaction_status(backendId_to_backendIP.get(backend_id), backendId_to_backendHttpPort.get(backend_id), tablet_id)
logger.info("Get compaction status: code=" + code + ", out=" + out + ", err=" + err)
assertEquals(code, 0)
def compactionStatus = parseJson(out.trim())
assertEquals("compaction task for this tablet is not running", compactionStatus.msg.toLowerCase())
return compactionStatus.run_status;
});
assertCompactionStatusAtMost(backendId_to_backendIP.get(tablet.BackendId), backendId_to_backendHttpPort.get(tablet.BackendId), tablet.TabletId, 10, TimeUnit.MINUTES)
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,7 @@ suite("test_index_compaction_p0", "p0, nonConcurrent") {

// wait for all compactions done
for (def tablet in tablets) {
Awaitility.await().atMost(1, TimeUnit.MINUTES).untilAsserted(() -> {
String tablet_id = tablet.TabletId
backend_id = tablet.BackendId
(code, out, err) = be_get_compaction_status(backendId_to_backendIP.get(backend_id), backendId_to_backendHttpPort.get(backend_id), tablet_id)
logger.info("Get compaction status: code=" + code + ", out=" + out + ", err=" + err)
assertEquals(code, 0)
def compactionStatus = parseJson(out.trim())
assertEquals("compaction task for this tablet is not running", compactionStatus.msg.toLowerCase())
return compactionStatus.run_status;
});
assertCompactionStatusAtMost(backendId_to_backendIP.get(tablet.BackendId), backendId_to_backendHttpPort.get(tablet.BackendId), tablet.TabletId, 1, TimeUnit.MINUTES)
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,7 @@ suite("test_index_compaction_p1", "p1, nonConcurrent") {

// wait for all compactions done
for (def tablet in tablets) {
Awaitility.await().atMost(10, TimeUnit.MINUTES).untilAsserted(() -> {
String tablet_id = tablet.TabletId
backend_id = tablet.BackendId
(code, out, err) = be_get_compaction_status(backendId_to_backendIP.get(backend_id), backendId_to_backendHttpPort.get(backend_id), tablet_id)
logger.info("Get compaction status: code=" + code + ", out=" + out + ", err=" + err)
assertEquals(code, 0)
def compactionStatus = parseJson(out.trim())
assertEquals("compaction task for this tablet is not running", compactionStatus.msg.toLowerCase())
return compactionStatus.run_status;
});
assertCompactionStatusAtMost(backendId_to_backendIP.get(tablet.BackendId), backendId_to_backendHttpPort.get(tablet.BackendId), tablet.TabletId, 10, TimeUnit.MINUTES)
}

for (def tablet in tablets) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,11 @@ suite("test_show_index_data", "p1") {
assertEquals("success", compactJson.status.toLowerCase())
}

Thread.sleep(30000)

// wait for all compactions done
for (def tablet in tablets) {
Awaitility.await().atMost(30, TimeUnit.MINUTES).untilAsserted(() -> {
Thread.sleep(30000)
String tablet_id = tablet.TabletId
backend_id = tablet.BackendId
(code, out, err) = be_get_compaction_status(backendId_to_backendIP.get(backend_id), backendId_to_backendHttpPort.get(backend_id), tablet_id)
logger.info("Get compaction status: code=" + code + ", out=" + out + ", err=" + err)
assertEquals(code, 0)
def compactionStatus = parseJson(out.trim())
assertEquals("compaction task for this tablet is not running", compactionStatus.msg.toLowerCase())
});
assertCompactionStatusAtMost(backendId_to_backendIP.get(tablet.BackendId), backendId_to_backendHttpPort.get(tablet.BackendId), tablet.TabletId, 30, TimeUnit.MINUTES)
}


Expand Down Expand Up @@ -244,10 +237,10 @@ suite("test_show_index_data", "p1") {
}
}
sql """ alter table ${show_table_name} drop column clientip"""
Awaitility.await().atMost(30, TimeUnit.MINUTES).untilAsserted(() -> {
Thread.sleep(30000)
tablets = sql_return_maparray """ show tablets from ${show_table_name}; """
for (def tablet in tablets) {
Thread.sleep(30000)

for (def tablet in tablets) {
Awaititly.await().pollInterval(2, TimeUnit.SECONDS).atMost(30, TimeUnit.MINUTES).untilAsserted({
String tablet_id = tablet.TabletId
(code, out, err) = curl("GET", tablet.CompactionStatus)
logger.info("Show tablets status: code=" + code + ", out=" + out + ", err=" + err)
Expand All @@ -263,8 +256,8 @@ suite("test_show_index_data", "p1") {
logger.info("rowsetid: " + rowsetid)
assertTrue(!rowsetids.contains(rowsetid))
}
}
});
})
}
}

def build_index = {
Expand Down Expand Up @@ -292,10 +285,10 @@ suite("test_show_index_data", "p1") {
if (!isCloudMode()) {
sql """ build index status_idx on ${show_table_name}"""
}
Awaitility.await().atMost(30, TimeUnit.MINUTES).untilAsserted(() -> {
Thread.sleep(30000)
tablets = sql_return_maparray """ show tablets from ${show_table_name}; """
for (def tablet in tablets) {
Thread.Sleep(10000)

for (def tablet in tablets) {
Awaititly.await().pollInterval(2, TimeUnit.SECONDS).atMost(30, TimeUnit.MINUTES).untilAsserted({
String tablet_id = tablet.TabletId
(code, out, err) = curl("GET", tablet.CompactionStatus)
logger.info("Show tablets status: code=" + code + ", out=" + out + ", err=" + err)
Expand All @@ -311,8 +304,8 @@ suite("test_show_index_data", "p1") {
logger.info("rowsetid: " + rowsetid)
assertTrue(!rowsetids.contains(rowsetid))
}
}
});
})
}
}

def drop_index = {
Expand All @@ -336,10 +329,10 @@ suite("test_show_index_data", "p1") {
}
}
sql """ DROP INDEX status_idx on ${show_table_name}"""
Awaitility.await().atMost(30, TimeUnit.MINUTES).untilAsserted(() -> {
Thread.sleep(30000)
tablets = sql_return_maparray """ show tablets from ${show_table_name}; """
for (def tablet in tablets) {
Thread.sleep(30000)

for (def tablet in tablets) {
Awaititly.await().pollInterval(2, TimeUnit.SECONDS).atMost(30, TimeUnit.MINUTES).untilAsserted({
String tablet_id = tablet.TabletId
(code, out, err) = curl("GET", tablet.CompactionStatus)
logger.info("Show tablets status: code=" + code + ", out=" + out + ", err=" + err)
Expand All @@ -355,8 +348,8 @@ suite("test_show_index_data", "p1") {
logger.info("rowsetid: " + rowsetid)
assertTrue(!rowsetids.contains(rowsetid))
}
}
});
})
}
}

// 1. load data
Expand Down
Loading
Loading