Skip to content
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

CIV: Report Portal Integration with AMI Validation #284

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sshmulev
Copy link
Collaborator

@sshmulev sshmulev commented Nov 2, 2023

No description provided.

@narmaku
Copy link
Collaborator

narmaku commented Nov 8, 2023

Please update the README.md explaining how the new feature works and how to use it (env vars, etc.).

@narmaku
Copy link
Collaborator

narmaku commented Nov 8, 2023

Don't forget to update the unit tests 👍

@narmaku narmaku self-requested a review November 8, 2023 06:00
return logger


def get_rp_config():
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we can move this function to config_lib.py. We may also introduce a new class in that file, which can be called PytestConfig. It can be useful in the future to actually add more config there directly, instead of having it hardcoded in pytest.ini.


from lib import test_lib


@pytest.fixture(scope="session")
def rp_logger():
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a way of defining this fixture only if the arg -rp (or --report-portal) is used?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

mmm... I'm not sure, need to investigate this - maybe a marker for this use?

Copy link
Collaborator

Choose a reason for hiding this comment

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

If this fixture does not affect current logic/report (in the case we don't use -rp option), then it's not a big deal and we can leave it enabled at a session level by default. I wonder if this has performance implications though.

cloud-image-val.py Outdated Show resolved Hide resolved

from lib import test_lib


@pytest.fixture(scope="session")
def rp_logger():
Copy link
Collaborator

Choose a reason for hiding this comment

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

What about the custom attributes we plan to add for each test case? Will that be done in a separate pull request?
I can imagine it will be a fixture defined like this: @pytest.fixture(autouse=True, scope='function').

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

According to the examples provided here https://github.com/reportportal/agent-python-pytest#readme I think that we don't need to make a second rest API call for this, we need to create markers on top of TestsAWS class and these markers will be attached as attributes to Report Portal items.
I think I'll work on this in a different PR because it might take more time probabbly , what do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, it makes sense to create as separate ticket for this and another PR.
Just one comment for future PR: Let's remember we need custom attributes for each test case separately, and they won't be fixed attributes, they will be dynamic, their values will vary during runtime (e.g. AMI ID, region, instance ID, public dns, etc.).

test_suite/conftest.py Outdated Show resolved Hide resolved
@sshmulev sshmulev force-pushed the report_portal_agent branch 14 times, most recently from ef020cc to d7f0f17 Compare November 9, 2023 06:01
@narmaku
Copy link
Collaborator

narmaku commented Nov 9, 2023

Let's add the report portal pytest agent in requirements.txt

@@ -64,6 +70,9 @@
os.environ['PYTHONPATH'] = ':'.join(
[f'{os.path.dirname(__file__)}', os.environ['PYTHONPATH']])

rp_config = PytestConfig()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's make this part optional, only in the case --rp option is passed as argument.

run_on: List of distro-version (or only distro) combinations where the test should be executed.
exclude_on: List of distro-version (or only distro) combinations where the test should NOT be executed.
jira_skip: List of Jira ticker ids. If any of these tickets are not closed, the test will be skipped.
rp_verify_ssl = False
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's add this options programmatically with the new class we created (PytestConfig).

@@ -134,7 +135,8 @@ def test_run_tests_in_all_instances(self, mocker, validator):
validator.run_tests_in_all_instances(self.test_instances)

mock_run_tests.assert_called_once_with(
validator.config["output_file"], self.test_config["test_filter"], self.test_config["include_markers"])
validator.config["output_file"], self.test_config["test_filter"], self.test_config["include_markers"],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we can format the args like this for easier readability:

mock_run_tests.assert_called_once_with(validator.config["output_file"],
                                       self.test_config["test_filter"],
                                       self.test_config["include_markers"],
                                       self.test_config["report_portal"])

from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry

from lib import test_lib


@pytest.fixture(scope="session")
def rp_logger():
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would add a if guard here, checking if CIVConfig contains report_portal.
If not, just return and don't continue with current logic.

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.

2 participants