Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions test/features/connection.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
43 changes: 34 additions & 9 deletions test/features/steps/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Loading