Support 2-digit major versions pkgs, add tests 52/76652/2
authorDaniel Farrell <dfarrell@redhat.com>
Thu, 4 Oct 2018 15:17:33 +0000 (11:17 -0400)
committerDaniel Farrell <dfarrell@redhat.com>
Thu, 4 Oct 2018 20:05:10 +0000 (16:05 -0400)
The regular expression that was extracting major version numbers from
URLs was assuming the major version number was one digit. Allow it to be
one or more digits. Add tests that fail (as-expected) without the test,
in the same way the functional tests for Neon fail.

Jira: INTPAK-204
Change-Id: I369606cc7cc7ba57baa2b80ba497ae6367602289
Signed-off-by: Daniel Farrell <dfarrell@redhat.com>
packages/lib.py
packages/test_lib.py

index 96d5923208be0b7d6828c526f59aa7f27940f1f1..dccda7cfa928193dfbf63a823d8446b0800058dd 100644 (file)
@@ -61,7 +61,7 @@ def extract_version(url):
     #  distribution-karaf-0.3.4-Lithium-SR4.tar.gz
     # major_version = 3
     # minor_version = 4
-    re_out = re.search(r'\d\.(\d)\.(\d)', url)
+    re_out = re.search(r'\d\.(\d+)\.(\d)', url)
     version["version_major"] = re_out.group(1)
     version["version_minor"] = re_out.group(2)
 
index d394d31e6775bbcdd36141c1ed4d232b50892226..2bf5511eb1cab3d8106b17b66a01c81c4098afb4 100644 (file)
@@ -103,6 +103,28 @@ class TestExtractVersion(unittest.TestCase):
         self.assertEqual(version["pkg_version"], "0.1.20180411snap563")
         self.assertEqual(version["codename"], "-SNAPSHOT")
 
+    def test_neon_snapshot_url(self):
+        """Test URL of an ODL Neon snapshot build."""
+        # NB: This will need to be updated as old builds expire
+        url = "%s/opendaylight.snapshot/org/opendaylight/integration/karaf/0.10.0-SNAPSHOT/karaf-0.10.0-20181004.142605-697.tar.gz" % self.nexus_url
+        version = lib.extract_version(url)
+        self.assertEqual(version["version_major"], "10")
+        self.assertEqual(version["version_minor"], "0")
+        self.assertEqual(version["version_patch"], "0")
+        self.assertEqual(version["pkg_version"], "0.1.20181004snap697")
+        self.assertEqual(version["codename"], "-SNAPSHOT")
+
+    def test_neon_snapshot_zip_url(self):
+        """Test URL of an ODL Neon snapshot build zip archive."""
+        # NB: This will need to be updated as old builds expire
+        url = "%s/opendaylight.snapshot/org/opendaylight/integration/karaf/0.10.0-SNAPSHOT/karaf-0.10.0-20181004.142605-697.zip" % self.nexus_url
+        version = lib.extract_version(url)
+        self.assertEqual(version["version_major"], "10")
+        self.assertEqual(version["version_minor"], "0")
+        self.assertEqual(version["version_patch"], "0")
+        self.assertEqual(version["pkg_version"], "0.1.20181004snap697")
+        self.assertEqual(version["codename"], "-SNAPSHOT")
+
     def test_oxygen_multipatch_zip_url(self):
         """Test URL of an ODL Oxygen multipatch-test build zip archive."""
         # NB: This will need to be updated as old builds expire
@@ -125,6 +147,17 @@ class TestExtractVersion(unittest.TestCase):
         self.assertEqual(version["pkg_version"], "0.1.20180531snap59")
         self.assertEqual(version["codename"], "-SNAPSHOT")
 
+    def test_neon_multipatch_zip_url(self):
+        """Test URL of an ODL Neon multipatch-test build zip archive."""
+        # NB: This will need to be updated as old builds expire
+        url = "%s/opendaylight.snapshot/org/opendaylight/integration/integration/distribution/karaf/0.10.0-SNAPSHOT/karaf-0.10.0-20180925.093600-5.zip" % self.nexus_url
+        version = lib.extract_version(url)
+        self.assertEqual(version["version_major"], "10")
+        self.assertEqual(version["version_minor"], "0")
+        self.assertEqual(version["version_patch"], "0")
+        self.assertEqual(version["pkg_version"], "0.1.20180925snap5")
+        self.assertEqual(version["codename"], "-SNAPSHOT")
+
 
 class TestGetSnapURL(unittest.TestCase):