Skip to content

Conversation

vojtechtrefny
Copy link
Member

@vojtechtrefny vojtechtrefny commented Aug 6, 2025

Summary by Sourcery

Add support for CI-specific tests and improve iSCSI test setup

New Features:

  • Add --jenkins flag to include CI-only tests and set JENKINS_HOME environment variable

Enhancements:

  • Start iscsi-init.service in iSCSI tests to ensure correct initialization
  • Add udisks2-iscsi package to test dependency installation for Fedora and CentOS

Copy link

sourcery-ai bot commented Aug 6, 2025

Reviewer's Guide

This PR enhances the iSCSI test setup by adding a Jenkins mode flag, ensuring the iscsi-init service is started in tests, and including the udisks2-iscsi package as a test dependency in Ansible playbooks.

Sequence diagram for starting iscsi-init.service in iSCSI test setup

sequenceDiagram
    participant TestRunner
    participant Systemd
    participant iSCSIService as iscsi-init.service

    TestRunner->>Systemd: Start iscsi-init.service (in setUp)
    Systemd->>iSCSIService: Activate service
    iSCSIService-->>Systemd: Service started
    Systemd-->>TestRunner: Confirmation of service start
    TestRunner->>TestRunner: Proceed with iSCSI tests
Loading

Class diagram for updated iSCSI test setup

classDiagram
    class ISCSITest {
        +setUp()
        +test_iscsi_functionality()
    }
    ISCSITest : +setUp() now starts iscsi-init.service
Loading

File-Level Changes

Change Details Files
Added a Jenkins-specific run mode to the test runner
  • Introduced a --jenkins CLI option in run_tests.py
  • Set JENKINS_HOME environment variable when --jenkins is used
  • Updated argument parser to recognize the new flag
tests/run_tests.py
Included udisks2-iscsi as a test dependency in Ansible tasks
  • Added udisks2-iscsi to Fedora test dependencies
  • Added udisks2-iscsi to CentOS test dependencies
misc/blivet-tasks.yml
Ensure iscsi-init.service is started during iSCSI test setup
  • Inserted a systemctl call to start iscsi-init.service in setUp()
  • Silenced service start output by redirecting to DEVNULL
tests/storage_tests/iscsi_test.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @vojtechtrefny - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@vojtechtrefny vojtechtrefny marked this pull request as draft August 6, 2025 11:54
@vojtechtrefny vojtechtrefny marked this pull request as ready for review August 6, 2025 12:55
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @vojtechtrefny - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments

### Comment 1
<location> `tests/storage_tests/iscsi_test.py:115` </location>
<code_context>
         except RuntimeError as e:
             raise RuntimeError("Failed to setup targetcli device for testing: %s" % e)

+        subprocess.call(["systemctl", "start", "iscsi-init.service"], stdout=subprocess.DEVNULL)
+
     def _force_logout(self):
</code_context>

<issue_to_address>
Consider asserting that iscsi-init.service started successfully.

The test setup does not verify if 'iscsi-init.service' starts successfully, which could cause tests to run in an invalid state. Please check the return code and fail early if the service fails to start.
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
        subprocess.call(["systemctl", "start", "iscsi-init.service"], stdout=subprocess.DEVNULL)
=======
        ret = subprocess.call(["systemctl", "start", "iscsi-init.service"], stdout=subprocess.DEVNULL)
        if ret != 0:
            raise RuntimeError("Failed to start iscsi-init.service (systemctl exit code: %d)" % ret)
>>>>>>> REPLACE

</suggested_fix>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@@ -112,6 +112,8 @@ def setUp(self):
except RuntimeError as e:
raise RuntimeError("Failed to setup targetcli device for testing: %s" % e)

subprocess.call(["systemctl", "start", "iscsi-init.service"], stdout=subprocess.DEVNULL)
Copy link

Choose a reason for hiding this comment

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

suggestion (testing): Consider asserting that iscsi-init.service started successfully.

The test setup does not verify if 'iscsi-init.service' starts successfully, which could cause tests to run in an invalid state. Please check the return code and fail early if the service fails to start.

Suggested change
subprocess.call(["systemctl", "start", "iscsi-init.service"], stdout=subprocess.DEVNULL)
ret = subprocess.call(["systemctl", "start", "iscsi-init.service"], stdout=subprocess.DEVNULL)
if ret != 0:
raise RuntimeError("Failed to start iscsi-init.service (systemctl exit code: %d)" % ret)

@vojtechtrefny vojtechtrefny merged commit 5de4ccd into storaged-project:main Aug 7, 2025
14 of 16 checks passed
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.

1 participant