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

Create a new module: new_test_util #111

Merged
merged 7 commits into from
Apr 24, 2018
Merged

Create a new module: new_test_util #111

merged 7 commits into from
Apr 24, 2018

Conversation

ankushagarwal
Copy link

@ankushagarwal ankushagarwal commented Apr 21, 2018

Create a new module: new_test_util.py. This is intended to replace test_util.py. It includes a number of changes:

  • Uses junit-xml module to create test xml files instead of manually creating them
  • Show test case logs in gubernator (so that we don't have to rely on argo to show logs)
  • Reduce boilerplate code required to create a new test
  • Wrap every test case so that one failing test case does not prevent other tests from running
  • Provide an init method which handles heavy lifting of setting up logging and common args

Also

  • Refactor py_checks into test_py_checks and test_py_lint

    • These are written using new_test_util module
  • Eventually the plan is to move all existing tests across Kubeflow to new_test_util

  • Move from mlkube-testing to kubeflow-ci for test worker image

/cc @lluunn
/cc @jlewi

…st_util.py. It includes a number of changes:

* Uses junit-xml module to create test xml files instead of manually creating them
* Show test case logs in gubernator (so that we don't have to rely on argo to show logs)
* Reduce boilerplate code required to create a new test
* Wrap every test case so that one failing test case does not prevent other tests from running
* Provide an init method which handles heavy lifting of setting up logging and common args

Also
* Refactor py_checks into test_py_checks and test_py_lint
  * These are written using new_test_util module

* Eventually the plan is to move all existing tests across Kubeflow to new_test_util

* Move from mlkube-testing to kubeflow-ci for test worker image
@k8s-ci-robot k8s-ci-robot requested review from jlewi and lluunn April 21, 2018 01:39
@ankushagarwal ankushagarwal changed the title Create a new module: new_test_util.py. This is intended to replace test_util.py. It includes a number of changes: Create a new module: new_test_util Apr 21, 2018
self.test_func = test_func
super(TestCase, self).__init__(**kwargs)

def add_failure_info(self, message=None, output=None, failure_type=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

please add doc. what's this function for and what is each arg.

Copy link
Author

Choose a reason for hiding this comment

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

Done


def generate_xml(self):
output_file = os.path.join(self.artifacts_dir,
"junit_" + self.name + ".xml")
Copy link
Contributor

Choose a reason for hiding this comment

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

I remember we should replace "_" by "-" (or the opposite) in the name?

Copy link
Author

Choose a reason for hiding this comment

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

I tested _ and it seems to work.

The Gubernator example https://github.com/kubernetes/test-infra/tree/master/gubernator also uses _

Copy link
Contributor

Choose a reason for hiding this comment

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

See #638.
https://github.com/kubeflow/kubeflow/pull/638/files#diff-2552a6a0cb5a74e3184790464405bedcR309

test-grid is the problem and we want only 1 "_" in the name.

Please fix and a comment explaining why we do this.

def generate_xml(self):
output_file = os.path.join(self.artifacts_dir,
"junit_" + self.name + ".xml")
ET.ElementTree(ET.fromstring(junit_xml.TestSuite.to_xml_string(
Copy link
Contributor

Choose a reason for hiding this comment

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

what's this elementTree doing?

Copy link
Author

Choose a reason for hiding this comment

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

My bad. This long chained function call is not easy to understand. Added comment to explain what's happening and broke this down into 3 separate calls.

@ankushagarwal
Copy link
Author

/retest


This is intended to replace test_util.py
"""
import argparse
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we just call this package util.py?
The package is kubeflow.testing
so unless we already have a util.py file that seems fine. And this avoids the prefix "new".

We should avoid the prefix "new" because at some point we'd probably want to rename it anyway since the "new" will no longer be relevant and then we'd just have to update a bunch of call sites.

So it would be better to pick a name that we won't want to change.

Copy link
Author

Choose a reason for hiding this comment

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

We already have a util.py

Copy link
Author

Choose a reason for hiding this comment

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

Renamed to test_helper.py

@jlewi
Copy link
Contributor

jlewi commented Apr 24, 2018

nice change.

@jlewi
Copy link
Contributor

jlewi commented Apr 24, 2018

/lgtm but I only did a drive by review to respond to the issue with "_" so please wait for Lunkai to review.
/hold

@lluunn
Copy link
Contributor

lluunn commented Apr 24, 2018

/lgtm

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jlewi, lluunn

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ankushagarwal
Copy link
Author

/hold cancel

@k8s-ci-robot k8s-ci-robot merged commit bfab11b into kubeflow:master Apr 24, 2018
k8s-ci-robot pushed a commit to kubeflow/examples that referenced this pull request Apr 24, 2018
@ankushagarwal ankushagarwal deleted the make-testing-great-again2 branch April 25, 2018 16:54
k8s-ci-robot pushed a commit to kubeflow/training-operator that referenced this pull request May 4, 2018
* Update py_lint and py_test

kubeflow/testing#111 refactored these two tests
into two separate files

/cc @gaocegege

* Ignore jupyterhub_spawner.py
yph152 pushed a commit to yph152/tf-operator that referenced this pull request Jun 18, 2018
* Update py_lint and py_test

kubeflow/testing#111 refactored these two tests
into two separate files

/cc @gaocegege

* Ignore jupyterhub_spawner.py
jetmuffin pushed a commit to jetmuffin/tf-operator that referenced this pull request Jul 9, 2018
* Update py_lint and py_test

kubeflow/testing#111 refactored these two tests
into two separate files

/cc @gaocegege

* Ignore jupyterhub_spawner.py
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.

4 participants