From 2e2b4b3f82a5ca1638a7bb783fc758cc14de2116 Mon Sep 17 00:00:00 2001 From: Leonid Fedorov Date: Wed, 30 Jul 2025 13:57:40 +0000 Subject: [PATCH] chore(tests): make local mtr runnner smarter --- tests/scripts/fullmtr.sh | 77 ---------------------------- tests/scripts/run_mtr.sh | 107 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+), 77 deletions(-) delete mode 100644 tests/scripts/fullmtr.sh create mode 100755 tests/scripts/run_mtr.sh diff --git a/tests/scripts/fullmtr.sh b/tests/scripts/fullmtr.sh deleted file mode 100644 index bbda72ee2..000000000 --- a/tests/scripts/fullmtr.sh +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/bash - -SCRIPT_LOCATION=$(dirname "$0") -MARIADB_SOURCE_PATH=$(realpath $SCRIPT_LOCATION/../../../../../) -COLUMNSTORE_MTR_SOURCE=$(realpath $SCRIPT_LOCATION/../../mysql-test/columnstore) -INSTALLED_MTR_PATH='/usr/share/mysql/mysql-test' -COLUMSNTORE_MTR_INSTALLED=${INSTALLED_MTR_PATH}/plugin/columnstore/ -PATCHNAME=$(realpath $SCRIPT_LOCATION)/mtr_warn.patch -CURRENT_DIR=$(pwd) -mysql -e "create database if not exists test;" -SOCKET=$(mysql -e "show variables like 'socket';" | grep socket | cut -f2) - -export ASAN_OPTIONS=abort_on_error=1:disable_coredump=0,print_stats=false,detect_odr_violation=0,check_initialization_order=1,detect_stack_use_after_return=1,atexit=false,log_path=/core/asan.hz - -# needed when run MTR tests locally, see mariadb-test-run.pl:417, mtr functions -# are added to the database mtr only when --extern is not specified - -add_mtr_warn_functions() { - echo "Adding mtr warnings functions..." - cd /tmp - mysql -e "drop database if exists mtr" - cp ${MARIADB_SOURCE_PATH}/mysql-test/include/mtr_warnings.sql mtr_warnings.sql - patch -p1 <${PATCHNAME} - mysql -e "create database if not exists mtr;" - mysql mtr $CURRENT_DIR/mtr.$1.cores-before - ./mtr --force --extern=socket=${SOCKET} --max-test-fail=0 --testcase-timeout=60 --suite=columnstore/$1 $2 | tee $CURRENT_DIR/mtr.$1.log 2>&1 - # dump analyses. - systemctl stop mariadb - systemctl start mariadb - ls /core >$CURRENT_DIR/mtr.$1.cores-after - echo "reports or coredumps:" - diff -u $CURRENT_DIR/mtr.$1.cores-before $CURRENT_DIR/mtr.$1.cores-after && echo "no new reports or coredumps" - rm $CURRENT_DIR/mtr.$1.cores-before $CURRENT_DIR/mtr.$1.cores-after -} - -add_mtr_warn_functions - -if (($# == 2)); then - run_suite $1 $2 - exit 1 -fi - -if (($# == 1)); then - run_suite $1 - exit 1 -fi - -run_suite basic -run_suite bugfixes -run_suite setup -run_suite devregression -run_suite autopilot -run_suite extended -run_suite multinode -run_suite oracle -run_suite 1pmonly - -cd - diff --git a/tests/scripts/run_mtr.sh b/tests/scripts/run_mtr.sh new file mode 100755 index 000000000..f48cc9d5c --- /dev/null +++ b/tests/scripts/run_mtr.sh @@ -0,0 +1,107 @@ +#!/bin/bash + + +SCRIPT_LOCATION=$(dirname "$0") +COLUMNSTORE_SOURCE_PATH=$(realpath $SCRIPT_LOCATION/../../) +MARIADB_SOURCE_PATH=$(realpath $SCRIPT_LOCATION/../../../../../) +COLUMNSTORE_MTR_SOURCE=$(realpath $COLUMNSTORE_SOURCE_PATH/mysql-test/columnstore) +INSTALLED_MTR_PATH='/usr/share/mysql/mysql-test/' +PATCHNAME=$(realpath $SCRIPT_LOCATION)/mtr_warn.patch +CURRENT_DIR=$(pwd) + +source $COLUMNSTORE_SOURCE_PATH/build/utils.sh + + +optparse.define short=s long=suite desc="whole suite to run" variable=SUITE_NAME +optparse.define short=t long=test_full_name desc="Testname with suite as like bugfixes.mcol-4899" variable=TEST_FULL_NAME default="" +optparse.define short=f long=full desc="Run full MTR" variable=RUN_FULL default=false value=true +optparse.define short=r long=record desc="Record the result" variable=RECORD default=false value=true +optparse.define short=e long=no-extern desc="Run without --extern" variable=EXTERN default=true value=false + +source $(optparse.build) + +mariadb -e "create database if not exists test;" +SOCKET=$(mariadb -e "show variables like 'socket';" | grep socket | cut -f2) + +export ASAN_OPTIONS=abort_on_error=1:disable_coredump=0,print_stats=false,detect_odr_violation=0,check_initialization_order=1,detect_stack_use_after_return=1,atexit=false,log_path=/core/asan.hz + + +# needed when run MTR tests locally, see mariadb-test-run.pl:417, mtr functions +# are added to the database mtr only when --extern is not specified + +add_mtr_warn_functions() { + message "Adding mtr warnings functions..." + cd /tmp + mariadb -e "drop database if exists mtr" + cp ${MARIADB_SOURCE_PATH}/mysql-test/include/mtr_warnings.sql mtr_warnings.sql + patch -p1 <${PATCHNAME} + mariadb -e "create database if not exists mtr;" + mariadb mtr $CURRENT_DIR/mtr.$1.cores-before + + if [[ $EXTERN == true ]]; then + EXTERN_FLAG="--extern=socket=${SOCKET}" + else + EXTERN_FLAG="" + fi + + if [[ $RECORD == true ]]; then + RECORD_FLAG="--record" + else + RECORD_FLAG="" + fi + + ./mtr --force $EXTERN_FLAG $RECORD_FLAG --max-test-fail=0 --testcase-timeout=60 --suite=columnstore/$1 $2 | tee $CURRENT_DIR/mtr.$1.log 2>&1 + # dump analyses. + systemctl stop mariadb + systemctl start mariadb + ls /core >$CURRENT_DIR/mtr.$1.cores-after + message "reports or coredumps:" + diff -u $CURRENT_DIR/mtr.$1.cores-before $CURRENT_DIR/mtr.$1.cores-after && echo "no new reports or coredumps" + rm $CURRENT_DIR/mtr.$1.cores-before $CURRENT_DIR/mtr.$1.cores-after +} + +add_mtr_warn_functions + + +if [[ $RUN_FULL == true ]]; then + message "Running FULL MTR" + run_suite basic + run_suite bugfixes + run_suite setup + run_suite devregression + run_suite autopilot + run_suite extended + run_suite multinode + run_suite oracle + run_suite 1pmonly +else + message "Running suite $SUITE_NAME with test $TEST_NAME" + run_suite $SUITE_NAME $TEST_NAME +fi + +cd -