diff --git a/test/features/connection.feature b/test/features/connection.feature index b06935ea..63644301 100644 --- a/test/features/connection.feature +++ b/test/features/connection.feature @@ -4,23 +4,23 @@ Feature: connect to a database: Scenario: run mycli on localhost without port When we run mycli with arguments "host=localhost" without arguments "port" When we query "status" - Then status contains "via UNIX socket" + Then status consistent with socket Scenario: run mycli on TCP host without port When we run mycli without arguments "port" When we query "status" - Then status contains "via TCP/IP" + Then status consistent with tcp_ip Scenario: run mycli with port but without host When we run mycli without arguments "host" When we query "status" - Then status contains "via TCP/IP" + Then status consistent with tcp_ip @requires_local_db Scenario: run mycli without host and port When we run mycli without arguments "host port" When we query "status" - Then status contains "via UNIX socket" + Then status consistent with socket Scenario: run mycli with my.cnf configuration When we create my.cnf file diff --git a/test/features/steps/connection.py b/test/features/steps/connection.py index dbc1eb4d..2ff14097 100644 --- a/test/features/steps/connection.py +++ b/test/features/steps/connection.py @@ -20,15 +20,40 @@ def step_run_cli_without_args(context, excluded_args, exact_args=""): wrappers.run_cli(context, run_args=parse_cli_args_to_dict(exact_args), exclude_args=parse_cli_args_to_dict(excluded_args).keys()) -@then('status contains "{expression}"') -def status_contains(context, expression): - wrappers.expect_exact(context, f"{expression}", timeout=5) - - # Normally, the shutdown after scenario waits for the prompt. - # But we may have changed the prompt, depending on parameters, - # so let's wait for its last character - context.cli.expect_exact(">") - context.atprompt = True +@then('status consistent with socket') +def status_consistent_with_socket(context): + # The connection can actually fall back to TCP/IP, so the test is + # inherently flaky. We just dodge that with a conditional. + if getattr(context.cn, 'unix_socket', None): + wrappers.expect_exact(context, 'via UNIX socket', timeout=5) + + # Normally, the shutdown after scenario waits for the prompt. + # But we may have changed the prompt, depending on parameters, + # so let's wait for its last character + context.cli.expect_exact(">") + context.atprompt = True + else: + wrappers.expect_exact(context, 'via TCP/IP', timeout=5) + context.cli.expect_exact(">") + context.atprompt = True + + +@then('status consistent with tcp_ip') +def status_consistent_with_tcp_ip(context): + # the connection can actually fall back to socket, so the test is + # inherently flaky. We just dodge that with a conditional. + if not getattr(context.cn, 'unix_socket', None): + wrappers.expect_exact(context, 'via TCP/IP', timeout=5) + + # Normally, the shutdown after scenario waits for the prompt. + # But we may have changed the prompt, depending on parameters, + # so let's wait for its last character + context.cli.expect_exact(">") + context.atprompt = True + else: + wrappers.expect_exact(context, 'via UNIX socket', timeout=5) + context.cli.expect_exact(">") + context.atprompt = True @when("we create my.cnf file")