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 all 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
3 changes: 3 additions & 0 deletions regression-test/plugins/cloud_compaction_plugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ Suite.metaClass.doCloudCompaction = { String tableName /* param */ ->
//assertEquals("success", compactJson.status.toLowerCase())
}

// waiting compaction to start
Thread.sleep(10000)

// wait for all compactions done
for (String[] tablet in tablets) {
boolean running = true
Expand Down
88 changes: 88 additions & 0 deletions regression-test/plugins/plugin_compaction.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// 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

/*
* make sure compactions are triggered and sleep a short time ( maybe 10 seconds ) waiting for compactions starting.
*/
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()) {
// run_status == true means compactions are running
// run_status == false means compaction are finished
return !compactionStatus.run_status
} else {
return false
}
}

Suite.metaClass.assertCompactionStatus = { String backendIP, String backendPort, String tabletID ->
Awaitility.await().atMost(30, TimeUnit.SECONDS).pollInterval(1, SECONDS).untilAsserted({
assert checkComactionStatus(backendIP, backendPort, tabletID)
})
}

Suite.metaClass.assertCompactionStatusAtMost = { String backendIP, String backendPort, String tabletID, long t, TimeUnit tu ->
Awaitility.await().atMost(t, tu).pollInterval(1, SECONDS).untilAsserted({
assert checkComactionStatus(backendIP, backendPort, tabletID)
})
}

// let table do full compaction, and waiting for them done.
// TODO: auto compaction what.
Suite.metaClass.doCompactionWaitDone = { String tableName ->
// get table tablets.
def tablets = sql_return_maparray """ show tablets from ${tableName}; """

def backendId_to_backendIP = [:]
def backendId_to_backendHttpPort = [:]
getBackendIpHttpPort(backendId_to_backendIP, backendId_to_backendHttpPort);

// trigger compactions for all tablets in ${tableName}
for (def tablet in tablets) {
String tablet_id = tablet.TabletId
def backend_id = tablet.BackendId
def (code, out, err) = be_run_cumulative_compaction(backendId_to_backendIP.get(backend_id), backendId_to_backendHttpPort.get(backend_id), tablet_id)
logger.info("Run compaction: code=" + code + ", out=" + out + ", err=" + err)
assertEquals(code, 0)
def compactJson = parseJson(out.trim())
if (compactJson.status.toLowerCase() == "fail") {
assertEquals(disableAutoCompaction, false)
logger.info("Compaction was done automatically!")
}
if (disableAutoCompaction) {
assertEquals("success", compactJson.status.toLowerCase())
}
}

// waiting compaction to start
Thread.sleep(10000)

// wait for all compactions done
for (def tablet in tablets) {
assertCompactionStatus(backendId_to_backendIP.get(tablet.BackendId), backendId_to_backendHttpPort.get(tablet.BackendId), tablet.TabletId)
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ suite("test_stale_rowset") {
}
}

// waiting compaction to start
Thread.sleep(10000)

// wait for all compactions done
for (String[] tablet in tablets) {
boolean running = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ suite('compaction_width_array_column', "p2") {
assertEquals("success", compactJson.status.toLowerCase())
}

// waiting compaction to start
Thread.sleep(10000)

// wait for all compactions done
for (def tablet in tablets) {
boolean running = true
Expand Down
42 changes: 12 additions & 30 deletions regression-test/suites/compaction/test_base_compaction.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,12 @@ suite("test_base_compaction", "p2") {
assertEquals("success", compactJson.status.toLowerCase())
}

// wait compaction to start
Thread.sleep(10000)

// 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 @@ -206,18 +200,12 @@ suite("test_base_compaction", "p2") {
assertEquals("success", compactJson.status.toLowerCase())
}

// wait compaction to start
Thread.sleep(10000)

// 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 @@ -235,18 +223,12 @@ suite("test_base_compaction", "p2") {
assertEquals("success", compactJson.status.toLowerCase())
}

// wait compaction to start
Thread.sleep(10000)

// 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 @@ -146,18 +145,12 @@ suite("test_base_compaction_no_value", "p2") {
assertEquals("success", compactJson.status.toLowerCase())
}

// wait compaction to start
Thread.sleep(10000)

// 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 @@ -206,18 +199,12 @@ suite("test_base_compaction_no_value", "p2") {
assertEquals("success", compactJson.status.toLowerCase())
}

// wait compaction to start
Thread.sleep(10000)

// 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 @@ -234,19 +221,13 @@ suite("test_base_compaction_no_value", "p2") {
def compactJson = parseJson(out.trim())
assertEquals("success", compactJson.status.toLowerCase())
}

// wait compaction to start
Thread.sleep(10000)

// 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 @@ -114,6 +114,9 @@ suite("test_compaction_with_delete") {
assertEquals("success", compactJson.status.toLowerCase())
}
}

// wait compaction to start
Thread.sleep(10000)

// wait for all compactions done
for (def tablet in tablets) {
Expand Down
16 changes: 4 additions & 12 deletions regression-test/suites/compaction/test_compaction_agg_keys.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,12 @@ suite("test_compaction_agg_keys") {
}
}

// wait compaction to start
Thread.sleep(10000)

// 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 @@ -112,6 +112,8 @@ suite("test_compaction_agg_keys_with_array_map") {
}
}

Thread.sleep(10000)

// wait for all compactions done
for (def tablet in tablets) {
boolean running = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ suite("test_compaction_agg_keys_with_delete") {
}
}

Thread.sleep(10000)

// wait for all compactions done
for (def tablet in tablets) {
boolean running = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ suite("test_compaction_dup_keys") {
}
}

Thread.sleep(10000)

// wait for all compactions done
for (def tablet in tablets) {
boolean running = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ suite("test_compaction_dup_keys_with_delete") {
}
}

Thread.sleep(10000)

// wait for all compactions done
for (def tablet in tablets) {
boolean running = true
Expand Down
14 changes: 4 additions & 10 deletions regression-test/suites/compaction/test_compaction_uniq_keys.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,12 @@ suite("test_compaction_uniq_keys") {
}
}

// wait compaction to start
Thread.sleep(10000)

// 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 @@ -124,6 +124,8 @@ suite("test_compaction_uniq_keys_ck") {
}
}

Thread.sleep(10000)

// wait for all compactions done
for (def tablet in tablets) {
boolean running = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ suite("test_compaction_uniq_keys_row_store", "p0") {
}
}

Thread.sleep(10000)

// wait for all compactions done
for (def tablet in tablets) {
boolean running = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ suite("test_compaction_uniq_keys_row_store_ck", "p0") {
}
}

Thread.sleep(10000)

// wait for all compactions done
for (def tablet in tablets) {
boolean running = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ suite("test_compaction_uniq_keys_with_delete") {
}
}

Thread.sleep(10000)

// wait for all compactions done
for (def tablet in tablets) {
boolean running = true
Expand Down
Loading
Loading