コード例 #1
0
 def setUp(self):
     super(InstanceDetailViewTest, self).setUp()
     self.build_links_method = InstanceView._build_links
     self.build_flavor_links_method = InstanceView._build_flavor_links
     self.build_config_method = InstanceDetailView._build_configuration_info
     InstanceView._build_links = Mock()
     InstanceView._build_flavor_links = Mock()
     InstanceDetailView._build_configuration_info = Mock()
     self.instance = Mock()
     self.instance.created = 'Yesterday'
     self.instance.updated = 'Now'
     self.instance.datastore_version = Mock()
     self.instance.datastore_version.name = 'mysql_test_version'
     self.instance.datastore_version.manager = 'mysql'
     self.instance.hostname = 'test.trove.com'
     self.ip = "1.2.3.4"
     self.instance.addresses = {"private": [{"addr": self.ip}]}
     self.instance.volume_used = '3'
     self.instance.root_password = '******'
     self.instance.get_visible_ip_addresses = lambda: ["1.2.3.4"]
     self.instance.slave_of_id = None
     self.instance.slaves = []
     self.instance.locality = 'affinity'
     self.fault_message = 'Error'
     self.fault_details = 'details'
     self.fault_date = 'now'
     self.instance.fault = Mock()
     self.instance.fault.message = self.fault_message
     self.instance.fault.details = self.fault_details
     self.instance.fault.updated = self.fault_date
     self.context = trove_testtools.TroveTestContext(self)
     self.req = Mock()
     self.req.environ = Mock()
     self.req.environ.__getitem__ = Mock(return_value=self.context)
コード例 #2
0
 def setUp(self):
     super(SimpleInstanceTest, self).setUp()
     self.context = trove_testtools.TroveTestContext(self, is_admin=True)
     db_info = DBInstance(InstanceTasks.BUILDING, name="TestInstance")
     self.instance = SimpleInstance(None,
                                    db_info,
                                    InstanceServiceStatus(
                                        ServiceStatuses.BUILDING),
                                    ds_version=Mock(),
                                    ds=Mock(),
                                    locality='affinity')
     self.instance.context = self.context
     db_info.addresses = [
         {
             'type': 'private',
             'address': '123.123.123.123'
         },
         {
             'type': 'private',
             'address': '10.123.123.123'
         },
         {
             'type': 'public',
             'address': '15.123.123.123'
         },
     ]
     self.orig_ip_regex = CONF.ip_regex
     self.orig_black_list_regex = CONF.black_list_regex
コード例 #3
0
 def _init(self):
     self.mock = mox.Mox()
     self.instance_id = 500
     context = trove_testtools.TroveTestContext(self)
     self.db_info = DBInstance.create(
         name="instance",
         flavor_id=OLD_FLAVOR_ID,
         tenant_id=999,
         volume_size=None,
         datastore_version_id=test_config.dbaas_datastore_version_id,
         task_status=InstanceTasks.RESIZING)
     self.server = self.mock.CreateMock(Server)
     self.instance = models.BuiltInstanceTasks(
         context,
         self.db_info,
         self.server,
         datastore_status=InstanceServiceStatus.create(
             instance_id=self.db_info.id,
             status=rd_instance.ServiceStatuses.RUNNING))
     self.instance.server.flavor = {'id': OLD_FLAVOR_ID}
     self.guest = self.mock.CreateMock(guest.API)
     self.instance._guest = self.guest
     self.instance.refresh_compute_server_info = lambda: None
     self.instance._refresh_datastore_status = lambda: None
     self.mock.StubOutWithMock(self.instance, 'update_db')
     self.mock.StubOutWithMock(self.instance,
                               'set_datastore_status_to_paused')
     self.poll_until_mocked = False
     self.action = None
コード例 #4
0
 def setUp(self):
     super(GuestAgentManagerTest, self).setUp()
     self.context = trove_testtools.TroveTestContext(self)
     self.manager = Manager()
     self.origin_MySqlAppStatus = dbaas.MySqlAppStatus
     self.origin_os_path_exists = os.path.exists
     self.origin_format = volume.VolumeDevice.format
     self.origin_migrate_data = volume.VolumeDevice.migrate_data
     self.origin_mount = volume.VolumeDevice.mount
     self.origin_unmount = volume.VolumeDevice.unmount
     self.origin_mount_points = volume.VolumeDevice.mount_points
     self.origin_stop_mysql = dbaas.MySqlApp.stop_db
     self.origin_start_mysql = dbaas.MySqlApp.start_mysql
     self.origin_update_overrides = dbaas.MySqlApp.update_overrides
     self.origin_pkg_is_installed = pkg.Package.pkg_is_installed
     self.origin_os_path_exists = os.path.exists
     self.origin_chown = operating_system.chown
     # set up common mock objects, etc. for replication testing
     self.patcher_gfvs = patch(
         'trove.guestagent.dbaas.get_filesystem_volume_stats')
     self.patcher_rs = patch(self.manager.replication_namespace + "." +
                             self.manager.replication_strategy)
     self.mock_gfvs_class = self.patcher_gfvs.start()
     self.mock_rs_class = self.patcher_rs.start()
     self.repl_datastore_manager = 'mysql'
     self.repl_replication_strategy = 'MysqlGTIDReplication'
コード例 #5
0
    def setUp(self, *args, **kwargs):
        super(RedisGuestAgentManagerTest, self).setUp()
        self.patch_ope = patch('os.path.expanduser')
        self.mock_ope = self.patch_ope.start()
        self.addCleanup(self.patch_ope.stop)
        self.context = trove_testtools.TroveTestContext(self)
        self.manager = RedisManager()
        self.packages = 'redis-server'
        self.origin_RedisAppStatus = redis_service.RedisAppStatus
        self.origin_start_redis = redis_service.RedisApp.start_redis
        self.origin_stop_redis = redis_service.RedisApp.stop_db
        self.origin_install_redis = redis_service.RedisApp._install_redis
        self.origin_install_if_needed = \
            redis_service.RedisApp.install_if_needed
        self.origin_format = VolumeDevice.format
        self.origin_mount = VolumeDevice.mount
        self.origin_mount_points = VolumeDevice.mount_points
        self.origin_restore = backup.restore
        self.patch_rs = patch(
            'trove.guestagent.datastore.experimental.redis.manager.'
            'REPLICATION_STRATEGY_CLASS')
        self.mock_rs_class = self.patch_rs.start()
        self.addCleanup(self.patch_rs.stop)
        self.patch_gfvs = patch(
            'trove.guestagent.dbaas.get_filesystem_volume_stats')
        self.mock_gfvs_class = self.patch_gfvs.start()
        self.addCleanup(self.patch_gfvs.stop)

        self.repl_datastore_manager = 'redis'
        self.repl_replication_strategy = 'RedisSyncReplication'
コード例 #6
0
 def setUp(self):
     super(GuestAgentManagerTest, self).setUp()
     self.manager = Manager()
     self.context = trove_testtools.TroveTestContext(self)
     self.patcher_rs = patch(self.manager.replication_namespace + "." +
                             self.manager.replication_strategy)
     self.mock_rs_class = self.patcher_rs.start()
コード例 #7
0
 def setUp(self):
     super(ClusterTest, self).setUp()
     self.get_client_patch = patch.object(task_api.API, 'get_client')
     self.get_client_mock = self.get_client_patch.start()
     self.addCleanup(self.get_client_patch.stop)
     self.cluster_id = str(uuid.uuid4())
     self.cluster_name = "Cluster" + self.cluster_id
     self.tenant_id = "23423432"
     self.dv_id = "1"
     self.db_info = DBCluster(ClusterTasks.NONE,
                              id=self.cluster_id,
                              name=self.cluster_name,
                              tenant_id=self.tenant_id,
                              datastore_version_id=self.dv_id,
                              task_id=ClusterTasks.NONE._code)
     self.context = trove_testtools.TroveTestContext(self)
     self.datastore = Mock()
     self.dv = Mock()
     self.dv.manager = "pxc"
     self.datastore_version = self.dv
     self.cluster = galera_api.GaleraCommonCluster(
         self.context, self.db_info, self.datastore, self.datastore_version)
     self.cluster._server_group_loaded = True
     self.instances = [
         {'volume_size': 1, 'flavor_id': '1234',
          'nics': [{"net-id": "foo-bar"}]},
         {'volume_size': 1, 'flavor_id': '1234',
          'nics': [{"net-id": "foo-bar"}]},
         {'volume_size': 1, 'flavor_id': '1234',
          'nics': [{"net-id": "foo-bar"}]}]
コード例 #8
0
 def _init(self):
     self.instance_id = 500
     context = trove_testtools.TroveTestContext(self)
     self.db_info = DBInstance.create(
         name="instance",
         flavor_id=OLD_FLAVOR_ID,
         tenant_id=999,
         volume_size=None,
         datastore_version_id=test_config.dbaas_datastore_version_id,
         task_status=InstanceTasks.RESIZING)
     self.server = mock.MagicMock(spec=Server)
     self.instance = models.BuiltInstanceTasks(
         context,
         self.db_info,
         self.server,
         datastore_status=InstanceServiceStatus.create(
             instance_id=self.db_info.id,
             status=srvstatus.ServiceStatuses.RUNNING))
     self.instance.server.flavor = {'id': OLD_FLAVOR_ID}
     self.guest = mock.MagicMock(spec=guest.API)
     self.instance._guest = self.guest
     self.instance.refresh_compute_server_info = lambda: None
     self.instance._refresh_datastore_status = lambda: None
     self.instance.update_db = mock.Mock()
     self.instance.set_datastore_status_to_paused = mock.Mock()
     self.poll_until_side_effects = []
     self.action = None
コード例 #9
0
    def test_controller_action_found(self,
                                     mock_cluster_load,
                                     mock_cluster_api_strategy):

        body = {'do_stuff': {}}
        tenant_id = Mock()
        context = trove_testtools.TroveTestContext(self)
        id = Mock()

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

        cluster = Mock()
        cluster.datastore_version.manager = 'pxc'
        mock_cluster_load.return_value = cluster

        strat = Mock()
        do_stuff_func = Mock()
        strat.cluster_controller_actions = \
            {'do_stuff': do_stuff_func}
        mock_cluster_api_strategy.return_value = strat

        self.controller.action(req, body, tenant_id, id)
        self.assertEqual(1, do_stuff_func.call_count)
コード例 #10
0
    def test_create_clusters_disabled(self,
                                      mock_cluster_create,
                                      mock_get_datastore_version):

        cfg.CONF.set_override('cluster_support', False, group='redis',
                              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 = '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)
コード例 #11
0
    def setUp(self, *args, **kwargs):
        super(GuestAgentManagerTest, self).setUp()

        # TODO(pmalik): Remove this line when
        # https://review.openstack.org/#/c/308707/ merges.
        self.patch_datastore_manager('vertica')

        self.context = trove_testtools.TroveTestContext(self)
        self.manager = Manager()
        self.origin_format = volume.VolumeDevice.format
        self.origin_migrate_data = volume.VolumeDevice.migrate_data
        self.origin_mount = volume.VolumeDevice.mount
        self.origin_unmount = volume.VolumeDevice.unmount
        self.origin_mount_points = volume.VolumeDevice.mount_points
        self.origin_set_read = volume.VolumeDevice.set_readahead_size
        self.origin_install_vertica = VerticaApp.install_vertica
        self.origin_create_db = VerticaApp.create_db
        self.origin_stop_db = VerticaApp.stop_db
        self.origin_start_db = VerticaApp.start_db
        self.origin_restart = VerticaApp.restart
        self.origin_install_if = VerticaApp.install_if_needed
        self.origin_enable_root = VerticaApp.enable_root
        self.origin_is_root_enabled = VerticaApp.is_root_enabled
        self.origin_prepare_for_install_vertica = (
            VerticaApp.prepare_for_install_vertica)
        self.origin_add_udls = VerticaApp.add_udls
コード例 #12
0
ファイル: test_storage.py プロジェクト: konstar/tesora-trove
    def test_swift_segment_checksum_etag_mismatch(self, mock_logging):
        """This tests that when etag doesn't match segment uploaded checksum
            False is returned and None for checksum and location
        """
        context = trove_testtools.TroveTestContext(self)
        # this backup_id will trigger fake swift client with calculate_etag
        # enabled to spit out a bad etag when a segment object is uploaded
        backup_id = 'bad_segment_etag_123'
        user = '******'
        password = '******'

        swift_client = FakeSwiftConnection()
        with patch.object(remote,
                          'create_swift_client',
                          return_value=swift_client):
            storage_strategy = SwiftStorage(context)

            with MockBackupRunner(filename=backup_id,
                                  user=user,
                                  password=password) as runner:
                (success, note, checksum,
                 location) = storage_strategy.save(runner.manifest, runner)

        self.assertFalse(success, "The backup should have failed!")
        self.assertTrue(note.startswith("Error saving data to Swift!"))
        self.assertIsNone(checksum,
                          "Swift checksum should be None for failed backup.")
        self.assertEqual(
            'http://mockswift/v1/database_backups/'
            'bad_segment_etag_123.gz.enc', location,
            "Incorrect swift location was returned.")
コード例 #13
0
 def setUp(self):
     super(ClusterTest, self).setUp()
     self.get_client_patch = patch.object(task_api.API, 'get_client')
     self.get_client_mock = self.get_client_patch.start()
     self.addCleanup(self.get_client_patch.stop)
     self.cluster_id = str(uuid.uuid4())
     self.cluster_name = "Cluster" + self.cluster_id
     self.tenant_id = "23423432"
     self.dv_id = "1"
     self.db_info = DBCluster(ClusterTasks.NONE,
                              id=self.cluster_id,
                              name=self.cluster_name,
                              tenant_id=self.tenant_id,
                              datastore_version_id=self.dv_id,
                              task_id=ClusterTasks.NONE._code)
     self.context = trove_testtools.TroveTestContext(self)
     self.datastore = Mock()
     self.dv = Mock()
     self.dv.manager = "vertica"
     self.datastore_version = self.dv
     self.cluster = vertica_api.VerticaCluster(self.context, self.db_info,
                                               self.datastore,
                                               self.datastore_version)
     self.instances = [{'volume_size': 1, 'flavor_id': '1234',
                        'instance_type': 'master'},
                       {'volume_size': 1, 'flavor_id': '1234',
                        'instance_type': 'member'},
                       {'volume_size': 1, 'flavor_id': '1234',
                        'instance_type': 'member'}]
     self.db_instances = [1, 2, 3]
コード例 #14
0
 def setUp(self):
     super(TestInstanceController, self).setUp()
     self.controller = InstanceController()
     self.locality = 'affinity'
     self.instance = {
         "instance": {
             "volume": {
                 "size": "1"
             },
             "users": [{
                 "name": "user1",
                 "password": "******",
                 "databases": [{
                     "name": "firstdb"
                 }]
             }],
             "flavorRef":
             "https://*****:*****@(D",
             "databases": [{
                 "name": "firstdb",
                 "collate": "latin2_general_ci",
                 "character_set": "latin2"
             }, {
                 "name": "db2"
             }],
             "locality":
             self.locality
         }
     }
     self.context = trove_testtools.TroveTestContext(self)
     self.req = Mock(remote_addr='ip:port', host='myhost')
コード例 #15
0
    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 = 'redis'
        datastore = Mock()
        mock_get_datastore_version.return_value = (datastore,
                                                   datastore_version)
        instances = [
            {
                "volume_size": None,
                'volume_type': None,
                "flavor_id": "1234",
                "availability_zone": "az",
                'modules': None,
                "nics": [
                    {"net-id": "e89aa5fd-6b0a-436d-a75c-1545d34d5331"}
                ]
            },
            {
                "volume_size": None,
                'volume_type': None,
                "flavor_id": "1234",
                "availability_zone": "az",
                'modules': None,
                "nics": [
                    {"net-id": "e89aa5fd-6b0a-436d-a75c-1545d34d5331"}
                ]
            },
            {
                "volume_size": None,
                'volume_type': None,
                "flavor_id": "1234",
                "availability_zone": "az",
                'modules': None,
                "nics": [
                    {"net-id": "e89aa5fd-6b0a-436d-a75c-1545d34d5331"}
                ]
            }
        ]
        mock_id_from_href.return_value = '1234'

        mock_cluster = Mock()
        mock_cluster.instances = []
        mock_cluster.instances_without_server = []
        mock_cluster.datastore_version.manager = 'redis'
        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)
コード例 #16
0
    def setUp(self, *args, **kwargs):
        super(GuestAgentCassandraDBManagerTest, self).setUp()
        self.real_status = cass_service.CassandraAppStatus.set_status

        class FakeInstanceServiceStatus(object):
            status = ServiceStatuses.NEW

            def save(self):
                pass

        cass_service.CassandraAppStatus.set_status = MagicMock(
            return_value=FakeInstanceServiceStatus())
        self.context = trove_testtools.TroveTestContext(self)
        self.manager = cass_manager.Manager()
        self.manager._Manager__admin = cass_service.CassandraAdmin(
            models.CassandraUser('Test'))
        self.admin = self.manager._Manager__admin
        self.pkg = cass_service.packager
        self.origin_os_path_exists = os.path.exists
        self.origin_format = volume.VolumeDevice.format
        self.origin_migrate_data = volume.VolumeDevice.migrate_data
        self.origin_mount = volume.VolumeDevice.mount
        self.origin_mount_points = volume.VolumeDevice.mount_points
        self.origin_stop_db = cass_service.CassandraApp.stop_db
        self.origin_start_db = cass_service.CassandraApp.start_db
        self.origin_install_db = cass_service.CassandraApp._install_db
        self.original_get_ip = netutils.get_my_ipv4
        self.orig_make_host_reachable = (
            cass_service.CassandraApp.apply_initial_guestagent_configuration)
コード例 #17
0
ファイル: test_api.py プロジェクト: paramtech/tesora-trove
    def test_load_api(self, get_client_mock):
        context = trove_testtools.TroveTestContext(self)
        manager = 'mongodb'

        self.assertTrue(isinstance(task_api.load(context), task_api.API))
        self.assertTrue(
            isinstance(task_api.load(context, manager), MongoDbTaskManagerAPI))
コード例 #18
0
 def test_with_notification(self):
     context = trove_testtools.TroveTestContext(self)
     self.assertTrue(context.notification.needs_end_notification)
     with notification.NotificationCastWrapper(context, "foo"):
         self.assertEqual('foo', context.notification.server_type)
     self.assertEqual('api', context.notification.server_type)
     self.assertFalse(context.notification.needs_end_notification)
コード例 #19
0
    def setUp(self):
        super(GuestAgentDB2ManagerTest, self).setUp()
        self.real_status = db2_service.DB2AppStatus.set_status

        class FakeInstanceServiceStatus(object):
            status = ServiceStatuses.NEW

            def save(self):
                pass

        db2_service.DB2AppStatus.set_status = MagicMock(
            return_value=FakeInstanceServiceStatus())
        self.context = trove_testtools.TroveTestContext(self)
        self.manager = db2_manager.Manager()
        self.real_db_app_status = db2_service.DB2AppStatus
        self.origin_format = volume.VolumeDevice.format
        self.origin_mount = volume.VolumeDevice.mount
        self.origin_mount_points = volume.VolumeDevice.mount_points
        self.origin_stop_db = db2_service.DB2App.stop_db
        self.origin_start_db = db2_service.DB2App.start_db
        self.orig_change_ownership = (db2_service.DB2App.change_ownership)
        self.orig_create_databases = db2_service.DB2Admin.create_database
        self.orig_list_databases = db2_service.DB2Admin.list_databases
        self.orig_delete_database = db2_service.DB2Admin.delete_database
        self.orig_create_users = db2_service.DB2Admin.create_user
        self.orig_list_users = db2_service.DB2Admin.list_users
        self.orig_delete_user = db2_service.DB2Admin.delete_user
コード例 #20
0
    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='pxc',
                              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 = 'pxc'
        mock_get_datastore_version.return_value = (Mock(), datastore_version)

        mock_cluster = Mock()
        mock_cluster.datastore_version.manager = 'pxc'
        mock_cluster_create.return_value = mock_cluster
        self.controller.create(req, body, tenant_id)
コード例 #21
0
    def setUp(self):
        super(GuestAgentCouchDBManagerTest, self).setUp()
        self.real_status = couchdb_service.CouchDBAppStatus.set_status

        class FakeInstanceServiceStatus(object):
            status = ServiceStatuses.NEW

            def save(self):
                pass

        couchdb_service.CouchDBAppStatus.set_status = MagicMock(
            return_value=FakeInstanceServiceStatus())
        self.context = trove_testtools.TroveTestContext(self)
        self.manager = couchdb_manager.Manager()
        self.pkg = couchdb_service.packager
        self.real_db_app_status = couchdb_service.CouchDBAppStatus
        self.origin_os_path_exists = os.path.exists
        self.origin_format = volume.VolumeDevice.format
        self.origin_migrate_data = volume.VolumeDevice.migrate_data
        self.origin_mount = volume.VolumeDevice.mount
        self.origin_mount_points = volume.VolumeDevice.mount_points
        self.origin_stop_db = couchdb_service.CouchDBApp.stop_db
        self.origin_start_db = couchdb_service.CouchDBApp.start_db
        self.original_get_ip = netutils.get_my_ipv4
        self.orig_make_host_reachable = (
            couchdb_service.CouchDBApp.make_host_reachable)
コード例 #22
0
 def setUp(self):
     super(ClusterTest, self).setUp()
     self.get_client_patch = patch.object(task_api.API, 'get_client')
     self.get_client_mock = self.get_client_patch.start()
     self.addCleanup(self.get_client_patch.stop)
     self.cluster_id = str(uuid.uuid4())
     self.cluster_name = "Cluster" + self.cluster_id
     self.tenant_id = "23423432"
     self.dv_id = "1"
     self.db_info = DBCluster(ClusterTasks.NONE,
                              id=self.cluster_id,
                              name=self.cluster_name,
                              tenant_id=self.tenant_id,
                              datastore_version_id=self.dv_id,
                              task_id=ClusterTasks.NONE._code)
     self.context = trove_testtools.TroveTestContext(self)
     self.datastore = Mock()
     self.dv = Mock()
     self.dv.manager = "mongodb"
     self.datastore_version = self.dv
     self.cluster = mongodb_api.MongoDbCluster(self.context, self.db_info,
                                               self.datastore,
                                               self.datastore_version)
     self.instances = [{'volume_size': 1, 'flavor_id': '1234'},
                       {'volume_size': 1, 'flavor_id': '1234'},
                       {'volume_size': 1, 'flavor_id': '1234'}]
     self.volume_support = CONF.get(self.dv.manager).volume_support
     self.remote_nova = remote.create_nova_client
コード例 #23
0
 def setUp(self):
     super(SimpleInstanceTest, self).setUp()
     self.context = trove_testtools.TroveTestContext(self, is_admin=True)
     db_info = DBInstance(InstanceTasks.BUILDING, name="TestInstance")
     self.instance = SimpleInstance(None,
                                    db_info,
                                    InstanceServiceStatus(
                                        ServiceStatuses.BUILDING),
                                    ds_version=Mock(),
                                    ds=Mock(),
                                    locality='affinity')
     self.instance.context = self.context
     db_info.addresses = {
         "private": [{
             "addr": "123.123.123.123"
         }],
         "internal": [{
             "addr": "10.123.123.123"
         }],
         "public": [{
             "addr": "15.123.123.123"
         }]
     }
     self.orig_conf = CONF.network_label_regex
     self.orig_ip_regex = CONF.ip_regex
     self.orig_black_list_regex = CONF.black_list_regex
コード例 #24
0
ファイル: test_storage.py プロジェクト: konstar/tesora-trove
    def test_swift_checksum_save(self):
        """This tests that SwiftStorage.save returns the swift checksum for
        large files.
        """
        context = trove_testtools.TroveTestContext(self)
        backup_id = '123'
        user = '******'
        password = '******'

        swift_client = FakeSwiftConnection()
        with patch.object(remote,
                          'create_swift_client',
                          return_value=swift_client):
            storage_strategy = SwiftStorage(context)

            with MockBackupRunner(filename=backup_id,
                                  user=user,
                                  password=password) as runner:
                (success, note, checksum,
                 location) = storage_strategy.save(runner.manifest, runner)

        self.assertTrue(success, "The backup should have been successful.")
        self.assertIsNotNone(note, "A note should have been returned.")
        self.assertEqual('http://mockswift/v1/database_backups/123.gz.enc',
                         location, "Incorrect swift location was returned.")
コード例 #25
0
    def setUp(self):
        self.context = trove_testtools.TroveTestContext(self, is_admin=True)
        util.init_db()

        self.datastore = datastore_models.DBDatastore.create(
            id=str(uuid.uuid4()),
            name='test' + str(uuid.uuid4()),
            default_version_id=str(uuid.uuid4()))

        self.datastore_version1 = datastore_models.DBDatastoreVersion.create(
            id=self.datastore.default_version_id,
            name='name' + str(uuid.uuid4()),
            image_id='old_image',
            packages=str(uuid.uuid4()),
            datastore_id=self.datastore.id,
            manager='test',
            active=1)

        self.datastore_version2 = datastore_models.DBDatastoreVersion.create(
            id=str(uuid.uuid4()),
            name='name' + str(uuid.uuid4()),
            image_id='new_image',
            packages=str(uuid.uuid4()),
            datastore_id=self.datastore.id,
            manager='test',
            active=1)

        self.safe_nova_client = models.create_nova_client
        models.create_nova_client = nova.fake_create_nova_client
        super(TestInstanceUpgrade, self).setUp()
コード例 #26
0
 def setUp(self):
     super(GuestAgentManagerTest, self).setUp('mysql')
     self.context = trove_testtools.TroveTestContext(self)
     self.replication_strategy = 'MysqlGTIDReplication'
     self.patch_rs = patch(
         'trove.guestagent.strategies.replication.get_strategy',
         return_value=self.replication_strategy)
     self.mock_rs = self.patch_rs.start()
     self.addCleanup(self.patch_rs.stop)
     self.manager = Manager()
     self.origin_MySqlAppStatus = dbaas.MySqlAppStatus.get
     self.origin_os_path_exists = os.path.exists
     self.origin_format = volume.VolumeDevice.format
     self.origin_migrate_data = volume.VolumeDevice.migrate_data
     self.origin_mount = volume.VolumeDevice.mount
     self.origin_unmount = volume.VolumeDevice.unmount
     self.origin_mount_points = volume.VolumeDevice.mount_points
     self.origin_stop_mysql = dbaas.MySqlApp.stop_db
     self.origin_start_mysql = dbaas.MySqlApp.start_mysql
     self.origin_update_overrides = dbaas.MySqlApp.update_overrides
     self.origin_install_if_needed = dbaas.MySqlApp.install_if_needed
     self.origin_secure = dbaas.MySqlApp.secure
     self.origin_secure_root = dbaas.MySqlApp.secure_root
     self.origin_pkg_is_installed = pkg.Package.pkg_is_installed
     self.origin_os_path_exists = os.path.exists
     self.origin_chown = operating_system.chown
     # set up common mock objects, etc. for replication testing
     self.patcher_gfvs = patch(
         'trove.guestagent.dbaas.get_filesystem_volume_stats')
     self.patcher_rs = patch(
         'trove.guestagent.strategies.replication.get_instance')
     self.mock_gfvs_class = self.patcher_gfvs.start()
     self.mock_rs_class = self.patcher_rs.start()
コード例 #27
0
 def setUp(self):
     super(VerticaTaskManagerAPITest, self).setUp()
     self.context = context.TroveContext()
     self.api = task_api(self.context)
     self.call_context = trove_testtools.TroveTestContext(self)
     self.api.client.prepare = Mock(return_value=self.call_context)
     self.call_context.cast = Mock()
     self.rpc_api_version = '1.0'
コード例 #28
0
 def setUp(self):
     super(BaseLimitTestSuite, self).setUp()
     self.context = trove_testtools.TroveTestContext(self)
     self.absolute_limits = {
         "max_instances": 55,
         "max_volumes": 100,
         "max_backups": 40
     }
コード例 #29
0
 def setUp(self):
     super(TestPolicy, self).setUp()
     self.context = trove_testtools.TroveTestContext(self)
     self.mock_enforcer = MagicMock()
     get_enforcer_patch = patch.object(trove_policy, 'get_enforcer',
                                       return_value=self.mock_enforcer)
     self.addCleanup(get_enforcer_patch.stop)
     self.mock_get_enforcer = get_enforcer_patch.start()
コード例 #30
0
 def setUp(self):
     super(NeutronDriverTest, self).setUp()
     self.context = trove_testtools.TroveTestContext(self)
     self.orig_neutron_driver = NetworkRemoteModelBase.get_driver
     self.orig_create_sg = driver.create_security_group
     self.orig_add_sg_rule = driver.add_security_group_rule
     self.orig_del_sg_rule = driver.delete_security_group_rule
     self.orig_del_sg = driver.delete_security_group
     NetworkRemoteModelBase.get_driver = Mock(return_value=driver)