def setup_cluster(self, bare_image_provider, cluster_type): installers = cluster_types[cluster_type] config_filename = ConfigurableCluster.check_for_cluster_config() if config_filename: self.cluster = ConfigurableCluster.start_bare_cluster( config_filename, self, StandalonePrestoInstaller.assert_installed) else: self.cluster, bare_cluster = DockerCluster.start_cluster( bare_image_provider, cluster_type) # If we've found images and started a non-bare cluster, the # containers have already had the installers applied to them. # We do need to get the test environment in sync with the # containers by calling the following two functions. # # We do this to save the cost of running the installers on the # docker containers every time we run a test. In practice, # that turns out to be a fairly expensive thing to do. if not bare_cluster: self._apply_post_install_hooks(installers) self._update_replacement_keywords(installers) else: raise RuntimeError("Docker images have not been created")
def setup_cluster(self, bare_image_provider, cluster_type): installers = cluster_types[cluster_type] config_filename = ConfigurableCluster.check_for_cluster_config() if config_filename: self.cluster = ConfigurableCluster.start_bare_cluster( config_filename, self, StandalonePrestoInstaller.assert_installed) self.cluster.ensure_correct_execution_environment() BaseProductTestCase.run_installers(self.cluster, installers, self) else: self.cluster, bare_cluster = DockerCluster.start_cluster( bare_image_provider, cluster_type) self.cluster.ensure_correct_execution_environment() # If we've found images and started a non-bare cluster, the # containers have already had the installers applied to them. # We do need to get the test environment in sync with the # containers by calling the following two functions. # # We do this to save the cost of running the installers on the # docker containers every time we run a test. In practice, # that turns out to be a fairly expensive thing to do. if not bare_cluster: self._apply_post_install_hooks(installers) self._update_replacement_keywords(installers) else: raise RuntimeError("Docker images have not been created")
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 __create_and_start_single_centos_container(self, build_or_runtime): cluster_type = 'installer_tester' bare_image_provider = NoHadoopBareImageProvider(build_or_runtime) 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 _setup_image(self, bare_image_provider, cluster_type): installers = cluster_types[cluster_type] self.testcase.cluster, bare_cluster = DockerCluster.start_cluster( bare_image_provider, cluster_type) # If we got a bare cluster back, we need to run the installers on it. # applying the post-install hooks and updating the replacement # keywords is handled internally in _run_installers. # # If we got a non-bare cluster back, that means the image already exists # and we created the cluster using that image. if bare_cluster: BaseProductTestCase.run_installers(self.testcase.cluster, installers, self.testcase) if isinstance(self.testcase.cluster, DockerCluster): self.testcase.cluster.commit_images(bare_image_provider, cluster_type) self.testcase.cluster.tear_down()
def _setup_image(self, bare_image_provider, cluster_type): installers = cluster_types[cluster_type] self.testcase.cluster, bare_cluster = DockerCluster.start_cluster( bare_image_provider, cluster_type) # If we got a bare cluster back, we need to run the installers on it. # applying the post-install hooks and updating the replacement # keywords is handled internally in _run_installers. # # If we got a non-bare cluster back, that means the image already exists # and we created the cluster using that image. if bare_cluster: self._run_installers(installers) if isinstance(self.testcase.cluster, DockerCluster): self.testcase.cluster.commit_images(bare_image_provider, cluster_type) self.testcase.cluster.tear_down()
def _build_installer_in_docker(self, cluster, online_installer=None, unique=False): if online_installer is None: pa_test_online_installer = os.environ.get( 'PA_TEST_ONLINE_INSTALLER') online_installer = pa_test_online_installer is not None if isinstance(cluster, ConfigurableCluster): online_installer = True container_name = 'installer' cluster_type = 'installer_builder' bare_image_provider = NoHadoopBareImageProvider("build") installer_container, created_bare = DockerCluster.start_cluster( bare_image_provider, cluster_type, 'installer', []) if created_bare: installer_container.commit_images(bare_image_provider, cluster_type) try: shutil.copytree( prestoadmin.main_dir, os.path.join( installer_container.get_local_mount_dir(container_name), 'presto-admin'), ignore=shutil.ignore_patterns('tmp', '.git', 'presto*.rpm')) # Pin pip to 7.1.2 because 8.0.0 removed support for distutils # installed projects, of which the system setuptools is one on our # Docker image. pip 8.0.1 or 8.0.2 replaced the error with a # deprecation warning, and also warns that Python 2.6 is # deprecated. While we still need to support Python 2.6, we'll pin # pip to a 7.x version, but we should revisit this once we no # longer need to support 2.6: # https://github.com/pypa/pip/issues/3384 installer_container.run_script_on_host( 'set -e\n' # use explicit versions of dependent packages 'pip install --upgrade pycparser==2.18 cffi==1.11.5\n' 'pip install --upgrade pycparser==2.18 PyNaCl==1.2.1\n' 'pip install --upgrade pycparser==2.18 idna==2.1 cryptography==2.1.1\n' 'pip install --upgrade pip==9.0.2\n' 'pip install --upgrade wheel==0.23.0\n' 'pip install --upgrade setuptools==20.1.1\n' 'mv %s/presto-admin ~/\n' 'cd ~/presto-admin\n' 'make %s\n' 'cp dist/prestoadmin-*.tar.gz %s' % (installer_container.mount_dir, 'dist' if online_installer else 'dist-offline', installer_container.mount_dir), container_name) try: os.makedirs(cluster.get_dist_dir(unique)) except OSError, e: if e.errno != errno.EEXIST: raise local_container_dist_dir = os.path.join( prestoadmin.main_dir, installer_container.get_local_mount_dir(container_name)) installer_file = fnmatch.filter( os.listdir(local_container_dist_dir), 'prestoadmin-*.tar.gz')[0] shutil.copy(os.path.join(local_container_dist_dir, installer_file), cluster.get_dist_dir(unique))
def _build_installer_in_docker(self, cluster, online_installer=None, unique=False): if online_installer is None: pa_test_online_installer = os.environ.get('PA_TEST_ONLINE_INSTALLER') online_installer = pa_test_online_installer is not None if isinstance(cluster, ConfigurableCluster): online_installer = True container_name = 'installer' cluster_type = 'installer_builder' bare_image_provider = NoHadoopBareImageProvider(BASE_IMAGES_TAG) installer_container, created_bare = DockerCluster.start_cluster( bare_image_provider, cluster_type, 'installer', []) if created_bare: installer_container.commit_images( bare_image_provider, cluster_type) try: shutil.copytree( prestoadmin.main_dir, os.path.join( installer_container.get_local_mount_dir(container_name), 'presto-admin'), ignore=shutil.ignore_patterns('tmp', '.git', 'presto*.rpm') ) # Pin pip to 7.1.2 because 8.0.0 removed support for distutils # installed projects, of which the system setuptools is one on our # Docker image. pip 8.0.1 or 8.0.2 replaced the error with a # deprecation warning, and also warns that Python 2.6 is # deprecated. While we still need to support Python 2.6, we'll pin # pip to a 7.x version, but we should revisit this once we no # longer need to support 2.6: # https://github.com/pypa/pip/issues/3384 installer_container.run_script_on_host( 'set -e\n' 'pip install --upgrade pip==7.1.2\n' 'pip install --upgrade wheel==0.23.0\n' 'pip install --upgrade setuptools==20.1.1\n' 'mv %s/presto-admin ~/\n' 'cd ~/presto-admin\n' 'make %s\n' 'cp dist/prestoadmin-*.tar.bz2 %s' % (installer_container.mount_dir, 'dist' if online_installer else 'dist-offline', installer_container.mount_dir), container_name) try: os.makedirs(cluster.get_dist_dir(unique)) except OSError, e: if e.errno != errno.EEXIST: raise local_container_dist_dir = os.path.join( prestoadmin.main_dir, installer_container.get_local_mount_dir(container_name) ) installer_file = fnmatch.filter( os.listdir(local_container_dist_dir), 'prestoadmin-*.tar.bz2')[0] shutil.copy( os.path.join(local_container_dist_dir, installer_file), cluster.get_dist_dir(unique))