X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=rwlaunchpad%2Fplugins%2Frwpkgmgr%2Ftest%2Futest_publisher_dts.py;h=b5ea4805c98f94fe7f5e903b74ef7d04a5c728b5;hb=da28246cbc7b0118355b94df11e8d0dca1590932;hp=a02e5c665a7c01f38fe9a0a836e06ecfb208e5c8;hpb=7032313e5ce57f8b0d76af95bcf51c985d4b8692;p=osm%2FSO.git diff --git a/rwlaunchpad/plugins/rwpkgmgr/test/utest_publisher_dts.py b/rwlaunchpad/plugins/rwpkgmgr/test/utest_publisher_dts.py index a02e5c66..b5ea4805 100755 --- a/rwlaunchpad/plugins/rwpkgmgr/test/utest_publisher_dts.py +++ b/rwlaunchpad/plugins/rwpkgmgr/test/utest_publisher_dts.py @@ -26,6 +26,10 @@ import unittest import uuid import xmlrunner +#Setting RIFT_VAR_ROOT if not already set for unit test execution +if "RIFT_VAR_ROOT" not in os.environ: + os.environ['RIFT_VAR_ROOT'] = os.path.join(os.environ['RIFT_INSTALL'], 'var/rift/unittest') + import gi gi.require_version('RwDts', '1.0') gi.require_version('RwPkgMgmtYang', '1.0') @@ -145,7 +149,7 @@ class TestCase(rift.test.dts.AbstractDTSTest): assert download_id is not None # Waiting for 5 secs to be sure that the file is downloaded - yield from asyncio.sleep(5, loop=self.loop) + yield from asyncio.sleep(10, loop=self.loop) xpath = "/download-jobs/job[download-id='{}']".format( download_id) result = yield from self.read_xpath(xpath) @@ -153,6 +157,32 @@ class TestCase(rift.test.dts.AbstractDTSTest): assert result.status == "COMPLETED" assert len(self.job_handler.tasks) == 0 + @rift.test.dts.async_test + def test_url_download_unreachable_ip(self): + """ + Integration Test: + Ensure that a bad IP does not block forever + """ + yield from self.job_handler.register() + + proxy = mock.MagicMock() + + # Here, we are assuming that there is no HTTP server at 10.1.2.3 + url = "http://10.1.2.3/common/unittests/plantuml.jar" + url_downloader = downloader.PackageFileDownloader(url, "1", "/", "VNFD", proxy) + + download_id = yield from self.job_handler.register_downloader(url_downloader) + assert download_id is not None + + # Waiting for 10 secs to be sure all reconnect attempts have been exhausted + yield from asyncio.sleep(10, loop=self.loop) + xpath = "/download-jobs/job[download-id='{}']".format( + download_id) + result = yield from self.read_xpath(xpath) + self.log.debug("Test result before complete check - %s", result) + assert result.status == "FAILED" + assert len(self.job_handler.tasks) == 0 + @rift.test.dts.async_test def test_cancelled(self):