Running mysqltest by obd.sh

When using obd.sh to run the mysqltest test, you need to use the OceanBase database deployed through obd.sh. This article uses examples to introduce how to use obd.sh to deploy the OceanBase database and run the mysqltest test starting from compiling the source code.

Background

In order to simplify the operating steps for developers and reduce their understanding costs, we encapsulate some OBD commands into the obd.sh script and store the script in the oceanbase/tools/deploy directory of the OceanBase source code. This article runs the mysqltest test by calling the obd test mysqltest commands in OBD.

Concepts

mysqltest is a test in the OceanBase database access test. Simply put, it takes the written case file as input and compares the output of the database with the expected output. The cases tested by mysqltest in the OceanBase database are all located in the tools/deploy/mysql_test directory of the OceanBase source code.

case is the smallest execution unit of mysqltest. A case contains at least one test file and one result file. Classifying cases forms a suite, and a suite is a collection of cases.

When running the mysqltest test, it is divided into different modes according to the selected nodes. The common mysqltest modes are as follows.

  • c mode: Connect to the server where the Primary Zone is located to run mysqltest. For example, use the configuration file distributed.yaml to deploy the cluster and then connect to server1 to run the test.

    ./obd.sh mysqltest -n <name> --suite acs --test-server=server1
    
  • Slave mode: Connect to a server other than the Primary Zone to run mysqltest. For example, use the configuration file distributed.yaml to deploy the cluster and then connect to server2 to run the test.

    ./obd.sh mysqltest -n <name> --suite acs --test-server=server2
    
  • Proxy mode: Connect to the cluster through ODP for mysqltest testing. For example, use the configuration file distributed-with-proxy.yaml to deploy the cluster and run the test.

    ./obd.sh mysqltest -n <name> --all
    

Steps

Step 1: Compile OceanBase database from source code

Please refer to build-and-run to compile the OceanBase database from source code.

Step 2: Run mysqltest test

You can choose to test in full or specify a case or suite for testing. For the specific meaning of parameters used when executing the obd.sh script, please refer to Appendix.

  • Full test, that is, run all suites in the mysql_test/test_suite directory, please refer to the following command.

    [admin@obtest ~]$ cd oceanbase/tools/deploy
    [admin@obtest deploy]$ ./obd.sh mysqltest -n test --all
    
  • Specify case for testing, for example, specify mysql_test/test_suite/alter/t/alter_log_archive_option.test. Please refer to the following command.

    [admin@obtest ~]$ cd oceanbase/tools/deploy
    [admin@obtest deploy]$ ./obd.sh mysqltest -n test --test-dir ./mysql_test/test_suite/alter/t --result-dir ./mysql_test/test_suite/alter/r --test-set alter_log_archive_option
    
  • To specify a suite test, for example, to execute a test on a specified suite in the mysql_test/test_suite directory, please refer to the following command.

    [admin@obtest ~]$ cd oceanbase/tools/deploy
    [admin@obtest deploy]$ ./obd.sh mysqltest -n test --suite acs
    

Appendix

When executing the mysqltest test, you can configure some parameters according to the actual situation. The parameters are explained in the following table:

Parameter NameRequiredTypeDefaultNote
-nYstringnullThe cluster name.
--componentNstringnullThe name of the component to be tested. Candidates are obproxy, obproxy-ce, oceanbase, and oceanbase-ce. When empty, checks are performed in the order obproxy, obproxy-ce, oceanbase, oceanbase-ce. If it is detected that the component exists, it will no longer be traversed, and the hit component will be used for subsequent testing.
--test-serverNstringThe default is the first node in the server under the specified componentThe machine to be tested can be set to the name value corresponding to the servers in the yaml file. If the name value is not configured after servers, the ip value will be used, which must be under the specified component. A certain node name.
--userNstringadminThe username for executing the test, generally does not need to be modified.。
--passwordNstringadminPassword
--databaseNstringtestdatabase
--mysqltest-binNstring/u01/obclient/bin/mysqltestmysqltest binary file path.
--obclient-binNstringobclientobclient binary file path.
--test-dirNstring./mysql_test/tThe directory where the test-file required by mysqltest is stored. If the test file cannot be found, it will try to find it in the OBD built-in.
--test-file-suffixNstring.testmysqltest 所需的 test-file 的后缀。
--result-dirNstring./mysql_test/rThe directory where the result-file required by mysqltest is stored. If the result file is not found, it will try to find it in the OBD built-in.
--result-file-suffixNstring.resultThe suffix of result-file required by mysqltest.
--recordNboolfalseOnly the execution results of mysqltest are recorded as record-file.
--record-dirNstring./recordThe directory where the execution results of mysqltest are recorded.
--record-file-suffixNstring.recordThe suffix that records the execution results of mysqltest.
--tmp-dirNstring./tmptmpdir option for mysqltest.
--var-dirNstring./varThe log directory will be created under this directory and passed to mysqltest as the logdir option.
--test-setNstringnotest case array. Use commas (,) to separate multiple cases.
--excludeNstringnoThe test case array needs to be excluded. Use commas (,) to separate multiple cases.
--test-patternNstringnoThe regular expression that test filenames match. All cases matching the expression will override the test-set option.
--suiteNstringnosuite array. A suite contains multiple tests, which can be separated by commas (,).
--suite-dirNstring./mysql_test/test_suiteThe directory where the suite directory is stored. If the suite directory is not found, it will try to find it in the OBD built-in.
--allNboolfalseExecute all cases under --suite-dir. The directory where the suite directory is stored.
--need-initNboolfalseExecute init sql file. A new cluster may need to execute some initialization files before executing mysqltest, such as creating the account and tenant required for the case. The directory where the suite directory is stored. Not enabled by default.
--init-sql-dirNstring./The directory where the init sql file is located. When the sql file is not found, it will try to find it in the OBD built-in.
--init-sql-filesNstringDefault is emptyArray of init sql files to be executed when init is required. English comma (,) separation. If not filled in, if init is required, OBD will execute the built-in init according to the cluster configuration.
--auto-retryNboolfalseAutomatically redeploy the cluster and try again when it fails.
--psmallNboolfalseExecute the case in psmall mode.
--slicesNintnullThe number of groups into which the cases to be executed will be divided.
--slice-idxNintnullSpecify the current group id.
--slb-hostNstringnullSpecify the soft load balancing center.
--exec-idNstringnullSpecify execution id.
--case-filterNstring./mysql_test/filter.pyThe filter.py file maintains the cases that need to be filtered.
--reboot-timeoutNint0Restart timeout.
--reboot-retriesNint5Number of retries for failed restarts.
--collect-allNboolfalseWhether to collect component logs.
--log-dirNstringThe default is log under tmp_dirThe log storage path of mysqltest.
--log-patternNstring*.logCollect log file names matching the regular expression, and the hit files will be collected.
--case-timeoutNint3600mysqltest timeout for a single test.
--disable-rebootNboolfalseNo more restarts during test execution.
--collect-componentsNstringnullUsed to specify the components to be collected for logs. Multiple components are separated by commas (,).
--init-onlyNboolfalseWhen true, only init SQL is executed.