Network access during unit tests

Bug #1791586 reported by Thomas Goirand
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
TOSCA Parser
New
Medium
Unassigned

Bug Description

Hi. Building the tosca-parser package in Debian, we also run unit tests. Unfortunately, a number of them are doing network access, for example downloading stuff from github. This is by definition forbidden in the Debian policy, so I had to patch them out.

To make sure there is no network access, I'm also setting-up environment variables:
export http_proxy=127.0.0.1:9
export https_proxy=127.0.0.1:9
export HTTP_PROXY=127.0.0.1:9
export HTTPS_PROXY=127.0.0.1:9
export RES_OPTIONS=attempts:0

This is the normal way to disable network in the debian/rules file.

What would be great was if the tosca-parser unit test suite could detect the above environment variable, and if they are present, just don't run these unit tests that are doing network access. Indeed, having Debian specific patches to maintain is painful on each new upstream release. This could easily be done using function decorators (skipIf...). For example, using testtools, something like this could be done:

@testtools.skipIf(os.environ['RES_OPTIONS'] == 'attempts:0',
                  'Disabled doing network access in test suite')

Please consider doing this, this would really be helpful for downstream package maintainers.

Cheers,

Thomas Goirand (zigo)

Revision history for this message
Thomas Goirand (thomas-goirand) wrote :

I forgot to post the list of unit test with problems. Here it is:

test_prereq.CSARPrereqTest.test_url_is_zip
test_prereq.CSARPrereqTest.test_csar_invalid_import_url
test_prereq.CSARPrereqTest.test_valid_csar_with_url_import_and_script
test_toscatpl.ToscaTemplateTest.test_repositories_definition
test_toscatpl.ToscaTemplateTest.test_csar_parsing_elk_url_based
test_toscatpl.ToscaTemplateTest.test_local_template_with_url_import
test_toscatpl.ToscaTemplateTest.test_repositories
test_toscatpl.ToscaTemplateTest.test_yaml_dict_tpl_with_params_and_url_import
test_toscatpl.ToscaTemplateTest.test_url_template_with_local_relpath_import
test_toscatpl.ToscaTemplateTest.test_url_template_with_url_import
test_toscatpl.ToscaTemplateTest.test_url_template_with_local_abspath_import
test_toscatplvalidation.ToscaTemplateValidationTest.test_imports_file_namespace_fields
test_toscatplvalidation.ToscaTemplateValidationTest.test_imports_without_import_name
test_toscatplvalidation.ToscaTemplateValidationTest.test_imports_duplicate_name
test_toscatplvalidation.ToscaTemplateValidationTest.test_imports_wth_import_name
test_toscatplvalidation.ToscaTemplateValidationTest.test_imports_file_with_uri

Changed in tosca-parser:
importance: Undecided → Medium
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.