Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a smoke test for the configure command and fixes flaky integration tests by adding proper retry logic and correcting test assertions. The changes improve test reliability by handling transient SSH connection issues and fixing incorrect header validation in the LKE node view test.
Changes:
- Added retry logic with 10 attempts for SSH connectivity test to handle transient failures
- Fixed incorrect header assertions in LKE node view test (split malformed string into proper header list and added missing pool_id)
- Added smoke test for
linode-cli configure --helpcommand
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/integration/ssh/test_ssh.py | Added subprocess import, .strip() calls for consistency, and retry logic for flaky SSH connectivity test |
| tests/integration/lke/test_clusters.py | Fixed malformed header list in test_view_node from single concatenated string to proper list with pool_id |
| tests/integration/account/test_account.py | Added smoke test for configure command help output |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ] | ||
|
|
||
| output = "" | ||
| for attempt in range(NUM_OF_RETRIES): |
There was a problem hiding this comment.
The loop variable 'attempt' is unused. Consider using '_' to indicate that this variable is intentionally not used, or use 'attempt' in error messages or logging to provide better debugging information.
| for attempt in range(NUM_OF_RETRIES): | |
| for _ in range(NUM_OF_RETRIES): |
| for attempt in range(NUM_OF_RETRIES): | ||
| result = subprocess.run( | ||
| ssh_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True | ||
| ) | ||
| output = result.stdout | ||
| if "0% packet loss" in output: | ||
| break | ||
| time.sleep(10) | ||
|
|
||
| assert ( | ||
| "0% packet loss" in output | ||
| ), f"Ping failed after {NUM_OF_RETRIES} retries: {output}" |
There was a problem hiding this comment.
The assertion message includes the output, but doesn't include which attempt failed or any stderr output from the subprocess. Consider including result.stderr in the assertion message to help debug SSH connection failures. The stderr would show SSH errors like connection refused, authentication failures, etc.
| for attempt in range(NUM_OF_RETRIES): | |
| result = subprocess.run( | |
| ssh_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True | |
| ) | |
| output = result.stdout | |
| if "0% packet loss" in output: | |
| break | |
| time.sleep(10) | |
| assert ( | |
| "0% packet loss" in output | |
| ), f"Ping failed after {NUM_OF_RETRIES} retries: {output}" | |
| stderr_output = "" | |
| last_attempt = 0 | |
| for attempt in range(NUM_OF_RETRIES): | |
| result = subprocess.run( | |
| ssh_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True | |
| ) | |
| output = result.stdout | |
| stderr_output = result.stderr | |
| last_attempt = attempt + 1 | |
| if "0% packet loss" in output: | |
| break | |
| time.sleep(10) | |
| assert ( | |
| "0% packet loss" in output | |
| ), ( | |
| f"Ping failed after {NUM_OF_RETRIES} retries " | |
| f"(last attempt {last_attempt}): stdout: {output}, stderr: {stderr_output}" | |
| ) |
| output = result.stdout | ||
| if "0% packet loss" in output: | ||
| break | ||
| time.sleep(10) |
There was a problem hiding this comment.
The sleep occurs even after the last retry attempt. Following the pattern in helpers.py (lines 136-137), consider adding a check if attempt < NUM_OF_RETRIES - 1: before the sleep to avoid an unnecessary 10-second delay when all retries are exhausted.
| time.sleep(10) | |
| if attempt < NUM_OF_RETRIES - 1: | |
| time.sleep(10) |
📝 Description
Test for configure and fix flaky tests
✔️ How to Test
make test-int TEST_CASE=test_account.py
make test-int TEST_CASE=test_clusters.py
make test-int TEST_CASE=test_ssh.py