You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

155 lines
6.1 KiB

  1. These are the assorted notes that will be turned into a manual eventually.
  2. ==========================
  3. Tests are organized in suites.
  4. A "suite" is a subdirectory inside, one of,
  5. <basedir>/mysql-test/suite
  6. <basedir>/mysql-test
  7. <basedir>/share/mysql-test/suite
  8. <basedir>/share/mysql-test
  9. <basedir>/share/mysql/mysql-test/suite
  10. <basedir>/share/mysql/mysql-test
  11. <basedir>/storage/*/mysql-test-suites
  12. This is supposed to cover running mtr from a source directory and installed.
  13. ==========================
  14. A suite contains *.test and *.result files. They can be in the t/ and r/
  15. subdirectories under the suitedir or directly in the suitedir
  16. (that is suitedir/t/*.test or suitedir/*.test, same for *.result))
  17. ==========================
  18. A suite can contain a suite.opt file - at the same location where .test files
  19. are or in the suite directory. As usual, the .opt file can use $-substitutions
  20. for the environment variables.
  21. Usually, using my.cnf template (see below) is preferrable.
  22. But command line options (.opt files and combinations file) get special
  23. treatment - they can have special options that affect mtr behavior. cnf
  24. files cannot. Special options are
  25. --timezone, --plugin-load, --result-file, --config-file-template,
  26. --default-time-zone, --force-restart
  27. In particular, all --plugin-load instances on the command line (on the
  28. combined command line, assembled from different .opt and combinations
  29. files) are merged into one. That is, if, say, test-master.opt file contains
  30. --plugin-load=aaa.so and suite.opt has --plugin-load=bbb.so that mysqld
  31. will get --plugin-load=aaa.so:bbb.so. Also, empty --plugin-load options are
  32. removed from the command line. Which means that one can safely specify
  33. --plugin-load=$AAA_SO and if aaa.so was not built (perhaps, the plugin was
  34. statically linked into the server), the .opt file will not result in the
  35. invalid command line option that can cause the server to refuse to start.
  36. ==========================
  37. A suite can have suite.pm file in the suitedir. It must declare a
  38. package that inherits from My::Suite.
  39. The suite.pm needs to have @ISA=qw(My::Suite) and it must end
  40. with bless {}; - that is it must return an object of that class.
  41. It can also return a string - in this case all tests in the suite
  42. will be skipped, with this string being printed as a reason.
  43. A suite class can define config_files() and servers() methods.
  44. A config_files method returns a list of additional config files (besides
  45. my.cnf), that this suite needs to be created. For every file it specifies
  46. a function that will create it, when given a My::Config object. For example:
  47. sub config_files { ( 'config.ini' => \&write_ini,
  48. 'new.conf' => \&do_new_conf ) }
  49. A servers method returns a list of processes that needs to be started for
  50. this suite. A process is specified as a pair (regex, hash). A regex must
  51. match a section in the my.cnf template (for example, qr/mysqld\./ corresponds
  52. to all mysqld processes), a hash contains these options:
  53. SORT => a number, processes are started in the order of increasing SORT
  54. values (and stopped in the reverse order). mysqld has number 300.
  55. START => a function to start a process. It takes two arguments,
  56. My::Config::Group and My::Test. If START is undefined the process
  57. will not be started.
  58. WAIT => a function waits for the process to be started. It takes
  59. My::Config::Group as an argument. Internallys mtr first invokes
  60. START for all processes, then WAIT for all started processes.
  61. example: sub servers { ( qr/^foo$/ => { SORT => 200,
  62. START => \&start_foo,
  63. WAIT => \&wait_foo } ) }
  64. See sphinx suite for an example.
  65. ==========================
  66. A suite can have my.cnf template file in the suitedir.
  67. A my.cnf template uses a normal my.cnf syntax - groups, options,
  68. and values - with templating extensions. They are
  69. * There can be groups with non-standard names, not used by mysqld.
  70. These groups may be used by the suite.pm file somehow.
  71. For example, they can be written to the additional config files.
  72. See sphinx suite for an example.
  73. * There can be ENV group. It sets values for the environment variables.
  74. * Values can refer to each other - they will be expanded as needed.
  75. A reference to a value of an option looks like @groupname.optionname.
  76. For example
  77. [mysqld.2]
  78. master-port= @mysqld.1.port
  79. it sets the master-port in the mysqld.2 group to the value of
  80. port in the mysqld.1 group.
  81. * An option name may start from '#'. In the resulting my.cnf it will look
  82. like a comment, but it still can be referred to. For example:
  83. [example]
  84. #foo = localhost:@mysqld.1.port
  85. bar = http://@example.#foo/index.html
  86. * There are two special - in this regard - groups.
  87. Via the ENV group one can refer to any environment variable, not only
  88. to values in the [ENV] group of my.cnf file.
  89. Via the OPT group one can refer to special values:
  90. @OPT.vardir - a path to vardir
  91. @OPT.port - a new port number is reserved out of the pool. It will not
  92. match any other port number used by this test run.
  93. See sphinx suite for an example.
  94. Most probably a suite my.cnf will need to start from
  95. !include include/default_my.cnf
  96. and then modify the configuration as necessary.
  97. ==========================
  98. A suite can have combinations file in the suitedir. It uses my.cnf syntax
  99. but it cannot use @-substitutions. Instead, it can use $-substitutions for
  100. the environment variables. Because the combination options will not be
  101. merged to a my.cnf, but will be added to the command line. Example:
  102. [conf1]
  103. opt1=val1
  104. [conf2]
  105. opt1=val2
  106. opt2=$HAVE_SOMETHING
  107. Such a file will cause every test from the suite to be run twice - once
  108. with mysqld using --opt1=val1 and the other one with mysqld using
  109. --opt1=val2 --opt2=$HAVE_SOMETHING
  110. One can limit mtr run to a subset of combinations by setting environment
  111. variable SUITENAME_COMBINATIONS to the ':'-separated set of combination
  112. names. E.g.
  113. RPL_COMBINATIONS=mix:row ./mtr --suite rpl
  114. See innodb_plugin suite for an example of how suite.pm may set this variable
  115. to exclude unsupported configurations.
  116. ==========================