コード例 #1
0
ファイル: test_cluster.py プロジェクト: openstack/cinder
    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 = utils.create_cluster(self.ctxt)
        self.assertIsNone(db.cluster_destroy(self.ctxt, cluster.id))
        self.assertIsNotNone(utils.create_cluster(self.ctxt,
                                                  name=cluster.name))
コード例 #2
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 = utils.create_cluster(self.ctxt)
        self.assertIsNone(db.cluster_destroy(self.ctxt, cluster.id))
        self.assertIsNotNone(utils.create_cluster(self.ctxt,
                                                  name=cluster.name))
コード例 #3
0
ファイル: test_cluster.py プロジェクト: openstack/cinder
 def test_cluster_get_is_up_on_empty_cluster(self):
     """Test is_up filter works on empty clusters."""
     cluster = utils.create_cluster(self.ctxt)
     db_cluster = db.cluster_get(self.ctxt, cluster.id, is_up=False)
     self.assertEqual(cluster.id, db_cluster.id)
     self.assertRaises(exception.ClusterNotFound,
                       db.cluster_get, self.ctxt, cluster.id, is_up=True)
コード例 #4
0
    def test_init_host_with_rpc_clustered_replication(self):
        # These are not OVOs but ORM instances
        cluster = utils.create_cluster(self.context)
        service = utils.create_service(self.context,
                                       {'cluster_name': cluster.name,
                                        'binary': cluster.binary})
        self.assertNotEqual(fields.ReplicationStatus.ENABLED,
                            cluster.replication_status)
        self.assertNotEqual(fields.ReplicationStatus.ENABLED,
                            service.replication_status)

        vol_manager = manager.VolumeManager(
            'cinder.tests.fake_driver.FakeHAReplicatedLoggingVolumeDriver',
            host=service.host, cluster=cluster.name)
        vol_manager.driver = mock.Mock()
        vol_manager.driver.get_volume_stats.return_value = {
            'replication_enabled': True
        }
        vol_manager.init_host_with_rpc()

        cluster_ovo = objects.Cluster.get_by_id(self.context, cluster.id)
        service_ovo = objects.Service.get_by_id(self.context, service.id)

        self.assertEqual(fields.ReplicationStatus.ENABLED,
                         cluster_ovo.replication_status)
        self.assertEqual(fields.ReplicationStatus.ENABLED,
                         service_ovo.replication_status)
コード例 #5
0
    def test_init_host_with_rpc_clustered_replication(self):
        # These are not OVOs but ORM instances
        cluster = utils.create_cluster(self.context)
        service = utils.create_service(self.context,
                                       {'cluster_name': cluster.name,
                                        'binary': cluster.binary})
        self.assertNotEqual(fields.ReplicationStatus.ENABLED,
                            cluster.replication_status)
        self.assertNotEqual(fields.ReplicationStatus.ENABLED,
                            service.replication_status)

        vol_manager = manager.VolumeManager(
            'cinder.tests.fake_driver.FakeHAReplicatedLoggingVolumeDriver',
            host=service.host, cluster=cluster.name)
        vol_manager.driver = mock.Mock()
        vol_manager.driver.get_volume_stats.return_value = {
            'replication_enabled': True
        }
        vol_manager.init_host_with_rpc()

        cluster_ovo = objects.Cluster.get_by_id(self.context, cluster.id)
        service_ovo = objects.Service.get_by_id(self.context, service.id)

        self.assertEqual(fields.ReplicationStatus.ENABLED,
                         cluster_ovo.replication_status)
        self.assertEqual(fields.ReplicationStatus.ENABLED,
                         service_ovo.replication_status)
コード例 #6
0
 def test_cluster_get_is_up_on_empty_cluster(self):
     """Test is_up filter works on empty clusters."""
     cluster = utils.create_cluster(self.ctxt)
     db_cluster = db.cluster_get(self.ctxt, cluster.id, is_up=False)
     self.assertEqual(cluster.id, db_cluster.id)
     self.assertRaises(exception.ClusterNotFound,
                       db.cluster_get, self.ctxt, cluster.id, is_up=True)
コード例 #7
0
 def test_cluster_update(self):
     """Test basic cluster update."""
     cluster = utils.create_cluster(self.ctxt)
     self.assertFalse(cluster.disabled)
     db.cluster_update(self.ctxt, cluster.id, {'disabled': True})
     db_cluster = db.cluster_get(self.ctxt, cluster.id)
     self.assertTrue(db_cluster.disabled)
コード例 #8
0
ファイル: test_cluster.py プロジェクト: openstack/cinder
 def test_cluster_update(self):
     """Test basic cluster update."""
     cluster = utils.create_cluster(self.ctxt)
     self.assertFalse(cluster.disabled)
     db.cluster_update(self.ctxt, cluster.id, {'disabled': True})
     db_cluster = db.cluster_get(self.ctxt, cluster.id)
     self.assertTrue(db_cluster.disabled)
コード例 #9
0
ファイル: test_cluster.py プロジェクト: openstack/cinder
 def test_cluster_get_with_summary_empty_cluster(self):
     """Test getting empty cluster with summary information."""
     cluster = utils.create_cluster(self.ctxt)
     db_cluster = db.cluster_get(self.ctxt, cluster.id,
                                 services_summary=True)
     self.assertEqual(0, db_cluster.num_hosts)
     self.assertEqual(0, db_cluster.num_down_hosts)
     self.assertIsNone(db_cluster.last_heartbeat)
コード例 #10
0
 def test_cluster_get_with_summary_empty_cluster(self):
     """Test getting empty cluster with summary information."""
     cluster = utils.create_cluster(self.ctxt)
     db_cluster = db.cluster_get(self.ctxt, cluster.id,
                                 services_summary=True)
     self.assertEqual(0, db_cluster.num_hosts)
     self.assertEqual(0, db_cluster.num_down_hosts)
     self.assertIsNone(db_cluster.last_heartbeat)
コード例 #11
0
 def test_cluster_get_by_name(self):
     """Getting a cluster by name will include backends if not specified."""
     cluster = utils.create_cluster(self.ctxt, name='cluster@backend')
     # Get without the backend
     db_cluster = db.cluster_get(self.ctxt, name='cluster')
     self.assertEqual(cluster.id, db_cluster.id)
     # Get with the backend detail
     db_cluster = db.cluster_get(self.ctxt, name='cluster@backend')
     self.assertEqual(cluster.id, db_cluster.id)
コード例 #12
0
 def test_cluster_get_without_summary(self):
     """Test getting cluster without summary information."""
     cluster = utils.create_cluster(self.ctxt)
     db_cluster = db.cluster_get(self.ctxt, cluster.id)
     self.assertRaises(exc.DetachedInstanceError,
                       getattr, db_cluster, 'num_hosts')
     self.assertRaises(exc.DetachedInstanceError,
                       getattr, db_cluster, 'num_down_hosts')
     self.assertIsNone(db_cluster.last_heartbeat)
コード例 #13
0
ファイル: test_cluster.py プロジェクト: openstack/cinder
 def test_cluster_get_without_summary(self):
     """Test getting cluster without summary information."""
     cluster = utils.create_cluster(self.ctxt)
     db_cluster = db.cluster_get(self.ctxt, cluster.id)
     self.assertRaises(exc.DetachedInstanceError,
                       getattr, db_cluster, 'num_hosts')
     self.assertRaises(exc.DetachedInstanceError,
                       getattr, db_cluster, 'num_down_hosts')
     self.assertIsNone(db_cluster.last_heartbeat)
コード例 #14
0
ファイル: test_cluster.py プロジェクト: openstack/cinder
 def test_cluster_get_by_name(self):
     """Getting a cluster by name will include backends if not specified."""
     cluster = utils.create_cluster(self.ctxt, name='cluster@backend')
     # Get without the backend
     db_cluster = db.cluster_get(self.ctxt, name='cluster')
     self.assertEqual(cluster.id, db_cluster.id)
     # Get with the backend detail
     db_cluster = db.cluster_get(self.ctxt, name='cluster@backend')
     self.assertEqual(cluster.id, db_cluster.id)
コード例 #15
0
ファイル: test_cluster.py プロジェクト: openstack/cinder
 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)
コード例 #16
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)
コード例 #17
0
    def test_cluster_create_duplicate(self):
        """Test that unique constraints are working.

        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 = utils.create_cluster(self.ctxt)
        self.assertRaises(exception.ClusterExists,
                          utils.create_cluster,
                          self.ctxt,
                          name=cluster.name)
コード例 #18
0
ファイル: test_cluster.py プロジェクト: openstack/cinder
    def test_cluster_create_duplicate(self):
        """Test that unique constraints are working.

        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 = utils.create_cluster(self.ctxt)
        self.assertRaises(exception.ClusterExists,
                          utils.create_cluster,
                          self.ctxt,
                          name=cluster.name)
コード例 #19
0
 def test_cluster_get_fail(self):
     """Test that cluster get will fail if the cluster doesn't exists."""
     utils.create_cluster(self.ctxt, name='cluster@backend')
     self.assertRaises(exception.ClusterNotFound,
                       db.cluster_get, self.ctxt, 'name=cluster@backend2')
コード例 #20
0
ファイル: test_cluster.py プロジェクト: openstack/cinder
 def test_cluster_create_cfg_disabled(self):
     """Test that create uses enable_new_services configuration option."""
     self.override_config('enable_new_services', False)
     cluster = utils.create_cluster(self.ctxt, disabled=None)
     self.assertTrue(cluster.disabled)
コード例 #21
0
 def test_cluster_create_disabled_preference(self):
     """Test that provided disabled value has highest priority on create."""
     self.override_config('enable_new_services', False)
     cluster = utils.create_cluster(self.ctxt)
     self.assertFalse(cluster.disabled)
コード例 #22
0
 def test_cluster_create_cfg_disabled(self):
     """Test that create uses enable_new_services configuration option."""
     self.override_config('enable_new_services', False)
     cluster = utils.create_cluster(self.ctxt, disabled=None)
     self.assertTrue(cluster.disabled)
コード例 #23
0
ファイル: test_cluster.py プロジェクト: openstack/cinder
 def test_cluster_create_disabled_preference(self):
     """Test that provided disabled value has highest priority on create."""
     self.override_config('enable_new_services', False)
     cluster = utils.create_cluster(self.ctxt)
     self.assertFalse(cluster.disabled)
コード例 #24
0
 def test_cluster_get_services_on_empty_cluster(self):
     """Test get_services filter works on empty clusters."""
     cluster = utils.create_cluster(self.ctxt)
     db_cluster = db.cluster_get(self.ctxt, cluster.id, get_services=True)
     self.assertEqual(cluster.id, db_cluster.id)
     self.assertListEqual([], db_cluster.services)
コード例 #25
0
ファイル: test_cluster.py プロジェクト: openstack/cinder
 def test_cluster_get_services_on_empty_cluster(self):
     """Test get_services filter works on empty clusters."""
     cluster = utils.create_cluster(self.ctxt)
     db_cluster = db.cluster_get(self.ctxt, cluster.id, get_services=True)
     self.assertEqual(cluster.id, db_cluster.id)
     self.assertListEqual([], db_cluster.services)
コード例 #26
0
ファイル: test_cluster.py プロジェクト: openstack/cinder
 def test_cluster_get_fail(self):
     """Test that cluster get will fail if the cluster doesn't exists."""
     utils.create_cluster(self.ctxt, name='cluster@backend')
     self.assertRaises(exception.ClusterNotFound,
                       db.cluster_get, self.ctxt, 'name=cluster@backend2')