Example #1
0
 def _start_mysql(self):
     datastore = Mock(spec=DatastoreVersion)
     datastore.datastore_name = "mysql"
     datastore.name = "mysql-5.6"
     datastore.manager = "mysql"
     config = template.SingleInstanceConfigTemplate(datastore, NEW_FLAVOR.__dict__, self.instance.id)
     self.instance.guest.start_db_with_conf_changes(config.render())
Example #2
0
 def test_add_shard(
     self,
     mock_find_all,
     mock_load_any_instance,
     mock_check_quotas,
     mock_instance_create,
     mock_update_db,
     mock_task_api_load,
     mock_load_by_uuid,
 ):
     self.cluster.db_info.task_status = ClusterTasks.NONE
     (mock_find_all.return_value.all.return_value) = [
         DBInstance(InstanceTasks.NONE, name="TestInstance1", shard_id="1", id="1", datastore_version_id="1"),
         DBInstance(InstanceTasks.NONE, name="TestInstance2", shard_id="1", id="2", datastore_version_id="1"),
         DBInstance(InstanceTasks.NONE, name="TestInstance3", shard_id="1", id="3", datastore_version_id="1"),
     ]
     mock_datastore_version = Mock()
     mock_datastore_version.manager = "mongodb"
     mock_load_by_uuid.return_value = mock_datastore_version
     mock_task_api = Mock()
     mock_task_api.mongodb_add_shard_cluster.return_value = None
     mock_task_api_load.return_value = mock_task_api
     self.cluster.add_shard()
     mock_update_db.assert_called_with(task_status=ClusterTasks.ADDING_SHARD)
     mock_task_api.mongodb_add_shard_cluster.assert_called
Example #3
0
    def test_create_clusters(self, mock_get_datastore_version, mock_id_from_href, mock_cluster_create):
        body = self.cluster
        tenant_id = Mock()
        context = Mock()

        req = Mock()
        req.environ = Mock()
        req.environ.__getitem__ = Mock(return_value=context)
        datastore_version = Mock()
        datastore_version.manager = "mongodb"
        datastore = Mock()
        mock_get_datastore_version.return_value = (datastore, datastore_version)
        instances = [
            {"volume_size": 1, "flavor_id": "1234"},
            {"volume_size": 1, "flavor_id": "1234"},
            {"volume_size": 1, "flavor_id": "1234"},
            {"volume_size": 1, "flavor_id": "1234"},
            {"volume_size": 1, "flavor_id": "1234"},
        ]
        mock_id_from_href.return_value = "1234"

        mock_cluster = Mock()
        mock_cluster.instances = []
        mock_cluster.datastore_version.manager = "mongodb"
        mock_cluster_create.return_value = mock_cluster

        self.controller.create(req, body, tenant_id)
        mock_cluster_create.assert_called_with(context, "products", datastore, datastore_version, instances)
    def test_create_clusters(self, mock_get_datastore_version, mock_id_from_href, mock_cluster_create):
        body = self.cluster
        tenant_id = Mock()
        context = trove_testtools.TroveTestContext(self)

        req = Mock()
        req.environ = Mock()
        req.environ.__getitem__ = Mock(return_value=context)
        datastore_version = Mock()
        datastore_version.manager = "vertica"
        datastore = Mock()
        mock_get_datastore_version.return_value = (datastore, datastore_version)
        instances = [
            {
                "volume_size": 1,
                "volume_type": None,
                "flavor_id": "1234",
                "availability_zone": "az",
                "modules": None,
                "region_name": None,
                "nics": [{"net-id": "e89aa5fd-6b0a-436d-a75c-1545d34d5331"}],
            }
        ] * 3
        mock_id_from_href.return_value = "1234"

        mock_cluster = Mock()
        mock_cluster.instances = []
        mock_cluster.instances_without_server = []
        mock_cluster.datastore_version.manager = "vertica"
        mock_cluster_create.return_value = mock_cluster

        self.controller.create(req, body, tenant_id)
        mock_cluster_create.assert_called_with(context, "products", datastore, datastore_version, instances, {}, None)
Example #5
0
 def test_replica_config_rendering(self):
     datastore = Mock(spec=DatastoreVersion)
     datastore.datastore_name = "MySql"
     datastore.name = "mysql-5.6"
     datastore.manager = "mysql"
     config = template.ReplicaConfigTemplate(datastore, self.flavor_dict, self.server_id)
     self.assertTrue(self._find_in_template(config.render(), "relay_log"))
Example #6
0
 def test_single_instance_config_rendering(self):
     datastore = Mock(spec=DatastoreVersion)
     datastore.datastore_name = "MySql"
     datastore.name = "mysql-5.6"
     datastore.manager = "mysql"
     config = template.SingleInstanceConfigTemplate(datastore, self.flavor_dict, self.server_id)
     self.validate_template(config.render(), "query_cache_size", self.flavor_dict, self.server_id)
Example #7
0
 def test_renderer_discovers_special_config(self):
     """Finds our special config file for the version 'mysql-test'."""
     datastore = Mock(spec=DatastoreVersion)
     datastore.datastore_name = "mysql"
     datastore.name = "mysql-test"
     datastore.manager = "mysql"
     config = template.SingleInstanceConfigTemplate(datastore, self.flavor_dict, self.server_id)
     self.validate_template(config.render(), "hyper", {"ram": 0}, self.server_id)
Example #8
0
    def test_load(self, mock_find_by, mock_load_dsv_by_uuid, mock_ds_load):
        context = Mock()
        id = Mock()

        dsv = Mock()
        dsv.manager = "mongodb"
        mock_load_dsv_by_uuid.return_value = dsv
        cluster = models.Cluster.load(context, id)
        self.assertIsInstance(cluster, MongoDbCluster)
    def test_create_clusters_disabled(self, mock_get_datastore_version, mock_cluster_create):
        body = self.cluster
        tenant_id = Mock()
        context = trove_testtools.TroveTestContext(self)

        req = Mock()
        req.environ = MagicMock()
        req.environ.get = Mock(return_value=context)

        datastore_version = Mock()
        datastore_version.manager = "mysql"
        mock_get_datastore_version.return_value = (Mock(), datastore_version)

        self.assertRaises(exception.ClusterDatastoreNotSupported, self.controller.create, req, body, tenant_id)
    def test_load(self, mock_inst_load, mock_find_by, mock_load_dsv_by_uuid, mock_ds_load):
        context = trove_testtools.TroveTestContext(self)
        id = Mock()
        inst_mock = Mock()
        server_group = Mock()
        inst_mock.server_group = server_group
        mock_inst_load.return_value = [inst_mock]

        dsv = Mock()
        dsv.manager = "mongodb"
        mock_load_dsv_by_uuid.return_value = dsv
        cluster = models.Cluster.load(context, id)
        self.assertIsInstance(cluster, MongoDbCluster)
        self.assertEqual(server_group, cluster.server_group, "Unexpected server group")
    def test_create_clusters_disabled(self, mock_cluster_create, mock_get_datastore_version):

        cfg.CONF.set_override("cluster_support", False, group="vertica", enforce_type=True)

        body = self.cluster
        tenant_id = Mock()
        context = trove_testtools.TroveTestContext(self)

        req = Mock()
        req.environ = MagicMock()
        req.environ.get = Mock(return_value=context)

        datastore_version = Mock()
        datastore_version.manager = "vertica"
        mock_get_datastore_version.return_value = (Mock(), datastore_version)

        self.assertRaises(exception.TroveError, self.controller.create, req, body, tenant_id)
    def test_create_clusters_disabled(self, mock_cluster_create, mock_get_datastore_version):

        cfg.CONF.set_override("cluster_support", False, group="redis")

        body = self.cluster
        tenant_id = Mock()
        context = Mock()

        req = Mock()
        req.environ = MagicMock()
        req.environ.get = Mock(return_value=context)

        datastore_version = Mock()
        datastore_version.manager = "redis"
        mock_get_datastore_version.return_value = (Mock(), datastore_version)

        self.assertRaisesRegexp(
            exception.TroveError, "Clusters not supported for", self.controller.create, req, body, tenant_id
        )
    def test_create_clusters_enabled(self, mock_cluster_create, mock_get_datastore_version, mock_cluster_view_data):

        cfg.CONF.set_override("cluster_support", True, group="redis")

        body = self.cluster
        tenant_id = Mock()
        context = Mock()

        req = Mock()
        req.environ = MagicMock()
        req.environ.get = Mock(return_value=context)

        datastore_version = Mock()
        datastore_version.manager = "redis"
        mock_get_datastore_version.return_value = (Mock(), datastore_version)

        mock_cluster = Mock()
        mock_cluster.datastore_version.manager = "redis"
        mock_cluster_create.return_value = mock_cluster
        self.controller.create(req, body, tenant_id)