From 713c39431b15cda72bf077fe769c9180cbbf6cd2 Mon Sep 17 00:00:00 2001
From: Sulverus <sulverus@gmail.com>
Date: Mon, 25 May 2015 16:01:23 +0300
Subject: [PATCH] Space crash test

---
 test/box/space_crash.result  | 29 +++++++++++++++++++++++
 test/box/space_crash.test.py | 46 ++++++++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+)
 create mode 100644 test/box/space_crash.result
 create mode 100644 test/box/space_crash.test.py

diff --git a/test/box/space_crash.result b/test/box/space_crash.result
new file mode 100644
index 0000000000..4b13a72631
--- /dev/null
+++ b/test/box/space_crash.result
@@ -0,0 +1,29 @@
+#
+# A test case for: http://bugs.launchpad.net/bugs/712456
+# Verify that when trying to access a non-existing or
+# very large space id, no crash occurs.
+#
+
+---
+- error:
+    errcode: (36)
+    errmsg: Space '1' does not exist
+...
+---
+- error:
+    errcode: (36)
+    errmsg: Space '65537' does not exist
+...
+---
+- error:
+    errcode: (36)
+    errmsg: Space '4294967295' does not exist
+...
+#
+# A test case for: http://bugs.launchpad.net/bugs/716683
+# Admin console should not stall on unknown command.
+
+show status
+---
+- error: '[string "show status"]:1: ''='' expected near ''status'''
+...
diff --git a/test/box/space_crash.test.py b/test/box/space_crash.test.py
new file mode 100644
index 0000000000..36a3bca232
--- /dev/null
+++ b/test/box/space_crash.test.py
@@ -0,0 +1,46 @@
+from lib.utils import check_libs
+check_libs()
+from tarantool.request import RequestSelect
+
+errstr = """---
+- error:
+    errcode: {0}
+    errmsg: {1}
+..."""
+
+def format_error(response):
+    return errstr.format(
+        "(%d)" % response.return_code,
+        response.return_message)
+
+def format_yamllike(response):
+    table = ("\n"+"\n".join(["- "+str(list(k)) for k in response])) \
+            if len(response) else ""
+    return "---{0}\n...".format(table)
+
+def select(conn, space_no, index_no, key, offset=0, limit=0, iterator=0):
+    data = RequestSelect(
+        conn, space_no, index_no, 
+        key, offset, limit, iterator
+    )
+    response = conn._send_request(data)
+
+    if response.return_code:
+        return format_error(response)
+    return format_yamllike(response)
+
+print """#
+# A test case for: http://bugs.launchpad.net/bugs/712456
+# Verify that when trying to access a non-existing or
+# very large space id, no crash occurs.
+#
+"""
+print select(iproto.py_con, 1, 0, [0])
+print select(iproto.py_con, 65537, 0, [0])
+print select(iproto.py_con, 4294967295, 0, [0])
+
+print """#
+# A test case for: http://bugs.launchpad.net/bugs/716683
+# Admin console should not stall on unknown command.
+"""
+admin("show status", simple=True)
-- 
GitLab