You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2022/12/29 11:03:55 UTC

[iotdb] branch rel/1.0 updated: [To rel/1.0][IOTDB-5313] Fix python client didn't handle redirection status code correctly (#8664)

This is an automated email from the ASF dual-hosted git repository.

haonan pushed a commit to branch rel/1.0
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/rel/1.0 by this push:
     new 97afaff0d1 [To rel/1.0][IOTDB-5313] Fix python client didn't handle redirection status code correctly (#8664)
97afaff0d1 is described below

commit 97afaff0d1b2f04662df3501ea48080884c792b2
Author: Haonan <hh...@outlook.com>
AuthorDate: Thu Dec 29 19:03:47 2022 +0800

    [To rel/1.0][IOTDB-5313] Fix python client didn't handle redirection status code correctly (#8664)
---
 client-py/iotdb/Session.py                       | 5 +++--
 client-py/iotdb/dbapi/tests/test_connection.py   | 1 +
 client-py/iotdb/dbapi/tests/test_cursor.py       | 1 +
 client-py/iotdb/sqlalchemy/tests/test_dialect.py | 3 ++-
 client-py/tests/test_aligned_timeseries.py       | 1 +
 client-py/tests/test_delete_data.py              | 1 +
 client-py/tests/test_one_device.py               | 1 +
 client-py/tests/test_session.py                  | 3 ++-
 8 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/client-py/iotdb/Session.py b/client-py/iotdb/Session.py
index ebcc174dc9..2c599f0a3c 100644
--- a/client-py/iotdb/Session.py
+++ b/client-py/iotdb/Session.py
@@ -71,7 +71,8 @@ logger = logging.getLogger("IoTDB")
 
 
 class Session(object):
-    SUCCESS_CODE = 200
+    SUCCESS_STATUS = 200
+    REDIRECTION_RECOMMEND = 400
     DEFAULT_FETCH_SIZE = 10000
     DEFAULT_USER = "root"
     DEFAULT_PASSWORD = "root"
@@ -1046,7 +1047,7 @@ class Session(object):
         verify success of operation
         :param status: execution result status
         """
-        if status.code == Session.SUCCESS_CODE:
+        if status.code == Session.SUCCESS_STATUS or status.code == Session.REDIRECTION_RECOMMEND:
             return 0
 
         logger.error("error status is %s", status)
diff --git a/client-py/iotdb/dbapi/tests/test_connection.py b/client-py/iotdb/dbapi/tests/test_connection.py
index cb1f6c1e65..d0d878ce2b 100644
--- a/client-py/iotdb/dbapi/tests/test_connection.py
+++ b/client-py/iotdb/dbapi/tests/test_connection.py
@@ -34,6 +34,7 @@ def print_message(message):
     print("*********")
     print(message)
     print("*********")
+    assert False
 
 
 def test_connection():
diff --git a/client-py/iotdb/dbapi/tests/test_cursor.py b/client-py/iotdb/dbapi/tests/test_cursor.py
index b0ece9d0e6..4737aa95ea 100644
--- a/client-py/iotdb/dbapi/tests/test_cursor.py
+++ b/client-py/iotdb/dbapi/tests/test_cursor.py
@@ -35,6 +35,7 @@ def print_message(message):
     print("*********")
     print(message)
     print("*********")
+    assert False
 
 
 def test_cursor():
diff --git a/client-py/iotdb/sqlalchemy/tests/test_dialect.py b/client-py/iotdb/sqlalchemy/tests/test_dialect.py
index 20615cc3e8..ac8bde6ed2 100644
--- a/client-py/iotdb/sqlalchemy/tests/test_dialect.py
+++ b/client-py/iotdb/sqlalchemy/tests/test_dialect.py
@@ -38,6 +38,7 @@ def print_message(message):
     print("*********")
     print(message)
     print("*********")
+    assert False
 
 
 def test_dialect():
@@ -65,7 +66,7 @@ def test_dialect():
         insp = inspect(eng)
         # test get_schema_names
         schema_names = insp.get_schema_names()
-        if not operator.eq(schema_names, ["root.cursor", "root.cursor_s1"]):
+        if not operator.eq(schema_names, ["root.cursor_s1", "root.cursor"]):
             test_fail()
             print_message("test get_schema_names failed!")
         # test get_table_names
diff --git a/client-py/tests/test_aligned_timeseries.py b/client-py/tests/test_aligned_timeseries.py
index 6e6c6ee23b..e0236d7f42 100644
--- a/client-py/tests/test_aligned_timeseries.py
+++ b/client-py/tests/test_aligned_timeseries.py
@@ -38,6 +38,7 @@ def print_message(message):
     print("*********")
     print(message)
     print("*********")
+    assert False
 
 
 def test_aligned_timeseries():
diff --git a/client-py/tests/test_delete_data.py b/client-py/tests/test_delete_data.py
index a73aa73fc6..031e8ef6e6 100644
--- a/client-py/tests/test_delete_data.py
+++ b/client-py/tests/test_delete_data.py
@@ -37,6 +37,7 @@ def print_message(message):
     print("*********")
     print(message)
     print("*********")
+    assert False
 
 
 def test_delete_date():
diff --git a/client-py/tests/test_one_device.py b/client-py/tests/test_one_device.py
index e2fad149fa..ce4c02b012 100644
--- a/client-py/tests/test_one_device.py
+++ b/client-py/tests/test_one_device.py
@@ -37,6 +37,7 @@ def print_message(message):
     print("*********")
     print(message)
     print("*********")
+    assert False
 
 
 def test_one_device():
diff --git a/client-py/tests/test_session.py b/client-py/tests/test_session.py
index e7ae79fcb9..6780ac35f1 100644
--- a/client-py/tests/test_session.py
+++ b/client-py/tests/test_session.py
@@ -41,6 +41,7 @@ def print_message(message):
     print("*********")
     print(message)
     print("*********")
+    assert False
 
 
 def test_session():
@@ -213,7 +214,7 @@ def test_session():
             [True, 77, 88, 1.25, 8.125, "test_records02"],
         ]
         data_type_list_ = [data_types_, data_types_]
-        device_ids_ = ["root.sg_test_01.d_01", "root.sg_test_01.d_01"]
+        device_ids_ = ["root.sg_test_01.d_01", "root.sg_test_01.d_02"]
         if (
             session.insert_records(
                 device_ids_, [2, 3], measurements_list_, data_type_list_, values_list_