From 5f4bbe50c450b1a70227adcb67196e7353ebab2d Mon Sep 17 00:00:00 2001 From: Kaitmazian Maksim <m.kaitmazian@picodata.io> Date: Wed, 16 Oct 2024 17:04:21 +0300 Subject: [PATCH] tests: increase pexpect timeout to reduce flakiness --- test/conftest.py | 2 ++ test/int/test_cli_connect.py | 54 ++++++++++++++--------------- test/int/test_cli_ux.py | 18 +++++----- test/int/test_expelling.py | 7 ++-- test/pgproto/tab_completion_test.py | 4 +-- 5 files changed, 43 insertions(+), 42 deletions(-) diff --git a/test/conftest.py b/test/conftest.py index 3e5046bf3e..8471fca185 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -53,6 +53,8 @@ METRICS_PORT = 7500 MAX_LOGIN_ATTEMPTS = 4 PICO_SERVICE_ID = 32 +CLI_TIMEOUT = 10 # seconds + # Note: our tarantool.error.tnt_strerror only knows about first 113 error codes.. class ErrorCode: diff --git a/test/int/test_cli_connect.py b/test/int/test_cli_connect.py index 8b1a05adb8..15e9e4f5e5 100644 --- a/test/int/test_cli_connect.py +++ b/test/int/test_cli_connect.py @@ -5,7 +5,7 @@ import subprocess import hashlib import socket import time -from conftest import Cluster, Instance, eprint +from conftest import CLI_TIMEOUT, Cluster, Instance, eprint from dataclasses import dataclass @@ -22,7 +22,7 @@ def test_connect_testuser(i1: Instance): command=i1.binary_path, args=["connect", f"{i1.host}:{i1.port}", "-u", "testuser"], encoding="utf-8", - timeout=1, + timeout=CLI_TIMEOUT, ) cli.logfile = sys.stdout @@ -46,7 +46,7 @@ def test_connect_user_host_port(i1: Instance): "overridden", ], encoding="utf-8", - timeout=1, + timeout=CLI_TIMEOUT, ) cli.logfile = sys.stdout @@ -65,7 +65,7 @@ def test_connect_guest(i1: Instance): command=i1.binary_path, args=["connect", f"{i1.host}:{i1.port}"], encoding="utf-8", - timeout=1, + timeout=CLI_TIMEOUT, ) cli.logfile = sys.stdout @@ -86,7 +86,7 @@ def test_connect_user_with_role(i1: Instance): command=i1.binary_path, args=["connect", f"{i1.host}:{i1.port}", "-u", "testuser"], encoding="utf-8", - timeout=1, + timeout=CLI_TIMEOUT, ) cli.logfile = sys.stdout @@ -105,7 +105,7 @@ def test_no_pass(i1: Instance): command=i1.binary_path, args=["connect", f"{i1.host}:{i1.port}", "-u", "user"], encoding="utf-8", - timeout=1, + timeout=CLI_TIMEOUT, ) cli.logfile = sys.stdout @@ -122,7 +122,7 @@ def test_wrong_pass(i1: Instance): command=i1.binary_path, args=["connect", f"{i1.host}:{i1.port}", "-u", "testuser"], encoding="utf-8", - timeout=1, + timeout=CLI_TIMEOUT, ) cli.logfile = sys.stdout @@ -139,7 +139,7 @@ def test_connection_refused(binary_path: str): command=binary_path, args=["connect", "127.0.0.1:0", "-u", "testuser"], encoding="utf-8", - timeout=1, + timeout=CLI_TIMEOUT, ) cli.logfile = sys.stdout @@ -156,7 +156,7 @@ def test_connect_auth_type_ok(i1: Instance): command=i1.binary_path, args=["connect", f"{i1.host}:{i1.port}", "-u", "testuser"], encoding="utf-8", - timeout=1, + timeout=CLI_TIMEOUT, ) cli.logfile = sys.stdout @@ -175,7 +175,7 @@ def test_connect_auth_type_wrong(i1: Instance): command=i1.binary_path, args=["connect", f"{i1.host}:{i1.port}", "-u", "testuser", "-a", "ldap"], encoding="utf-8", - timeout=1, + timeout=CLI_TIMEOUT, ) cli.logfile = sys.stdout @@ -192,7 +192,7 @@ def test_connect_auth_type_md5(i1: Instance): command=i1.binary_path, args=["connect", f"{i1.host}:{i1.port}", "-u", "testuser", "-a", "md5"], encoding="utf-8", - timeout=1, + timeout=CLI_TIMEOUT, ) cli.logfile = sys.stdout @@ -298,7 +298,7 @@ def test_connect_auth_type_ldap(cluster: Cluster): command=i1.binary_path, args=["connect", f"{i1.host}:{i1.port}", "-u", username, "-a", "ldap"], encoding="utf-8", - timeout=1, + timeout=CLI_TIMEOUT, ) cli.logfile = sys.stdout @@ -317,7 +317,7 @@ def test_connect_auth_type_unknown(binary_path: str): args=["connect", ":0", "-u", "testuser", "-a", "deadbeef"], env={"NO_COLOR": "1"}, encoding="utf-8", - timeout=1, + timeout=CLI_TIMEOUT, ) cli.logfile = sys.stdout @@ -331,7 +331,7 @@ def test_admin_enoent(binary_path: str): args=["admin", "wrong/path/t.sock"], env={"NO_COLOR": "1"}, encoding="utf-8", - timeout=1, + timeout=CLI_TIMEOUT, ) cli.logfile = sys.stdout @@ -348,7 +348,7 @@ def test_admin_econnrefused(binary_path: str): args=["admin", "/dev/null"], env={"NO_COLOR": "1"}, encoding="utf-8", - timeout=1, + timeout=CLI_TIMEOUT, ) cli.logfile = sys.stdout @@ -365,7 +365,7 @@ def test_admin_invalid_path(binary_path: str): args=["admin", "./[][]"], env={"NO_COLOR": "1"}, encoding="utf-8", - timeout=1, + timeout=CLI_TIMEOUT, ) cli.logfile = sys.stdout @@ -380,7 +380,7 @@ def test_admin_empty_path(binary_path: str): args=["admin", ""], env={"NO_COLOR": "1"}, encoding="utf-8", - timeout=1, + timeout=CLI_TIMEOUT, ) cli.logfile = sys.stdout @@ -409,7 +409,7 @@ def test_admin_with_password(cluster: Cluster): ], env={"NO_COLOR": "1"}, encoding="utf-8", - timeout=1, + timeout=CLI_TIMEOUT, ) cli.logfile = sys.stdout cli.expect_exact("Enter password for admin: ") @@ -441,7 +441,7 @@ def test_connect_unix_ok_via_default_sock(cluster: Cluster): command=i1.binary_path, args=["admin", "./admin.sock"], encoding="utf-8", - timeout=1, + timeout=CLI_TIMEOUT, ) cli.logfile = sys.stdout @@ -473,7 +473,7 @@ def test_connect_with_empty_password_path(binary_path: str): args=["connect", ":3301", "--password-file", "", "-u", "trash"], env={"NO_COLOR": "1"}, encoding="utf-8", - timeout=1, + timeout=CLI_TIMEOUT, ) cli.logfile = sys.stdout @@ -497,7 +497,7 @@ def test_connect_with_wrong_password_path(binary_path: str): ], env={"NO_COLOR": "1"}, encoding="utf-8", - timeout=1, + timeout=CLI_TIMEOUT, ) cli.logfile = sys.stdout @@ -525,7 +525,7 @@ def test_connect_with_password_from_file(i1: Instance, binary_path: str): ], env={"NO_COLOR": "1"}, encoding="utf-8", - timeout=1, + timeout=CLI_TIMEOUT, ) cli.logfile = sys.stdout @@ -541,7 +541,7 @@ def test_connect_connection_info_and_help(i1: Instance): command=i1.binary_path, args=["connect", f"{i1.host}:{i1.port}", "-u", "testuser"], encoding="utf-8", - timeout=1, + timeout=CLI_TIMEOUT, ) cli.logfile = sys.stdout @@ -579,7 +579,7 @@ def test_admin_connection_info_and_help(cluster: Cluster): command=i1.binary_path, args=["admin", socket_path], encoding="utf-8", - timeout=1, + timeout=CLI_TIMEOUT, ) cli.logfile = sys.stdout @@ -602,7 +602,7 @@ def test_connect_with_incorrect_url(cluster: Cluster): command=i1.binary_path, args=["connect", address], encoding="utf-8", - timeout=1, + timeout=CLI_TIMEOUT, ) cli.logfile = sys.stdout return cli @@ -646,7 +646,7 @@ def test_connect_timeout(cluster: Cluster): *([f"--timeout={timeout}"] if timeout is not None else []), ], encoding="utf-8", - timeout=10, + timeout=CLI_TIMEOUT, ) cli.logfile = sys.stdout return cli @@ -663,7 +663,7 @@ def test_connect_timeout(cluster: Cluster): cli.expect_exact("Connection Error. Try to reconnect: connect timeout") cli.expect_exact(pexpect.EOF) - cli = connect_to("1000010002", timeout=1) + cli = connect_to("1000010002", timeout=CLI_TIMEOUT) cli.expect_exact("Connection Error. Try to reconnect: connect timeout") cli.expect_exact(pexpect.EOF) diff --git a/test/int/test_cli_ux.py b/test/int/test_cli_ux.py index fcb2854c4a..d1f06c9301 100644 --- a/test/int/test_cli_ux.py +++ b/test/int/test_cli_ux.py @@ -3,7 +3,7 @@ import os import pytest import sys import subprocess -from conftest import Cluster, log_crawler +from conftest import CLI_TIMEOUT, Cluster, log_crawler from tarantool.error import ( # type: ignore NetworkError, ) @@ -20,7 +20,7 @@ def test_connect_ux(cluster: Cluster): command=i1.binary_path, args=["connect", f"{i1.host}:{i1.port}", "-u", "andy"], encoding="utf-8", - timeout=1, + timeout=CLI_TIMEOUT, ) cli.logfile = sys.stdout @@ -101,7 +101,7 @@ def test_admin_ux(cluster: Cluster): command=i1.binary_path, args=["admin", "./admin.sock"], encoding="utf-8", - timeout=1, + timeout=CLI_TIMEOUT, ) cli.logfile = sys.stdout @@ -159,7 +159,7 @@ def test_lua_completion(cluster: Cluster): command=i1.binary_path, args=["admin", "./admin.sock"], encoding="utf-8", - timeout=1, + timeout=CLI_TIMEOUT, ) cli.logfile = sys.stdout @@ -209,7 +209,7 @@ def test_sql_explain_ok(cluster: Cluster): command=i1.binary_path, args=["admin", "./admin.sock"], encoding="utf-8", - timeout=1, + timeout=CLI_TIMEOUT, ) cli.logfile = sys.stdout @@ -329,7 +329,7 @@ def test_connect_pretty_message_on_server_crash(cluster: Cluster): command=i1.binary_path, args=["connect", f"{i1.host}:{i1.port}"], encoding="utf-8", - timeout=1, + timeout=CLI_TIMEOUT, ) cli.logfile = sys.stdout cli.expect_exact( @@ -349,7 +349,7 @@ def test_connect_pretty_message_on_server_crash(cluster: Cluster): command=i2.binary_path, args=["admin", "./admin.sock"], encoding="utf-8", - timeout=1, + timeout=CLI_TIMEOUT, ) cli.logfile = sys.stdout cli.expect_exact("picodata> ") @@ -370,7 +370,7 @@ def test_input_with_custom_delimiter(cluster: Cluster): command=i1.binary_path, args=["connect", f"{i1.host}:{i1.port}", "-u", "andy"], encoding="utf-8", - timeout=1, + timeout=CLI_TIMEOUT, ) cli.logfile = sys.stdout @@ -510,7 +510,7 @@ def test_do_not_ban_admin_via_unix_socket(cluster: Cluster): command=i1.binary_path, args=["admin", "./admin.sock"], encoding="utf-8", - timeout=1, + timeout=CLI_TIMEOUT, ) cli.logfile = sys.stdout diff --git a/test/int/test_expelling.py b/test/int/test_expelling.py index 21a619cad3..88507a4af2 100644 --- a/test/int/test_expelling.py +++ b/test/int/test_expelling.py @@ -1,7 +1,7 @@ import pytest import sys import pexpect # type: ignore -from conftest import Cluster, Instance, Retriable, log_crawler +from conftest import CLI_TIMEOUT, Cluster, Instance, Retriable, log_crawler @pytest.fixture @@ -115,7 +115,6 @@ def test_raft_id_after_expel(cluster: Cluster): def test_expel_timeout(cluster: Cluster): cluster.deploy(instance_count=1) [i1] = cluster.instances - timeout = 1 # If the peer is not resolving, by default we hang on # for 5 seconds. We can change it by specifying `timeout`. @@ -125,11 +124,11 @@ def test_expel_timeout(cluster: Cluster): args=[ "expel", "random_instance_id", - f"--timeout={timeout}", + f"--timeout={CLI_TIMEOUT}", "--peer=10001", ], encoding="utf-8", - timeout=10, + timeout=CLI_TIMEOUT, ) cli.logfile = sys.stdout diff --git a/test/pgproto/tab_completion_test.py b/test/pgproto/tab_completion_test.py index 4eec728bed..dfbf2198d9 100644 --- a/test/pgproto/tab_completion_test.py +++ b/test/pgproto/tab_completion_test.py @@ -6,7 +6,7 @@ import subprocess import re import os import psycopg -from conftest import Postgres +from conftest import CLI_TIMEOUT, Postgres from packaging.version import Version # type: ignore @@ -47,7 +47,7 @@ def test_tab_completion(postgres: Postgres): ], env={"LC_ALL": "C"}, encoding="utf-8", - timeout=5, + timeout=CLI_TIMEOUT, ) psql.logfile = sys.stdout psql.expect_exact("=>") -- GitLab