Merge "Fix connection timeouts in URL downloader"
[osm/SO.git] / rwlaunchpad / plugins / rwpkgmgr / test / utest_publisher_dts.py
index a02e5c6..518b927 100755 (executable)
@@ -145,7 +145,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 +153,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):