def setup_cluster(self, bare_image_provider, cluster_type):
        try:
            installers = self._cluster_types[cluster_type]
        except KeyError:
            self.fail(
                '%s is not a valid cluster type. Valid cluster types are %s' %
                (cluster_type, ', '.join(self._cluster_types.keys())))

        config_filename = ConfigurableCluster.check_for_cluster_config()

        if config_filename:
            self.cluster = ConfigurableCluster.start_bare_cluster(
                config_filename, self,
                StandalonePrestoInstaller.assert_installed)
        else:
            try:
                self.cluster = DockerCluster.start_existing_images(
                    bare_image_provider, cluster_type)
                if self.cluster:
                    self._apply_post_install_hooks(installers)
                    self._update_replacement_keywords(installers)
                    return
                self.cluster = DockerCluster.start_bare_cluster(
                    bare_image_provider)
            except DockerClusterException as e:
                self.fail(e.msg)

        self._run_installers(installers)

        if isinstance(self.cluster, DockerCluster):
            self.cluster.commit_images(bare_image_provider, cluster_type)
    def setup_cluster(self, cluster_type):
        try:
            installers = self._cluster_types[cluster_type]
        except KeyError:
            self.fail(
                '%s is not a valid cluster type. Valid cluster types are %s' %
                (cluster_type, ', '.join(self._cluster_types.keys())))

        config_filename = ConfigurableCluster.check_for_cluster_config()

        if config_filename:
            self.cluster = ConfigurableCluster.start_bare_cluster(
                config_filename, self,
                StandalonePrestoInstaller.assert_installed)
        else:
            try:
                self.cluster = DockerCluster.start_existing_images(
                    cluster_type)
                if self.cluster:
                    self._apply_post_install_hooks(installers)
                    return
                self.cluster = DockerCluster.start_bare_cluster()
            except DockerClusterException as e:
                self.fail(e.msg)

        self._run_installers(installers)

        if isinstance(self.cluster, DockerCluster):
            self.cluster.commit_images(cluster_type)
    def setup_cluster(self, bare_image_provider, cluster_type):
        installers = cluster_types[cluster_type]

        config_filename = ConfigurableCluster.check_for_cluster_config()

        if config_filename:
            self.cluster = ConfigurableCluster.start_bare_cluster(
                config_filename, self,
                StandalonePrestoInstaller.assert_installed)
            self.cluster.ensure_correct_execution_environment()
            BaseProductTestCase.run_installers(self.cluster, installers, self)
        else:
            self.cluster, bare_cluster = DockerCluster.start_cluster(
                bare_image_provider, cluster_type)
            self.cluster.ensure_correct_execution_environment()

            # If we've found images and started a non-bare cluster, the
            # containers have already had the installers applied to them.
            # We do need to get the test environment in sync with the
            # containers by calling the following two functions.
            #
            # We do this to save the cost of running the installers on the
            # docker containers every time we run a test. In practice,
            # that turns out to be a fairly expensive thing to do.
            if not bare_cluster:
                self._apply_post_install_hooks(installers)
                self._update_replacement_keywords(installers)
            else:
                raise RuntimeError("Docker images have not been created")
    def setup_cluster(self, bare_image_provider, cluster_type):
        installers = cluster_types[cluster_type]

        config_filename = ConfigurableCluster.check_for_cluster_config()

        if config_filename:
            self.cluster = ConfigurableCluster.start_bare_cluster(
                config_filename, self,
                StandalonePrestoInstaller.assert_installed)
        else:
            self.cluster, bare_cluster = DockerCluster.start_cluster(
                bare_image_provider, cluster_type)

            # If we've found images and started a non-bare cluster, the
            # containers have already had the installers applied to them.
            # We do need to get the test environment in sync with the
            # containers by calling the following two functions.
            #
            # We do this to save the cost of running the installers on the
            # docker containers every time we run a test. In practice,
            # that turns out to be a fairly expensive thing to do.
            if not bare_cluster:
                self._apply_post_install_hooks(installers)
                self._update_replacement_keywords(installers)
            else:
                raise RuntimeError("Docker images have not been created")
 def setup_cluster(self, cluster_type='base'):
     cluster_types = ['presto', 'base']
     config_filename = ConfigurableCluster.check_for_cluster_config()
     try:
         if cluster_type == 'presto':
             if config_filename:
                 self.cluster = ConfigurableCluster.start_presto_cluster(
                     config_filename, self.install_default_presto,
                     self.assert_installed
                 )
             else:
                 self.cluster = DockerCluster.start_presto_cluster(
                     self.install_default_presto)
         elif cluster_type == 'base':
             if config_filename:
                 self.cluster = ConfigurableCluster.start_base_cluster(
                     config_filename, self.assert_installed
                 )
             else:
                 self.cluster = DockerCluster.start_base_cluster()
         else:
             self.fail('{0} is not a supported cluster type. Must choose '
                       'one from {1}'.format(cluster_type, cluster_types))
     except DockerClusterException as e:
         self.fail(e.msg)