def test_cluster_destroy(self):
     """Test basic cluster destroy."""
     cluster = utils.create_cluster(self.ctxt)
     # On creation race_preventer is marked with a 0
     self.assertEqual(0, cluster.race_preventer)
     db.cluster_destroy(self.ctxt, cluster.id)
     db_cluster = db.cluster_get(self.ctxt, cluster.id, read_deleted='yes')
     self.assertTrue(db_cluster.deleted)
     self.assertIsNotNone(db_cluster.deleted_at)
     # On deletion race_preventer is marked with the id
     self.assertEqual(cluster.id, db_cluster.race_preventer)
Exemple #2
0
 def test_cluster_destroy(self):
     """Test basic cluster destroy."""
     cluster = utils.create_cluster(self.ctxt)
     # On creation race_preventer is marked with a 0
     self.assertEqual(0, cluster.race_preventer)
     db.cluster_destroy(self.ctxt, cluster.id)
     db_cluster = db.cluster_get(self.ctxt, cluster.id, read_deleted='yes')
     self.assertTrue(db_cluster.deleted)
     self.assertIsNotNone(db_cluster.deleted_at)
     # On deletion race_preventer is marked with the id
     self.assertEqual(cluster.id, db_cluster.race_preventer)
    def test_service_disabled_on_create_based_on_flag(self):
        ctxt = context.get_admin_context()
        self.flags(enable_new_services=False)
        host = 'foo'
        binary = 'cinder-fake'
        cluster = 'cluster'
        app = service.Service.create(host=host, binary=binary, cluster=cluster)
        ref = db.service_get(ctxt, app.service_id)
        db.service_destroy(ctxt, app.service_id)
        self.assertTrue(ref.disabled)

        # Check that the cluster is also enabled
        db_cluster = objects.ClusterList.get_all(ctxt)[0]
        self.assertTrue(db_cluster.disabled)
        db.cluster_destroy(ctxt, db_cluster.id)
Exemple #4
0
    def test_service_disabled_on_create_based_on_flag(self):
        ctxt = context.get_admin_context()
        self.flags(enable_new_services=False)
        host = 'foo'
        binary = 'cinder-fake'
        cluster = 'cluster'
        app = service.Service.create(host=host, binary=binary, cluster=cluster)
        ref = db.service_get(ctxt, app.service_id)
        db.service_destroy(ctxt, app.service_id)
        self.assertTrue(ref.disabled)

        # Check that the cluster is also enabled
        db_cluster = objects.ClusterList.get_all(ctxt)[0]
        self.assertTrue(db_cluster.disabled)
        db.cluster_destroy(ctxt, db_cluster.id)
    def test_cluster_create_not_duplicate(self):
        """Test that unique constraints will work with delete operation.

        To remove potential races on creation we have a constraint set on name
        and race_preventer fields, and we set value on creation to 0, so 2
        clusters with the same name will fail this constraint.  On deletion we
        change this field to the same value as the id which will be unique and
        will not conflict with the creation of another cluster with the same
        name.
        """
        cluster = self._create_cluster()
        self.assertIsNone(db.cluster_destroy(self.ctxt, cluster.id))
        self.assertIsNotNone(self._create_cluster(name=cluster.name))
Exemple #6
0
    def test_cluster_create_not_duplicate(self):
        """Test that unique constraints will work with delete operation.

        To remove potential races on creation we have a constraint set on name
        and race_preventer fields, and we set value on creation to 0, so 2
        clusters with the same name will fail this constraint.  On deletion we
        change this field to the same value as the id which will be unique and
        will not conflict with the creation of another cluster with the same
        name.
        """
        cluster = self._create_cluster()
        self.assertIsNone(db.cluster_destroy(self.ctxt, cluster.id))
        self.assertIsNotNone(self._create_cluster(name=cluster.name))
Exemple #7
0
 def destroy(self):
     with self.obj_as_admin():
         updated_values = db.cluster_destroy(self._context, self.id)
     for field, value in updated_values.items():
         setattr(self, field, value)
     self.obj_reset_changes(updated_values.keys())