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

Record suite info in test summary yaml. #949

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

mhaoli
Copy link
Collaborator

@mhaoli mhaoli commented Dec 2, 2024

Record the suite class name in summary yaml. No information will be added if the test is triggered by suite_runner.run_suite.

To record suite info, this PR adds a new test summary entry type SuiteInfo and record class SuiteInfoRecord.


This change is Reviewable

@mhaoli mhaoli added this to the Mobly Release 1.13 milestone Dec 2, 2024
@mhaoli mhaoli self-assigned this Dec 2, 2024
Copy link
Collaborator

@xianyuanjia xianyuanjia left a comment

Choose a reason for hiding this comment

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

How would this impact any downstream parsing of the results? Would the new entries be ignored by default?

Reviewable status: 0 of 4 files reviewed, 2 unresolved discussions (waiting on @mhaoli and @xpconanfan)


mobly/records.py line 734 at r1 (raw file):

  """A record representing the suite info in test summary."""

  KEY_SUITE_CLASS_NAME = 'Suite Class Name'

Could simplify to Suite Name.

Code quote:

KEY_SUITE_CLASS_NAME

mobly/records.py line 739 at r1 (raw file):

  def __init__(self, suite_class_name):
    self.suite_class_name = suite_class_name
    self.timestamp = time.time()

Would it be better to record a begin and end time instead? So we can report the total execution time of a suite.

Code quote:

    self.timestamp = time.time()

@mhaoli mhaoli requested a review from xianyuanjia December 3, 2024 12:48
Copy link
Collaborator Author

@mhaoli mhaoli left a comment

Choose a reason for hiding this comment

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

I did some verification and think this CL should be safe. I'd love to know if you suggest other things to be checked.

I ran a mobly_mh_test successfully, consulted Yao about the result parsing logic, did code search to find possible breakage. I only found that a warning will be printed on MH side, I'll ask MH team about how to fix it.

Reviewable status: 0 of 4 files reviewed, 2 unresolved discussions (waiting on @xianyuanjia and @xpconanfan)


mobly/records.py line 734 at r1 (raw file):

Previously, xianyuanjia wrote…

Could simplify to Suite Name.

I'm considering suite name may contain more info than only suite class name. Pinged you to discuss offline.


mobly/records.py line 739 at r1 (raw file):

Previously, xianyuanjia wrote…

Would it be better to record a begin and end time instead? So we can report the total execution time of a suite.

Good idea. DONE.

mobly/records.py Outdated Show resolved Hide resolved
@xpconanfan
Copy link
Collaborator

xpconanfan commented Dec 3, 2024 via email

@mhaoli
Copy link
Collaborator Author

mhaoli commented Dec 3, 2024

Do you really need a new class for a string and two timestamps? Also, why adding a field to the test report when most situations don't involve suite? Could you do this without modifying the records module?

I just thought this is a proper way to record mobly internal info to summary file.

If we want to avoid modifying the records module, I can record the suite info with record type UserData. Modifying.

@xpconanfan
Copy link
Collaborator

xpconanfan commented Dec 4, 2024 via email

mobly/suite_runner.py Outdated Show resolved Hide resolved
mobly/suite_runner.py Outdated Show resolved Hide resolved
@mhaoli mhaoli requested a review from xpconanfan December 10, 2024 07:49
@mhaoli mhaoli changed the title Record suite class name in summary yaml. Record suite info in test summary yaml. Dec 18, 2024
@mhaoli mhaoli force-pushed the record_suite_class_name branch from c2a8049 to 929cfe8 Compare December 20, 2024 14:31
Copy link
Collaborator Author

@mhaoli mhaoli left a comment

Choose a reason for hiding this comment

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

Resolved comments in this thread.

Reviewable status: 0 of 5 files reviewed, 5 unresolved discussions (waiting on @xianyuanjia and @xpconanfan)


mobly/records.py line 734 at r1 (raw file):

Previously, mhaoli (Minghao Li) wrote…

I'm considering suite name may contain more info than only suite class name. Pinged you to discuss offline.

Added a field 'Suite Name' which is either the suite class name or a user defined suite name. But I didn't remove field Test Suite Class as I think we need to keep this info.

Copy link
Collaborator

@xianyuanjia xianyuanjia left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 5 files at r4, 3 of 3 files at r6, all commit messages.
Reviewable status: 4 of 5 files reviewed, 7 unresolved discussions (waiting on @mhaoli and @xpconanfan)


mobly/base_suite.py line 56 at r6 (raw file):

    """The name of this suite.

    By default, use the name of the test class. User can overwrite to return

suite class?

Code quote:

test class

mobly/base_suite.py line 73 at r6 (raw file):

      A dict of suite information. Keys and values must be serializable.
    """
    return {}

There is no implementation here. Is this intentional? If so, please leave a TODO.

Code quote:

return {}

mobly/suite_runner.py line 114 at r6 (raw file):

  _end_time: int | None

  def __init__(self, test_suite_class):

Is there anywhere that indicates clearly that this record only works for suite classes and not suites directly assembled via run_suite?

mobly/suite_runner.py Outdated Show resolved Hide resolved
Copy link
Collaborator Author

@mhaoli mhaoli left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 of 5 files reviewed, 7 unresolved discussions (waiting on @xianyuanjia and @xpconanfan)


mobly/base_suite.py line 56 at r6 (raw file):

Previously, xianyuanjia wrote…

suite class?

Good catch. DONE.


mobly/base_suite.py line 73 at r6 (raw file):

Previously, xianyuanjia wrote…

There is no implementation here. Is this intentional? If so, please leave a TODO.

This is intentional. This method is for users to override to record customized info to test summary, e.g. suite version. By default, it just returns an empty dict.

Modified docstring to clarify this.


mobly/suite_runner.py line 114 at r6 (raw file):

Previously, xianyuanjia wrote…

Is there anywhere that indicates clearly that this record only works for suite classes and not suites directly assembled via run_suite?

Good point, clarified this point in docstring of this class.

mobly/suite_runner.py Outdated Show resolved Hide resolved
@mhaoli mhaoli requested a review from xianyuanjia December 24, 2024 08:47
Copy link
Collaborator

@xianyuanjia xianyuanjia left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed all commit messages.
Reviewable status: 1 of 5 files reviewed, 4 unresolved discussions (waiting on @xpconanfan)

@mhaoli mhaoli removed the request for review from xpconanfan December 27, 2024 03:35
# Optional interfaces that users can override to record customized suite
# information to test summary.

def get_suite_name(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

shouldn't this just be part of the suite info?
why should it be a separate getter method?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Test suites can return any custom values in suite info, our infra won't parse it and just write it to summary file.

So I created separate getter methods for fields that our infra needs to parse.

"""
return self.__class__.__name__

def get_run_identifier(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

what is "run identifier"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is for key run context that will be displayed as part of the title in our result viewer.

Through this we can include info like the phone brand and phone model.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants