From 89ab44d50e985abbc8b461a40f3d9716313847cf Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Sun, 12 Mar 2017 10:45:03 +0300 Subject: [PATCH] Fix #119 (oltp_insert.lua + --auto-inc=0 fails) Fix oltp_insert.lua when run with --auto-inc disabled. Add regression tests. --- src/lua/oltp_insert.lua | 3 ++- tests/Makefile.am | 4 +--- tests/include/script_oltp_common.sh | 10 +++++++++- tests/t/script_oltp_insert_mysql.t | 6 ++++++ tests/t/script_oltp_insert_pgsql.t | 6 ++++++ tests/t/script_oltp_point_select_mysql.t | 6 ++++++ tests/t/script_oltp_point_select_pgsql.t | 6 ++++++ tests/t/script_oltp_read_write_mysql.t | 12 ++++++++++++ tests/t/script_oltp_read_write_pgsql.t | 6 ++++++ tests/test_run.sh | 6 ++++-- 10 files changed, 58 insertions(+), 7 deletions(-) diff --git a/src/lua/oltp_insert.lua b/src/lua/oltp_insert.lua index 042d4e5..62a5573 100755 --- a/src/lua/oltp_insert.lua +++ b/src/lua/oltp_insert.lua @@ -40,7 +40,8 @@ function event() if (sysbench.opt.auto_inc) then i = 0 else - i = sysbench.rand.unique() + -- Convert a uint32_t value to SQL INT + i = sysbench.rand.unique() - 2147483648 end con:query(string.format("INSERT INTO %s (id, k, c, pad) VALUES " .. diff --git a/tests/Makefile.am b/tests/Makefile.am index dfdb086..c003260 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -56,6 +56,4 @@ uninstall-local: rm -f -r $(DESTDIR)$(testdir) test: - PATH="$(top_srcdir)/third_party/cram/scripts:$$PATH" \ -PYTHONPATH="$(top_srcdir)/third_party/cram:$$PYTHONPATH" \ -./test_run.sh + ./test_run.sh diff --git a/tests/include/script_oltp_common.sh b/tests/include/script_oltp_common.sh index b421869..de34380 100644 --- a/tests/include/script_oltp_common.sh +++ b/tests/include/script_oltp_common.sh @@ -47,7 +47,7 @@ db_show_table sbtest6 || true # Error on non-existing table db_show_table sbtest7 || true # Error on non-existing table db_show_table sbtest8 || true # Error on non-existing table -# Test --create-secondary=off +echo "# Test --create-secondary=off" ARGS="${OLTP_SCRIPT_PATH} ${DB_DRIVER_ARGS} ${SB_EXTRA_ARGS} --tables=1" sysbench --create-secondary=off $ARGS prepare @@ -55,3 +55,11 @@ sysbench --create-secondary=off $ARGS prepare db_show_table sbtest1 sysbench $ARGS cleanup + +echo "# Test --auto-inc=off" + +ARGS="$ARGS --auto-inc=off --verbosity=1" + +sysbench $ARGS prepare +sysbench $ARGS run +sysbench $ARGS cleanup diff --git a/tests/t/script_oltp_insert_mysql.t b/tests/t/script_oltp_insert_mysql.t index aed2542..f38d246 100644 --- a/tests/t/script_oltp_insert_mysql.t +++ b/tests/t/script_oltp_insert_mysql.t @@ -177,6 +177,7 @@ oltp_point_select.lua + MySQL tests ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest6' doesn't exist ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest7' doesn't exist ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest8' doesn't exist + # Test --create-secondary=off sysbench * (glob) Creating table 'sbtest1'... @@ -193,3 +194,8 @@ oltp_point_select.lua + MySQL tests sysbench * (glob) Dropping table 'sbtest1'... + # Test --auto-inc=off + Creating table 'sbtest1'... + Inserting 10000 records into 'sbtest1' + Creating a secondary index on 'sbtest1'... + Dropping table 'sbtest1'... diff --git a/tests/t/script_oltp_insert_pgsql.t b/tests/t/script_oltp_insert_pgsql.t index d46351f..6aece5c 100644 --- a/tests/t/script_oltp_insert_pgsql.t +++ b/tests/t/script_oltp_insert_pgsql.t @@ -178,6 +178,7 @@ oltp_point_select.lua + PostgreSQL tests Did not find any relation named "sbtest6". Did not find any relation named "sbtest7". Did not find any relation named "sbtest8". + # Test --create-secondary=off sysbench * (glob) Creating table 'sbtest1'... @@ -195,3 +196,8 @@ oltp_point_select.lua + PostgreSQL tests sysbench * (glob) Dropping table 'sbtest1'... + # Test --auto-inc=off + Creating table 'sbtest1'... + Inserting 10000 records into 'sbtest1' + Creating a secondary index on 'sbtest1'... + Dropping table 'sbtest1'... diff --git a/tests/t/script_oltp_point_select_mysql.t b/tests/t/script_oltp_point_select_mysql.t index 3bce8e0..32ee33d 100644 --- a/tests/t/script_oltp_point_select_mysql.t +++ b/tests/t/script_oltp_point_select_mysql.t @@ -177,6 +177,7 @@ oltp_point_select.lua + MySQL tests ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest6' doesn't exist ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest7' doesn't exist ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest8' doesn't exist + # Test --create-secondary=off sysbench * (glob) Creating table 'sbtest1'... @@ -193,3 +194,8 @@ oltp_point_select.lua + MySQL tests sysbench * (glob) Dropping table 'sbtest1'... + # Test --auto-inc=off + Creating table 'sbtest1'... + Inserting 10000 records into 'sbtest1' + Creating a secondary index on 'sbtest1'... + Dropping table 'sbtest1'... diff --git a/tests/t/script_oltp_point_select_pgsql.t b/tests/t/script_oltp_point_select_pgsql.t index 79a2517..322d3bb 100644 --- a/tests/t/script_oltp_point_select_pgsql.t +++ b/tests/t/script_oltp_point_select_pgsql.t @@ -178,6 +178,7 @@ oltp_point_select.lua + PostgreSQL tests Did not find any relation named "sbtest6". Did not find any relation named "sbtest7". Did not find any relation named "sbtest8". + # Test --create-secondary=off sysbench * (glob) Creating table 'sbtest1'... @@ -195,3 +196,8 @@ oltp_point_select.lua + PostgreSQL tests sysbench * (glob) Dropping table 'sbtest1'... + # Test --auto-inc=off + Creating table 'sbtest1'... + Inserting 10000 records into 'sbtest1' + Creating a secondary index on 'sbtest1'... + Dropping table 'sbtest1'... diff --git a/tests/t/script_oltp_read_write_mysql.t b/tests/t/script_oltp_read_write_mysql.t index 16182de..d68e423 100644 --- a/tests/t/script_oltp_read_write_mysql.t +++ b/tests/t/script_oltp_read_write_mysql.t @@ -181,6 +181,7 @@ oltp_read_write.lua + MySQL tests ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest6' doesn't exist ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest7' doesn't exist ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest8' doesn't exist + # Test --create-secondary=off sysbench * (glob) Creating table 'sbtest1'... @@ -196,6 +197,11 @@ oltp_read_write.lua + MySQL tests ) ENGINE=MyISAM AUTO_INCREMENT=10001 DEFAULT CHARSET=* (glob) sysbench * (glob) + Dropping table 'sbtest1'... + # Test --auto-inc=off + Creating table 'sbtest1'... + Inserting 10000 records into 'sbtest1' + Creating a secondary index on 'sbtest1'... Dropping table 'sbtest1'... $ DB_DRIVER_ARGS="--db-driver=mysql --mysql-storage-engine=innodb $SBTEST_MYSQL_ARGS" @@ -372,6 +378,7 @@ oltp_read_write.lua + MySQL tests ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest6' doesn't exist ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest7' doesn't exist ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest8' doesn't exist + # Test --create-secondary=off sysbench * (glob) Creating table 'sbtest1'... @@ -388,3 +395,8 @@ oltp_read_write.lua + MySQL tests sysbench * (glob) Dropping table 'sbtest1'... + # Test --auto-inc=off + Creating table 'sbtest1'... + Inserting 10000 records into 'sbtest1' + Creating a secondary index on 'sbtest1'... + Dropping table 'sbtest1'... diff --git a/tests/t/script_oltp_read_write_pgsql.t b/tests/t/script_oltp_read_write_pgsql.t index 807ac1e..522b15c 100644 --- a/tests/t/script_oltp_read_write_pgsql.t +++ b/tests/t/script_oltp_read_write_pgsql.t @@ -181,6 +181,7 @@ oltp_read_write.lua + PostgreSQL tests Did not find any relation named "sbtest6". Did not find any relation named "sbtest7". Did not find any relation named "sbtest8". + # Test --create-secondary=off sysbench * (glob) Creating table 'sbtest1'... @@ -198,3 +199,8 @@ oltp_read_write.lua + PostgreSQL tests sysbench * (glob) Dropping table 'sbtest1'... + # Test --auto-inc=off + Creating table 'sbtest1'... + Inserting 10000 records into 'sbtest1' + Creating a secondary index on 'sbtest1'... + Dropping table 'sbtest1'... diff --git a/tests/test_run.sh b/tests/test_run.sh index 4193c11..991e9b7 100755 --- a/tests/test_run.sh +++ b/tests/test_run.sh @@ -42,8 +42,6 @@ ${dirlist[@]}" exit 1 fi -PATH="${sysbench_dir}:$PATH" - if [ -z ${srcdir+x} ] then SBTEST_INCDIR="$PWD/include" @@ -74,6 +72,10 @@ export SBTEST_SUITEDIR="$testroot/t" export SBTEST_CONFIG export SBTEST_INCDIR +# Add directories containing sysbench and cram to PATH +export PATH="${sysbench_dir}:${SBTEST_ROOTDIR}/../third_party/cram/scripts:$PATH" + +export PYTHONPATH="${SBTEST_ROOTDIR}/../third_party/cram:$PYTHONPATH" export LUA_PATH="$SBTEST_SCRIPTDIR/?.lua" . $SBTEST_CONFIG