Use obd.sh to run mysqltest

2024-06-28 05:30:30  Updated

When you use obd.sh to run mysqltest for test, you must use an OceanBase database deployed by using obd.sh. This topic describes how to compile the source code, use obd.sh to deploy OceanBase Database, and run mysqltest for test.

Background information

To simplify operations, we have encapsulated some commands of OceanBase Deployer (OBD) into the obd.sh script. The script is stored in the oceanbase/tools/deploy directory of the OceanBase source code. In this example, mysqltest calls the obd test mysqltest command in OBD.

Concepts

mysqltest runs entry tests for OceanBase Database. It uses a written test case file as the input and compares the database output against the expected output. mysqltest cases are all located in the oceanbase/tools/deploy/mysql_test directory of the OceanBase source code.

A case is the minimum execution unit of mysqltest, and contains at least one test file and one result file. A suite is a collection of cases of the same type.

mysqltest tests can be classified into different modes. Each mode consists of different nodes.

Note

For more information about the parameters in mysqltest, see Appendix.

  • c mode: Connect to the server node where the primary zone resides and run mysqltest. If the OceanBase cluster is deployed by using the distributed.yaml configuration file, connect to the cluster based on the settings in the server1 section in the configuration file to run the test.

    ./obd.sh mysqltest -n <name> --suite acs --test-server=server1
    
  • Slave mode: Connect to the server node where a non-primary zone resides to run mysqltest. If the OceanBase cluster is deployed by using the distributed.yaml configuration file, connect to the cluster based on the settings in the server2 section in the configuration file to run the test.

    ./obd.sh mysqltest -n <name> --suite acs --test-server=server2
    
  • Proxy mode: Use OceanBase Database Proxy (ODP) to connect to an OceanBase cluster to run mysqltest. For example, use the distributed-with-proxy.yaml configuration file to deploy a cluster and run the test.

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

Procedure

This topic uses an x86 CentOS Linux 7.9 server as the environment. For more information about the compilation and deployment process, see GitHub repository.

Step 1: Compile the source code of OceanBase Database

  1. Download the source code of OceanBase Database.

    [admin@obtest ~]$ git clone https://github.com/oceanbase/oceanbase.git
    
  2. Prepare the dependency package based on the operating system.

    [admin@obtest ~]$ sudo yum install git wget rpm* cpio make glibc-devel glibc-headers binutils m4
    
  3. Complete the compilation.

    [admin@obtest ~]$ cd oceanbase
    [admin@obtest oceanbase]$ bash build.sh release --init --make
    

Step 2: Deploy the compiled OceanBase file

  1. Prepare the configuration file.

    [admin@obtest ~]$ sudo yum install -y yum-utils
    [admin@obtest ~]$ sudo yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo
    [admin@obtest ~]$ sudo yum install -y libtool libaio obclient
    [admin@obtest ~]$ cd oceanbase/tools/deploy
    [admin@obtest deploy]$ ./obd.sh prepare
    

    The obd.sh prepare command copies the binary file from the compilation directory, such as build_release, creates an image, and then generates a default configuration file based on the current environment. If multiple compilation directories exist, the command selects the first one by default.

    You can use the default configuration file that is generated during the deployment. You can also download other configuration files from the GitHub repository and modify them as needed. You must select a configuration file based on the test mode of mysqltest.

    Note

    For more information about test modes of mysqltest, see Concepts.

    • You can use any configuration file to run a mysqltest test in c mode.

    • To run a mysqltest test in slave mode, you must use the distributed.yaml or distributed-with-proxy.yaml file to deploy a two-node cluster.

    • To run a mysqltest test in proxy mode, you must use the distributed-with-proxy.yaml file to deploy an OceanBase cluster and deploy ODP in the OceanBase cluster.

  2. (Optional) Modify the configuration file.

    To modify the port and directory information in a configuration file, run the following command:

    [admin@obtest deploy]$ vim distributed-with-proxy.yaml
    

    The following table describes the key parameters.

    Parameter Required? Description
    servers Yes Specify each server in the format of - name: server identifier (line feed) ip: server IP address. You can specify multiple servers. The server identifiers must be unique.
    You can specify unique server IP addresses in the format of - <ip> (line feed)- <ip>, where - <ip> is equivalent to - name: server IP address (line feed) ip: server IP address.
    mysql_port Yes The port number for the SQL service protocol.
    rpc_port Yes The port number for remote access, which is the RPC communication port between the observer process and other node processes.
    home_path Yes The installation path of the component.
    production_mode Yes Specifies whether to enable the production mode. If the production mode is enabled, mysqltest checks whether the server resources meet the production environment requirements. We recommend that you disable this mode for a test scenario. Otherwise, the deployment may fail.
    devname No The network interface card (NIC) corresponding to the IP address specified in servers. You can view the mapping between IP addresses and NICs by using the ip addr command.
    listen_port Yes The listening port of ODP.
    prometheus_listen_port Yes The Prometheus service port of ODP.
  3. Deploy OceanBase Database.

    [admin@obtest deploy]$ ./obd.sh deploy -c distributed-with-proxy.yaml -n test
    

    Here, -c specifies the path of the configuration file for deployment. In this example, the distributed-with-proxy.yaml file is used. -n specifies the name of the cluster to be deployed. In this example, test is used.

Step 3: Run the mysqltest test

You can select a full test or specify the cases or suites for the test.

  • Run the following commands to perform a full test, namely to run all suites in the mysql_test/test_suite directory:

    [admin@obtest ~]$ cd oceanbase/tools/deploy
    [admin@obtest deploy]$ ./obd.sh mysqltest -n test --all
    
  • Run the following commands to perform a test by specifying the test cases, for example, test cases in mysql_test/test_suite/alter/t/alter_log_archive_option.test:

    [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
    
  • Run the following commands to perform a test by specifying the test suites, for example, suites in the mysql_test/test_suite directory:

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

Appendix

When you run a mysqltest test, you can configure options as required. The following table describes the options.

Option Required? Data type Default value Description
-n Yes String Empty The name of the cluster where the test is executed.
–component No String Empty The name of the component to be tested. Valid values: obproxy, obproxy-ce, oceanbase, and oceanbase-ce. If you do not specify a value, the existence of obproxy, obproxy-ce, oceanbase, and oceanbase-ce is checked sequentially. The traversal stops when a component is found, and the component is then tested.
–test-server No String The name of the first node under the specified component. You can set this parameter to the value of name in servers in the .yaml file. If name is not specified for the servers parameter, you can use the ip value. It must be a node under the specified component.
–user No String admin The username used to perform the test. Generally, you do not need to modify the value.
–password No String admin The user password used to perform the test.
–database No String test The database where the test is to be performed.
–mysqltest-bin No String /u01/obclient/bin/mysqltest The path to the directory where the binary files of mysqltest are stored.
–obclient-bin No String obclient The path to the directory where the binary files of OBClient are stored.
–test-dir No String ./mysql_test/t The directory where the test file required by mysqltest is stored. If the test file cannot be found, the system will try to find it in the built-in OBD directory.
–test-file-suffix No String .test The suffix of the test file that is required by mysqltest.
–result-dir No String ./mysql_test/r The directory where the result file required by mysqltest is stored. If the result file cannot be found, the system will try to find it in the built-in OBD directory.
–result-file-suffix No String .result The suffix of the result file that is required by mysqltest.
–record No Boolean false The record file that records only the execution result of mysqltest.
–record-dir No String ./record The directory where the execution result of mysqltest is stored.
–record-file-suffix No String .record The suffix of the file that records the execution result of mysqltest.
–tmp-dir No String ./tmp The temporary directory for mysqltest, which stores temporary files generated during the test.
–var-dir No String ./var The path where the log directory will be created. The path will be passed in as the --log-dir option to mysqltest.
–test-set No String N/A The test case array. Separate multiple cases with commas (,).
–exclude No String N/A The array of test cases to be excluded. Separate multiple cases with commas (,).
–test-pattern No String N/A The regular expression that matches the test file name. All cases that match the expression will override the test-set option.
–suite No String N/A The suite array. Separate tests in a suite with commas (,).
–suite-dir No String ./mysql_test/test_suite The path where suites are stored. When a suite cannot be found, the system will try to find it in the built-in OBD directory.
–all No Boolean false Specifies to execute all cases in the --suite-dir directory. --suite-dir specifies the path where suites are stored.
–need-init No Boolean false Specifies to execute initialization SQL files. For a new cluster, the system may need to execute some initialization files before running mysqltest, for example, initialization files that create accounts and tenants required for creating test cases. The feature is disabled by default.
–init-sql-dir No String ./ The directory where initialization SQL files are located. When the SQL files cannot be found, the system will try to find them in the built-in OBD directory.
–init-sql-files No String Empty The array of initialization SQL files to be executed. Separate the files with commas (,). If initialization is required but this field is not set, OBD executes the built-in initialization file based on the cluster configuration.
–auto-retry No Boolean false Specifies to automatically redeploy the cluster upon a deployment failure.
–psmall No Boolean false Specifies whether to execute the cases in psmall mode.
–slices No Integer Empty The number of slices into which the case to be executed is divided.
–slice-idx No Integer Empty The ID of the current slice.
–slb-host No String Empty The host for soft load balancing.
–exec-id No String Empty The ID of the execution.
–case-filter No String ./mysql_test/filter.py The filter.py file, which contains lists of cases to be filtered out.
–reboot-timeout No Integer 0 The timeout period for a restart.
–reboot-retries No Integer 5 The number of retries allowed if the restart fails.
–collect-all No Boolean false Specifies whether to collect component logs.
–log-dir No String $–var-dir/log The path to the directory where the mysqltest logs are stored.
–log-pattern No String *.log The regular expression that is used to match log file names. Files that match the expression are collected.
–case-timeout No Integer 3600 The timeout period for a single test of mysqltest.
–disable-reboot No Boolean false Specifies whether to disable restart during the test.
–collect-components No String Empty The components for which the logs are collected. Separate the components with commas (,).
–init-only No Boolean false Specifies whether to execute only initialization SQL files.

Contact Us