Skip to content

TEST: update python script to enable examples smoke test #10521

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

Merged
merged 5 commits into from
May 21, 2019

Conversation

jamesbeyond
Copy link
Contributor

Description

The goal of this PR is to enable examples smoke test in CI

  • the new scripts will check examples.json if contains 'test', 'compare_log', 'baud_rate' keys
  • the new scripts will dump test_spec.json test in examples compiled successfully

The auto generated test_spec.json can be consumed by GreenTea.
This PR is related with ARMmbed/mbed-os-tools#162

examples.json is not required to be changed at moment.
later on when test cases in each example are ready, corresponding example then will need to be updated.

Pull request type

[ ] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[x] Test update
[ ] Breaking change

Reviewers

@OPpuolitaival

@ciarmcom ciarmcom requested review from OPpuolitaival and a team May 2, 2019 13:00
@ciarmcom
Copy link
Member

ciarmcom commented May 2, 2019

@jamesbeyond, thank you for your changes.
@OPpuolitaival @ARMmbed/mbed-os-tools @ARMmbed/mbed-os-maintainers please review.

 * it will check examples.json if contains 'test', 'compare_log', 'baud_rate' keys
 * it will dump test_spec.json test in examples compiled successfully
Copy link
Contributor

@bridadan bridadan left a comment

Choose a reason for hiding this comment

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

In general this all seems pretty reasonable! I have a few suggestions below,

"""save the given json data to test_spec.json"""
print ("Dumping json test_specs file {}".format(name))
with open(name, 'w') as outfile:
json.dump(json_spec, outfile , indent=4)
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe we have an existing function that you can use: https://github.com/ARMmbed/mbed-os/blob/master/tools/utils.py#L184

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review, all your comments been addressed

if image:
image_info = [{"binary_type": "bootable","path": normpath(join(name,image)),"compare_log":log}]
else:
print ("Warning: could not found built image for example %s" % name)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit pick on the wording of the warning:

Suggested change
print ("Warning: could not found built image for example %s" % name)
print ("Warning: could not find built image for example %s" % name)

print ("\n#### STDOUT ####\n%s\n#### STDERR ####\n%s\n#### End of STDOUT/STDERR ####\n" % (std_out,std_err))

if test_example:
log = example['compare_log'].pop(0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason this needs to be a pop vs the following:

Suggested change
log = example['compare_log'].pop(0)
log = example['compare_log']

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here pop() is used because the value of compare_log will be a list of logs files.
The reason for that is because some of the example repos contains more than one example, e.g. the mbed-os-example-tls and mbed-os-example-ble. So the each log file need to match with
the individual sub-example. So we need to pop the file out of list regardless the compilation for each sub-example pass of fail

Copy link
Contributor

Choose a reason for hiding this comment

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

May I request that this comment is added to the code please.

test_json['builds'][test_group]['tests'][name]={"binaries":image_info}
else:
print("Warning: Test for %s will not be generated." % name)
print("One or more of 'test' 'baud_rate' and 'compare_log' keys are missing from the json file\n")
Copy link
Contributor

Choose a reason for hiding this comment

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

nit pick on wording, missing some commas:

Suggested change
print("One or more of 'test' 'baud_rate' and 'compare_log' keys are missing from the json file\n")
print("One or more of 'test', 'baud_rate', and 'compare_log' keys are missing from the example config json file\n")

Copy link
Contributor

@0xc0170 0xc0170 left a comment

Choose a reason for hiding this comment

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

Besides above suggestions, LGTM

Copy link
Contributor

@OPpuolitaival OPpuolitaival left a comment

Choose a reason for hiding this comment

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

Need documenting at least

@@ -380,31 +382,60 @@ def compile_repos(config, toolchains, targets, profile, verbose, examples):
successes = []
compiled = True
pass_status = True
if example.has_key('test') and example.has_key('baud_rate') and example.has_key('compare_log'):
Copy link
Contributor

@OPpuolitaival OPpuolitaival May 3, 2019

Choose a reason for hiding this comment

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

This is true for this kind of json object:
{
"name": "Something",
"test": False,
"baund_rate": "invalid",
"compare_log": null
}

Why it need to have "test" key even if the value is not documented or does not even matter?

These values really need to be documented. Actually same problem with whole examples.json. @adbridge do you know any documentation for that json file?

Copy link
Contributor

Choose a reason for hiding this comment

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

No not that i am aware of....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To me, the test key is just a on/off switch. similar to the compile key, just following the conventions.
It can be used, when we have the compare_log and baud_rate ready, but choose not run the test for some reasons. (e.g. the example requires some special HW, but that's not available on the RaaS, or there are some breaking change happening, we need to turn off tests for some examples temperately )

Copy link
Contributor

Choose a reason for hiding this comment

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

@jamesbeyond then the condition need to check the value of example['test'] alse. For example:
if example.has_key('test') and example['test'] and example.has_key('baud_rate') and example.has_key('compare_log'):

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I was checking that condition in later code, after reviewing, I think what you suggested would be more make scene. So this is fixed

@jamesbeyond
Copy link
Contributor Author

all comments been addressed, please review again @bridadan @OPpuolitaival

Copy link
Contributor

@bridadan bridadan left a comment

Choose a reason for hiding this comment

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

Thanks for addressing my comments!

@0xc0170
Copy link
Contributor

0xc0170 commented May 13, 2019

While waiting for final approvals, CI started

@mbed-ci
Copy link

mbed-ci commented May 13, 2019

Test run: SUCCESS

Summary: 11 of 11 test jobs passed
Build number : 1
Build artifacts

@0xc0170
Copy link
Contributor

0xc0170 commented May 15, 2019

@OPpuolitaival @adbridge Happy with this?

PRs to examples are slowly getting integrated

Copy link
Contributor

@adbridge adbridge left a comment

Choose a reason for hiding this comment

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

It would be better to use the logging module rather than print but I'm not going to block the PR on that. That could always be a downline improvement.

@jamesbeyond
Copy link
Contributor Author

It would be better to use the logging module rather than print but I'm not going to block the PR on that. That could always be a downline improvement.

Yeah, I just following the original script that using the print. I agree logging module would be a better solution. I think we will consider the improvements in separate PR

@adbridge
Copy link
Contributor

@mark-edgeworth are you happy with the comment?

Copy link
Contributor

@mark-edgeworth mark-edgeworth left a comment

Choose a reason for hiding this comment

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

Yes, that's what I had in mind 👍

@jamesbeyond
Copy link
Contributor Author

I think we got good level of reviews, can we have the CI start? @ARMmbed/mbed-os-maintainers

@0xc0170
Copy link
Contributor

0xc0170 commented May 20, 2019

CI started

@jamesbeyond
Copy link
Contributor Author

seems something wrong with checkout stage of the CI? @ARMmbed/mbed-os-maintainers

@cmonr
Copy link
Contributor

cmonr commented May 20, 2019

Pipeline restarted.
Recently, GitHub has increased the degree of repo clone throttling.

@mbed-ci
Copy link

mbed-ci commented May 20, 2019

Test run: SUCCESS

Summary: 11 of 11 test jobs passed
Build number : 3
Build artifacts

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.

9 participants