26
26
27
27
from prestoadmin .util import constants
28
28
from tests .base_test_case import BaseTestCase
29
- from tests .configurable_cluster import ConfigurableCluster
30
- from tests .docker_cluster import DockerCluster , DockerClusterException
29
+ from tests .docker_cluster import DockerCluster
31
30
32
- from tests .product .mode_installers import StandaloneModeInstaller , \
33
- YarnSliderModeInstaller
34
- from tests .product .prestoadmin_installer import PrestoadminInstaller
31
+ from tests .configurable_cluster import ConfigurableCluster
32
+ from tests .product .cluster_types import cluster_types
35
33
from tests .product .standalone .presto_installer import StandalonePrestoInstaller
36
- from tests .product .topology_installer import TopologyInstaller
37
- from tests .product .yarn_slider .slider_installer import SliderInstaller
34
+
38
35
39
36
PRESTO_VERSION = r'.+'
40
37
RETRY_TIMEOUT = 120
41
38
RETRY_INTERVAL = 5
42
39
43
40
44
41
class BaseProductTestCase (BaseTestCase ):
45
- STANDALONE_BARE_CLUSTER = 'bare'
46
- BARE_CLUSTER = 'bare'
47
- PA_ONLY_CLUSTER = 'pa_only_standalone'
48
- STANDALONE_PRESTO_CLUSTER = 'presto'
49
-
50
- PA_ONLY_YS_CLUSTER = 'pa_only_ys'
51
- PA_SLIDER_CLUSTER = 'pa_slider'
52
-
53
- _cluster_types = {
54
- BARE_CLUSTER : [],
55
- PA_ONLY_CLUSTER : [PrestoadminInstaller ,
56
- StandaloneModeInstaller ],
57
- STANDALONE_PRESTO_CLUSTER : [PrestoadminInstaller ,
58
- StandaloneModeInstaller ,
59
- TopologyInstaller ,
60
- StandalonePrestoInstaller ],
61
- PA_ONLY_YS_CLUSTER : [PrestoadminInstaller ,
62
- YarnSliderModeInstaller ],
63
- PA_SLIDER_CLUSTER : [PrestoadminInstaller ,
64
- YarnSliderModeInstaller ,
65
- SliderInstaller ]
66
- }
67
-
68
42
default_workers_config_ = """coordinator=false
69
43
discovery.uri=http://master:8080
70
44
http-server.http.port=8080
@@ -134,19 +108,11 @@ def setUp(self):
134
108
self .cluster = None
135
109
self .default_keywords = {}
136
110
137
- def _run_installers (self , installers ):
138
- cluster = self .cluster
139
- for installer in installers :
140
- dependencies = installer .get_dependencies ()
141
-
142
- for dependency in dependencies :
143
- dependency .assert_installed (self )
144
-
145
- installer_instance = installer (self )
146
- installer_instance .install ()
147
-
148
- self .default_keywords .update (installer_instance .get_keywords ())
149
- cluster .postinstall (installer )
111
+ def tearDown (self ):
112
+ self .restore_stdout_stderr_keep_open ()
113
+ if self .cluster :
114
+ self .cluster .tear_down ()
115
+ super (BaseProductTestCase , self ).tearDown ()
150
116
151
117
def _apply_post_install_hooks (self , installers ):
152
118
for installer in installers :
@@ -158,12 +124,7 @@ def _update_replacement_keywords(self, installers):
158
124
self .default_keywords .update (installer_instance .get_keywords ())
159
125
160
126
def setup_cluster (self , bare_image_provider , cluster_type ):
161
- try :
162
- installers = self ._cluster_types [cluster_type ]
163
- except KeyError :
164
- self .fail (
165
- '%s is not a valid cluster type. Valid cluster types are %s' %
166
- (cluster_type , ', ' .join (self ._cluster_types .keys ())))
127
+ installers = cluster_types [cluster_type ]
167
128
168
129
config_filename = ConfigurableCluster .check_for_cluster_config ()
169
130
@@ -172,42 +133,22 @@ def setup_cluster(self, bare_image_provider, cluster_type):
172
133
config_filename , self ,
173
134
StandalonePrestoInstaller .assert_installed )
174
135
else :
175
- try :
176
- self .cluster , bare_cluster = DockerCluster .start_cluster (
177
- bare_image_provider , cluster_type )
178
-
179
- # If we've found images and started a non-bare cluster, the
180
- # containers have already had the installers applied to them.
181
- # We do need to get the test environment in sync with the
182
- # containers by calling the following two functions.
183
- #
184
- # Once that's done, the cluster and test environment is in the
185
- # same state it would be as if we'd called _run_installers on
186
- # a bare cluster, and we can return.
187
- #
188
- # We do this to save the cost of running the installers on the
189
- # docker containers every time we run a test. In practice,
190
- # that turns out to be a fairly expensive thing to do.
191
- if not bare_cluster :
192
- self ._apply_post_install_hooks (installers )
193
- self ._update_replacement_keywords (installers )
194
- return
195
- except DockerClusterException as e :
196
- self .fail (e .msg )
197
-
198
- # If we got a bare cluster back, we need to run the installers on it.
199
- # applying the post-install hooks and updating the replacement
200
- # keywords is handled internally in _run_installers.
201
- self ._run_installers (installers )
202
-
203
- if isinstance (self .cluster , DockerCluster ):
204
- self .cluster .commit_images (bare_image_provider , cluster_type )
205
-
206
- def tearDown (self ):
207
- self .restore_stdout_stderr_keep_open ()
208
- if self .cluster :
209
- self .cluster .tear_down ()
210
- super (BaseProductTestCase , self ).tearDown ()
136
+ self .cluster , bare_cluster = DockerCluster .start_cluster (
137
+ bare_image_provider , cluster_type )
138
+
139
+ # If we've found images and started a non-bare cluster, the
140
+ # containers have already had the installers applied to them.
141
+ # We do need to get the test environment in sync with the
142
+ # containers by calling the following two functions.
143
+ #
144
+ # We do this to save the cost of running the installers on the
145
+ # docker containers every time we run a test. In practice,
146
+ # that turns out to be a fairly expensive thing to do.
147
+ if not bare_cluster :
148
+ self ._apply_post_install_hooks (installers )
149
+ self ._update_replacement_keywords (installers )
150
+ else :
151
+ raise RuntimeError ("Docker images have not been created" )
211
152
212
153
def dump_and_cp_topology (self , topology , cluster = None ):
213
154
if not cluster :
0 commit comments