stoneatom / stonedb

StoneDB is an Open-Source MySQL HTAP and MySQL-Native DataBase for OLTP, Real-Time Analytics, a counterpart of MySQLHeatWave. (https://stonedb.io)
https://stonedb.io/
GNU General Public License v2.0
862 stars 139 forks source link

How to compile the code for DevTest and run `make mtr test` #1516

Open zzzz-vincent opened 1 year ago

zzzz-vincent commented 1 year ago

General Question

Hi I am interested in contributing to this project :) But I have following questions:

1) I didn't find how to run make mtr test per https://github.com/stoneatom/stonedb/blob/stonedb-5.7-dev/CONTRIBUTING.md. I tried running it from the root directory, but it resulted in an error message: "make: *** No rule to make target 'mtr'. Stop." I also checked the documentation in issue #1448 , but I found it to be somewhat vague since the crucial step of "building your stonedb" is only mentioned in a comment.

2) I am wondering if there are any additional build steps required before running make mtr test. Currently, the only way I can compile the code is by running sh stonedb_build.sh, which takes a significant amount of time and is not suitable for DevTest.

3) Finally, I would like to ask for your suggestion on setting up C++ auto-completion in my IDE. I am currently using VSCode with clangd, but it does not seem to be working very well. Any advice you can provide on this matter would be greatly appreciated.

hustjieke commented 1 year ago

General Question

Hi I am interested in contributing to this project :) But I have following questions:

  1. I didn't find how to run make mtr test per https://github.com/stoneatom/stonedb/blob/stonedb-5.7-dev/CONTRIBUTING.md. I tried running it from the root directory, but it resulted in an error message: "make: *** No rule to make target 'mtr'. Stop." I also checked the documentation in issue docs: add description “how to add and run a mtr test" in contribute.md #1448 , but I found it to be somewhat vague since the crucial step of "building your stonedb" is only mentioned in a comment.
  2. I am wondering if there are any additional build steps required before running make mtr test. Currently, the only way I can compile the code is by running sh stonedb_build.sh, which takes a significant amount of time and is not suitable for DevTest.
  3. Finally, I would like to ask for your suggestion on setting up C++ auto-completion in my IDE. I am currently using VSCode with clangd, but it does not seem to be working very well. Any advice you can provide on this matter would be greatly appreciated.

Nice question! We'll replenish a guide doc on how to write and run a mtr test today. For question2, there is another way to make build step1, in stonedb repo:

$ mkdir build
$ cd build
$ mkdir mysql57 install
$ cd mysql57

step2, in dir mysql57, run cmake:

cmake ../../ \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/github/stonedb/build/install \
-DMYSQL_DATADIR=/github/stonedb/build/install/data \
-DSYSCONFDIR=/github/stonedb/build/install \
-DMYSQL_UNIX_ADDR=/github/stonedb/build/install/tmp/mysql.sock \
-DWITH_EMBEDDED_SERVER=OFF \
-DWITH_TIANMU_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8mb4 \
-DDEFAULT_COLLATION=utf8mb4_general_ci \
-DDOWNLOAD_BOOST=0 \
-DWITH_BOOST=/usr/local/stonedb-boost \
-DWITH_MARISA=/usr/local/stonedb-marisa \
-DWITH_ROCKSDB=/usr/local/stonedb-gcc-rocksdb

step3, in dir mysql57, after cmake success, run make install -j xxx, e.g.:

$ make install -j24

24 is for the process cores in my machine.

hustjieke commented 1 year ago

For question 3, you can check if you env. has installed clang-formate-10, if not, install it first.

step1, for example in ubuntu:

apt-get update && apt-get install -y clang-format-10

step2, execute cmd:

$ cd storage/tianmu/
$ ls
async_tests  base  CMakeLists.txt  common  compress  core  exporter  handler  index  loader  mm  system  types  util  vc
$ find ./ -type f -name "*.cpp" -o -name "*.h" -o -name "*.c"| xargs /usr/bin/clang-format-10 -i
zzzz-vincent commented 1 year ago

Thanks, it worked! A clear doc can be very helpful for new developers :) Just wanted to add more on how to set up clangd in VSCode for this project. So probably others who are using this plugin for auto-complete and syntax check can find it useful:

before running: cmake ../../ \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/github/stonedb/build/install \ -DMYSQL_DATADIR=/github/stonedb/build/install/data \ -DSYSCONFDIR=/github/stonedb/build/install \ -DMYSQL_UNIX_ADDR=/github/stonedb/build/install/tmp/mysql.sock \ -DWITH_EMBEDDED_SERVER=OFF \ -DWITH_TIANMU_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DMYSQL_TCP_PORT=3306 \ -DENABLED_LOCAL_INFILE=1 \ -DEXTRA_CHARSETS=all \ -DDEFAULT_CHARSET=utf8mb4 \ -DDEFAULT_COLLATION=utf8mb4_general_ci \ -DDOWNLOAD_BOOST=0 \ -DWITH_BOOST=/usr/local/stonedb-boost \ -DWITH_MARISA=/usr/local/stonedb-marisa \ -DWITH_ROCKSDB=/usr/local/stonedb-gcc-rocksdb

  1. add -DCMAKE_EXPORT_COMPILE_COMMANDS=1 to the args above
  2. run ln -s build/mysql57/compile_commands.json build/ to make a symbolic link, clangd auto detects this json file from project top dir or build dir.
  3. reload VSCode
zzzz-vincent commented 1 year ago

Hi I reopened this issue to check if any doc has updated to run mtr test I tried ./mysql-test-run.pl --suite=innodb --mysqld=--default-storage-engine=innodb --nowarnings --force --nocheck-testcases --retry=0 --do-test-list=./suite/innodb/include/innodb_testlist --parallel=10 but there was an error saying:

2023-04-10T07:01:39.863817Z 0 [ERROR] Plugin 'TIANMU' init function returned error. 2023-04-10T07:01:39.863833Z 0 [ERROR] Plugin 'TIANMU' registration as a STORAGE ENGINE failed. 2023-04-10T07:01:39.863980Z 0 [ERROR] Failed to initialize dynamic plugins. 2023-04-10T07:01:39.863992Z 0 [ERROR] Aborting

any thoughts for this? Thanks!

hustjieke commented 1 year ago

Hi I reopened this issue to check if any doc has updated to run mtr test I tried ./mysql-test-run.pl --suite=innodb --mysqld=--default-storage-engine=innodb --nowarnings --force --nocheck-testcases --retry=0 --do-test-list=./suite/innodb/include/innodb_testlist --parallel=10 but there was an error saying:

2023-04-10T07:01:39.863817Z 0 [ERROR] Plugin 'TIANMU' init function returned error. 2023-04-10T07:01:39.863833Z 0 [ERROR] Plugin 'TIANMU' registration as a STORAGE ENGINE failed. 2023-04-10T07:01:39.863980Z 0 [ERROR] Failed to initialize dynamic plugins. 2023-04-10T07:01:39.863992Z 0 [ERROR] Aborting

any thoughts for this? Thanks!

Do you want run mtr on innodb?

zzzz-vincent commented 1 year ago

actually I was trying both, the other is ./mysql-test-run.pl --suite=tianmu --nowarnings --force --nocheck-testcases --retry=0 --parallel=10 but the error is the same.

I just follow the instruction above and tun the cli in ~/stonedb/build/mysql57/mysql-test

zzzz-vincent commented 1 year ago

Oh it worked. It was due to the log dir was not correctly setup in https://github.com/stoneatom/stonedb/blob/166f87ae32ba96dcfb2d35a4bddb244bdf0b1dad/mysql-test/mysql-test-run.pl#L4198-L4201 but the error was pointing to something else. We can add one more check point after the L4201 to indicate it.

hustjieke commented 1 year ago

Do you run mtr test in make dir or install dir?

~/stonedb/build/mysql57/mysql-test

should be

~/stonedb/build/install/mysql-test

??