def test_HadoopVersion(self): for vs, main, cdh, ext in [ ("0.20.2", (0, 20, 2), (), ()), ("0.20.203.0", (0, 20, 203, 0), (), ()), ("0.20.2-cdh3u4", (0, 20, 2), (3, 2, 4), ()), ("1.0.4-SNAPSHOT", (1, 0, 4), (), ("SNAPSHOT", )), ("2.0.0-mr1-cdh4.1.0", (2, 0, 0), (4, 1, 0), ("mr1", )), ("0.20.2+320", (0, 20, 2), (3, 0, 320), ()), ]: v = hu.HadoopVersion(vs) for name, attr in ("main", main), ("cdh", cdh), ("ext", ext): self.assertEqual(getattr(v, name), attr) self.assertEqual(v.is_cloudera(), len(v.cdh) > 0) self.assertEqual(v.tuple, main + cdh + ext) for s in "bla", '0.20.str', '0.20.2+str': self.assertRaises(hu.HadoopVersionError, hu.HadoopVersion, s)
def __get_available_versions(self): pattern = re.compile(r"^hadoop-.+\d$") available = [ hu.HadoopVersion(fn.split("-", 1)[1]) for fn in os.listdir("src") if pattern.match(fn) ] if self.hadoop_version_info.is_cloudera(): available = [vinfo for vinfo in available if ( vinfo.is_cloudera() and vinfo.main == self.hadoop_version_info.main and vinfo.ext == self.hadoop_version_info.ext )] cmp_attr = "cdh" else: available = [vinfo for vinfo in available if not vinfo.is_cloudera()] cmp_attr = "main" return available, cmp_attr
def test_HadoopVersion(self): for vs, main, dist, dver, dext in [ ("0.20.2", (0, 20, 2), 'apache', (), ()), ("0.20.203.0", (0, 20, 203, 0), 'apache', (), ()), ("0.20.2-cdh3u4", (0, 20, 2), 'cdh', (3, 2, 4), ()), ("1.0.4-SNAPSHOT", (1, 0, 4), 'apache', (), ("SNAPSHOT", )), ("2.0.0-mr1-cdh4.1.0", (2, 0, 0), 'cdh', (4, 1, 0), ("mr1", )), ("0.20.2+320", (0, 20, 2), 'apache', (3, 0, 320), ()), ("2.6.0.2.2.0.0-2041", (2, 6, 0), 'hdp', (2, 2, 0, 0), ('2041', )), ]: v = hu.HadoopVersion(vs) for name, attr in ("main", main), ('distribution', dist), \ ("dist_version", dver), ("dist_ext", dext): self.assertEqual(getattr(v, name), attr) self.assertEqual(v.is_cloudera(), dist == 'cdh') self.assertEqual(v.is_apache(), dist == 'apache') self.assertEqual(v.is_hortonworks(), dist == 'hdp') self.assertEqual(v.tuple, main + dver + dext) # minimal check -- tag is currently unused self.assertTrue(dist in v.tag()) for s in "bla", '0.20.str', '0.20.2+str': self.assertRaises(hu.HadoopVersionError, hu.HadoopVersion, s)