| 250 | |
| 251 | |
| 252 | class ImpalaTestClusterProperties(object): |
| 253 | _instance = None |
| 254 | |
| 255 | """ |
| 256 | Acquires and provides characteristics about the way the Impala under test was compiled |
| 257 | and its likely effects on its responsiveness to automated test timings. |
| 258 | TODO: Support remote urls for catalogd web UI.""" |
| 259 | |
| 260 | def __init__(self, build_flavor, library_link_type, web_ui_url, pytest_config, |
| 261 | catalogd_web_ui_url=DEFAULT_LOCAL_CATALOGD_WEB_UI_URL): |
| 262 | self._build_flavor = build_flavor |
| 263 | self._library_link_type = library_link_type |
| 264 | self._pytest_config = pytest_config |
| 265 | self._web_ui_url = web_ui_url |
| 266 | self._catalogd_web_ui_url = catalogd_web_ui_url |
| 267 | self._runtime_flags = None # Lazily populated to avoid unnecessary web UI calls. |
| 268 | self._catalogd_runtime_flags = None # Lazily populated |
| 269 | |
| 270 | @classmethod |
| 271 | def create_new_instance(cls, pytest_config=None): |
| 272 | web_ui_url = IMPALA_REMOTE_URL or DEFAULT_LOCAL_WEB_UI_URL |
| 273 | if IMPALA_REMOTE_URL: |
| 274 | # If IMPALA_REMOTE_URL is set, prefer detecting from the web UI. |
| 275 | build_flavor, link_type =\ |
| 276 | ImpalaTestClusterFlagsDetector.detect_using_web_ui(web_ui_url) |
| 277 | else: |
| 278 | build_flavor, link_type =\ |
| 279 | ImpalaTestClusterFlagsDetector.detect_using_build_root_or_web_ui(IMPALA_HOME) |
| 280 | return ImpalaTestClusterProperties( |
| 281 | build_flavor, link_type, web_ui_url, pytest_config=pytest_config) |
| 282 | |
| 283 | @classmethod |
| 284 | def get_instance(cls, pytest_config=None): |
| 285 | """Implements lazy initialization of a singleton instance of this class. We cannot |
| 286 | initialize the instances when this module is imported because some dependencies may |
| 287 | not be available yet, e.g. the pytest config object. Thus we instead initialize it |
| 288 | the first time that a test needs it.""" |
| 289 | if cls._instance is not None: |
| 290 | return cls._instance |
| 291 | |
| 292 | assert pytest_config is not None, ( |
| 293 | "Initial pytest_config must be provided for singleton") |
| 294 | cls._instance = cls.create_new_instance(pytest_config) |
| 295 | return cls._instance |
| 296 | |
| 297 | @property |
| 298 | def build_flavor(self): |
| 299 | """ |
| 300 | Return the correct ImpalaBuildFlavors for the Impala under test. |
| 301 | """ |
| 302 | return self._build_flavor |
| 303 | |
| 304 | @property |
| 305 | def library_link_type(self): |
| 306 | """ |
| 307 | Return the library link type (either static or dynamic) for the Impala under test. |
| 308 | """ |
| 309 | return self._library_link_type |