From caa1033f65465a677ed63a957a25cc60ea3c17ca Mon Sep 17 00:00:00 2001 From: esha <shadrin.e@gmail.com> Date: Fri, 21 Mar 2014 16:35:54 +0400 Subject: [PATCH] Fixed sql(common, pg, mysql) and sophia tests purpose: OOS-build tests fail --- test/module/net_sql.common.lua | 4 +++- test/module/net_sql.common.result | 2 +- test/module/net_sql.common.test | 4 ++++ test/module/net_sql.mysql.lua | 4 +++- test/module/net_sql.mysql.result | 6 +++--- test/module/net_sql.mysql.skipcond | 7 ++++--- test/module/net_sql.mysql.test | 14 ++++++++++++-- test/module/net_sql.pg.lua | 4 +++- test/module/net_sql.pg.result | 10 +++++----- test/module/net_sql.pg.skipcond | 7 ++++--- test/module/net_sql.pg.test | 14 ++++++++++++-- test/module/sophia.test | 7 +++++-- test/test-run.py | 14 +++----------- 13 files changed, 62 insertions(+), 35 deletions(-) diff --git a/test/module/net_sql.common.lua b/test/module/net_sql.common.lua index 715defa432..22f4ea4aed 100644 --- a/test/module/net_sql.common.lua +++ b/test/module/net_sql.common.lua @@ -1,4 +1,6 @@ -package.path = "../../src/module/sql/?.lua;"..package.path +package.path = os.getenv("TARANTOOL_SRC_DIR").."/src/module/sql/?.lua" +package.cpath = "?.so" + require("sql") if type(box.net.sql) ~= "table" then error("net.sql load failed") diff --git a/test/module/net_sql.common.result b/test/module/net_sql.common.result index 2d07734260..4f6b6e6b3b 100644 --- a/test/module/net_sql.common.result +++ b/test/module/net_sql.common.result @@ -4,5 +4,5 @@ lua type(box.net.sql) ... lua c = box.net.sql.connect('abcd') --- -error: '../../src/module/sql/sql.lua:29: Unknown driver ''abcd''' +error: src/module/sql/sql.lua:29: Unknown driver ''abcd''' ... diff --git a/test/module/net_sql.common.test b/test/module/net_sql.common.test index b7e5db3a07..f4c6e5759e 100644 --- a/test/module/net_sql.common.test +++ b/test/module/net_sql.common.test @@ -1,8 +1,12 @@ # encoding: tarantool +import sys server.stop() server.deploy(init_lua="module/net_sql.common.lua") +sys.stdout.push_filter("error: .*/src/module/sql/sql.lua", "error: src/module/sql/sql.lua") + exec admin "lua type(box.net.sql)" exec admin "lua c = box.net.sql.connect('abcd')" +sys.stdout.clear_all_filters() diff --git a/test/module/net_sql.mysql.lua b/test/module/net_sql.mysql.lua index d3ff697f24..fff78eeca2 100644 --- a/test/module/net_sql.mysql.lua +++ b/test/module/net_sql.mysql.lua @@ -1,4 +1,6 @@ -package.path = "../../src/module/sql/?.lua;"..package.path +package.path = os.getenv("TARANTOOL_SRC_DIR").."/src/module/sql/?.lua" +package.cpath = "?.so" + require("sql") if type(box.net.sql) ~= "table" then error("net.sql load failed") diff --git a/test/module/net_sql.mysql.result b/test/module/net_sql.mysql.result index 4c32f11aa2..38e854a3f8 100644 --- a/test/module/net_sql.mysql.result +++ b/test/module/net_sql.mysql.result @@ -1,10 +1,10 @@ lua c = box.net.sql.connect('abcd') --- -error: '../../src/module/sql/sql.lua:29: Unknown driver ''abcd''' +error: src/module/sql/sql.lua:29: Unknown driver ''abcd''' ... lua c = box.net.sql.connect('mysql') --- -error: '../../src/module/sql/sql.lua:64: Usage: box.net.sql.connect(''mysql'', host, port, user, password, db, ...)' +error: src/module/sql/sql.lua:64: Usage: box.net.sql.connect(''mysql'', host, port, user, password, db, ...)' ... lua dump = function(v) return box.cjson.encode(v) end --- @@ -33,7 +33,7 @@ port: string ... lua c:execute('SEL ECT 1') --- -error: '../../src/module/sql/sql.lua:105: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''SEL ECT 1'' at line 1' +error: src/module/sql/sql.lua:105: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''SEL ECT 1'' at line 1' ... lua dump({c:execute('SELECT ? AS bool1, ? AS bool2, ? AS nil, ? AS num, ? AS str', true, false, nil, 123, 'abc')}) --- diff --git a/test/module/net_sql.mysql.skipcond b/test/module/net_sql.mysql.skipcond index a9ba5af05b..1ea7c51207 100644 --- a/test/module/net_sql.mysql.skipcond +++ b/test/module/net_sql.mysql.skipcond @@ -3,7 +3,8 @@ import os try: - (host, port, user, password, db) = os.getenv('MYSQL').split(':') - + (host, port, user, password, db) = os.getenv('MYSQL').split(':') + if not os.path.exists(os.path.join(self.args.builddir, 'src/module/mysql/mysql.so')): + raise RuntimeError('No MySQL module found') except (RuntimeError, TypeError, NameError, AttributeError, ValueError): - self.skip = 1 + self.skip = 1 diff --git a/test/module/net_sql.mysql.test b/test/module/net_sql.mysql.test index 8f879eae50..df5856a3ad 100644 --- a/test/module/net_sql.mysql.test +++ b/test/module/net_sql.mysql.test @@ -1,15 +1,22 @@ # encoding: tarantool import os import shutil +import sys module_path = os.path.join(vardir, "box/net") module_path_so = module_path + "/mysql.so" -os.makedirs(module_path) -shutil.copy("../src/module/mysql/mysql.so", module_path_so) +try: + os.makedirs(module_path) +except OSError: + pass + +shutil.copy(os.path.join(self.args.builddir, "src/module/mysql/mysql.so"), module_path_so) server.stop() server.deploy(init_lua="module/net_sql.mysql.lua") +sys.stdout.push_filter("error: .*/src/module/sql/sql.lua", "error: src/module/sql/sql.lua") + exec admin "lua c = box.net.sql.connect('abcd')" exec admin "lua c = box.net.sql.connect('mysql')" exec admin "lua dump = function(v) return box.cjson.encode(v) end" @@ -39,3 +46,6 @@ exec admin "lua c:commit()" os.unlink(module_path_so) os.removedirs(module_path) + +sys.stdout.clear_all_filters() + diff --git a/test/module/net_sql.pg.lua b/test/module/net_sql.pg.lua index 6711d955d3..9db3a2097c 100644 --- a/test/module/net_sql.pg.lua +++ b/test/module/net_sql.pg.lua @@ -1,4 +1,6 @@ -package.path = "../../src/module/sql/?.lua;"..package.path +package.path = os.getenv("TARANTOOL_SRC_DIR").."/src/module/sql/?.lua" +package.cpath = "?.so" + require("sql") if type(box.net.sql) ~= "table" then error("net.sql load failed") diff --git a/test/module/net_sql.pg.result b/test/module/net_sql.pg.result index c0477b13e5..d5231f0eac 100644 --- a/test/module/net_sql.pg.result +++ b/test/module/net_sql.pg.result @@ -1,10 +1,10 @@ lua c = box.net.sql.connect('abcd') --- -error: '../../src/module/sql/sql.lua:29: Unknown driver ''abcd''' +error: src/module/sql/sql.lua:29: Unknown driver ''abcd''' ... lua c = box.net.sql.connect('pg') --- -error: '../../src/module/sql/sql.lua:64: Usage: box.net.sql.connect(''pg'', host, port, user, password, db, ...)' +error: src/module/sql/sql.lua:64: Usage: box.net.sql.connect(''pg'', host, port, user, password, db, ...)' ... lua dump = function(v) return box.cjson.encode(v) end --- @@ -72,7 +72,7 @@ lua dump({c:select('SELECT * FROM (VALUES (1,2), (2,3)) t')}) ... lua dump({c:single('SELECT * FROM (VALUES (1,2), (2,3)) t')}) --- -error: '../../src/module/sql/sql.lua:156: SQL request returned multiply rows' +error: src/module/sql/sql.lua:156: SQL request returned multiply rows' ... lua dump({c:single('SELECT * FROM (VALUES (1,2)) t')}) --- @@ -84,14 +84,14 @@ lua dump({c:perform('SELECT * FROM (VALUES (1,2), (2,3)) t')}) ... lua c:execute('SELEC T') --- -error: '../../src/module/sql/sql.lua:105: ERROR: syntax error at or near "SELEC" +error: src/module/sql/sql.lua:105: ERROR: syntax error at or near "SELEC" LINE 1: SELEC T ^ ' ... lua c = box.net.sql.connect('abcd') --- -error: '../../src/module/sql/sql.lua:29: Unknown driver ''abcd''' +error: src/module/sql/sql.lua:29: Unknown driver ''abcd''' ... lua c:quote('abc"cde"def') --- diff --git a/test/module/net_sql.pg.skipcond b/test/module/net_sql.pg.skipcond index 2eef42415d..b50d8f86ea 100644 --- a/test/module/net_sql.pg.skipcond +++ b/test/module/net_sql.pg.skipcond @@ -3,7 +3,8 @@ import os try: - (host, port, user, password, db) = os.getenv('PG').split(':') - + (host, port, user, password, db) = os.getenv('PG').split(':') + if not os.path.exists(os.path.join(self.args.builddir, 'src/module/pg/pg.so')): + raise RuntimeError('No PG module found') except (RuntimeError, TypeError, NameError, AttributeError, ValueError): - self.skip = 1 + self.skip = 1 diff --git a/test/module/net_sql.pg.test b/test/module/net_sql.pg.test index 3d1144824f..a8ecf9a890 100644 --- a/test/module/net_sql.pg.test +++ b/test/module/net_sql.pg.test @@ -1,15 +1,22 @@ # encoding: tarantool import os import shutil +import sys module_path = os.path.join(vardir, "box/net") module_path_so = module_path + "/pg.so" -os.makedirs(module_path) -shutil.copy("../src/module/pg/pg.so", module_path_so) +try: + os.makedirs(module_path) +except OSError: + pass + +shutil.copy(os.path.join(self.args.builddir,"src/module/pg/pg.so"), module_path_so) server.stop() server.deploy(init_lua="module/net_sql.pg.lua") +sys.stdout.push_filter("error: .*/src/module/sql/sql.lua", "error: src/module/sql/sql.lua") + exec admin "lua c = box.net.sql.connect('abcd')" exec admin "lua c = box.net.sql.connect('pg')" @@ -53,3 +60,6 @@ exec admin "lua c:txn(function(dbi) dbi:single('SELECT 1') end)" os.unlink(module_path_so) os.removedirs(module_path) + +sys.stdout.clear_all_filters() + diff --git a/test/module/sophia.test b/test/module/sophia.test index 2bb2613747..25a4c6fb95 100644 --- a/test/module/sophia.test +++ b/test/module/sophia.test @@ -4,8 +4,11 @@ import shutil module_path = os.path.join(vardir, "box") module_path_so = module_path + "/sophia.so" -os.makedirs(module_path) -shutil.copy("../src/module/sophia/sophia.so", module_path_so) +try: + os.makedirs(module_path) +except OSError: + pass +shutil.copy(os.path.join(self.args.builddir, "src/module/sophia/sophia.so"), module_path_so) server.stop() server.deploy(init_lua="module/sophia.lua") diff --git a/test/test-run.py b/test/test-run.py index 143b402277..ed8759e072 100755 --- a/test/test-run.py +++ b/test/test-run.py @@ -137,22 +137,13 @@ class Options: def setenv(): - os.putenv("TARANTOOL_PLUGIN_DIR", - string.join( - ( - os.path.join(os.getcwd(), '../src/plugin/mysql'), - os.path.join(os.getcwd(), '../src/plugin/pg') - ), - ':' - ) - ) + os.putenv("TARANTOOL_SRC_DIR", os.path.abspath('..')) ####################################################################### # Program body ####################################################################### def main(): - setenv() options = Options() oldcwd = os.getcwd() # Change the current working directory to where all test @@ -163,7 +154,8 @@ def main(): if not path: path = '.' os.chdir(path) - + setenv() + failed_tests = 0 try: -- GitLab