class TestInstaller(BaseProductTestCase): def setUp(self): super(TestInstaller, self).setUp() self.centos_container = \ self.__create_and_start_single_centos_container() self.pa_installer = PrestoadminInstaller(self) def tearDown(self): super(TestInstaller, self).tearDown() self.centos_container.tear_down() @attr('smoketest') @docker_only def test_online_installer(self): self.pa_installer._build_installer_in_docker(self.centos_container, online_installer=True, unique=True) self.__verify_third_party_dir(False) self.pa_installer.install( dist_dir=self.centos_container.get_dist_dir(unique=True)) self.run_prestoadmin('--help', raise_error=True, cluster=self.centos_container) @attr('smoketest') @docker_only def test_offline_installer(self): self.pa_installer._build_installer_in_docker( self.centos_container, online_installer=False, unique=True) self.__verify_third_party_dir(True) self.centos_container.exec_cmd_on_host( self.centos_container.master, 'ifdown eth0') self.pa_installer.install( dist_dir=self.centos_container.get_dist_dir(unique=True)) self.run_prestoadmin('--help', raise_error=True, cluster=self.centos_container) def __create_and_start_single_centos_container(self): centos_container = DockerCluster( 'master', [], DEFAULT_LOCAL_MOUNT_POINT, DEFAULT_DOCKER_MOUNT_POINT) # we can't assume that another test has created the image centos_container.create_image( BASE_TD_DOCKERFILE_DIR, BASE_TD_IMAGE_NAME, BASE_IMAGE_NAME ) centos_container.start_containers( BASE_TD_IMAGE_NAME, cap_add=['NET_ADMIN'] ) return centos_container def __verify_third_party_dir(self, is_third_party_present): matches = fnmatch.filter( os.listdir(self.centos_container.get_dist_dir(unique=True)), 'prestoadmin-*.tar.bz2') if len(matches) > 1: raise RuntimeError( 'More than one archive found in the dist directory ' + ' '.join(matches) ) cmd_to_run = ['tar', '-tf', os.path.join( self.centos_container.get_dist_dir(unique=True), matches[0]) ] popen_obj = subprocess.Popen(cmd_to_run, cwd=main_dir, stdout=subprocess.PIPE) retcode = popen_obj.returncode if retcode: raise RuntimeError('Non zero return code when executing ' + ' '.join(cmd_to_run)) stdout = popen_obj.communicate()[0] match = re.search('/third-party/', stdout) if is_third_party_present and match is None: raise RuntimeError('Expected to have an offline installer with ' 'a third-party directory. Found no ' 'third-party directory in the installer ' 'archive.') elif not is_third_party_present and match: raise RuntimeError('Expected to have an online installer with no ' 'third-party directory. Found a third-party ' 'directory in the installer archive.')
class TestInstaller(BaseProductTestCase): def setUp(self): super(TestInstaller, self).setUp() self.centos_container = \ self.__create_and_start_single_centos_container() self.pa_installer = PrestoadminInstaller(self) def tearDown(self): super(TestInstaller, self).tearDown() self.centos_container.tear_down() @attr('smoketest') @docker_only def test_online_installer(self): self.pa_installer._build_installer_in_docker(self.centos_container, online_installer=True, unique=True) self.__verify_third_party_dir(False) self.pa_installer.install(dist_dir=self.centos_container.get_dist_dir( unique=True)) self.run_prestoadmin('--help', raise_error=True, cluster=self.centos_container) @attr('smoketest') @docker_only def test_offline_installer(self): self.pa_installer._build_installer_in_docker(self.centos_container, online_installer=False, unique=True) self.__verify_third_party_dir(True) self.centos_container.exec_cmd_on_host(self.centos_container.master, 'ifdown eth0') self.pa_installer.install(dist_dir=self.centos_container.get_dist_dir( unique=True)) self.run_prestoadmin('--help', raise_error=True, cluster=self.centos_container) def __create_and_start_single_centos_container(self): centos_container = DockerCluster('master', [], DEFAULT_LOCAL_MOUNT_POINT, DEFAULT_DOCKER_MOUNT_POINT) # we can't assume that another test has created the image centos_container.create_image(BASE_TD_DOCKERFILE_DIR, BASE_TD_IMAGE_NAME, BASE_IMAGE_NAME) centos_container.start_containers(BASE_TD_IMAGE_NAME, cap_add=['NET_ADMIN']) return centos_container def __verify_third_party_dir(self, is_third_party_present): matches = fnmatch.filter( os.listdir(self.centos_container.get_dist_dir(unique=True)), 'prestoadmin-*.tar.bz2') if len(matches) > 1: raise RuntimeError( 'More than one archive found in the dist directory ' + ' '.join(matches)) cmd_to_run = [ 'tar', '-tf', os.path.join(self.centos_container.get_dist_dir(unique=True), matches[0]) ] popen_obj = subprocess.Popen(cmd_to_run, cwd=main_dir, stdout=subprocess.PIPE) retcode = popen_obj.returncode if retcode: raise RuntimeError('Non zero return code when executing ' + ' '.join(cmd_to_run)) stdout = popen_obj.communicate()[0] match = re.search('/third-party/', stdout) if is_third_party_present and match is None: raise RuntimeError('Expected to have an offline installer with ' 'a third-party directory. Found no ' 'third-party directory in the installer ' 'archive.') elif not is_third_party_present and match: raise RuntimeError('Expected to have an online installer with no ' 'third-party directory. Found a third-party ' 'directory in the installer archive.')
class TestInstaller(BaseProductTestCase): def setUp(self): super(TestInstaller, self).setUp() self.setup_cluster(NoHadoopBareImageProvider, STANDALONE_BARE_CLUSTER) self.centos_container = \ self.__create_and_start_single_centos_container() self.pa_installer = PrestoadminInstaller(self) def tearDown(self): super(TestInstaller, self).tearDown() self.centos_container.tear_down() @attr('smoketest') def test_online_installer(self): self.pa_installer._build_installer_in_docker(self.centos_container, online_installer=True, unique=True) self.__verify_third_party_dir(False) self.pa_installer.install(dist_dir=self.centos_container.get_dist_dir( unique=True)) self.run_prestoadmin('--help', raise_error=True) @attr('smoketest', 'offline_installer') @docker_only def test_offline_installer(self): self.pa_installer._build_installer_in_docker(self.centos_container, online_installer=False, unique=True) self.__verify_third_party_dir(True) self.centos_container.exec_cmd_on_host( # IMPORTANT: ifdown eth0 fails silently without taking the # interface down if the NET_ADMIN capability isn't set for the # container. ifconfig eth0 down accomplishes the same thing, but # results in a failure if it fails. self.centos_container.master, 'ifconfig eth0 down') self.pa_installer.install(dist_dir=self.centos_container.get_dist_dir( unique=True)) self.run_prestoadmin('--help', raise_error=True) def __create_and_start_single_centos_container(self): cluster_type = 'installer_tester' bare_image_provider = NoHadoopBareImageProvider(BASE_IMAGES_TAG) centos_container, bare_cluster = DockerCluster.start_cluster( bare_image_provider, cluster_type, 'master', [], cap_add=['NET_ADMIN']) if bare_cluster: centos_container.commit_images(bare_image_provider, cluster_type) return centos_container def __verify_third_party_dir(self, is_third_party_present): matches = fnmatch.filter( os.listdir(self.centos_container.get_dist_dir(unique=True)), 'prestoadmin-*.tar.gz') if len(matches) > 1: raise RuntimeError( 'More than one archive found in the dist directory ' + ' '.join(matches)) cmd_to_run = [ 'tar', '-tf', os.path.join(self.centos_container.get_dist_dir(unique=True), matches[0]) ] popen_obj = subprocess.Popen(cmd_to_run, cwd=main_dir, stdout=subprocess.PIPE) retcode = popen_obj.returncode if retcode: raise RuntimeError('Non zero return code when executing ' + ' '.join(cmd_to_run)) stdout = popen_obj.communicate()[0] match = re.search('/third-party/', stdout) if is_third_party_present and match is None: raise RuntimeError('Expected to have an offline installer with ' 'a third-party directory. Found no ' 'third-party directory in the installer ' 'archive.') elif not is_third_party_present and match: raise RuntimeError('Expected to have an online installer with no ' 'third-party directory. Found a third-party ' 'directory in the installer archive.')
class TestInstaller(BaseProductTestCase): def setUp(self): super(TestInstaller, self).setUp() self.setup_cluster(NoHadoopBareImageProvider, STANDALONE_BARE_CLUSTER) self.centos_container = \ self.__create_and_start_single_centos_container() self.pa_installer = PrestoadminInstaller(self) def tearDown(self): super(TestInstaller, self).tearDown() self.centos_container.tear_down() @attr('smoketest') def test_online_installer(self): self.pa_installer._build_installer_in_docker(self.centos_container, online_installer=True, unique=True) self.__verify_third_party_dir(False) self.pa_installer.install( dist_dir=self.centos_container.get_dist_dir(unique=True)) self.run_prestoadmin('--help', raise_error=True) @attr('smoketest', 'offline_installer') @docker_only def test_offline_installer(self): self.pa_installer._build_installer_in_docker( self.centos_container, online_installer=False, unique=True) self.__verify_third_party_dir(True) self.centos_container.exec_cmd_on_host( # IMPORTANT: ifdown eth0 fails silently without taking the # interface down if the NET_ADMIN capability isn't set for the # container. ifconfig eth0 down accomplishes the same thing, but # results in a failure if it fails. self.centos_container.master, 'ifconfig eth0 down') self.pa_installer.install( dist_dir=self.centos_container.get_dist_dir(unique=True)) self.run_prestoadmin('--help', raise_error=True) def __create_and_start_single_centos_container(self): cluster_type = 'installer_tester' bare_image_provider = NoHadoopBareImageProvider(BASE_IMAGES_TAG) centos_container, bare_cluster = DockerCluster.start_cluster( bare_image_provider, cluster_type, 'master', [], cap_add=['NET_ADMIN']) if bare_cluster: centos_container.commit_images(bare_image_provider, cluster_type) return centos_container def __verify_third_party_dir(self, is_third_party_present): matches = fnmatch.filter( os.listdir(self.centos_container.get_dist_dir(unique=True)), 'prestoadmin-*.tar.bz2') if len(matches) > 1: raise RuntimeError( 'More than one archive found in the dist directory ' + ' '.join(matches) ) cmd_to_run = ['tar', '-tf', os.path.join( self.centos_container.get_dist_dir(unique=True), matches[0]) ] popen_obj = subprocess.Popen(cmd_to_run, cwd=main_dir, stdout=subprocess.PIPE) retcode = popen_obj.returncode if retcode: raise RuntimeError('Non zero return code when executing ' + ' '.join(cmd_to_run)) stdout = popen_obj.communicate()[0] match = re.search('/third-party/', stdout) if is_third_party_present and match is None: raise RuntimeError('Expected to have an offline installer with ' 'a third-party directory. Found no ' 'third-party directory in the installer ' 'archive.') elif not is_third_party_present and match: raise RuntimeError('Expected to have an online installer with no ' 'third-party directory. Found a third-party ' 'directory in the installer archive.')