Loading README.md +10 −0 Changes for README.md: 10 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -185,6 +185,16 @@ execute the following command: It will generate a specific `errors.log` file into the `results` folder with the description of the different steps developed and the mismatched observed on them. ### Keep the requests and responses out of the terminal Every request and response is written to the terminal as well as to `log.html`. On a full run that is thousands of them. With `ETSI_QUIET_IO=1` they go to `log.html` and `output.xml` only, and the terminal shows one line per Test Case: ```ETSI_QUIET_IO=1 robot --outputdir ./results ./TP/NGSI-LD``` The `Output` and `Output Notification` keywords also take `console=${False}` for a single call. ### Measure the API coverage of a run [scripts/api_coverage](./scripts/api_coverage) counts, from a run's `output.xml`, which operations of the NGSI-LD Loading libraries/logUtils.py +33 −8 Changes for libraries/logUtils.py: 33 added lines, 8 removed lines. Original line number Diff line number Diff line from __future__ import unicode_literals from __future__ import division from json import dumps, JSONDecodeError, loads from os import environ from robot.api import logger from robot.api.deco import keyword def _to_console(console): """Should this be echoed to the terminal? The `console` argument of the keywords below is documented ("If false, the JSON is not written to terminal") and was ignored - every request and every response went to the terminal. On a full run that is thousands of request/response pairs, which bury the one line per test that tells what happened. ETSI_QUIET_IO=1 switches the echo off for the whole run, without touching a test. Nothing is lost: logger.info always writes to log.html and output.xml. `console` may come from Robot as a string ("False", "no", "0", "off"). """ if environ.get("ETSI_QUIET_IO") == "1": return False if isinstance(console, str): return console.strip().lower() not in ("false", "no", "0", "off", "") return bool(console) @keyword(name="Output", tags=("I/O",)) def output(response, description, console=True): """*Request and response are output to terminal and file (in JSON).* Loading Loading @@ -34,11 +55,13 @@ def output(response, description, console=True): pretty_request_json = dumps(request_json, indent=4, sort_keys=False, separators=(",", ": ")) pretty_response_json = dumps(response_json, indent=4, sort_keys=False, separators=(",", ": ")) logger.info("\n" + description, also_console=True) logger.info("Request ->", also_console=True) logger.info(pretty_request_json, also_console=True) logger.info("Response ->", also_console=True) logger.info(pretty_response_json, also_console=True) echo = _to_console(console) logger.info("\n" + description, also_console=echo) logger.info("Request ->", also_console=echo) logger.info(pretty_request_json, also_console=echo) logger.info("Response ->", also_console=echo) logger.info(pretty_response_json, also_console=echo) @keyword(name="Output Notification", tags=("I/O",)) Loading @@ -54,6 +77,8 @@ def output_notification(body, headers, description, console=True): pretty_request_json = dumps(request_json, indent=4, sort_keys=False, separators=(",", ": ")) logger.info("\n" + description, also_console=True) logger.info("Notification ->", also_console=True) logger.info(pretty_request_json, also_console=True) echo = _to_console(console) logger.info("\n" + description, also_console=echo) logger.info("Notification ->", also_console=echo) logger.info(pretty_request_json, also_console=echo) Loading
README.md +10 −0 Changes for README.md: 10 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -185,6 +185,16 @@ execute the following command: It will generate a specific `errors.log` file into the `results` folder with the description of the different steps developed and the mismatched observed on them. ### Keep the requests and responses out of the terminal Every request and response is written to the terminal as well as to `log.html`. On a full run that is thousands of them. With `ETSI_QUIET_IO=1` they go to `log.html` and `output.xml` only, and the terminal shows one line per Test Case: ```ETSI_QUIET_IO=1 robot --outputdir ./results ./TP/NGSI-LD``` The `Output` and `Output Notification` keywords also take `console=${False}` for a single call. ### Measure the API coverage of a run [scripts/api_coverage](./scripts/api_coverage) counts, from a run's `output.xml`, which operations of the NGSI-LD Loading
libraries/logUtils.py +33 −8 Changes for libraries/logUtils.py: 33 added lines, 8 removed lines. Original line number Diff line number Diff line from __future__ import unicode_literals from __future__ import division from json import dumps, JSONDecodeError, loads from os import environ from robot.api import logger from robot.api.deco import keyword def _to_console(console): """Should this be echoed to the terminal? The `console` argument of the keywords below is documented ("If false, the JSON is not written to terminal") and was ignored - every request and every response went to the terminal. On a full run that is thousands of request/response pairs, which bury the one line per test that tells what happened. ETSI_QUIET_IO=1 switches the echo off for the whole run, without touching a test. Nothing is lost: logger.info always writes to log.html and output.xml. `console` may come from Robot as a string ("False", "no", "0", "off"). """ if environ.get("ETSI_QUIET_IO") == "1": return False if isinstance(console, str): return console.strip().lower() not in ("false", "no", "0", "off", "") return bool(console) @keyword(name="Output", tags=("I/O",)) def output(response, description, console=True): """*Request and response are output to terminal and file (in JSON).* Loading Loading @@ -34,11 +55,13 @@ def output(response, description, console=True): pretty_request_json = dumps(request_json, indent=4, sort_keys=False, separators=(",", ": ")) pretty_response_json = dumps(response_json, indent=4, sort_keys=False, separators=(",", ": ")) logger.info("\n" + description, also_console=True) logger.info("Request ->", also_console=True) logger.info(pretty_request_json, also_console=True) logger.info("Response ->", also_console=True) logger.info(pretty_response_json, also_console=True) echo = _to_console(console) logger.info("\n" + description, also_console=echo) logger.info("Request ->", also_console=echo) logger.info(pretty_request_json, also_console=echo) logger.info("Response ->", also_console=echo) logger.info(pretty_response_json, also_console=echo) @keyword(name="Output Notification", tags=("I/O",)) Loading @@ -54,6 +77,8 @@ def output_notification(body, headers, description, console=True): pretty_request_json = dumps(request_json, indent=4, sort_keys=False, separators=(",", ": ")) logger.info("\n" + description, also_console=True) logger.info("Notification ->", also_console=True) logger.info(pretty_request_json, also_console=True) echo = _to_console(console) logger.info("\n" + description, also_console=echo) logger.info("Notification ->", also_console=echo) logger.info(pretty_request_json, also_console=echo)