From: Daniele Varrazzo Date: Sun, 12 Jun 2022 01:04:14 +0000 (+0200) Subject: test(crdb): add tests to expose canceled copy problem X-Git-Tag: 3.1~49^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b669359837304a7183e62016546ea710d2210e22;p=thirdparty%2Fpsycopg.git test(crdb): add tests to expose canceled copy problem See https://github.com/cockroachdb/cockroach/issues/81559 --- diff --git a/tests/crdb/test_copy.py b/tests/crdb/test_copy.py index 2c20f2fde..21eb78b60 100644 --- a/tests/crdb/test_copy.py +++ b/tests/crdb/test_copy.py @@ -155,6 +155,19 @@ def test_copy_in_records_binary(conn, format): assert data == [(None, "hello"), (None, "world")] +@pytest.mark.crdb_skip("copy canceled") +def test_copy_in_buffers_with_py_error(conn): + cur = conn.cursor() + ensure_table(cur, sample_tabledef) + with pytest.raises(e.QueryCanceled) as exc: + with cur.copy("copy copy_in from stdin") as copy: + copy.write(sample_text) + raise Exception("nuttengoggenio") + + assert "nuttengoggenio" in str(exc.value) + assert conn.info.transaction_status == conn.TransactionStatus.INERROR + + def test_copy_in_allchars(conn): cur = conn.cursor() ensure_table(cur, "col1 int primary key, col2 int, data text") diff --git a/tests/crdb/test_copy_async.py b/tests/crdb/test_copy_async.py index 464277c36..7642b5635 100644 --- a/tests/crdb/test_copy_async.py +++ b/tests/crdb/test_copy_async.py @@ -160,6 +160,19 @@ async def test_copy_in_records_binary(aconn, format): assert data == [(None, "hello"), (None, "world")] +@pytest.mark.crdb_skip("copy canceled") +async def test_copy_in_buffers_with_py_error(aconn): + cur = aconn.cursor() + await ensure_table(cur, sample_tabledef) + with pytest.raises(e.QueryCanceled) as exc: + async with cur.copy("copy copy_in from stdin") as copy: + await copy.write(sample_text) + raise Exception("nuttengoggenio") + + assert "nuttengoggenio" in str(exc.value) + assert aconn.info.transaction_status == aconn.TransactionStatus.INERROR + + async def test_copy_in_allchars(aconn): cur = aconn.cursor() await ensure_table(cur, "col1 int primary key, col2 int, data text")