Move oltp_point_select.lua from sysbench/tests/db/ to sysbench/lua/.

Move oltp_point_select.lua to the sysbench/lua/ directory. Add basic
regression tests.
This commit is contained in:
Alexey Kopytov
2017-01-15 16:13:14 +03:00
parent ebc2cb5420
commit 84fed669cc
9 changed files with 407 additions and 196 deletions

View File

@ -16,5 +16,5 @@
SUBDIRS = internal
dist_pkgdata_DATA = common.lua oltp.lua
dist_pkgdata_DATA = oltp_common.lua oltp.lua \
oltp_point_select.lua

View File

@ -1,190 +0,0 @@
-- Input parameters
-- oltp-tables-count - number of tables to create
-- oltp-secondary - use secondary key instead PRIMARY key for id column
--
--
function create_insert(table_id)
local index_name
local i
local j
local query
if (oltp_secondary) then
index_name = "KEY xid"
else
index_name = "PRIMARY KEY"
end
if (pgsql_variant == 'redshift') then
auto_inc_type = "INTEGER IDENTITY(1,1)"
else
auto_inc_type = "SERIAL"
end
i = table_id
print("Creating table 'sbtest" .. i .. "'...")
if ((db_driver == "mysql") or (db_driver == "attachsql")) then
query = [[
CREATE TABLE sbtest]] .. i .. [[ (
id INTEGER UNSIGNED NOT NULL ]] ..
((oltp_auto_inc and "AUTO_INCREMENT") or "") .. [[,
k INTEGER UNSIGNED DEFAULT '0' NOT NULL,
c CHAR(120) DEFAULT '' NOT NULL,
pad CHAR(60) DEFAULT '' NOT NULL,
]] .. index_name .. [[ (id)
) /*! ENGINE = ]] .. mysql_table_engine ..
" MAX_ROWS = " .. myisam_max_rows .. " */ " ..
(mysql_table_options or "")
elseif (db_driver == "pgsql") then
query = [[
CREATE TABLE sbtest]] .. i .. [[ (
id ]] .. auto_inc_type .. [[ NOT NULL,
k INTEGER DEFAULT '0' NOT NULL,
c CHAR(120) DEFAULT '' NOT NULL,
pad CHAR(60) DEFAULT '' NOT NULL,
]] .. index_name .. [[ (id)
) ]]
elseif (db_driver == "drizzle") then
query = [[
CREATE TABLE sbtest (
id INTEGER NOT NULL ]] .. ((oltp_auto_inc and "AUTO_INCREMENT") or "") .. [[,
k INTEGER DEFAULT '0' NOT NULL,
c CHAR(120) DEFAULT '' NOT NULL,
pad CHAR(60) DEFAULT '' NOT NULL,
]] .. index_name .. [[ (id)
) ]]
else
print("Unknown database driver: " .. db_driver)
return 1
end
db_query(query)
print("Inserting " .. oltp_table_size .. " records into 'sbtest" .. i .. "'")
if (oltp_auto_inc) then
db_bulk_insert_init("INSERT INTO sbtest" .. i .. "(k, c, pad) VALUES")
else
db_bulk_insert_init("INSERT INTO sbtest" .. i .. "(id, k, c, pad) VALUES")
end
local c_val
local pad_val
for j = 1,oltp_table_size do
c_val = sb_rand_str([[
###########-###########-###########-###########-###########-###########-###########-###########-###########-###########]])
pad_val = sb_rand_str([[
###########-###########-###########-###########-###########]])
if (oltp_auto_inc) then
db_bulk_insert_next("(" .. sb_rand(1, oltp_table_size) .. ", '".. c_val .."', '" .. pad_val .. "')")
else
db_bulk_insert_next("("..j.."," .. sb_rand(1, oltp_table_size) .. ",'".. c_val .."', '" .. pad_val .. "' )")
end
end
db_bulk_insert_done()
if oltp_create_secondary then
print("Creating secondary indexes on 'sbtest" .. i .. "'...")
db_query("CREATE INDEX k_" .. i .. " on sbtest" .. i .. "(k)")
end
end
function prepare()
local query
local i
local j
set_vars()
db_connect()
for i = 1,oltp_tables_count do
create_insert(i)
end
return 0
end
function cleanup()
local i
set_vars()
for i = 1,oltp_tables_count do
print("Dropping table 'sbtest" .. i .. "'...")
db_query("DROP TABLE IF EXISTS sbtest".. i )
end
end
function set_vars()
oltp_table_size = tonumber(oltp_table_size) or 10000
oltp_range_size = tonumber(oltp_range_size) or 100
oltp_tables_count = tonumber(oltp_tables_count) or 1
oltp_point_selects = tonumber(oltp_point_selects) or 10
oltp_simple_ranges = tonumber(oltp_simple_ranges) or 1
oltp_sum_ranges = tonumber(oltp_sum_ranges) or 1
oltp_order_ranges = tonumber(oltp_order_ranges) or 1
oltp_distinct_ranges = tonumber(oltp_distinct_ranges) or 1
oltp_index_updates = tonumber(oltp_index_updates) or 1
oltp_non_index_updates = tonumber(oltp_non_index_updates) or 1
oltp_delete_inserts = tonumber(oltp_delete_inserts) or 1
if (oltp_range_selects == 'off') then
oltp_range_selects = false
else
oltp_range_selects = true
end
if (oltp_auto_inc == 'off') then
oltp_auto_inc = false
else
oltp_auto_inc = true
end
if (oltp_read_only == 'on') then
oltp_read_only = true
else
oltp_read_only = false
end
if (oltp_write_only == 'on') then
oltp_write_only = true
else
oltp_write_only = false
end
if (oltp_read_only and oltp_write_only) then
error("--oltp-read-only and --oltp-write-only are mutually exclusive")
end
if (oltp_skip_trx == 'on') then
oltp_skip_trx = true
else
oltp_skip_trx = false
end
if (oltp_create_secondary == 'off') then
oltp_create_secondary = false
else
oltp_create_secondary = true
end
if (pgsql_variant == 'redshift') then
oltp_create_secondary = false
oltp_delete_inserts = 0
end
end

View File

@ -17,8 +17,6 @@
dist_pkgdata_DATA = delete.lua insert.lua bulk_insert.lua \
oltp_read_write.lua oltp_read_only.lua \
oltp_common.lua \
oltp_point_select.lua \
parallel_prepare.lua \
select_random_points.lua \
select_random_ranges.lua \

View File

@ -1,12 +1,13 @@
#!/usr/bin/env bash
#
################################################################################
# Common code for legacy OLTP tests
# Common code for OLTP tests
#
# Expects the following variables and callback functions to be defined by the
# caller:
#
# DB_DRIVER_ARGS -- extra driver-specific arguments to pass to sysbench
# OLTP_SCRIPT_PATH -- path to the script file to execute
#
# db_show_table() -- called with a single argument to dump a specified table
# schema
@ -14,7 +15,7 @@
set -eu
ARGS="--test=${SBTEST_INCDIR}/oltp_legacy/oltp.lua $DB_DRIVER_ARGS --oltp-tables-count=8"
ARGS="--test=${OLTP_SCRIPT_PATH} $DB_DRIVER_ARGS --oltp-tables-count=8"
sysbench $ARGS prepare

View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
#
OLTP_SCRIPT_PATH=${SBTEST_SCRIPTDIR}/oltp_point_select.lua
. ${SBTEST_INCDIR}/script_oltp_common.sh

View File

@ -0,0 +1,193 @@
########################################################################
oltp_point_select.lua + MySQL tests
########################################################################
$ if [ -z "${SBTEST_MYSQL_ARGS:-}" ]
> then
> exit 80
> fi
$ function db_show_table() {
> mysql -uroot sbtest -Nse "SHOW CREATE TABLE $1\G"
> }
$ DB_DRIVER_ARGS="--db-driver=mysql --mysql-table-engine=innodb $SBTEST_MYSQL_ARGS"
$ . $SBTEST_INCDIR/script_oltp_point_select_common.sh
sysbench *.* * (glob)
Creating table 'sbtest1'...
Inserting 10000 records into 'sbtest1'
Creating secondary indexes on 'sbtest1'...
Creating table 'sbtest2'...
Inserting 10000 records into 'sbtest2'
Creating secondary indexes on 'sbtest2'...
Creating table 'sbtest3'...
Inserting 10000 records into 'sbtest3'
Creating secondary indexes on 'sbtest3'...
Creating table 'sbtest4'...
Inserting 10000 records into 'sbtest4'
Creating secondary indexes on 'sbtest4'...
Creating table 'sbtest5'...
Inserting 10000 records into 'sbtest5'
Creating secondary indexes on 'sbtest5'...
Creating table 'sbtest6'...
Inserting 10000 records into 'sbtest6'
Creating secondary indexes on 'sbtest6'...
Creating table 'sbtest7'...
Inserting 10000 records into 'sbtest7'
Creating secondary indexes on 'sbtest7'...
Creating table 'sbtest8'...
Inserting 10000 records into 'sbtest8'
Creating secondary indexes on 'sbtest8'...
*************************** 1. row ***************************
sbtest1
CREATE TABLE `sbtest1` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`k` int(10) unsigned NOT NULL DEFAULT '0',
`c` char(120)* NOT NULL DEFAULT '', (glob)
`pad` char(60)* NOT NULL DEFAULT '', (glob)
PRIMARY KEY (`id`),
KEY `k_1` (`k`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=* MAX_ROWS=1000000 (glob)
*************************** 1. row ***************************
sbtest2
CREATE TABLE `sbtest2` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`k` int(10) unsigned NOT NULL DEFAULT '0',
`c` char(120)* NOT NULL DEFAULT '', (glob)
`pad` char(60)* NOT NULL DEFAULT '', (glob)
PRIMARY KEY (`id`),
KEY `k_2` (`k`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=* MAX_ROWS=1000000 (glob)
*************************** 1. row ***************************
sbtest3
CREATE TABLE `sbtest3` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`k` int(10) unsigned NOT NULL DEFAULT '0',
`c` char(120)* NOT NULL DEFAULT '', (glob)
`pad` char(60)* NOT NULL DEFAULT '', (glob)
PRIMARY KEY (`id`),
KEY `k_3` (`k`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=* MAX_ROWS=1000000 (glob)
*************************** 1. row ***************************
sbtest4
CREATE TABLE `sbtest4` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`k` int(10) unsigned NOT NULL DEFAULT '0',
`c` char(120)* NOT NULL DEFAULT '', (glob)
`pad` char(60)* NOT NULL DEFAULT '', (glob)
PRIMARY KEY (`id`),
KEY `k_4` (`k`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=* MAX_ROWS=1000000 (glob)
*************************** 1. row ***************************
sbtest5
CREATE TABLE `sbtest5` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`k` int(10) unsigned NOT NULL DEFAULT '0',
`c` char(120)* NOT NULL DEFAULT '', (glob)
`pad` char(60)* NOT NULL DEFAULT '', (glob)
PRIMARY KEY (`id`),
KEY `k_5` (`k`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=* MAX_ROWS=1000000 (glob)
*************************** 1. row ***************************
sbtest6
CREATE TABLE `sbtest6` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`k` int(10) unsigned NOT NULL DEFAULT '0',
`c` char(120)* NOT NULL DEFAULT '', (glob)
`pad` char(60)* NOT NULL DEFAULT '', (glob)
PRIMARY KEY (`id`),
KEY `k_6` (`k`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=* MAX_ROWS=1000000 (glob)
*************************** 1. row ***************************
sbtest7
CREATE TABLE `sbtest7` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`k` int(10) unsigned NOT NULL DEFAULT '0',
`c` char(120)* NOT NULL DEFAULT '', (glob)
`pad` char(60)* NOT NULL DEFAULT '', (glob)
PRIMARY KEY (`id`),
KEY `k_7` (`k`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=* MAX_ROWS=1000000 (glob)
*************************** 1. row ***************************
sbtest8
CREATE TABLE `sbtest8` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`k` int(10) unsigned NOT NULL DEFAULT '0',
`c` char(120)* NOT NULL DEFAULT '', (glob)
`pad` char(60)* NOT NULL DEFAULT '', (glob)
PRIMARY KEY (`id`),
KEY `k_8` (`k`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=* MAX_ROWS=1000000 (glob)
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest9' doesn't exist
sysbench *.* * (glob)
Running the test with following options:
Number of threads: 2
Initializing random number generator from current time
Initializing worker threads...
Threads started!
OLTP test statistics:
queries performed:
read: 100
write: 0
other: 0
total: 100
transactions: 100 (* per sec.) (glob)
queries: 100 (* per sec.) (glob)
ignored errors: 0 (* per sec.) (glob)
reconnects: 0 (* per sec.) (glob)
General statistics:
total time: *s (glob)
total number of events: 100
total time taken by event execution: *s (glob)
Latency statistics:
min: *.*ms (glob)
avg: *.*ms (glob)
max: *.*ms (glob)
approx. 95th percentile: *.*ms (glob)
Threads fairness:
events (avg/stddev): */* (glob)
execution time (avg/stddev): */* (glob)
sysbench *.* * (glob)
Dropping table 'sbtest1'...
Dropping table 'sbtest2'...
Dropping table 'sbtest3'...
Dropping table 'sbtest4'...
Dropping table 'sbtest5'...
Dropping table 'sbtest6'...
Dropping table 'sbtest7'...
Dropping table 'sbtest8'...
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest1' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest2' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest3' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest4' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest5' doesn't exist
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
sysbench * (glob)
Creating table 'sbtest1'...
Inserting 10000 records into 'sbtest1'
*************************** 1. row ***************************
sbtest1
CREATE TABLE `sbtest1` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`k` int(10) unsigned NOT NULL DEFAULT '0',
`c` char(120)* NOT NULL DEFAULT '', (glob)
`pad` char(60)* NOT NULL DEFAULT '', (glob)
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=* MAX_ROWS=1000000 (glob)
sysbench * (glob)
Dropping table 'sbtest1'...

View File

@ -0,0 +1,203 @@
########################################################################
oltp_point_select.lua + PostgreSQL tests
########################################################################
$ if [ -z "${SBTEST_PGSQL_ARGS:-}" ]
> then
> exit 80
> fi
$ DB_DRIVER_ARGS="--db-driver=pgsql $SBTEST_PGSQL_ARGS"
$ function db_show_table() {
> psql -c "\d+ $1" sbtest
> }
$ . $SBTEST_INCDIR/script_oltp_point_select_common.sh
sysbench *.* * (glob)
Creating table 'sbtest1'...
Inserting 10000 records into 'sbtest1'
Creating secondary indexes on 'sbtest1'...
Creating table 'sbtest2'...
Inserting 10000 records into 'sbtest2'
Creating secondary indexes on 'sbtest2'...
Creating table 'sbtest3'...
Inserting 10000 records into 'sbtest3'
Creating secondary indexes on 'sbtest3'...
Creating table 'sbtest4'...
Inserting 10000 records into 'sbtest4'
Creating secondary indexes on 'sbtest4'...
Creating table 'sbtest5'...
Inserting 10000 records into 'sbtest5'
Creating secondary indexes on 'sbtest5'...
Creating table 'sbtest6'...
Inserting 10000 records into 'sbtest6'
Creating secondary indexes on 'sbtest6'...
Creating table 'sbtest7'...
Inserting 10000 records into 'sbtest7'
Creating secondary indexes on 'sbtest7'...
Creating table 'sbtest8'...
Inserting 10000 records into 'sbtest8'
Creating secondary indexes on 'sbtest8'...
Table "public.sbtest1"
Column | Type | Modifiers | Storage | Stats target | Description
--------+----------------+------------------------------------------------------+----------+--------------+-------------
id | integer | not null default nextval('sbtest1_id_seq'::regclass) | plain | |
k | integer | not null default 0 | plain | |
c | character(120) | not null default ''::bpchar | extended | |
pad | character(60) | not null default ''::bpchar | extended | |
Indexes:
"sbtest1_pkey" PRIMARY KEY, btree (id)
"k_1" btree (k)
Table "public.sbtest2"
Column | Type | Modifiers | Storage | Stats target | Description
--------+----------------+------------------------------------------------------+----------+--------------+-------------
id | integer | not null default nextval('sbtest2_id_seq'::regclass) | plain | |
k | integer | not null default 0 | plain | |
c | character(120) | not null default ''::bpchar | extended | |
pad | character(60) | not null default ''::bpchar | extended | |
Indexes:
"sbtest2_pkey" PRIMARY KEY, btree (id)
"k_2" btree (k)
Table "public.sbtest3"
Column | Type | Modifiers | Storage | Stats target | Description
--------+----------------+------------------------------------------------------+----------+--------------+-------------
id | integer | not null default nextval('sbtest3_id_seq'::regclass) | plain | |
k | integer | not null default 0 | plain | |
c | character(120) | not null default ''::bpchar | extended | |
pad | character(60) | not null default ''::bpchar | extended | |
Indexes:
"sbtest3_pkey" PRIMARY KEY, btree (id)
"k_3" btree (k)
Table "public.sbtest4"
Column | Type | Modifiers | Storage | Stats target | Description
--------+----------------+------------------------------------------------------+----------+--------------+-------------
id | integer | not null default nextval('sbtest4_id_seq'::regclass) | plain | |
k | integer | not null default 0 | plain | |
c | character(120) | not null default ''::bpchar | extended | |
pad | character(60) | not null default ''::bpchar | extended | |
Indexes:
"sbtest4_pkey" PRIMARY KEY, btree (id)
"k_4" btree (k)
Table "public.sbtest5"
Column | Type | Modifiers | Storage | Stats target | Description
--------+----------------+------------------------------------------------------+----------+--------------+-------------
id | integer | not null default nextval('sbtest5_id_seq'::regclass) | plain | |
k | integer | not null default 0 | plain | |
c | character(120) | not null default ''::bpchar | extended | |
pad | character(60) | not null default ''::bpchar | extended | |
Indexes:
"sbtest5_pkey" PRIMARY KEY, btree (id)
"k_5" btree (k)
Table "public.sbtest6"
Column | Type | Modifiers | Storage | Stats target | Description
--------+----------------+------------------------------------------------------+----------+--------------+-------------
id | integer | not null default nextval('sbtest6_id_seq'::regclass) | plain | |
k | integer | not null default 0 | plain | |
c | character(120) | not null default ''::bpchar | extended | |
pad | character(60) | not null default ''::bpchar | extended | |
Indexes:
"sbtest6_pkey" PRIMARY KEY, btree (id)
"k_6" btree (k)
Table "public.sbtest7"
Column | Type | Modifiers | Storage | Stats target | Description
--------+----------------+------------------------------------------------------+----------+--------------+-------------
id | integer | not null default nextval('sbtest7_id_seq'::regclass) | plain | |
k | integer | not null default 0 | plain | |
c | character(120) | not null default ''::bpchar | extended | |
pad | character(60) | not null default ''::bpchar | extended | |
Indexes:
"sbtest7_pkey" PRIMARY KEY, btree (id)
"k_7" btree (k)
Table "public.sbtest8"
Column | Type | Modifiers | Storage | Stats target | Description
--------+----------------+------------------------------------------------------+----------+--------------+-------------
id | integer | not null default nextval('sbtest8_id_seq'::regclass) | plain | |
k | integer | not null default 0 | plain | |
c | character(120) | not null default ''::bpchar | extended | |
pad | character(60) | not null default ''::bpchar | extended | |
Indexes:
"sbtest8_pkey" PRIMARY KEY, btree (id)
"k_8" btree (k)
Did not find any relation named "sbtest9".
sysbench *.* * (glob)
Running the test with following options:
Number of threads: 2
Initializing random number generator from current time
Initializing worker threads...
Threads started!
OLTP test statistics:
queries performed:
read: 100
write: 0
other: 0
total: 100
transactions: 100 (* per sec.) (glob)
queries: 100 (* per sec.) (glob)
ignored errors: 0 (* per sec.) (glob)
reconnects: 0 (* per sec.) (glob)
General statistics:
total time: *s (glob)
total number of events: 100
total time taken by event execution: *s (glob)
Latency statistics:
min: *.*ms (glob)
avg: *.*ms (glob)
max: *.*ms (glob)
approx. 95th percentile: *.*ms (glob)
Threads fairness:
events (avg/stddev): */* (glob)
execution time (avg/stddev): */* (glob)
sysbench *.* * (glob)
Dropping table 'sbtest1'...
Dropping table 'sbtest2'...
Dropping table 'sbtest3'...
Dropping table 'sbtest4'...
Dropping table 'sbtest5'...
Dropping table 'sbtest6'...
Dropping table 'sbtest7'...
Dropping table 'sbtest8'...
Did not find any relation named "sbtest1".
Did not find any relation named "sbtest2".
Did not find any relation named "sbtest3".
Did not find any relation named "sbtest4".
Did not find any relation named "sbtest5".
Did not find any relation named "sbtest6".
Did not find any relation named "sbtest7".
Did not find any relation named "sbtest8".
sysbench * (glob)
Creating table 'sbtest1'...
Inserting 10000 records into 'sbtest1'
Table "public.sbtest1"
Column | Type | Modifiers | Storage | Stats target | Description
--------+----------------+------------------------------------------------------+----------+--------------+-------------
id | integer | not null default nextval('sbtest1_id_seq'::regclass) | plain | |
k | integer | not null default 0 | plain | |
c | character(120) | not null default ''::bpchar | extended | |
pad | character(60) | not null default ''::bpchar | extended | |
Indexes:
"sbtest1_pkey" PRIMARY KEY, btree (id)
sysbench * (glob)
Dropping table 'sbtest1'...