def test07_MPP_15789(self): """ This test covers the case of obsolete dependencies. When we update a gppkg and the new gppkg has different dependencies from the original gppkg, the dependencies of the original gppkg will get left behind. When we remove the gppkg, only the newer dependencies will be removed and the old ones will still remain on the system. """ update_gppkg_spec = GppkgSpec("alpha", "1.1") A_spec = RPMSpec("A", "2", "1", ["B = 1-1"]) B_spec = self.B_spec self.build(update_gppkg_spec, A_spec, [B_spec]) self.install(self.alpha_spec.get_filename()) self.update(update_gppkg_spec.get_filename()) self.remove(update_gppkg_spec.get_filename()) results = run_command("rpm -qa --dbpath %s" % RPM_DATABASE) self.assertEqual(results, "")
def test04_install_dependencies_incompatible(self): """ Install gppkg alpha with dependencies B, shared Install gppkg gamma with dependencies F, shared where version(gamma.shared) < version(alpha.shared) """ shared_dep_spec = RPMSpec("shared", "0", "1") F_spec = RPMSpec("F", "1", "1") E_spec = RPMSpec("E", "1", "1", ["F = 1-1", "shared = 0-1"]) gamma_spec = GppkgSpec("gamma", "1.0") self.build(gamma_spec, E_spec, [F_spec, shared_dep_spec]) self.install(self.alpha_spec.get_filename()) #The error generated by gppkg when we try to install a package with a lower version #when a higher version is already installed will be of the form #gppkg:fips1:subraa4-[INFO]:-Starting gppkg with args: --install test-1.0-Linux-x86_64.gppkg #gppkg:fips1:subraa4-[INFO]:-Installing package test-1.0-Linux-x86_64.gppkg #gppkg:fips1:subraa4-[INFO]:-Validating rpm installation cmdStr='rpm --test -i /data/abhijits/greenplum/.tmp/dep-1-1.x86_64.rpm /data/abhijits/greenplum/.tmp/shared-1-1.x86_64.rpm /data/abhijits/greenplum/.tmp/test-1-1.x86_64.rpm --dbpath /data/abhijits/greenplum/share/packages/database --prefix /data/abhijits/greenplum' #gppkg:fips1:subraa4-[INFO]:-Exception = 'shared-2-1.x86_64.rpm' #gppkg:fips1:subraa4-[INFO]:-Exception = 'shared-2-1.x86_64.rpm' #gppkg:fips1:subraa4-[CRITICAL]:-gppkg failed. (Reason=''shared-2-1.x86_64.rpm'') exiting... #rpm --test command blows up and that is the main reason for the error. #rpm --test -i shared-2-1.x86_64.rpm gives the following error when a newer version is already installed, # package shared-1-1.x86_64 is already installed with self.assertRaises(ExecutionError): self.install(gamma_spec.get_filename()) self.check_rpm_uninstall(shared_dep_spec.get_package_name()) self.check_rpm_install(self.shared_dep_spec.get_package_name())
def test06_MPP_15788(self): """ This test covers the case where we want to update a package but are unable to do so due to the restrictions imposed by another version of the dependency already installed on the system. """ A_spec = RPMSpec("A", "1", "1", ["B = 1-1", "shared = 1-1"]) C_spec = RPMSpec("C", "1", "1", ["D = 1-1", "shared = 1-1"]) self.build(self.alpha_spec, A_spec, [self.B_spec, self.shared_dep_spec]) self.build(self.beta_spec, C_spec, [self.D_spec, self.shared_dep_spec]) self.install(self.alpha_spec.get_filename()) self.install(self.beta_spec.get_filename()) #package to be updated update_gppkg_spec = GppkgSpec("alpha", "1.1") A_spec = RPMSpec("A", "2", "1", ["B = 2-1", "shared = 2-1"]) B_spec = RPMSpec("B", "2", "1") shared_dep_spec = RPMSpec("shared", "2", "1") self.build(update_gppkg_spec, A_spec, [B_spec, shared_dep_spec]) with self.assertRaises(ExecutionError): self.update(update_gppkg_spec.get_filename())
def setUp(self): self.A_spec = RPMSpec("A", "1", "1") self.alpha_spec = GppkgSpec("alpha", "1.0") self.B_spec = RPMSpec("B", "1", "1") self.beta_spec = GppkgSpec("beta", "1.0") self.alpha_info = ['Name alpha', 'Version 1.0', 'Architecture x86_64', 'OS %s' % OS, 'GPDBVersion %s' % GPDB_VERSION, 'Description Temporary Test Package']
class SingleDependenciesTestCase(GppkgTestCase): """Covers install/update/remove tests of gppkgs which have a single dependency""" def setUp(self): super(SingleDependenciesTestCase, self).cleanup() self.A_spec = RPMSpec("A", "1", "1", ["B = 1-1"]) self.B_spec = RPMSpec("B", "1", "1") self.alpha_spec = GppkgSpec("alpha", "1.0") def test00_build(self): self.build(self.alpha_spec, self.A_spec, [self.B_spec]) def test01_install(self): gppkg_file = self.build(self.alpha_spec, self.A_spec, [self.B_spec]) self.install(gppkg_file) def test02_update_gppkg_higher(self): """ This test tries to update a gppkg with a higher version and the main and dependent rpms with a higher version. """ #Use gppkg from previous test self.install(self.alpha_spec.get_filename()) #New gppkg with higher gppkg, main and deps version update_main_rpm_spec = RPMSpec("A", "1", "2", ["B = 1-2"]) update_dep_rpm_spec = RPMSpec("B", "1", "2") update_gppkg_spec = GppkgSpec("alpha", "1.1") update_gppkg_file = self.build(update_gppkg_spec, update_main_rpm_spec, [update_dep_rpm_spec]) self.update(update_gppkg_file) @unittest.expectedFailure def test03_update_gppkg_lower(self): """ This test tries to update a gppkg with a lower version and the main and dependent rpms with a lower version. """ #Use the gppkg from previous test update_main_rpm_spec = RPMSpec("A", "1", "2", ["B = 1-2"]) update_dep_rpm_spec = RPMSpec("B", "1", "2") update_gppkg_spec = GppkgSpec("alpha", "1.1") self.install(update_gppkg_spec.get_filename()) #Original gppkg with a lower gppkg, main and deps version with self.assertRaisesRegexp( ExecutionError, "A newer version of %s is already installed" % self.alpha_spec.get_filename()): self.update(self.alpha_spec.get_filename()) def test04_uninstall(self): self.install(self.alpha_spec.get_filename()) self.remove(self.alpha_spec.get_filename())
def setUp(self): self.cleanup() self.alpha_spec = GppkgSpec("alpha", "1.0") self.A_spec = RPMSpec("A", "1", "1", ["B = 1-1", "shared >= 1-1"]) self.B_spec = RPMSpec("B", "1", "1") self.beta_spec = GppkgSpec("beta", "1.0") self.C_spec = RPMSpec("C", "1", "1", ["D = 1-1", "shared >= 1-1"]) self.D_spec = RPMSpec("D", "1", "1") self.shared_dep_spec = RPMSpec("shared", "1", "1")
def setUp(self): self.A_spec = RPMSpec("A", "1", "1") self.alpha_spec = GppkgSpec("alpha", "1.0") self.B_spec = RPMSpec("B", "1", "1") self.beta_spec = GppkgSpec("beta", "1.0") self.alpha_info = [ 'Name alpha', 'Version 1.0', 'Architecture x86_64', 'OS %s' % OS, 'GPDBVersion %s' % GPDB_VERSION, 'Description Temporary Test Package' ]
def test03_update_gppkg_lower(self): """ This test tries to update a gppkg with a lower version and the main and dependent rpms with a lower version. """ #Use the gppkg from previous test update_main_rpm_spec = RPMSpec("A", "1", "2", ["B = 1-2"]) update_dep_rpm_spec = RPMSpec("B", "1", "2") update_gppkg_spec = GppkgSpec("alpha", "1.1") self.install(update_gppkg_spec.get_filename()) #Original gppkg with a lower gppkg, main and deps version with self.assertRaisesRegexp(ExecutionError, "A newer version of %s is already installed" % self.alpha_spec.get_filename()): self.update(self.alpha_spec.get_filename())
class SingleDependenciesTestCase(GppkgTestCase): """Covers install/update/remove tests of gppkgs which have a single dependency""" def setUp(self): super(SingleDependenciesTestCase, self).cleanup() self.A_spec = RPMSpec("A", "1", "1", ["B = 1-1"]) self.B_spec = RPMSpec("B", "1", "1") self.alpha_spec = GppkgSpec("alpha", "1.0") def test00_build(self): self.build(self.alpha_spec, self.A_spec, [self.B_spec]) def test01_install(self): gppkg_file = self.build(self.alpha_spec, self.A_spec, [self.B_spec]) self.install(gppkg_file) def test02_update_gppkg_higher(self): """ This test tries to update a gppkg with a higher version and the main and dependent rpms with a higher version. """ #Use gppkg from previous test self.install(self.alpha_spec.get_filename()) #New gppkg with higher gppkg, main and deps version update_main_rpm_spec = RPMSpec("A", "1", "2", ["B = 1-2"]) update_dep_rpm_spec = RPMSpec("B", "1", "2") update_gppkg_spec = GppkgSpec("alpha", "1.1") update_gppkg_file = self.build(update_gppkg_spec, update_main_rpm_spec, [update_dep_rpm_spec]) self.update(update_gppkg_file) @unittest.expectedFailure def test03_update_gppkg_lower(self): """ This test tries to update a gppkg with a lower version and the main and dependent rpms with a lower version. """ #Use the gppkg from previous test update_main_rpm_spec = RPMSpec("A", "1", "2", ["B = 1-2"]) update_dep_rpm_spec = RPMSpec("B", "1", "2") update_gppkg_spec = GppkgSpec("alpha", "1.1") self.install(update_gppkg_spec.get_filename()) #Original gppkg with a lower gppkg, main and deps version with self.assertRaisesRegexp(ExecutionError, "A newer version of %s is already installed" % self.alpha_spec.get_filename()): self.update(self.alpha_spec.get_filename()) def test04_uninstall(self): self.install(self.alpha_spec.get_filename()) self.remove(self.alpha_spec.get_filename())
def setUp(self): self.A_spec = RPMSpec("A", "1", "1") self.alpha_spec = GppkgSpec("alpha", "1.0") self.B_spec = RPMSpec("B", "1", "1") self.beta_spec = GppkgSpec("beta", "1.0") self.alpha_info = [ "Name alpha", "Version 1.0", "Architecture x86_64", "OS %s" % OS, "GPDBVersion %s" % GPDB_VERSION, "Description Temporary Test Package", ]
def test05_update_dependencies_incompatible(self): """ Installs gppkg alpha with dependencies B, shared Update gppkg alpha' with dependencies B, shared where version(alpha'.shared) < version(alpha.shared) and version(alpha') > version(alpha) """ update_gppkg_spec = GppkgSpec("alpha", "2.0") B_spec = self.B_spec A_spec = RPMSpec("A", "1", "1", ["B = 1-1", "shared = 0-1"]) shared_dep_spec = RPMSpec("shared", "0", "1") self.build(update_gppkg_spec, A_spec, [B_spec, shared_dep_spec]) self.install(self.alpha_spec.get_filename()) with self.assertRaises(ExecutionError): self.update(update_gppkg_spec.get_filename())
def test00_wrong_os(self): os = "abcde" A_spec = self.A_spec alpha_spec = GppkgSpec("alpha", "1.0", GPDB_VERSION, os) gppkg_file = self.build(alpha_spec, A_spec) with self.assertRaisesRegex(ExecutionError, "%s OS required. %s OS found" % (os, OS)): self.install(gppkg_file)
def test03_update(self): """ Covers the case of update of gppkg with a shared dependency """ self.install(self.alpha_spec.get_filename()) self.install(self.beta_spec.get_filename()) #package to be updated update_spec = GppkgSpec("alpha", "1.1") rpm_spec = RPMSpec("A", "1", "2", ["B = 1-1", "shared >= 2-1"]) dep_spec = self.B_spec shared_dep_spec = RPMSpec("shared", "2", "1") self.build(update_spec, rpm_spec, [dep_spec, shared_dep_spec]) self.update(update_spec.get_filename()) self.check_rpm_uninstall(self.shared_dep_spec.get_package_name()) self.check_rpm_install(shared_dep_spec.get_package_name())
def test08_wrong_os_update(self): os = "windows" self.install(self.alpha_spec.get_filename()) invalid_os_gppkg = GppkgSpec("alpha", "1.1", GPDB_VERSION, os) gppkg_file = self.build(invalid_os_gppkg, self.A_spec) with self.assertRaisesRegex(ExecutionError, "%s os required. %s os found" % (os, OS)): self.update(gppkg_file)
def test01_wrong_arch(self): arch = "abcde" A_spec = self.A_spec alpha_spec = GppkgSpec("alpha", "1.0", GPDB_VERSION, OS, arch) gppkg_file = self.build(alpha_spec, A_spec) with self.assertRaisesRegex( ExecutionError, "%s Arch required. %s Arch found" % (arch, ARCH)): self.install(gppkg_file)
def test02_wrong_gpdbversion(self): gpdb_version = "4.6" A_spec = self.A_spec alpha_spec = GppkgSpec("alpha", "1.0", gpdb_version) gppkg_file = self.build(alpha_spec, A_spec) with self.assertRaisesRegex( ExecutionError, "requires Greenplum Database version %s" % gpdb_version): self.install(gppkg_file)
def test04_update_gppkg_lower(self): """ This test tries to update a gppkg which has a lower version, but the main comprising rpm is of higher version than the one already installed on the system. """ #Use gppkg from previous test self.install(self.alpha_spec.get_filename()) #Use gppkg which has a lower version, but the rpm is > the one installed update_rpm_spec = RPMSpec("A", "1", "2") update_gppkg_spec = GppkgSpec("alpha", "0.1") update_gppkg_file = self.build(update_gppkg_spec, update_rpm_spec) with self.assertRaisesRegex( ExecutionError, "Newer version of %s already installed" % update_gppkg_spec.get_package_name()): self.update(update_gppkg_file) #Check that the original package is still installed and not updated assert self.check_install(self.alpha_spec.get_filename())
def test09_wrong_arch_update(self): arch = "abcde" self.install(self.alpha_spec.get_filename()) invalid_os_gppkg = GppkgSpec("alpha", "1.1", GPDB_VERSION, OS, arch) gppkg_file = self.build(invalid_os_gppkg, self.A_spec) with self.assertRaisesRegex( ExecutionError, "%s Arch required. %s Arch found" % (arch, ARCH)): self.update(gppkg_file)
def test02_simple_update(self): gppkg_file = self.alpha_spec.get_filename() self.install(gppkg_file) update_rpm_spec = RPMSpec("A", "1", "2") update_gppkg_spec = GppkgSpec("alpha", "1.1") update_gppkg_file = self.build(update_gppkg_spec, update_rpm_spec) self.update(update_gppkg_file) #Check for the packages self.check_rpm_install(update_rpm_spec.get_package_name())
def test02_update_gppkg_higher(self): """ This test tries to update a gppkg with a higher version and the main and dependent rpms with a higher version. """ #Use gppkg from previous test self.install(self.alpha_spec.get_filename()) #New gppkg with higher gppkg, main and deps version update_main_rpm_spec = RPMSpec("A", "1", "2", ["B = 1-2"]) update_dep_rpm_spec = RPMSpec("B", "1", "2") update_gppkg_spec = GppkgSpec("alpha", "1.1") update_gppkg_file = self.build(update_gppkg_spec, update_main_rpm_spec, [update_dep_rpm_spec]) self.update(update_gppkg_file)
def test04_update_gppkg_lower(self): """ This test tries to update a gppkg which has a lower version, but the main comprising rpm is of higher version than the one already installed on the system. """ #Use gppkg from previous test self.install(self.alpha_spec.get_filename()) #Use gppkg which has a lower version, but the rpm is > the one installed update_rpm_spec = RPMSpec("A", "1", "2") update_gppkg_spec = GppkgSpec("alpha", "0.1") update_gppkg_file = self.build(update_gppkg_spec, update_rpm_spec) with self.assertRaisesRegexp(ExecutionError, "Newer version of %s already installed" % update_gppkg_spec.get_package_name()): self.update(update_gppkg_file) #Check that the original package is still installed and not updated assert self.check_install(self.alpha_spec.get_filename())
class SharedDependenciesTestCase(GppkgTestCase): """Covers install/update/remove of gppkgs which have a shared dependency""" def setUp(self): self.cleanup() self.alpha_spec = GppkgSpec("alpha", "1.0") self.A_spec = RPMSpec("A", "1", "1", ["B = 1-1", "shared >= 1-1"]) self.B_spec = RPMSpec("B", "1", "1") self.beta_spec = GppkgSpec("beta", "1.0") self.C_spec = RPMSpec("C", "1", "1", ["D = 1-1", "shared >= 1-1"]) self.D_spec = RPMSpec("D", "1", "1") self.shared_dep_spec = RPMSpec("shared", "1", "1") def tearDown(self): self.cleanup() results = run_command('rpm -qa --dbpath %s' % RPM_DATABASE) rpms = results.split() for rpm in rpms: run_command('rpm -e %s --dbpath %s' % (rpm, RPM_DATABASE)) def test00_build(self): self.build(self.alpha_spec, self.A_spec, [self.B_spec, self.shared_dep_spec]) self.build(self.beta_spec, self.C_spec, [self.D_spec, self.shared_dep_spec]) def test01_install(self): self.install(self.alpha_spec.get_filename()) self.install(self.beta_spec.get_filename()) def test02_uninstall(self): self.install(self.alpha_spec.get_filename()) self.install(self.beta_spec.get_filename()) self.remove(self.beta_spec.get_filename()) self.check_rpm_install(self.shared_dep_spec.get_package_name()) def test03_update(self): """ Covers the case of update of gppkg with a shared dependency """ self.install(self.alpha_spec.get_filename()) self.install(self.beta_spec.get_filename()) #package to be updated update_spec = GppkgSpec("alpha", "1.1") rpm_spec = RPMSpec("A", "1", "2", ["B = 1-1", "shared >= 2-1"]) dep_spec = self.B_spec shared_dep_spec = RPMSpec("shared", "2", "1") self.build(update_spec, rpm_spec, [dep_spec, shared_dep_spec]) self.update(update_spec.get_filename()) self.check_rpm_uninstall(self.shared_dep_spec.get_package_name()) self.check_rpm_install(shared_dep_spec.get_package_name()) def test04_install_dependencies_incompatible(self): """ Install gppkg alpha with dependencies B, shared Install gppkg gamma with dependencies F, shared where version(gamma.shared) < version(alpha.shared) """ shared_dep_spec = RPMSpec("shared", "0", "1") F_spec = RPMSpec("F", "1", "1") E_spec = RPMSpec("E", "1", "1", ["F = 1-1", "shared = 0-1"]) gamma_spec = GppkgSpec("gamma", "1.0") self.build(gamma_spec, E_spec, [F_spec, shared_dep_spec]) self.install(self.alpha_spec.get_filename()) #The error generated by gppkg when we try to install a package with a lower version #when a higher version is already installed will be of the form #gppkg:fips1:subraa4-[INFO]:-Starting gppkg with args: --install test-1.0-Linux-x86_64.gppkg #gppkg:fips1:subraa4-[INFO]:-Installing package test-1.0-Linux-x86_64.gppkg #gppkg:fips1:subraa4-[INFO]:-Validating rpm installation cmdStr='rpm --test -i /data/abhijits/greenplum/.tmp/dep-1-1.x86_64.rpm /data/abhijits/greenplum/.tmp/shared-1-1.x86_64.rpm /data/abhijits/greenplum/.tmp/test-1-1.x86_64.rpm --dbpath /data/abhijits/greenplum/share/packages/database --prefix /data/abhijits/greenplum' #gppkg:fips1:subraa4-[INFO]:-Exception = 'shared-2-1.x86_64.rpm' #gppkg:fips1:subraa4-[INFO]:-Exception = 'shared-2-1.x86_64.rpm' #gppkg:fips1:subraa4-[CRITICAL]:-gppkg failed. (Reason=''shared-2-1.x86_64.rpm'') exiting... #rpm --test command blows up and that is the main reason for the error. #rpm --test -i shared-2-1.x86_64.rpm gives the following error when a newer version is already installed, # package shared-1-1.x86_64 is already installed with self.assertRaises(ExecutionError): self.install(gamma_spec.get_filename()) self.check_rpm_uninstall(shared_dep_spec.get_package_name()) self.check_rpm_install(self.shared_dep_spec.get_package_name()) def test05_update_dependencies_incompatible(self): """ Installs gppkg alpha with dependencies B, shared Update gppkg alpha' with dependencies B, shared where version(alpha'.shared) < version(alpha.shared) and version(alpha') > version(alpha) """ update_gppkg_spec = GppkgSpec("alpha", "2.0") B_spec = self.B_spec A_spec = RPMSpec("A", "1", "1", ["B = 1-1", "shared = 0-1"]) shared_dep_spec = RPMSpec("shared", "0", "1") self.build(update_gppkg_spec, A_spec, [B_spec, shared_dep_spec]) self.install(self.alpha_spec.get_filename()) with self.assertRaises(ExecutionError): self.update(update_gppkg_spec.get_filename()) def test06_MPP_15788(self): """ This test covers the case where we want to update a package but are unable to do so due to the restrictions imposed by another version of the dependency already installed on the system. """ A_spec = RPMSpec("A", "1", "1", ["B = 1-1", "shared = 1-1"]) C_spec = RPMSpec("C", "1", "1", ["D = 1-1", "shared = 1-1"]) self.build(self.alpha_spec, A_spec, [self.B_spec, self.shared_dep_spec]) self.build(self.beta_spec, C_spec, [self.D_spec, self.shared_dep_spec]) self.install(self.alpha_spec.get_filename()) self.install(self.beta_spec.get_filename()) #package to be updated update_gppkg_spec = GppkgSpec("alpha", "1.1") A_spec = RPMSpec("A", "2", "1", ["B = 2-1", "shared = 2-1"]) B_spec = RPMSpec("B", "2", "1") shared_dep_spec = RPMSpec("shared", "2", "1") self.build(update_gppkg_spec, A_spec, [B_spec, shared_dep_spec]) with self.assertRaises(ExecutionError): self.update(update_gppkg_spec.get_filename()) @unittest.expectedFailure def test07_MPP_15789(self): """ This test covers the case of obsolete dependencies. When we update a gppkg and the new gppkg has different dependencies from the original gppkg, the dependencies of the original gppkg will get left behind. When we remove the gppkg, only the newer dependencies will be removed and the old ones will still remain on the system. """ update_gppkg_spec = GppkgSpec("alpha", "1.1") A_spec = RPMSpec("A", "2", "1", ["B = 1-1"]) B_spec = self.B_spec self.build(update_gppkg_spec, A_spec, [B_spec]) self.install(self.alpha_spec.get_filename()) self.update(update_gppkg_spec.get_filename()) self.remove(update_gppkg_spec.get_filename()) results = run_command("rpm -qa --dbpath %s" % RPM_DATABASE) self.assertEqual(results, "")
class QueryTestCase(GppkgTestCase): """Test the query option of gppkg""" def setUp(self): self.A_spec = RPMSpec("A", "1", "1") self.alpha_spec = GppkgSpec("alpha", "1.0") self.B_spec = RPMSpec("B", "1", "1") self.beta_spec = GppkgSpec("beta", "1.0") self.alpha_info = [ "Name alpha", "Version 1.0", "Architecture x86_64", "OS %s" % OS, "GPDBVersion %s" % GPDB_VERSION, "Description Temporary Test Package", ] def tearDown(self): """ Overriding the teardown here as successive tests in the suite make use of gppkg installed in the previous test. """ pass def check_info_results(self, output, expected_info_result): self.assertTrue(len(output.split("\n")) > 1) output = self.remove_timestamp(output) self.assertTrue(output == expected_info_result) def check_list_results(self, output, expected_list_result): self.assertTrue(len(output.split("\n")) > 1) output = output.split("\n")[self.start_output : self.end_output] self.assertTrue(output == expected_list_result) def get_file_list(self, gppkg_filename): file_list = [] with closing(tarfile.open(gppkg_filename, "r:gz")) as tarinfo: file_list = tarinfo.getnames() return file_list def test00_install(self): gppkg_file1 = self.build(self.alpha_spec, self.A_spec) gppkg_file2 = self.build(self.beta_spec, self.B_spec) self.install(gppkg_file1) self.install(gppkg_file2) def test01_query_all(self): results = run_command("gppkg -q --all") self.assertTrue( results.split("\n")[self.start_output : self.end_output].sort() == [self.alpha_spec.get_package_name(), self.beta_spec.get_package_name()].sort() ) results = run_command("gppkg --all -q") self.assertTrue( results.split("\n")[self.start_output : self.end_output].sort() == [self.alpha_spec.get_package_name(), self.beta_spec.get_package_name()].sort() ) self.assertRaises(ExecutionError, run_command, "gppkg -qall") def test02_query_info(self): # Normal order of the options results = run_command("gppkg -q --info %s" % self.alpha_spec.get_filename()) self.check_info_results(results, self.alpha_info) # Reverse order of the options results = run_command("gppkg --info -q %s" % self.alpha_spec.get_filename()) self.check_info_results(results, self.alpha_info) def test03_query_list(self): expected_list_result = self.get_file_list(self.alpha_spec.get_filename()) results = run_command("gppkg -q --list %s" % self.alpha_spec.get_filename()) self.check_list_results(results, expected_list_result) results = run_command("gppkg --list -q %s" % self.alpha_spec.get_filename()) self.check_list_results(results, expected_list_result) def test04_query_info_expanded(self): results = run_command("gppkg --query --info %s" % self.alpha_spec.get_filename()) self.check_info_results(results, self.alpha_info) results = run_command("gppkg --info --query %s" % self.alpha_spec.get_filename()) self.check_info_results(results, self.alpha_info) with self.assertRaises(ExecutionError): results = run_command("gppkg --query --info abcde") def test05_query_list_expanded(self): expected_list_result = self.get_file_list(self.alpha_spec.get_filename()) results = run_command("gppkg --query --list %s" % self.alpha_spec.get_filename()) self.check_list_results(results, expected_list_result) results = run_command("gppkg --list --query %s" % self.alpha_spec.get_filename()) self.check_list_results(results, expected_list_result) with self.assertRaises(ExecutionError): run_command("gppkg --query --list abcde") def test06_query_package(self): results = run_command("gppkg -q %s" % self.alpha_spec.get_filename()) self.assertTrue("%s is installed" % self.alpha_spec.get_filename().split("-")[0] in results) results = run_command("gppkg --query %s" % self.alpha_spec.get_filename()) self.assertTrue("%s is installed" % self.alpha_spec.get_filename().split("-")[0] in results) self.remove(self.alpha_spec.get_filename()) results = run_command("gppkg --query %s" % self.alpha_spec.get_filename()) self.assertTrue("%s is not installed" % self.alpha_spec.get_filename().split("-")[0] in results) with self.assertRaises(ExecutionError): run_command("gppkg --query abcde") def test07_clean_up(self): self.cleanup()
def setUp(self): super(SingleDependenciesTestCase, self).cleanup() self.A_spec = RPMSpec("A", "1", "1", ["B = 1-1"]) self.B_spec = RPMSpec("B", "1", "1") self.alpha_spec = GppkgSpec("alpha", "1.0")
class QueryTestCase(GppkgTestCase): """Test the query option of gppkg""" def setUp(self): self.A_spec = RPMSpec("A", "1", "1") self.alpha_spec = GppkgSpec("alpha", "1.0") self.B_spec = RPMSpec("B", "1", "1") self.beta_spec = GppkgSpec("beta", "1.0") self.alpha_info = [ 'Name alpha', 'Version 1.0', 'Architecture x86_64', 'OS %s' % OS, 'GPDBVersion %s' % GPDB_VERSION, 'Description Temporary Test Package' ] def tearDown(self): """ Overriding the teardown here as successive tests in the suite make use of gppkg installed in the previous test. """ pass def check_info_results(self, output, expected_info_result): self.assertTrue(len(output.split('\n')) > 1) output = self.remove_timestamp(output) self.assertTrue(output == expected_info_result) def check_list_results(self, output, expected_list_result): self.assertTrue(len(output.split('\n')) > 1) output = output.split('\n')[self.start_output:self.end_output] self.assertTrue(output == expected_list_result) def get_file_list(self, gppkg_filename): file_list = [] with closing(tarfile.open(gppkg_filename, 'r:gz')) as tarinfo: file_list = tarinfo.getnames() return file_list def test00_install(self): gppkg_file1 = self.build(self.alpha_spec, self.A_spec) gppkg_file2 = self.build(self.beta_spec, self.B_spec) self.install(gppkg_file1) self.install(gppkg_file2) def test01_query_all(self): results = run_command("gppkg -q --all") self.assertTrue( results.split('\n')[self.start_output:self.end_output].sort() == [ self.alpha_spec.get_package_name(), self.beta_spec.get_package_name() ].sort()) results = run_command("gppkg --all -q") self.assertTrue( results.split('\n')[self.start_output:self.end_output].sort() == [ self.alpha_spec.get_package_name(), self.beta_spec.get_package_name() ].sort()) self.assertRaises(ExecutionError, run_command, "gppkg -qall") def test02_query_info(self): #Normal order of the options results = run_command("gppkg -q --info %s" % self.alpha_spec.get_filename()) self.check_info_results(results, self.alpha_info) #Reverse order of the options results = run_command("gppkg --info -q %s" % self.alpha_spec.get_filename()) self.check_info_results(results, self.alpha_info) def test03_query_list(self): expected_list_result = self.get_file_list( self.alpha_spec.get_filename()) results = run_command("gppkg -q --list %s" % self.alpha_spec.get_filename()) self.check_list_results(results, expected_list_result) results = run_command("gppkg --list -q %s" % self.alpha_spec.get_filename()) self.check_list_results(results, expected_list_result) def test04_query_info_expanded(self): results = run_command("gppkg --query --info %s" % self.alpha_spec.get_filename()) self.check_info_results(results, self.alpha_info) results = run_command("gppkg --info --query %s" % self.alpha_spec.get_filename()) self.check_info_results(results, self.alpha_info) with self.assertRaises(ExecutionError): results = run_command("gppkg --query --info abcde") def test05_query_list_expanded(self): expected_list_result = self.get_file_list( self.alpha_spec.get_filename()) results = run_command("gppkg --query --list %s" % self.alpha_spec.get_filename()) self.check_list_results(results, expected_list_result) results = run_command("gppkg --list --query %s" % self.alpha_spec.get_filename()) self.check_list_results(results, expected_list_result) with self.assertRaises(ExecutionError): run_command("gppkg --query --list abcde") def test06_query_package(self): results = run_command("gppkg -q %s" % self.alpha_spec.get_filename()) self.assertTrue( "%s is installed" % self.alpha_spec.get_filename().split('-')[0] in results) results = run_command("gppkg --query %s" % self.alpha_spec.get_filename()) self.assertTrue( "%s is installed" % self.alpha_spec.get_filename().split('-')[0] in results) self.remove(self.alpha_spec.get_filename()) results = run_command("gppkg --query %s" % self.alpha_spec.get_filename()) self.assertTrue( "%s is not installed" % self.alpha_spec.get_filename().split('-')[0] in results) with self.assertRaises(ExecutionError): run_command("gppkg --query abcde") def test07_clean_up(self): self.cleanup()