Tarantool development patches archive
 help / color / mirror / Atom feed
From: Nikita Pettik <korablev@tarantool.org>
To: tarantool-patches@dev.tarantool.org
Cc: v.shpilevoy@tarantool.org
Subject: [Tarantool-patches] [PATCH v2 03/10] test: move box.error tests to box/error.test.lua
Date: Wed, 25 Mar 2020 04:42:59 +0300	[thread overview]
Message-ID: <edbd0d6ae6f6fd3b900b3dea109cf390bf7b1aee.1585097339.git.korablev@tarantool.org> (raw)
In-Reply-To: <cover.1585097339.git.korablev@tarantool.org>
In-Reply-To: <cover.1585097339.git.korablev@tarantool.org>

We are going to introduce more tests related to error module, so let's
move all error-related tests from box/misc.test.lua to a separate test
file (box/error.test.lua).

Needed for #1148
---
 test/box/error.result   | 441 ++++++++++++++++++++++++++++++++++++++++
 test/box/error.test.lua |  80 ++++++++
 test/box/misc.result    | 423 --------------------------------------
 test/box/misc.test.lua  |  80 --------
 4 files changed, 521 insertions(+), 503 deletions(-)
 create mode 100644 test/box/error.result
 create mode 100644 test/box/error.test.lua

diff --git a/test/box/error.result b/test/box/error.result
new file mode 100644
index 000000000..9b6c8b462
--- /dev/null
+++ b/test/box/error.result
@@ -0,0 +1,441 @@
+-- test-run result file version 2
+env = require('test_run')
+ | ---
+ | ...
+test_run = env.new()
+ | ---
+ | ...
+
+space = box.schema.space.create('tweedledum')
+ | ---
+ | ...
+index = space:create_index('primary', { type = 'hash' })
+ | ---
+ | ...
+
+box.error({code = 123, reason = 'test'})
+ | ---
+ | - error: test
+ | ...
+box.error(box.error.ILLEGAL_PARAMS, "bla bla")
+ | ---
+ | - error: Illegal parameters, bla bla
+ | ...
+box.error()
+ | ---
+ | - error: Illegal parameters, bla bla
+ | ...
+e = box.error.last()
+ | ---
+ | ...
+e
+ | ---
+ | - Illegal parameters, bla bla
+ | ...
+e:unpack()
+ | ---
+ | - type: ClientError
+ |   code: 1
+ |   message: Illegal parameters, bla bla
+ |   trace:
+ |   - file: '[C]'
+ |     line: 4294967295
+ | ...
+e.type
+ | ---
+ | - ClientError
+ | ...
+e.code
+ | ---
+ | - 1
+ | ...
+e.message
+ | ---
+ | - Illegal parameters, bla bla
+ | ...
+tostring(e)
+ | ---
+ | - Illegal parameters, bla bla
+ | ...
+e = nil
+ | ---
+ | ...
+box.error.clear()
+ | ---
+ | ...
+box.error.last()
+ | ---
+ | - null
+ | ...
+space = box.space.tweedledum
+ | ---
+ | ...
+
+--
+-- gh-2080: box.error() crashes with wrong parameters
+box.error(box.error.UNSUPPORTED, "x", "x%s")
+ | ---
+ | - error: x does not support x%s
+ | ...
+box.error(box.error.UNSUPPORTED, "x")
+ | ---
+ | - error: 'bad argument #3 to ''?'' (no value)'
+ | ...
+box.error(box.error.UNSUPPORTED)
+ | ---
+ | - error: 'box.error(): bad arguments'
+ | ...
+
+--
+-- gh-3031: allow to create an error object with no throwing it.
+--
+e = box.error.new(box.error.UNKNOWN)
+ | ---
+ | ...
+e
+ | ---
+ | - Unknown error
+ | ...
+e = box.error.new(box.error.CREATE_SPACE, "space", "error")
+ | ---
+ | ...
+e
+ | ---
+ | - 'Failed to create space ''space'': error'
+ | ...
+box.error.new()
+ | ---
+ | - error: 'Usage: box.error.new(code, args)'
+ | ...
+
+--
+-- gh-4489: box.error has __concat metamethod
+--
+test_run:cmd("push filter '(.builtin/.*.lua):[0-9]+' to '\\1'")
+ | ---
+ | - true
+ | ...
+e = box.error.new(box.error.UNKNOWN)
+ | ---
+ | ...
+'left side: ' .. e
+ | ---
+ | - 'left side: Unknown error'
+ | ...
+e .. ': right side'
+ | ---
+ | - 'Unknown error: right side'
+ | ...
+e .. nil
+ | ---
+ | - error: 'builtin/error.lua: attempt to concatenate local ''rhs'' (a nil value)'
+ | ...
+nil .. e
+ | ---
+ | - error: 'builtin/error.lua: attempt to concatenate local ''lhs'' (a nil value)'
+ | ...
+e .. box.NULL
+ | ---
+ | - error: 'builtin/error.lua: attempt to concatenate ''string'' and ''void *'''
+ | ...
+box.NULL .. e
+ | ---
+ | - error: 'builtin/error.lua: attempt to concatenate ''void *'' and ''string'''
+ | ...
+123 .. e
+ | ---
+ | - 123Unknown error
+ | ...
+e .. 123
+ | ---
+ | - Unknown error123
+ | ...
+e .. e
+ | ---
+ | - Unknown errorUnknown error
+ | ...
+e .. {}
+ | ---
+ | - error: 'builtin/error.lua: attempt to concatenate local ''rhs'' (a table value)'
+ | ...
+{} .. e
+ | ---
+ | - error: 'builtin/error.lua: attempt to concatenate local ''lhs'' (a table value)'
+ | ...
+-1ULL .. e
+ | ---
+ | - error: 'builtin/error.lua: attempt to concatenate ''uint64_t'' and ''string'''
+ | ...
+e .. -1ULL
+ | ---
+ | - error: 'builtin/error.lua: attempt to concatenate ''string'' and ''uint64_t'''
+ | ...
+1LL .. e
+ | ---
+ | - error: 'builtin/error.lua: attempt to concatenate ''int64_t'' and ''string'''
+ | ...
+e .. 1LL
+ | ---
+ | - error: 'builtin/error.lua: attempt to concatenate ''string'' and ''int64_t'''
+ | ...
+e = nil
+ | ---
+ | ...
+
+--
+-- System errors expose errno as a field.
+--
+_, err = require('fio').open('not_existing_file')
+ | ---
+ | ...
+type(err.errno)
+ | ---
+ | - number
+ | ...
+-- Errors not related to the standard library do
+-- not expose errno.
+err = box.error.new(box.error.PROC_LUA, "errno")
+ | ---
+ | ...
+type(err.errno)
+ | ---
+ | - nil
+ | ...
+
+t = {}
+ | ---
+ | ...
+test_run:cmd("setopt delimiter ';'")
+ | ---
+ | - true
+ | ...
+
+for k,v in pairs(box.error) do
+   if type(v) == 'number' then
+    t[v] = 'box.error.'..tostring(k)
+   end
+end;
+ | ---
+ | ...
+t;
+ | ---
+ | - 0: box.error.UNKNOWN
+ |   1: box.error.ILLEGAL_PARAMS
+ |   2: box.error.MEMORY_ISSUE
+ |   3: box.error.TUPLE_FOUND
+ |   4: box.error.TUPLE_NOT_FOUND
+ |   5: box.error.UNSUPPORTED
+ |   6: box.error.NONMASTER
+ |   7: box.error.READONLY
+ |   8: box.error.INJECTION
+ |   9: box.error.CREATE_SPACE
+ |   10: box.error.SPACE_EXISTS
+ |   11: box.error.DROP_SPACE
+ |   12: box.error.ALTER_SPACE
+ |   13: box.error.INDEX_TYPE
+ |   14: box.error.MODIFY_INDEX
+ |   15: box.error.LAST_DROP
+ |   16: box.error.TUPLE_FORMAT_LIMIT
+ |   17: box.error.DROP_PRIMARY_KEY
+ |   18: box.error.KEY_PART_TYPE
+ |   19: box.error.EXACT_MATCH
+ |   20: box.error.INVALID_MSGPACK
+ |   21: box.error.PROC_RET
+ |   22: box.error.TUPLE_NOT_ARRAY
+ |   23: box.error.FIELD_TYPE
+ |   24: box.error.INDEX_PART_TYPE_MISMATCH
+ |   25: box.error.UPDATE_SPLICE
+ |   26: box.error.UPDATE_ARG_TYPE
+ |   27: box.error.FORMAT_MISMATCH_INDEX_PART
+ |   28: box.error.UNKNOWN_UPDATE_OP
+ |   29: box.error.UPDATE_FIELD
+ |   30: box.error.FUNCTION_TX_ACTIVE
+ |   31: box.error.KEY_PART_COUNT
+ |   32: box.error.PROC_LUA
+ |   33: box.error.NO_SUCH_PROC
+ |   34: box.error.NO_SUCH_TRIGGER
+ |   35: box.error.NO_SUCH_INDEX_ID
+ |   36: box.error.NO_SUCH_SPACE
+ |   37: box.error.NO_SUCH_FIELD_NO
+ |   38: box.error.EXACT_FIELD_COUNT
+ |   39: box.error.FIELD_MISSING
+ |   40: box.error.WAL_IO
+ |   41: box.error.MORE_THAN_ONE_TUPLE
+ |   42: box.error.ACCESS_DENIED
+ |   43: box.error.CREATE_USER
+ |   44: box.error.DROP_USER
+ |   45: box.error.NO_SUCH_USER
+ |   46: box.error.USER_EXISTS
+ |   47: box.error.PASSWORD_MISMATCH
+ |   48: box.error.UNKNOWN_REQUEST_TYPE
+ |   49: box.error.UNKNOWN_SCHEMA_OBJECT
+ |   50: box.error.CREATE_FUNCTION
+ |   51: box.error.NO_SUCH_FUNCTION
+ |   52: box.error.FUNCTION_EXISTS
+ |   53: box.error.BEFORE_REPLACE_RET
+ |   54: box.error.MULTISTATEMENT_TRANSACTION
+ |   55: box.error.TRIGGER_EXISTS
+ |   56: box.error.USER_MAX
+ |   57: box.error.NO_SUCH_ENGINE
+ |   58: box.error.RELOAD_CFG
+ |   59: box.error.CFG
+ |   60: box.error.SAVEPOINT_EMPTY_TX
+ |   61: box.error.NO_SUCH_SAVEPOINT
+ |   62: box.error.UNKNOWN_REPLICA
+ |   63: box.error.REPLICASET_UUID_MISMATCH
+ |   64: box.error.INVALID_UUID
+ |   65: box.error.REPLICASET_UUID_IS_RO
+ |   66: box.error.INSTANCE_UUID_MISMATCH
+ |   68: box.error.INVALID_ORDER
+ |   69: box.error.MISSING_REQUEST_FIELD
+ |   70: box.error.IDENTIFIER
+ |   71: box.error.DROP_FUNCTION
+ |   72: box.error.ITERATOR_TYPE
+ |   73: box.error.REPLICA_MAX
+ |   74: box.error.INVALID_XLOG
+ |   75: box.error.INVALID_XLOG_NAME
+ |   76: box.error.INVALID_XLOG_ORDER
+ |   77: box.error.NO_CONNECTION
+ |   78: box.error.TIMEOUT
+ |   79: box.error.ACTIVE_TRANSACTION
+ |   80: box.error.CURSOR_NO_TRANSACTION
+ |   81: box.error.CROSS_ENGINE_TRANSACTION
+ |   82: box.error.NO_SUCH_ROLE
+ |   83: box.error.ROLE_EXISTS
+ |   84: box.error.CREATE_ROLE
+ |   85: box.error.INDEX_EXISTS
+ |   86: box.error.SESSION_CLOSED
+ |   87: box.error.ROLE_LOOP
+ |   88: box.error.GRANT
+ |   89: box.error.PRIV_GRANTED
+ |   90: box.error.ROLE_GRANTED
+ |   91: box.error.PRIV_NOT_GRANTED
+ |   92: box.error.ROLE_NOT_GRANTED
+ |   93: box.error.MISSING_SNAPSHOT
+ |   94: box.error.CANT_UPDATE_PRIMARY_KEY
+ |   95: box.error.UPDATE_INTEGER_OVERFLOW
+ |   96: box.error.GUEST_USER_PASSWORD
+ |   97: box.error.TRANSACTION_CONFLICT
+ |   98: box.error.UNSUPPORTED_PRIV
+ |   99: box.error.LOAD_FUNCTION
+ |   100: box.error.FUNCTION_LANGUAGE
+ |   101: box.error.RTREE_RECT
+ |   102: box.error.PROC_C
+ |   103: box.error.UNKNOWN_RTREE_INDEX_DISTANCE_TYPE
+ |   104: box.error.PROTOCOL
+ |   105: box.error.UPSERT_UNIQUE_SECONDARY_KEY
+ |   106: box.error.WRONG_INDEX_RECORD
+ |   107: box.error.WRONG_INDEX_PARTS
+ |   108: box.error.WRONG_INDEX_OPTIONS
+ |   109: box.error.WRONG_SCHEMA_VERSION
+ |   110: box.error.MEMTX_MAX_TUPLE_SIZE
+ |   111: box.error.WRONG_SPACE_OPTIONS
+ |   112: box.error.UNSUPPORTED_INDEX_FEATURE
+ |   113: box.error.VIEW_IS_RO
+ |   114: box.error.NO_TRANSACTION
+ |   115: box.error.SYSTEM
+ |   116: box.error.LOADING
+ |   117: box.error.CONNECTION_TO_SELF
+ |   118: box.error.KEY_PART_IS_TOO_LONG
+ |   119: box.error.COMPRESSION
+ |   120: box.error.CHECKPOINT_IN_PROGRESS
+ |   121: box.error.SUB_STMT_MAX
+ |   122: box.error.COMMIT_IN_SUB_STMT
+ |   123: box.error.ROLLBACK_IN_SUB_STMT
+ |   124: box.error.DECOMPRESSION
+ |   125: box.error.INVALID_XLOG_TYPE
+ |   126: box.error.ALREADY_RUNNING
+ |   127: box.error.INDEX_FIELD_COUNT_LIMIT
+ |   128: box.error.LOCAL_INSTANCE_ID_IS_READ_ONLY
+ |   129: box.error.BACKUP_IN_PROGRESS
+ |   130: box.error.READ_VIEW_ABORTED
+ |   131: box.error.INVALID_INDEX_FILE
+ |   132: box.error.INVALID_RUN_FILE
+ |   133: box.error.INVALID_VYLOG_FILE
+ |   134: box.error.CHECKPOINT_ROLLBACK
+ |   135: box.error.VY_QUOTA_TIMEOUT
+ |   136: box.error.PARTIAL_KEY
+ |   137: box.error.TRUNCATE_SYSTEM_SPACE
+ |   138: box.error.LOAD_MODULE
+ |   139: box.error.VINYL_MAX_TUPLE_SIZE
+ |   140: box.error.WRONG_DD_VERSION
+ |   141: box.error.WRONG_SPACE_FORMAT
+ |   142: box.error.CREATE_SEQUENCE
+ |   143: box.error.ALTER_SEQUENCE
+ |   144: box.error.DROP_SEQUENCE
+ |   145: box.error.NO_SUCH_SEQUENCE
+ |   146: box.error.SEQUENCE_EXISTS
+ |   147: box.error.SEQUENCE_OVERFLOW
+ |   148: box.error.NO_SUCH_INDEX_NAME
+ |   149: box.error.SPACE_FIELD_IS_DUPLICATE
+ |   150: box.error.CANT_CREATE_COLLATION
+ |   151: box.error.WRONG_COLLATION_OPTIONS
+ |   152: box.error.NULLABLE_PRIMARY
+ |   153: box.error.NO_SUCH_FIELD_NAME_IN_SPACE
+ |   154: box.error.TRANSACTION_YIELD
+ |   155: box.error.NO_SUCH_GROUP
+ |   156: box.error.SQL_BIND_VALUE
+ |   157: box.error.SQL_BIND_TYPE
+ |   158: box.error.SQL_BIND_PARAMETER_MAX
+ |   159: box.error.SQL_EXECUTE
+ |   160: box.error.UPDATE_DECIMAL_OVERFLOW
+ |   161: box.error.SQL_BIND_NOT_FOUND
+ |   162: box.error.ACTION_MISMATCH
+ |   163: box.error.VIEW_MISSING_SQL
+ |   164: box.error.FOREIGN_KEY_CONSTRAINT
+ |   165: box.error.NO_SUCH_MODULE
+ |   166: box.error.NO_SUCH_COLLATION
+ |   167: box.error.CREATE_FK_CONSTRAINT
+ |   168: box.error.DROP_FK_CONSTRAINT
+ |   169: box.error.NO_SUCH_CONSTRAINT
+ |   170: box.error.CONSTRAINT_EXISTS
+ |   171: box.error.SQL_TYPE_MISMATCH
+ |   172: box.error.ROWID_OVERFLOW
+ |   173: box.error.DROP_COLLATION
+ |   174: box.error.ILLEGAL_COLLATION_MIX
+ |   175: box.error.SQL_NO_SUCH_PRAGMA
+ |   176: box.error.SQL_CANT_RESOLVE_FIELD
+ |   177: box.error.INDEX_EXISTS_IN_SPACE
+ |   178: box.error.INCONSISTENT_TYPES
+ |   179: box.error.SQL_SYNTAX_WITH_POS
+ |   180: box.error.SQL_STACK_OVERFLOW
+ |   181: box.error.SQL_SELECT_WILDCARD
+ |   182: box.error.SQL_STATEMENT_EMPTY
+ |   184: box.error.SQL_SYNTAX_NEAR_TOKEN
+ |   185: box.error.SQL_UNKNOWN_TOKEN
+ |   186: box.error.SQL_PARSER_GENERIC
+ |   187: box.error.SQL_ANALYZE_ARGUMENT
+ |   188: box.error.SQL_COLUMN_COUNT_MAX
+ |   189: box.error.HEX_LITERAL_MAX
+ |   190: box.error.INT_LITERAL_MAX
+ |   191: box.error.SQL_PARSER_LIMIT
+ |   192: box.error.INDEX_DEF_UNSUPPORTED
+ |   193: box.error.CK_DEF_UNSUPPORTED
+ |   194: box.error.MULTIKEY_INDEX_MISMATCH
+ |   195: box.error.CREATE_CK_CONSTRAINT
+ |   196: box.error.CK_CONSTRAINT_FAILED
+ |   197: box.error.SQL_COLUMN_COUNT
+ |   198: box.error.FUNC_INDEX_FUNC
+ |   199: box.error.FUNC_INDEX_FORMAT
+ |   200: box.error.FUNC_INDEX_PARTS
+ |   201: box.error.NO_SUCH_FIELD_NAME
+ |   202: box.error.FUNC_WRONG_ARG_COUNT
+ |   203: box.error.BOOTSTRAP_READONLY
+ |   204: box.error.SQL_FUNC_WRONG_RET_COUNT
+ |   205: box.error.FUNC_INVALID_RETURN_TYPE
+ |   206: box.error.SQL_PARSER_GENERIC_WITH_POS
+ |   207: box.error.REPLICA_NOT_ANON
+ |   208: box.error.CANNOT_REGISTER
+ |   209: box.error.SESSION_SETTING_INVALID_VALUE
+ |   210: box.error.SQL_PREPARE
+ |   211: box.error.WRONG_QUERY_ID
+ |   212: box.error.SEQUENCE_NOT_STARTED
+ | ...
+
+test_run:cmd("setopt delimiter ''");
+ | ---
+ | - true
+ | ...
+space:drop()
+ | ---
+ | ...
diff --git a/test/box/error.test.lua b/test/box/error.test.lua
new file mode 100644
index 000000000..d16cc5672
--- /dev/null
+++ b/test/box/error.test.lua
@@ -0,0 +1,80 @@
+env = require('test_run')
+test_run = env.new()
+
+space = box.schema.space.create('tweedledum')
+index = space:create_index('primary', { type = 'hash' })
+
+box.error({code = 123, reason = 'test'})
+box.error(box.error.ILLEGAL_PARAMS, "bla bla")
+box.error()
+e = box.error.last()
+e
+e:unpack()
+e.type
+e.code
+e.message
+tostring(e)
+e = nil
+box.error.clear()
+box.error.last()
+space = box.space.tweedledum
+
+--
+-- gh-2080: box.error() crashes with wrong parameters
+box.error(box.error.UNSUPPORTED, "x", "x%s")
+box.error(box.error.UNSUPPORTED, "x")
+box.error(box.error.UNSUPPORTED)
+
+--
+-- gh-3031: allow to create an error object with no throwing it.
+--
+e = box.error.new(box.error.UNKNOWN)
+e
+e = box.error.new(box.error.CREATE_SPACE, "space", "error")
+e
+box.error.new()
+
+--
+-- gh-4489: box.error has __concat metamethod
+--
+test_run:cmd("push filter '(.builtin/.*.lua):[0-9]+' to '\\1'")
+e = box.error.new(box.error.UNKNOWN)
+'left side: ' .. e
+e .. ': right side'
+e .. nil
+nil .. e
+e .. box.NULL
+box.NULL .. e
+123 .. e
+e .. 123
+e .. e
+e .. {}
+{} .. e
+-1ULL .. e
+e .. -1ULL
+1LL .. e
+e .. 1LL
+e = nil
+
+--
+-- System errors expose errno as a field.
+--
+_, err = require('fio').open('not_existing_file')
+type(err.errno)
+-- Errors not related to the standard library do
+-- not expose errno.
+err = box.error.new(box.error.PROC_LUA, "errno")
+type(err.errno)
+
+t = {}
+test_run:cmd("setopt delimiter ';'")
+
+for k,v in pairs(box.error) do
+   if type(v) == 'number' then
+    t[v] = 'box.error.'..tostring(k)
+   end
+end;
+t;
+
+test_run:cmd("setopt delimiter ''");
+space:drop()
diff --git a/test/box/misc.result b/test/box/misc.result
index 047591b60..9b76d7665 100644
--- a/test/box/misc.result
+++ b/test/box/misc.result
@@ -93,204 +93,6 @@ t = nil
 ---
 ...
 ----------------
--- # box.error
-----------------
-test_run:cmd("restart server default")
-env = require('test_run')
----
-...
-test_run = env.new()
----
-...
-box.error.last()
----
-- null
-...
-box.error({code = 123, reason = 'test'})
----
-- error: test
-...
-box.error(box.error.ILLEGAL_PARAMS, "bla bla")
----
-- error: Illegal parameters, bla bla
-...
-box.error()
----
-- error: Illegal parameters, bla bla
-...
-e = box.error.last()
----
-...
-e
----
-- Illegal parameters, bla bla
-...
-e:unpack()
----
-- type: ClientError
-  code: 1
-  message: Illegal parameters, bla bla
-  trace:
-  - file: '[C]'
-    line: 4294967295
-...
-e.type
----
-- ClientError
-...
-e.code
----
-- 1
-...
-e.message
----
-- Illegal parameters, bla bla
-...
-tostring(e)
----
-- Illegal parameters, bla bla
-...
-e = nil
----
-...
-box.error.clear()
----
-...
-box.error.last()
----
-- null
-...
-space = box.space.tweedledum
----
-...
---
--- gh-2080: box.error() crashes with wrong parameters
-box.error(box.error.UNSUPPORTED, "x", "x%s")
----
-- error: x does not support x%s
-...
-box.error(box.error.UNSUPPORTED, "x")
----
-- error: 'bad argument #3 to ''?'' (no value)'
-...
-box.error(box.error.UNSUPPORTED)
----
-- error: 'box.error(): bad arguments'
-...
---
--- gh-3031: allow to create an error object with no throwing it.
---
-e = box.error.new(box.error.UNKNOWN)
----
-...
-e
----
-- Unknown error
-...
-e = box.error.new(box.error.CREATE_SPACE, "space", "error")
----
-...
-e
----
-- 'Failed to create space ''space'': error'
-...
-box.error.new()
----
-- error: 'Usage: box.error.new(code, args)'
-...
---
--- gh-4489: box.error has __concat metamethod
---
-test_run:cmd("push filter '(.builtin/.*.lua):[0-9]+' to '\\1'")
----
-- true
-...
-e = box.error.new(box.error.UNKNOWN)
----
-...
-'left side: ' .. e
----
-- 'left side: Unknown error'
-...
-e .. ': right side'
----
-- 'Unknown error: right side'
-...
-e .. nil
----
-- error: 'builtin/error.lua: attempt to concatenate local ''rhs'' (a nil value)'
-...
-nil .. e
----
-- error: 'builtin/error.lua: attempt to concatenate local ''lhs'' (a nil value)'
-...
-e .. box.NULL
----
-- error: 'builtin/error.lua: attempt to concatenate ''string'' and ''void *'''
-...
-box.NULL .. e
----
-- error: 'builtin/error.lua: attempt to concatenate ''void *'' and ''string'''
-...
-123 .. e
----
-- 123Unknown error
-...
-e .. 123
----
-- Unknown error123
-...
-e .. e
----
-- Unknown errorUnknown error
-...
-e .. {}
----
-- error: 'builtin/error.lua: attempt to concatenate local ''rhs'' (a table value)'
-...
-{} .. e
----
-- error: 'builtin/error.lua: attempt to concatenate local ''lhs'' (a table value)'
-...
--1ULL .. e
----
-- error: 'builtin/error.lua: attempt to concatenate ''uint64_t'' and ''string'''
-...
-e .. -1ULL
----
-- error: 'builtin/error.lua: attempt to concatenate ''string'' and ''uint64_t'''
-...
-1LL .. e
----
-- error: 'builtin/error.lua: attempt to concatenate ''int64_t'' and ''string'''
-...
-e .. 1LL
----
-- error: 'builtin/error.lua: attempt to concatenate ''string'' and ''int64_t'''
-...
-e = nil
----
-...
---
--- System errors expose errno as a field.
---
-_, err = require('fio').open('not_existing_file')
----
-...
-type(err.errno)
----
-- number
-...
--- Errors not related to the standard library do
--- not expose errno.
-err = box.error.new(box.error.PROC_LUA, "errno")
----
-...
-type(err.errno)
----
-- nil
-...
-----------------
 -- # box.stat
 ----------------
 t = {}
@@ -413,231 +215,6 @@ type(require('yaml').encode(box.slab.info()));
 ---
 - string
 ...
-----------------
--- # box.error
-----------------
-t = {}
-for k,v in pairs(box.error) do
-   if type(v) == 'number' then
-    t[v] = 'box.error.'..tostring(k)
-   end
-end;
----
-...
-t;
----
-- 0: box.error.UNKNOWN
-  1: box.error.ILLEGAL_PARAMS
-  2: box.error.MEMORY_ISSUE
-  3: box.error.TUPLE_FOUND
-  4: box.error.TUPLE_NOT_FOUND
-  5: box.error.UNSUPPORTED
-  6: box.error.NONMASTER
-  7: box.error.READONLY
-  8: box.error.INJECTION
-  9: box.error.CREATE_SPACE
-  10: box.error.SPACE_EXISTS
-  11: box.error.DROP_SPACE
-  12: box.error.ALTER_SPACE
-  13: box.error.INDEX_TYPE
-  14: box.error.MODIFY_INDEX
-  15: box.error.LAST_DROP
-  16: box.error.TUPLE_FORMAT_LIMIT
-  17: box.error.DROP_PRIMARY_KEY
-  18: box.error.KEY_PART_TYPE
-  19: box.error.EXACT_MATCH
-  20: box.error.INVALID_MSGPACK
-  21: box.error.PROC_RET
-  22: box.error.TUPLE_NOT_ARRAY
-  23: box.error.FIELD_TYPE
-  24: box.error.INDEX_PART_TYPE_MISMATCH
-  25: box.error.UPDATE_SPLICE
-  26: box.error.UPDATE_ARG_TYPE
-  27: box.error.FORMAT_MISMATCH_INDEX_PART
-  28: box.error.UNKNOWN_UPDATE_OP
-  29: box.error.UPDATE_FIELD
-  30: box.error.FUNCTION_TX_ACTIVE
-  31: box.error.KEY_PART_COUNT
-  32: box.error.PROC_LUA
-  33: box.error.NO_SUCH_PROC
-  34: box.error.NO_SUCH_TRIGGER
-  35: box.error.NO_SUCH_INDEX_ID
-  36: box.error.NO_SUCH_SPACE
-  37: box.error.NO_SUCH_FIELD_NO
-  38: box.error.EXACT_FIELD_COUNT
-  39: box.error.FIELD_MISSING
-  40: box.error.WAL_IO
-  41: box.error.MORE_THAN_ONE_TUPLE
-  42: box.error.ACCESS_DENIED
-  43: box.error.CREATE_USER
-  44: box.error.DROP_USER
-  45: box.error.NO_SUCH_USER
-  46: box.error.USER_EXISTS
-  47: box.error.PASSWORD_MISMATCH
-  48: box.error.UNKNOWN_REQUEST_TYPE
-  49: box.error.UNKNOWN_SCHEMA_OBJECT
-  50: box.error.CREATE_FUNCTION
-  51: box.error.NO_SUCH_FUNCTION
-  52: box.error.FUNCTION_EXISTS
-  53: box.error.BEFORE_REPLACE_RET
-  54: box.error.MULTISTATEMENT_TRANSACTION
-  55: box.error.TRIGGER_EXISTS
-  56: box.error.USER_MAX
-  57: box.error.NO_SUCH_ENGINE
-  58: box.error.RELOAD_CFG
-  59: box.error.CFG
-  60: box.error.SAVEPOINT_EMPTY_TX
-  61: box.error.NO_SUCH_SAVEPOINT
-  62: box.error.UNKNOWN_REPLICA
-  63: box.error.REPLICASET_UUID_MISMATCH
-  64: box.error.INVALID_UUID
-  65: box.error.REPLICASET_UUID_IS_RO
-  66: box.error.INSTANCE_UUID_MISMATCH
-  68: box.error.INVALID_ORDER
-  69: box.error.MISSING_REQUEST_FIELD
-  70: box.error.IDENTIFIER
-  71: box.error.DROP_FUNCTION
-  72: box.error.ITERATOR_TYPE
-  73: box.error.REPLICA_MAX
-  74: box.error.INVALID_XLOG
-  75: box.error.INVALID_XLOG_NAME
-  76: box.error.INVALID_XLOG_ORDER
-  77: box.error.NO_CONNECTION
-  78: box.error.TIMEOUT
-  79: box.error.ACTIVE_TRANSACTION
-  80: box.error.CURSOR_NO_TRANSACTION
-  81: box.error.CROSS_ENGINE_TRANSACTION
-  82: box.error.NO_SUCH_ROLE
-  83: box.error.ROLE_EXISTS
-  84: box.error.CREATE_ROLE
-  85: box.error.INDEX_EXISTS
-  86: box.error.SESSION_CLOSED
-  87: box.error.ROLE_LOOP
-  88: box.error.GRANT
-  89: box.error.PRIV_GRANTED
-  90: box.error.ROLE_GRANTED
-  91: box.error.PRIV_NOT_GRANTED
-  92: box.error.ROLE_NOT_GRANTED
-  93: box.error.MISSING_SNAPSHOT
-  94: box.error.CANT_UPDATE_PRIMARY_KEY
-  95: box.error.UPDATE_INTEGER_OVERFLOW
-  96: box.error.GUEST_USER_PASSWORD
-  97: box.error.TRANSACTION_CONFLICT
-  98: box.error.UNSUPPORTED_PRIV
-  99: box.error.LOAD_FUNCTION
-  100: box.error.FUNCTION_LANGUAGE
-  101: box.error.RTREE_RECT
-  102: box.error.PROC_C
-  103: box.error.UNKNOWN_RTREE_INDEX_DISTANCE_TYPE
-  104: box.error.PROTOCOL
-  105: box.error.UPSERT_UNIQUE_SECONDARY_KEY
-  106: box.error.WRONG_INDEX_RECORD
-  107: box.error.WRONG_INDEX_PARTS
-  108: box.error.WRONG_INDEX_OPTIONS
-  109: box.error.WRONG_SCHEMA_VERSION
-  110: box.error.MEMTX_MAX_TUPLE_SIZE
-  111: box.error.WRONG_SPACE_OPTIONS
-  112: box.error.UNSUPPORTED_INDEX_FEATURE
-  113: box.error.VIEW_IS_RO
-  114: box.error.NO_TRANSACTION
-  115: box.error.SYSTEM
-  116: box.error.LOADING
-  117: box.error.CONNECTION_TO_SELF
-  118: box.error.KEY_PART_IS_TOO_LONG
-  119: box.error.COMPRESSION
-  120: box.error.CHECKPOINT_IN_PROGRESS
-  121: box.error.SUB_STMT_MAX
-  122: box.error.COMMIT_IN_SUB_STMT
-  123: box.error.ROLLBACK_IN_SUB_STMT
-  124: box.error.DECOMPRESSION
-  125: box.error.INVALID_XLOG_TYPE
-  126: box.error.ALREADY_RUNNING
-  127: box.error.INDEX_FIELD_COUNT_LIMIT
-  128: box.error.LOCAL_INSTANCE_ID_IS_READ_ONLY
-  129: box.error.BACKUP_IN_PROGRESS
-  130: box.error.READ_VIEW_ABORTED
-  131: box.error.INVALID_INDEX_FILE
-  132: box.error.INVALID_RUN_FILE
-  133: box.error.INVALID_VYLOG_FILE
-  134: box.error.CHECKPOINT_ROLLBACK
-  135: box.error.VY_QUOTA_TIMEOUT
-  136: box.error.PARTIAL_KEY
-  137: box.error.TRUNCATE_SYSTEM_SPACE
-  138: box.error.LOAD_MODULE
-  139: box.error.VINYL_MAX_TUPLE_SIZE
-  140: box.error.WRONG_DD_VERSION
-  141: box.error.WRONG_SPACE_FORMAT
-  142: box.error.CREATE_SEQUENCE
-  143: box.error.ALTER_SEQUENCE
-  144: box.error.DROP_SEQUENCE
-  145: box.error.NO_SUCH_SEQUENCE
-  146: box.error.SEQUENCE_EXISTS
-  147: box.error.SEQUENCE_OVERFLOW
-  148: box.error.NO_SUCH_INDEX_NAME
-  149: box.error.SPACE_FIELD_IS_DUPLICATE
-  150: box.error.CANT_CREATE_COLLATION
-  151: box.error.WRONG_COLLATION_OPTIONS
-  152: box.error.NULLABLE_PRIMARY
-  153: box.error.NO_SUCH_FIELD_NAME_IN_SPACE
-  154: box.error.TRANSACTION_YIELD
-  155: box.error.NO_SUCH_GROUP
-  156: box.error.SQL_BIND_VALUE
-  157: box.error.SQL_BIND_TYPE
-  158: box.error.SQL_BIND_PARAMETER_MAX
-  159: box.error.SQL_EXECUTE
-  160: box.error.UPDATE_DECIMAL_OVERFLOW
-  161: box.error.SQL_BIND_NOT_FOUND
-  162: box.error.ACTION_MISMATCH
-  163: box.error.VIEW_MISSING_SQL
-  164: box.error.FOREIGN_KEY_CONSTRAINT
-  165: box.error.NO_SUCH_MODULE
-  166: box.error.NO_SUCH_COLLATION
-  167: box.error.CREATE_FK_CONSTRAINT
-  168: box.error.DROP_FK_CONSTRAINT
-  169: box.error.NO_SUCH_CONSTRAINT
-  170: box.error.CONSTRAINT_EXISTS
-  171: box.error.SQL_TYPE_MISMATCH
-  172: box.error.ROWID_OVERFLOW
-  173: box.error.DROP_COLLATION
-  174: box.error.ILLEGAL_COLLATION_MIX
-  175: box.error.SQL_NO_SUCH_PRAGMA
-  176: box.error.SQL_CANT_RESOLVE_FIELD
-  177: box.error.INDEX_EXISTS_IN_SPACE
-  178: box.error.INCONSISTENT_TYPES
-  179: box.error.SQL_SYNTAX_WITH_POS
-  180: box.error.SQL_STACK_OVERFLOW
-  181: box.error.SQL_SELECT_WILDCARD
-  182: box.error.SQL_STATEMENT_EMPTY
-  184: box.error.SQL_SYNTAX_NEAR_TOKEN
-  185: box.error.SQL_UNKNOWN_TOKEN
-  186: box.error.SQL_PARSER_GENERIC
-  187: box.error.SQL_ANALYZE_ARGUMENT
-  188: box.error.SQL_COLUMN_COUNT_MAX
-  189: box.error.HEX_LITERAL_MAX
-  190: box.error.INT_LITERAL_MAX
-  191: box.error.SQL_PARSER_LIMIT
-  192: box.error.INDEX_DEF_UNSUPPORTED
-  193: box.error.CK_DEF_UNSUPPORTED
-  194: box.error.MULTIKEY_INDEX_MISMATCH
-  195: box.error.CREATE_CK_CONSTRAINT
-  196: box.error.CK_CONSTRAINT_FAILED
-  197: box.error.SQL_COLUMN_COUNT
-  198: box.error.FUNC_INDEX_FUNC
-  199: box.error.FUNC_INDEX_FORMAT
-  200: box.error.FUNC_INDEX_PARTS
-  201: box.error.NO_SUCH_FIELD_NAME
-  202: box.error.FUNC_WRONG_ARG_COUNT
-  203: box.error.BOOTSTRAP_READONLY
-  204: box.error.SQL_FUNC_WRONG_RET_COUNT
-  205: box.error.FUNC_INVALID_RETURN_TYPE
-  206: box.error.SQL_PARSER_GENERIC_WITH_POS
-  207: box.error.REPLICA_NOT_ANON
-  208: box.error.CANNOT_REGISTER
-  209: box.error.SESSION_SETTING_INVALID_VALUE
-  210: box.error.SQL_PREPARE
-  211: box.error.WRONG_QUERY_ID
-  212: box.error.SEQUENCE_NOT_STARTED
-...
 test_run:cmd("setopt delimiter ''");
 ---
 - true
diff --git a/test/box/misc.test.lua b/test/box/misc.test.lua
index e1c2f990f..350f9f75d 100644
--- a/test/box/misc.test.lua
+++ b/test/box/misc.test.lua
@@ -22,75 +22,6 @@ t = {} for n in pairs(box) do table.insert(t, tostring(n)) end table.sort(t)
 t
 t = nil
 
-----------------
--- # box.error
-----------------
-
-test_run:cmd("restart server default")
-env = require('test_run')
-test_run = env.new()
-box.error.last()
-box.error({code = 123, reason = 'test'})
-box.error(box.error.ILLEGAL_PARAMS, "bla bla")
-box.error()
-e = box.error.last()
-e
-e:unpack()
-e.type
-e.code
-e.message
-tostring(e)
-e = nil
-box.error.clear()
-box.error.last()
-space = box.space.tweedledum
---
--- gh-2080: box.error() crashes with wrong parameters
-box.error(box.error.UNSUPPORTED, "x", "x%s")
-box.error(box.error.UNSUPPORTED, "x")
-box.error(box.error.UNSUPPORTED)
-
---
--- gh-3031: allow to create an error object with no throwing it.
---
-e = box.error.new(box.error.UNKNOWN)
-e
-e = box.error.new(box.error.CREATE_SPACE, "space", "error")
-e
-box.error.new()
-
---
--- gh-4489: box.error has __concat metamethod
---
-test_run:cmd("push filter '(.builtin/.*.lua):[0-9]+' to '\\1'")
-e = box.error.new(box.error.UNKNOWN)
-'left side: ' .. e
-e .. ': right side'
-e .. nil
-nil .. e
-e .. box.NULL
-box.NULL .. e
-123 .. e
-e .. 123
-e .. e
-e .. {}
-{} .. e
--1ULL .. e
-e .. -1ULL
-1LL .. e
-e .. 1LL
-e = nil
-
---
--- System errors expose errno as a field.
---
-_, err = require('fio').open('not_existing_file')
-type(err.errno)
--- Errors not related to the standard library do
--- not expose errno.
-err = box.error.new(box.error.PROC_LUA, "errno")
-type(err.errno)
-
 ----------------
 -- # box.stat
 ----------------
@@ -138,17 +69,6 @@ box.runtime.info().maxalloc > 0;
 --
 type(require('yaml').encode(box.slab.info()));
 
-----------------
--- # box.error
-----------------
-t = {}
-for k,v in pairs(box.error) do
-   if type(v) == 'number' then
-    t[v] = 'box.error.'..tostring(k)
-   end
-end;
-t;
-
 test_run:cmd("setopt delimiter ''");
 
 -- A test case for Bug#901674
-- 
2.17.1

  parent reply	other threads:[~2020-03-25  1:43 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-25  1:42 [Tarantool-patches] [PATCH v2 00/10] Stacked diagnostics Nikita Pettik
2020-03-25  1:42 ` [Tarantool-patches] [PATCH v2 01/10] box: rfc for stacked diagnostic area Nikita Pettik
2020-03-25  8:27   ` Konstantin Osipov
2020-03-25 14:08     ` Nikita Pettik
2020-03-25  1:42 ` [Tarantool-patches] [PATCH v2 02/10] box: rename diag_add_error to diag_set_error Nikita Pettik
2020-03-25  8:27   ` Konstantin Osipov
2020-03-26  0:22   ` Vladislav Shpilevoy
2020-03-26 12:31     ` Nikita Pettik
2020-03-25  1:42 ` Nikita Pettik [this message]
2020-03-25  8:28   ` [Tarantool-patches] [PATCH v2 03/10] test: move box.error tests to box/error.test.lua Konstantin Osipov
2020-03-26  0:22   ` Vladislav Shpilevoy
2020-03-26 12:31     ` Nikita Pettik
2020-03-25  1:43 ` [Tarantool-patches] [PATCH v2 04/10] box/error: introduce box.error.set() method Nikita Pettik
2020-03-25  8:33   ` Konstantin Osipov
2020-03-25 17:41     ` Nikita Pettik
2020-03-26  0:22   ` Vladislav Shpilevoy
2020-03-26 12:31     ` Nikita Pettik
2020-03-25  1:43 ` [Tarantool-patches] [PATCH v2 05/10] box/error: don't set error created via box.error.new to diag Nikita Pettik
2020-03-26 16:50   ` Konstantin Osipov
2020-03-26 17:59     ` Nikita Pettik
2020-03-26 18:06       ` Nikita Pettik
2020-03-26 18:07       ` Alexander Turenko
2020-03-27  0:19   ` Vladislav Shpilevoy
2020-03-27 13:09     ` Nikita Pettik
2020-03-25  1:43 ` [Tarantool-patches] [PATCH v2 06/10] box: introduce stacked diagnostic area Nikita Pettik
2020-03-26 16:54   ` Konstantin Osipov
2020-03-26 18:03     ` Nikita Pettik
2020-03-26 18:08       ` Konstantin Osipov
2020-03-28 18:40   ` Vladislav Shpilevoy
2020-04-01 16:09     ` Nikita Pettik
2020-04-02  0:29       ` Vladislav Shpilevoy
2020-04-02 17:42         ` Nikita Pettik
2020-04-02 22:20           ` Vladislav Shpilevoy
2020-04-03  1:54             ` Nikita Pettik
2020-04-03 23:17               ` Vladislav Shpilevoy
2020-03-28 18:59   ` Vladislav Shpilevoy
2020-03-31 17:44     ` Nikita Pettik
2020-04-02  0:29       ` Vladislav Shpilevoy
2020-04-02 14:16         ` Nikita Pettik
2020-03-25  1:43 ` [Tarantool-patches] [PATCH v2 07/10] box: use stacked diagnostic area for functional indexes Nikita Pettik
2020-03-30 23:24   ` Vladislav Shpilevoy
2020-04-01 15:53     ` Nikita Pettik
2020-03-25  1:43 ` [Tarantool-patches] [PATCH v2 08/10] box/error: clarify purpose of reference counting in struct error Nikita Pettik
2020-03-30 23:24   ` Vladislav Shpilevoy
2020-03-25  1:43 ` [Tarantool-patches] [PATCH v2 09/10] iproto: refactor error encoding with mpstream Nikita Pettik
2020-03-30 23:24   ` Vladislav Shpilevoy
2020-04-01 15:54     ` Nikita Pettik
2020-03-25  1:43 ` [Tarantool-patches] [PATCH v2 10/10] iproto: support error stacked diagnostic area Nikita Pettik
2020-03-30 23:24   ` Vladislav Shpilevoy
2020-04-01 16:26     ` Nikita Pettik
2020-04-01 22:24       ` Nikita Pettik
2020-04-02  0:29         ` Vladislav Shpilevoy
2020-04-02 14:01           ` Nikita Pettik
2020-04-02 22:20             ` Vladislav Shpilevoy
2020-04-03  2:16               ` Nikita Pettik
2020-04-03 23:17                 ` Vladislav Shpilevoy
2020-04-06 11:07                   ` Nikita Pettik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=edbd0d6ae6f6fd3b900b3dea109cf390bf7b1aee.1585097339.git.korablev@tarantool.org \
    --to=korablev@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v2 03/10] test: move box.error tests to box/error.test.lua' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox