-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extract building dist package out of prestoadmin_installer #195
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
.PHONY: clean-all clean clean-eggs clean-build clean-pyc clean-test-containers clean-test \ | ||
clean-docs lint smoke test test-all test-rpm coverage docs open-docs release release-builds \ | ||
dist dist-online dist-offline wheel install precommit | ||
dist dist-online dist-offline wheel install precommit \ | ||
docker-dist docker-dist-online docker-dist-offline | ||
|
||
help: | ||
@echo "precommit - run \`quick' tests and tasks that should pass or succeed prior to pushing" | ||
|
@@ -25,6 +26,9 @@ help: | |
@echo "dist - package and build installer that requires an Internet connection" | ||
@echo "dist-online - package and build installer that requires an Internet connection" | ||
@echo "dist-offline - package and build installer that does not require an Internet connection" | ||
@echo "docker-dist - package and build installer (within a docker container) that requires an Internet connection" | ||
@echo "docker-dist-online - package and build installer (within a docker container) that requires an Internet connection" | ||
@echo "docker-dist-offline - package and build installer (within a docker container) that does not require an Internet connection" | ||
@echo "wheel - build wheel only" | ||
@echo "install - install the package to the active Python's site-packages" | ||
|
||
|
@@ -79,7 +83,7 @@ test: clean-test | |
|
||
TEST_SUITE?=tests.product | ||
|
||
test-all: clean-test docker-images | ||
test-all: clean-test docker-images docker-dist | ||
tox -- -s tests.unit | ||
tox -- -s tests.integration | ||
tox -e py26 -- -s ${TEST_SUITE} -a '!quarantine' | ||
|
@@ -121,6 +125,14 @@ dist-offline: clean-build clean-pyc | |
python setup.py bdist_prestoadmin | ||
ls -l dist | ||
|
||
docker-dist: docker-dist-online | ||
|
||
docker-dist-online: clean-build clean-pyc | ||
docker run --rm -v `pwd`:/workdir -w /workdir -u `id -u`:`id -g` teradatalabs/presto-admin-devenv:1 make dist-online | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please update the readme to cover the following:
Thanks! |
||
|
||
docker-dist-offline: clean-build clean-pyc | ||
docker run --rm -v `pwd`:/workdir -w /workdir -u `id -u`:`id -g` teradatalabs/presto-admin-devenv:1 make dist-offline | ||
|
||
wheel: clean | ||
python setup.py bdist_wheel | ||
ls -l dist | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,18 +16,11 @@ | |
Module for installing prestoadmin on a cluster. | ||
""" | ||
|
||
import errno | ||
import fnmatch | ||
import shutil | ||
import os | ||
|
||
import prestoadmin | ||
|
||
from tests.base_installer import BaseInstaller | ||
from tests.product.constants import LOCAL_RESOURCES_DIR | ||
from tests.no_hadoop_bare_image_provider import NoHadoopBareImageProvider | ||
|
||
from tests.docker_cluster import DockerCluster | ||
|
||
|
||
class PrestoadminInstaller(BaseInstaller): | ||
|
@@ -39,18 +32,13 @@ def get_dependencies(): | |
return [] | ||
|
||
def install(self, cluster=None, dist_dir=None): | ||
# Passing in a cluster supports the installation tests. We need to be | ||
# able to try an installation against an unsupported OS, and for that | ||
# testcase, we create a cluster that is local to the testcase and then | ||
# run the install on it. We can't replace self.cluster with the local | ||
# cluster in the test, because that would prevent the test's "regular" | ||
# cluster from getting torn down. | ||
if not cluster: | ||
cluster = self.testcase.cluster | ||
|
||
if not dist_dir: | ||
dist_dir = self._build_dist_if_necessary(cluster) | ||
self._copy_dist_to_host(cluster, dist_dir, cluster.master) | ||
dist_dir = cluster.get_dist_dir(unique=False) | ||
|
||
self.copy_dist_to_master(cluster, dist_dir) | ||
cluster.copy_to_host( | ||
LOCAL_RESOURCES_DIR + "/install-admin.sh", cluster.master) | ||
cluster.exec_cmd_on_host( | ||
|
@@ -69,84 +57,16 @@ def assert_installed(testcase, msg=None): | |
def get_keywords(self): | ||
return {} | ||
|
||
def _build_dist_if_necessary(self, cluster, unique=False): | ||
if (not os.path.isdir(cluster.get_dist_dir(unique)) or | ||
not fnmatch.filter( | ||
os.listdir(cluster.get_dist_dir(unique)), | ||
'prestoadmin-*.tar.bz2')): | ||
self._build_installer_in_docker(cluster, unique=unique) | ||
return cluster.get_dist_dir(unique) | ||
|
||
def _build_installer_in_docker(self, cluster, online_installer=None, | ||
unique=False): | ||
if online_installer is None: | ||
paTestOnlineInstaller = os.environ.get('PA_TEST_ONLINE_INSTALLER') | ||
online_installer = paTestOnlineInstaller is not None | ||
|
||
container_name = 'installer' | ||
cluster_type = 'installer_builder' | ||
bare_image_provider = NoHadoopBareImageProvider() | ||
|
||
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)) | ||
finally: | ||
installer_container.tear_down() | ||
|
||
@staticmethod | ||
def _copy_dist_to_host(cluster, local_dist_dir, dest_host): | ||
for dist_file in os.listdir(local_dist_dir): | ||
def copy_dist_to_master(self, cluster, dist_dir): | ||
if (not os.path.isdir(dist_dir) or | ||
len(fnmatch.filter( | ||
os.listdir(dist_dir), | ||
'prestoadmin-*.tar.bz2')) == 0): | ||
self.testcase.fail( | ||
'Unable to find presto-admin package. Have you run one of ' | ||
'`make dist*` or `make docker-dist*`?') | ||
for dist_file in os.listdir(dist_dir): | ||
if fnmatch.fnmatch(dist_file, "prestoadmin-*.tar.bz2"): | ||
cluster.copy_to_host( | ||
os.path.join(local_dist_dir, dist_file), | ||
dest_host) | ||
os.path.join(dist_dir, dist_file), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what happens if there is no match? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. above this |
||
cluster.master) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,30 +42,12 @@ def tearDown(self): | |
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) | ||
def test_installer(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm confused about how this test works now. How does the installer get into the docker container? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
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') | ||
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() | ||
|
@@ -109,3 +91,20 @@ def __verify_third_party_dir(self, is_third_party_present): | |
raise RuntimeError('Expected to have an online installer with no ' | ||
'third-party directory. Found a third-party ' | ||
'directory in the installer archive.') | ||
|
||
# This test should be run only with offline installer already build with `make dist-offline` | ||
@attr('offline_installer') | ||
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) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these should get called at the beginning of make test-all