You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@madlib.apache.org by njayaram2 <gi...@git.apache.org> on 2018/07/11 18:38:32 UTC
[GitHub] madlib pull request #290: madpack: Add madpack option to run unit tests.
GitHub user njayaram2 opened a pull request:
https://github.com/apache/madlib/pull/290
madpack: Add madpack option to run unit tests.
JIRA: MADLIB-1252
Unit tests in MADlib are written in python files, that are located in
the ...<module_name>/test/unit_tests/ folders, whose names begin with
the prefix "test_". This commit adds a new madpack option to run unit
tests similar to how we run install and dev checks.
- The new option added is: `unit-test`.
- Sample usage (on a postgres database, with MADlib installed on
database `madlib`):
* Run unit tests on all modules that have it defined:
src/bin/madpack -p postgres -c /madlib unit-test
* Run unit tests only for the `convex` module:
src/bin/madpack -p postgres -c /madlib unit-test -t convex
* Run unit tests only for the `convex` and decision trees module:
src/bin/madpack -p postgres -c /madlib unit-test -t
convex,recursive_partitioning/decision_tree
- Add command to run all unit tests in Jenkins build script.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/madlib/madlib madpack/unit-test
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/madlib/pull/290.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #290
----
commit 5f4395bc8548a5f74ba9a8fcb716f2a39ec51162
Author: Nandish Jayaram <nj...@...>
Date: 2018-07-11T00:32:24Z
madpack: Add madpack option to run unit tests.
JIRA: MADLIB-1252
Unit tests in MADlib are written in python files, that are located in
the ...<module_name>/test/unit_tests/ folders, whose names begin with
the prefix "test_". This commit adds a new madpack option to run unit
tests similar to how we run install and dev checks.
- The new option added is: `unit-test`.
- Sample usage (on a postgres database, with MADlib installed on
database `madlib`):
* Run unit tests on all modules that have it defined:
src/bin/madpack -p postgres -c /madlib unit-test
* Run unit tests only for the `convex` module:
src/bin/madpack -p postgres -c /madlib unit-test -t convex
* Run unit tests only for the `convex` and decision trees module:
src/bin/madpack -p postgres -c /madlib unit-test -t
convex,recursive_partitioning/decision_tree
- Add command to run all unit tests in Jenkins build script.
----
---
[GitHub] madlib issue #290: madpack: Add madpack option to run unit tests.
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit commented on the issue:
https://github.com/apache/madlib/pull/290
Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/madlib-pr-build/548/
---
[GitHub] madlib issue #290: madpack: Add madpack option to run unit tests.
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit commented on the issue:
https://github.com/apache/madlib/pull/290
Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/madlib-pr-build/547/
---
[GitHub] madlib issue #290: madpack: Add madpack option to run unit tests.
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit commented on the issue:
https://github.com/apache/madlib/pull/290
Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/madlib-pr-build/549/
---
[GitHub] madlib pull request #290: madpack: Add madpack option to run unit tests.
Posted by iyerr3 <gi...@git.apache.org>.
Github user iyerr3 commented on a diff in the pull request:
https://github.com/apache/madlib/pull/290#discussion_r201876605
--- Diff: src/madpack/madpack.py ---
@@ -809,22 +811,100 @@ def parse_arguments():
help="Temporary directory location for installation log files.")
parser.add_argument('-t', '--testcase', dest='testcase', default="",
- help="Module names to test, comma separated. Effective only for install-check.")
+ help="Module names to test, comma separated. Effective only for install-check, dev-check and unit-test.")
# Get the arguments
return parser.parse_args()
+def _is_madlib_installation_valid_for_tests(schema, db_madlib_ver):
+ # Compare OS and DB versions. Continue if OS = DB.
+ if get_rev_num(db_madlib_ver) != get_rev_num(new_madlib_ver):
+ _print_vers(new_madlib_ver, db_madlib_ver, con_args, schema)
+ info_(this, "Versions do not match. Unit-test stopped.", True)
+ return False
+ return True
+
+def _get_modset_for_tests(testcase, filename_prefix=''):
+ # Get all module and algo names to run tests for, is specified as a comma
+ # separated list.
+ info_(this, "> Running unit test scripts for:", verbose)
+ caseset = (set([test.strip() for test in testcase.split(',')])
+ if testcase != "" else set())
+ modset = {}
+ for case in caseset:
+ if case.find('/') > -1:
+ [mod, algo] = case.split('/')
+ if mod not in modset:
+ modset[mod] = []
+ if algo not in modset[mod]:
+ modset[mod].append(filename_prefix+algo)
+ else:
+ modset[case] = []
+ return modset
+
+def run_unit_tests(args, testcase):
+ """
+ Run unit tests.
+ """
+ if not _is_madlib_installation_valid_for_tests(args['schema'],
+ args['db_madlib_ver']):
+ return
+ modset = _get_modset_for_tests(testcase, 'test_')
+ # Loop through all modules and run unit tests
+ for moduleinfo in portspecs['modules']:
--- End diff --
We've a similar loop/pattern in multiple places within `madpack.py`. Can we refactor them all to simplify these functions.
---
[GitHub] madlib pull request #290: madpack: Add madpack option to run unit tests.
Posted by iyerr3 <gi...@git.apache.org>.
Github user iyerr3 commented on a diff in the pull request:
https://github.com/apache/madlib/pull/290#discussion_r201876197
--- Diff: src/ports/postgres/modules/convex/test/unit_tests/test_mlp_igd.py_in ---
@@ -126,10 +126,11 @@ class MLPMiniBatchTestCase(unittest.TestCase):
'dependent_varname': 'value',
'class_values': 'regression',
'grouping_cols': 'value',
+ 'dependent_vartype': 'value',
'foo': 'bar'}]
self.module = self.subject.MLPMinibatchPreProcessor("input")
self.assertTrue(self.module.preprocessed_summary_dict)
- self.assertEqual(5, len(self.module.preprocessed_summary_dict))
+ self.assertEqual(6, len(self.module.preprocessed_summary_dict))
--- End diff --
Let's put this as a separate commit (can be pushed to master already) since it's unrelated to this PR.
---
[GitHub] madlib pull request #290: madpack: Add madpack option to run unit tests.
Posted by njayaram2 <gi...@git.apache.org>.
Github user njayaram2 closed the pull request at:
https://github.com/apache/madlib/pull/290
---
[GitHub] madlib issue #290: madpack: Add madpack option to run unit tests.
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit commented on the issue:
https://github.com/apache/madlib/pull/290
Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/madlib-pr-build/544/
---
[GitHub] madlib issue #290: madpack: Add madpack option to run unit tests.
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit commented on the issue:
https://github.com/apache/madlib/pull/290
Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/madlib-pr-build/555/
---
[GitHub] madlib issue #290: madpack: Add madpack option to run unit tests.
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit commented on the issue:
https://github.com/apache/madlib/pull/290
Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/madlib-pr-build/546/
---
[GitHub] madlib issue #290: madpack: Add madpack option to run unit tests.
Posted by njayaram2 <gi...@git.apache.org>.
Github user njayaram2 commented on the issue:
https://github.com/apache/madlib/pull/290
Thank you for the comments @iyerr3 , will do the needful.
---