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')
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)
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):