Skip to content

TPT-4472: Create tests for stream commands - #901

Open
psnoch-akamai wants to merge 4 commits into
linode:devfrom
psnoch-akamai:TPT-4472-linode-cli-create-integration-tests-for-new-commands
Open

psnoch-akamai wants to merge 4 commits into
linode:devfrom
psnoch-akamai:TPT-4472-linode-cli-create-integration-tests-for-new-commands

Conversation

@psnoch-akamai

Copy link
Copy Markdown
Contributor

📝 Description

Create tests for stream commands

✔️ How to Test

@psnoch-akamai psnoch-akamai changed the title TPT-4472 Create tests for stream commands TPT-4472: Create tests for stream commands Jun 30, 2026
@psnoch-akamai
psnoch-akamai force-pushed the TPT-4472-linode-cli-create-integration-tests-for-new-commands branch from ef2bcee to 46eb9cb Compare November 4, 2026 16:15
@psnoch-akamai
psnoch-akamai requested a balanced review from Copilot November 4, 2026 16:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Negative tests assume ID 1 is invalid and can delete unrelated destinations or create unmanaged streams, while fixture defects cause setup failures and incomplete cleanup.

5 open issues
What changed in this PR

Adds integration coverage for the CLI’s stream and destination commands, including error handling and resource lifecycle checks.

Changes:

  • Adds help, listing, and negative-command tests, with smoke coverage for listings.
  • Exercises destination creation, viewing, history, and deletion, plus an opt-in long-running stream test.
  • Adds resource fixtures, status polling, and shared command registration.
File Description
tests/​integration/​streams/​test_streams.py Tests stream help, listing, errors, creation, and viewing.
tests/​integration/​streams/​test_destination.py Tests destination listing, errors, lifecycle, and history.
tests/​integration/​streams/​fixtures.py Provides storage-key, destination, and stream fixtures with cleanup and polling.
tests/​integration/​helpers.py Registers streams in the shared command map.

Review effort: Balanced

Comment on lines +23 to +24
host = os.getenv("LINODE_CLI_API_HOST")
if token is None:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any issue here

@mawilk90 mawilk90 Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All 3 of your IF conditionals here checks token value, instead of token, host, version. Moreover, host and version seem to be optional so there is no need to specify/check them unless you want to use specific host/version (e.g. v4beta)

@pytest.fixture
def create_object_storage_keys():
label = get_random_text(8) + "_destination_cli_test"
test_bucket = get_object_storage_buckets()["data"][0]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread tests/integration/streams/fixtures.py Resolved
Comment thread tests/integration/streams/fixtures.py Resolved
@psnoch-akamai
psnoch-akamai force-pushed the TPT-4472-linode-cli-create-integration-tests-for-new-commands branch from 46eb9cb to ef70629 Compare November 6, 2026 15:41
@psnoch-akamai
psnoch-akamai requested a balanced review from Copilot November 6, 2026 15:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Fixture setup fails with the normal token-only configuration or an empty bucket list, and destination-creation failures can expose credentials in CI logs.

3 open issues
3 resolved since last review

Review effort: Balanced

Comment on lines +124 to +125
"--details.access_key_secret",
create_object_storage_keys[1],

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@psnoch-akamai
psnoch-akamai force-pushed the TPT-4472-linode-cli-create-integration-tests-for-new-commands branch from ef70629 to 3202789 Compare November 10, 2026 13:47
@psnoch-akamai
psnoch-akamai requested a balanced review from Copilot November 10, 2026 13:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The new integration fixtures fail during setup when optional API overrides are absent or the account has no existing Object Storage buckets, preventing the destination and stream success tests from exercising the commands.

3 open issues

Review effort: Balanced

@psnoch-akamai
psnoch-akamai marked this pull request as ready for review November 10, 2026 14:17
@psnoch-akamai
psnoch-akamai requested review from a team as code owners November 10, 2026 14:17
@psnoch-akamai
psnoch-akamai requested review from mawilk90 and yec-akamai and removed request for a team November 10, 2026 14:17
@pytest.fixture
def create_object_storage_keys():
label = get_random_text(8) + "_destination_cli_test"
if get_object_storage_buckets()["data"][0] is None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will fail if there is no buckets at all (then data=[] leads to 'list index out of range' error). Moreover, wouldnt be better to create a bucket instead of checking if there is any already? It would let you run the tests no matter if it exists or not


# handle `--flag=value` form
if "=" in arg and arg.split("=", 1)[0] in SENSITIVE_ARG_NAMES:
flag, _ = arg.split("=", 1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can avoid "_" using [0] similarly as it is in IF:
flag = arg.split("=", 1)[0]

result_view_json["destinations"][0]["type"] == "akamai_object_storage"
)
assert result_view_json["status"] == "active"
assert result_view_json["type"] == "audit_logs"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we extract these assertions into separate function? Additionally, is it enough to just check existence of access_key_id, bucket_name, host, path etc. with no specific values?

)


def wait_for_stream_status(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to use existing wait_for_condition?

import pytest
import requests

from linodecli import ExitCodes

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to be unused?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants