16
16
Module for installing prestoadmin on a cluster.
17
17
"""
18
18
19
- import errno
20
19
import fnmatch
21
- import shutil
22
20
import os
23
21
24
- import prestoadmin
25
-
26
22
from tests .base_installer import BaseInstaller
27
23
from tests .product .constants import LOCAL_RESOURCES_DIR
28
- from tests .no_hadoop_bare_image_provider import NoHadoopBareImageProvider
29
-
30
- from tests .docker_cluster import DockerCluster
31
24
32
25
33
26
class PrestoadminInstaller (BaseInstaller ):
@@ -39,17 +32,18 @@ def get_dependencies():
39
32
return []
40
33
41
34
def install (self , cluster = None , dist_dir = None ):
42
- # Passing in a cluster supports the installation tests. We need to be
43
- # able to try an installation against an unsupported OS, and for that
44
- # testcase, we create a cluster that is local to the testcase and then
45
- # run the install on it. We can't replace self.cluster with the local
46
- # cluster in the test, because that would prevent the test's "regular"
47
- # cluster from getting torn down.
48
35
if not cluster :
49
36
cluster = self .testcase .cluster
50
37
51
38
if not dist_dir :
52
- dist_dir = self ._build_dist_if_necessary (cluster )
39
+ dist_dir = cluster .get_dist_dir (unique = False )
40
+
41
+ if (not os .path .isdir (dist_dir ) or
42
+ len (fnmatch .filter (os .listdir (dist_dir ), 'prestoadmin-*.tar.bz2' )) == 0 ):
43
+ self .testcase .fail (
44
+ 'Unable to find presto-admin package. '
45
+ 'Have you run one of `make dist*` or `make docker-dist*` command?' )
46
+
53
47
self ._copy_dist_to_host (cluster , dist_dir , cluster .master )
54
48
cluster .copy_to_host (
55
49
LOCAL_RESOURCES_DIR + "/install-admin.sh" , cluster .master )
@@ -69,80 +63,6 @@ def assert_installed(testcase, msg=None):
69
63
def get_keywords (self ):
70
64
return {}
71
65
72
- def _build_dist_if_necessary (self , cluster , unique = False ):
73
- if (not os .path .isdir (cluster .get_dist_dir (unique )) or
74
- not fnmatch .filter (
75
- os .listdir (cluster .get_dist_dir (unique )),
76
- 'prestoadmin-*.tar.bz2' )):
77
- self ._build_installer_in_docker (cluster , unique = unique )
78
- return cluster .get_dist_dir (unique )
79
-
80
- def _build_installer_in_docker (self , cluster , online_installer = None ,
81
- unique = False ):
82
- if online_installer is None :
83
- paTestOnlineInstaller = os .environ .get ('PA_TEST_ONLINE_INSTALLER' )
84
- online_installer = paTestOnlineInstaller is not None
85
-
86
- container_name = 'installer'
87
- cluster_type = 'installer_builder'
88
- bare_image_provider = NoHadoopBareImageProvider ()
89
-
90
- installer_container , created_bare = DockerCluster .start_cluster (
91
- bare_image_provider , cluster_type , 'installer' , [])
92
-
93
- if created_bare :
94
- installer_container .commit_images (
95
- bare_image_provider , cluster_type )
96
-
97
- try :
98
- shutil .copytree (
99
- prestoadmin .main_dir ,
100
- os .path .join (
101
- installer_container .get_local_mount_dir (container_name ),
102
- 'presto-admin' ),
103
- ignore = shutil .ignore_patterns ('tmp' , '.git' , 'presto*.rpm' )
104
- )
105
-
106
- # Pin pip to 7.1.2 because 8.0.0 removed support for distutils
107
- # installed projects, of which the system setuptools is one on our
108
- # Docker image. pip 8.0.1 or 8.0.2 replaced the error with a
109
- # deprecation warning, and also warns that Python 2.6 is
110
- # deprecated. While we still need to support Python 2.6, we'll pin
111
- # pip to a 7.x version, but we should revisit this once we no
112
- # longer need to support 2.6:
113
- # https://github.com/pypa/pip/issues/3384
114
- installer_container .run_script_on_host (
115
- 'set -e\n '
116
- 'pip install --upgrade pip==7.1.2\n '
117
- 'pip install --upgrade wheel==0.23.0\n '
118
- 'pip install --upgrade setuptools==20.1.1\n '
119
- 'mv %s/presto-admin ~/\n '
120
- 'cd ~/presto-admin\n '
121
- 'make %s\n '
122
- 'cp dist/prestoadmin-*.tar.bz2 %s'
123
- % (installer_container .mount_dir ,
124
- 'dist' if online_installer else 'dist-offline' ,
125
- installer_container .mount_dir ),
126
- container_name )
127
-
128
- try :
129
- os .makedirs (cluster .get_dist_dir (unique ))
130
- except OSError , e :
131
- if e .errno != errno .EEXIST :
132
- raise
133
- local_container_dist_dir = os .path .join (
134
- prestoadmin .main_dir ,
135
- installer_container .get_local_mount_dir (container_name )
136
- )
137
- installer_file = fnmatch .filter (
138
- os .listdir (local_container_dist_dir ),
139
- 'prestoadmin-*.tar.bz2' )[0 ]
140
- shutil .copy (
141
- os .path .join (local_container_dist_dir , installer_file ),
142
- cluster .get_dist_dir (unique ))
143
- finally :
144
- installer_container .tear_down ()
145
-
146
66
@staticmethod
147
67
def _copy_dist_to_host (cluster , local_dist_dir , dest_host ):
148
68
for dist_file in os .listdir (local_dist_dir ):
0 commit comments