MADlibers, I've been playing around Python code coverage ( https://coverage.readthedocs.io/en/coverage-4.4.1/) for MADlib python modules. As an example using PostgreSQL 9.6, I have been able to instrument the graph/apsp module (I think), run the corresponding install-check tests and generate a coverage report. I provide it here in case anyone is interested in playing with it.
System: macOS Sierra (Version 10.12.6) Code base: MADlib master Postgres: psql (PostgreSQL) 9.6.3 Install Python code coverage module - pip install coverage Apply the following patch to src/ports/postgres/modules/graph/apsp.py_in: diff --git a/src/ports/postgres/modules/graph/apsp.py_in b/src/ports/postgres/modules/graph/apsp.py_in index 42ee698d..34d09c12 100644 --- a/src/ports/postgres/modules/graph/apsp.py_in +++ b/src/ports/postgres/modules/graph/apsp.py_in @@ -1,4 +1,4 @@ -# coding=utf-8 +1# coding=utf-8 # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file @@ -27,6 +27,9 @@ @namespace graph """ +import coverage +cov = coverage.Coverage() +cov.start() import plpy from graph_utils import validate_graph_coding @@ -487,6 +490,8 @@ def graph_apsp(schema_madlib, vertex_table, vertex_id, edge_table, if is_hawq: plpy.execute("DROP TABLE IF EXISTS {0}".format(out_table_2)) + cov.save() + cov.html_report(directory='/Users/espino/python_coverage_html_report') return None Perform build: - rm -rf /usr/local/madlib; make -j8 install Install MADlib: - dropdb madlibtest; createdb madlibtest; /usr/local/madlib/bin/madpack -s madlib -p postgres install Run install-check (only for graph/apsp): - /usr/local/madlib/bin/madpack -s madlib -p postgres install-check -t graph/apsp Review report: - The code coverage report will be generated in /Users/espino/python_coverage_html_report. Open up the index.html file in your browser to view results. I'd be interested to hear if anyone else got it to work. Regards, -=e -- *Ed Espino*