tarantool / libslave

A standalone mysql replication client library, embeddable into your C++ application
GNU Lesser General Public License v3.0
9 stars 2 forks source link

Enable tests on CI #16

Closed ligurio closed 4 years ago

ligurio commented 4 years ago

Would be nice to fix tests compilation them and run on CI.

$ cmake -DWITH_TESTS=ON .. 
$ make 
...
[ 81%] Linking CXX executable db_filler
/usr/bin/ld: ../mysql/archive_output_directory/libperconaserverclient.a(client_plugin.cc.o): undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
/usr/bin/ld: /lib/x86_64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

https://github.com/tarantool/libslave/tree/master/test

ligurio commented 4 years ago

With option WITH_TESTING two binaries appears in a build directory after compilation: test/db_filler and test/test_client. First one is a tool to create test data and second one is a test client to simulate libslave in interactive mode. We should create glue to use them a simple test for libslave.

ligurio commented 4 years ago

If Boost_FOUND is set then additionally test/unit_test is built. Unfortunately it failed to connect to MySQL: Could not mysql_real_connect(): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) : 2002 unknown location(0): fatal error: in "[&]() { test_SetBinlogPos(); }"

password is here - /etc/mysql/debian.cnf command line to connect - mysql -h localhost -u debian-sys-maint -D mysql -p


$ sudo ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock

$ mysql -h localhost -u debian-sys-maint -D mysql -p
$ # looks like we should use native_password here (https://stackoverflow.com/questions/41645309/mysql-error-access-denied-for-user-rootlocalhost)

$ sergeyb@pony:~/sources/MRG/libslave$ ./build/test/unit_test 
Running 18 test cases...
You probably should specify parameters to mysql in the file test/data/mysql.conf first
Invalid Format_description event: number_of_event_types 40 > 38
Met exception in get_remote_binlog cycle. Message: Invalid Format_description event
/home/sergeyb/sources/MRG/libslave/test/unit_test.cpp(464): error: in "[&]() { test_StartStopPosition(); }": Has not AFTER image, expected '12321' during
unit_test: /usr/include/boost/optional/optional.hpp:1190: boost::optional<T>::reference_const_type boost::optional<T>::get() const [with T = unsigned int; boost::optional<T>::reference_const_type = const unsigned int&]: Assertion `this->is_initialized()' failed.
unknown location(0): fatal error: in "[&]() { test_StartStopPosition(); }": signal: SIGABRT (application abort requested)
/home/sergeyb/sources/MRG/libslave/test/unit_test.cpp(464): last checkpoint
terminate called after throwing an instance of 'std::runtime_error'
  what():  mysql_fetch_row() failed: Unknown MySQL error : 2000
unknown location(0): fatal error: in "[&]() { test_SetBinlogPos(); }": signal: SIGABRT (application abort requested)
*** stack smashing detected ***: terminated
*** stack smashing detected ***: terminated
unknown location(0): fatal error: in "[&]() { test_Disconnect(); }": signal: SIGABRT (application abort requested)
Aborted (core dumped)

sergeyb@pony:~/sources/MRG/libslave$ ./build/test/db_filler -h 127.0.0.1 -u root -p root -d test -s test -l test -P 3306 -c 10 -b 64
1601302601 Recreating table test...                                      
1601302601 Getting slave current position...
Master pos before insert is 'binlog.000015:2904775, GTIDs=-'
1601302601 Inserting data...
Inserting bulk 10 from 10
Inserted in 0.028 seconds                                                
Master pos after insert is 'binlog.000015:2915815, GTIDs=-'
1601302602 Updating data...
Updated in 0.005 seconds
Master pos after update is 'binlog.000015:2932809, GTIDs=-'
1601302602 Recreating table test...
terminate called after throwing an instance of 'std::runtime_error'
  what():  mysql_query() failed: BLOB, TEXT, GEOMETRY or JSON column 'settings' can't have a default value : 1101 : [CREATE TABLE test(
id int NOT NULL auto_increment,
created timestamp NOT NULL DEFAULT 0,
updated timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
status enum('active','blocked','deleted') NOT NULL DEFAULT 'active',
system_status enum('active','blocked','deleted') NOT NULL DEFAULT 'active',
alias varchar(255) NOT NULL,
user_id int NOT NULL,
banner_template_id int NOT NULL,
type_id text NOT NULL,
flags set('default_dithering', 'console', 'ext_console', 'int_console', 'abstract', 'force_use_usergeo', 'filter_topics', 'filter_thematics', 'rtb
', 'own_ctr', 'interface_only') NOT NULL DEFAULT 'default_dithering,own_ctr',
banners_count int unsigned NOT NULL DEFAULT 2,
shows_threshold_coeff double not null default 1.0,
min_a_ratio double not null default 0.0,
cpm_limit int NOT NULL,
block_cpm_limit int NOT NULL,
a_block_cpm_limit int NOT NULL,
block_banners text NOT NULL,
borrow_ctr_pad_id varchar(255) NOT NULL,
borrow_ctr_coeff varchar(255) NOT NULL,
borrow_ctr_no_ctr_action enum('no_show', 'default', 'default_with_coeff') NOT NULL default 'default',
banner_units int NOT NULL default 10,
marketing_min_share double NOT NULL, 
cpm_limit_share double NOT NULL default 1.0,
thematics_similarity_threshold double NOT NULL default 1.0,
uniq_shows_limit_coeff double NOT NULL default 1.0,
settings text not null default "",
PRIMARY KEY (id)
)]
Aborted (core dumped)
$
ligurio commented 4 years ago

Enabled test in CI - https://travis-ci.org/github/tarantool/libslave/jobs/734284381

Running 18 test cases...
You probably should specify parameters to mysql in the file test/data/mysql.conf first
Invalid Format_description event: number_of_event_types 40 > 38
Met exception in get_remote_binlog cycle. Message: Invalid Format_description event
/home/travis/build/tarantool/libslave/test/unit_test.cpp(464): error: in "[&]() { test_StartStopPosition(); }": Has not AFTER image, expected '12321' during
/home/travis/build/tarantool/libslave/test/unit_test.cpp(475): error: in "[&]() { test_StartStopPosition(); }": Has invalid AFTER image with '412919552'while expected '12321' during 
Myslave: Error reading packet from server: Lost connection to MySQL server during query; mysql_error: 2013
Myslave: Error from MySQL: Lost connection to MySQL server during query
Binlog monitor was stopped. Binlog events are not listened.
terminate called after throwing an instance of 'std::runtime_error'
  what():  mysql_fetch_row() failed: Unknown MySQL error : 2000
unknown location(0): fatal error: in "[&]() { test_StartStopPosition(); }": signal: SIGABRT (application abort requested)
/home/travis/build/tarantool/libslave/test/unit_test.cpp(475): last checkpoint
Invalid Format_description event: number_of_event_types 40 > 38
Met exception in get_remote_binlog cycle. Message: Invalid Format_description event
Met exception in get_remote_binlog cycle. Message: boost::bad_any_cast: failed conversion using boost::any_cast
*** stack smashing detected ***: terminated
unknown location(0): fatal error: in "[&]() { test_SetBinlogPos(); }": signal: SIGABRT (application abort requested)
terminate called recursively
unknown location(0): fatal error: in "[&]() { test_Disconnect(); }": signal: SIGABRT (application abort requested)
unknown location(0): fatal error: in "[&]() { test_Stat(); }": memory access violation at address: 0x7ffd4cc64d88: invalid permissions
*** 6 failures are detected in the test module "Master Test Suite"
terminate called recursively
Aborted (core dumped)