def test_install_on_wrong_os_offline_installer(self): image = 'ubuntu' tag = '14.04' host = image + '-master' ubuntu_container = DockerCluster(host, [], DEFAULT_LOCAL_MOUNT_POINT, DEFAULT_DOCKER_MOUNT_POINT) try: ubuntu_container.fetch_image_if_not_present(image, tag) ubuntu_container.start_containers( image + ':' + tag, cmd='tail -f /var/log/bootstrap.log') self.retry(lambda: ubuntu_container.run_script_on_host( install_py26_script, ubuntu_container.master)) ubuntu_container.exec_cmd_on_host( ubuntu_container.master, 'sudo apt-get -y install wget') self.assertRaisesRegexp( OSError, r'ERROR\n' r'Paramiko could not be imported. This usually means that', self.pa_installer.install, cluster=ubuntu_container ) finally: ubuntu_container.tear_down()
def build_installer_in_docker(self, online_installer=False, cluster=None, unique=False): if not cluster: cluster = self.cluster container_name = 'installer' installer_container = DockerCluster( container_name, [], DEFAULT_LOCAL_MOUNT_POINT, DEFAULT_DOCKER_MOUNT_POINT) try: installer_container.clean_up_presto_test_images() installer_container.create_image( os.path.join(LOCAL_RESOURCES_DIR, 'centos6-ssh-test'), 'teradatalabs/centos6-ssh-test', 'jdeathe/centos-ssh' ) installer_container.start_containers( 'teradatalabs/centos6-ssh-test' ) except DockerClusterException as e: installer_container.tear_down() self.fail(e.msg) 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') ) installer_container.run_script_on_host( '-e\n' 'pip install --upgrade pip\n' 'pip install --upgrade wheel\n' 'pip install --upgrade setuptools\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 not online_installer else 'dist-online', 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))
def _build_installer_in_docker(self, cluster, online_installer=False, unique=False): container_name = 'installer' installer_container = DockerCluster(container_name, [], DEFAULT_LOCAL_MOUNT_POINT, DEFAULT_DOCKER_MOUNT_POINT) try: installer_container.create_image(BASE_TD_DOCKERFILE_DIR, BASE_TD_IMAGE_NAME, BASE_IMAGE_NAME) installer_container.start_containers(BASE_TD_IMAGE_NAME) except DockerClusterException as e: installer_container.tear_down() self.testcase.fail(e.msg) 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))
def _build_installer_in_docker(self, cluster, online_installer=False, unique=False): container_name = 'installer' installer_container = DockerCluster( container_name, [], DEFAULT_LOCAL_MOUNT_POINT, DEFAULT_DOCKER_MOUNT_POINT) try: installer_container.create_image( BASE_TD_DOCKERFILE_DIR, BASE_TD_IMAGE_NAME, BASE_IMAGE_NAME ) installer_container.start_containers( BASE_TD_IMAGE_NAME ) except DockerClusterException as e: installer_container.tear_down() self.testcase.fail(e.msg) 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') ) installer_container.run_script_on_host( '-e\n' 'pip install --upgrade pip\n' 'pip install --upgrade wheel\n' 'pip install --upgrade setuptools\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 not online_installer else 'dist-online', 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))
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 _build_installer_in_docker(self, cluster, online_installer=False, unique=False): container_name = "installer" installer_container = DockerCluster(container_name, [], DEFAULT_LOCAL_MOUNT_POINT, DEFAULT_DOCKER_MOUNT_POINT) try: installer_container.create_image(BASE_TD_DOCKERFILE_DIR, BASE_TD_IMAGE_NAME, BASE_IMAGE_NAME) installer_container.start_containers(BASE_TD_IMAGE_NAME) except DockerClusterException as e: installer_container.tear_down() self.testcase.fail(e.msg) 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( "-e\n" "pip install --upgrade pip==7.1.2\n" "pip install --upgrade wheel==0.23.0\n" "pip install --upgrade setuptools\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))
def build_installer_in_docker(self, online_installer=False, cluster=None, unique=False): if not cluster: cluster = self.docker_cluster container_name = "installer" installer_container = DockerCluster(container_name, [], DEFAULT_LOCAL_MOUNT_POINT, DEFAULT_DOCKER_MOUNT_POINT) try: installer_container.create_image( os.path.join(LOCAL_RESOURCES_DIR, "centos6-ssh-test"), "teradatalabs/centos6-ssh-test", "jdeathe/centos-ssh", ) installer_container.start_containers("teradatalabs/centos6-ssh-test") except DockerClusterException as e: installer_container.tear_down_containers() self.fail(e.msg) 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"), ) installer_container.run_script( "-e\n" "pip install --upgrade pip\n" "pip install --upgrade wheel\n" "pip install --upgrade setuptools\n" "mv %s/presto-admin ~/\n" "cd ~/presto-admin\n" "make %s\n" "cp dist/prestoadmin-*.tar.bz2 %s" % ( installer_container.docker_mount_dir, "dist" if not online_installer else "dist-online", installer_container.docker_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))
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 __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( os.path.join(LOCAL_RESOURCES_DIR, 'centos6-ssh-test'), 'teradatalabs/centos6-ssh-test', 'jdeathe/centos-ssh' ) centos_container.start_containers( 'teradatalabs/centos6-ssh-test', cap_add=['NET_ADMIN'] ) return centos_container
def test_install_on_wrong_os_offline_installer(self): image = "ubuntu" tag = "14.04" host = image + "-master" ubuntu_container = DockerCluster(host, [], DEFAULT_LOCAL_MOUNT_POINT, DEFAULT_DOCKER_MOUNT_POINT) try: ubuntu_container.fetch_image_if_not_present(image, tag) ubuntu_container.start_containers(image + ":" + tag, cmd="tail -f /var/log/bootstrap.log") ubuntu_container.run_script_on_host(install_py26_script, ubuntu_container.master) ubuntu_container.exec_cmd_on_host(ubuntu_container.master, "sudo apt-get -y install wget") self.assertRaisesRegexp( OSError, r"ERROR\n" r"Paramiko could not be imported. This usually means that", self.pa_installer.install, cluster=ubuntu_container, ) finally: ubuntu_container.tear_down()
def test_install_on_wrong_os_offline_installer(self): image = 'teradatalabs/ubuntu-trusty-python2.6' tag = BASE_IMAGES_TAG host = 'wrong-os-master' ubuntu_container = DockerCluster(host, [], DEFAULT_LOCAL_MOUNT_POINT, DEFAULT_DOCKER_MOUNT_POINT) if not DockerCluster._check_for_images(image, image, tag): raise RuntimeError("Docker images have not been created") try: ubuntu_container.start_containers( image + ':' + tag, cmd='tail -f /var/log/bootstrap.log') self.assertRaisesRegexp( OSError, r'ERROR\n' r'Paramiko could not be imported. This usually means that', self.pa_installer.install, cluster=ubuntu_container) finally: ubuntu_container.tear_down()
def test_install_on_wrong_os_offline_installer(self): image = 'ubuntu' tag = '14.04' host = image + '-master' ubuntu_container = DockerCluster(host, [], DEFAULT_LOCAL_MOUNT_POINT, DEFAULT_DOCKER_MOUNT_POINT) try: ubuntu_container.fetch_image_if_not_present(image, tag) ubuntu_container.start_containers( image + ':' + tag, cmd='tail -f /var/log/bootstrap.log') ubuntu_container.run_script_on_host(install_py26_script, ubuntu_container.master) ubuntu_container.exec_cmd_on_host(ubuntu_container.master, 'sudo apt-get -y install wget') self.assertRaisesRegexp( OSError, r'ERROR\n' r'Paramiko could not be imported. This usually means that', self.pa_installer.install, cluster=ubuntu_container) finally: ubuntu_container.tear_down()
def test_install_on_wrong_os_offline_installer(self): image = 'teradatalabs/ubuntu-trusty-python2.6' tag = BASE_IMAGES_TAG host = 'wrong-os-master' ubuntu_container = DockerCluster(host, [], DEFAULT_LOCAL_MOUNT_POINT, DEFAULT_DOCKER_MOUNT_POINT) if not DockerCluster._check_for_images(image, image, tag): raise RuntimeError("Docker images have not been created") try: ubuntu_container.start_containers( image + ':' + tag, cmd='tail -f /var/log/bootstrap.log') self.assertRaisesRegexp( OSError, r'ERROR\n' r'Paramiko could not be imported. This usually means that', self.pa_installer.install, cluster=ubuntu_container ) finally: ubuntu_container.tear_down()