-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
issue: 4197123: Add Pytest to the workflow of the LogAnalyzer + issue: 4197133: Add Pytest #287
Merged
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
654d4f7
test
Miryam-Schwartz 2364f24
add pytest to requirments
Miryam-Schwartz 14aeb94
test
Miryam-Schwartz 07d3343
add tests
Miryam-Schwartz 9f78a58
add insall requierments to workflow
Miryam-Schwartz b079038
add copyright
Miryam-Schwartz c5539b7
fix comments
Miryam-Schwartz 042d4c8
fix comments
Miryam-Schwartz 49bf325
fix comments
Miryam-Schwartz b972bce
fix pytest path
Miryam-Schwartz 74c6af0
fix comments
Miryam-Schwartz 72703ae
fix comments
Miryam-Schwartz c812448
fix comments
Miryam-Schwartz e0654f2
fix comments
Miryam-Schwartz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# @copyright: | ||
# Copyright © 2013-2024 NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. | ||
|
||
# This software product is a proprietary product of Nvidia Corporation and its affiliates | ||
# (the "Company") and all right, title, and interest in and to the | ||
# software product, including all associated intellectual property rights, | ||
# are and shall remain exclusively with the Company. | ||
|
||
# This software product is governed by the End User License Agreement | ||
# provided with the software product. | ||
|
||
# @author: Miryam Schwartz | ||
# @date: Dec 08, 2024 | ||
|
||
import sys | ||
import os | ||
|
||
sys.path.append(os.getcwd() + "/src") # Add the src directory containing loganalyze | ||
sys.path.append("/".join(os.getcwd().split("/")[:-2])) # Add the root project directory |
38 changes: 38 additions & 0 deletions
38
plugins/ufm_log_analyzer_plugin/unit_tests/test_ibdiagnet_log_analyzer.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# @copyright: | ||
# Copyright © 2013-2024 NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. | ||
|
||
# This software product is a proprietary product of Nvidia Corporation and its affiliates | ||
# (the "Company") and all right, title, and interest in and to the | ||
# software product, including all associated intellectual property rights, | ||
# are and shall remain exclusively with the Company. | ||
|
||
# This software product is governed by the End User License Agreement | ||
# provided with the software product. | ||
|
||
# @author: Miryam Schwartz | ||
# @date: Dec 08, 2024 | ||
|
||
import pytest | ||
|
||
from loganalyze.log_analyzers.ibdiagnet_log_analyzer import IBDIAGNETLogAnalyzer | ||
|
||
# Define a test-specific subclass | ||
class TestIBDIAGNETLogAnalyzer(IBDIAGNETLogAnalyzer): | ||
def __init__(self, fabric_size_data): | ||
# Do not call the parent constructor, set up only what's needed for the test | ||
self._log_data_sorted = fabric_size_data | ||
|
||
@pytest.fixture | ||
def fabric_size_data(): | ||
# Shared mock data | ||
return {"switch_count": 10, "link_count": 50} | ||
|
||
@pytest.fixture | ||
def analyzer(fabric_size_data): | ||
# Return an instance of the test-specific subclass | ||
Miryam-Schwartz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return TestIBDIAGNETLogAnalyzer(fabric_size_data) | ||
|
||
def test_get_fabric_size(analyzer, fabric_size_data): | ||
# Call the method and check the result | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see the benefit in having this comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed |
||
result = analyzer.get_fabric_size() | ||
assert result == fabric_size_data, "get_fabric_size should return _log_data_sorted" |
39 changes: 39 additions & 0 deletions
39
plugins/ufm_log_analyzer_plugin/unit_tests/test_ufm_top_analyzer.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# @copyright: | ||
# Copyright © 2013-2024 NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. | ||
|
||
# This software product is a proprietary product of Nvidia Corporation and its affiliates | ||
# (the "Company") and all right, title, and interest in and to the | ||
# software product, including all associated intellectual property rights, | ||
# are and shall remain exclusively with the Company. | ||
|
||
# This software product is governed by the End User License Agreement | ||
# provided with the software product. | ||
|
||
# @author: Miryam Schwartz | ||
# @date: Dec 08, 2024 | ||
|
||
import pytest | ||
|
||
from loganalyze.log_analyzers.ufm_top_analyzer import UFMTopAnalyzer | ||
|
||
@pytest.fixture | ||
def analyzer(): | ||
# Fixture to initialize the analyzer object | ||
return UFMTopAnalyzer() | ||
|
||
def test_add_analyzer(analyzer): | ||
mock_analyzer_1 = "Analyzer1" | ||
mock_analyzer_2 = "Analyzer2" | ||
|
||
# Initially, the list should be empty | ||
assert len(analyzer._analyzers) == 0 | ||
|
||
# Add first analyzer and check the length | ||
analyzer.add_analyzer(mock_analyzer_1) | ||
assert len(analyzer._analyzers) == 1 | ||
assert mock_analyzer_1 in analyzer._analyzers | ||
|
||
# Add second analyzer and check the updated length | ||
analyzer.add_analyzer(mock_analyzer_2) | ||
assert len(analyzer._analyzers) == 2 | ||
assert mock_analyzer_2 in analyzer._analyzers |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be clear that you use the venv created for the tool, right? otherwise tests might fail due to missing dependencies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added