示例#1
0
 def test_create_object(self):
     self.patch_object(swift_utils, 'setup_test_container')
     self.setup_test_container.return_value = ('new-container', 'domain-id')
     self.patch_object(swift_utils,
                       'ObjectReplicas',
                       return_value='obj_replicas')
     swift_client = mock.MagicMock()
     self.assertEqual(
         swift_utils.create_object(swift_client, 'proxy-app',
                                   swift_test_data.STORAGE_TOPOLOGY,
                                   'my-prefix'),
         ('new-container', 'zaza_test_object.txt', 'obj_replicas'))
     self.setup_test_container.assert_called_once_with(
         swift_client, 'my-prefix')
     swift_client.put_object.assert_called_once_with(
         'new-container',
         'zaza_test_object.txt',
         content_type='text/plain',
         contents='File contents')
     self.ObjectReplicas.assert_called_once_with(
         'proxy-app',
         'domain-id',
         'new-container',
         'zaza_test_object.txt',
         swift_test_data.STORAGE_TOPOLOGY,
         model_name=None)
示例#2
0
    def test_900_remove_device_action(self):
        """Check remove-device action runs.

        This tests destroys the environment and should be run as last.
        """
        logging.info('Running remove-devices action on leader')
        action = zaza.model.run_action_on_leader(
            'swift-proxy-region1',
            'remove-devices',
            action_params={
                'ring': 'account',
                'search-value': 'r1z3'
            })
        logging.info(action)
        self.assertEqual(action.status, "completed")

        container_name, obj_name, _ = swift_utils.create_object(
            self.swift_region1,
            self.region1_proxy_app,
            self.storage_topology,
            self.RESOURCE_PREFIX,
            model_name=self.region1_model_name)
        # Check object is accessible from the region proxy.
        response = self.swift_region1.head_object(container_name, obj_name)
        self.assertIsNotNone(response)
    def test_902_two_regions_any_zones_three_replicas(self):
        """Create an object with three replicas across two regions.

        We set write affinity to write the first copy in the local
        region of the proxy used to perform the write, at least one
        of the other two replicas will end up in the opposite region
        based on primary partitions in the ring.
        """
        swift_utils.apply_proxy_config(
            self.region1_proxy_app, {
                'write-affinity': 'r1',
                'write-affinity-node-count': '1',
                'replicas': '3'
            }, self.region1_model_name)
        swift_utils.apply_proxy_config(
            self.region2_proxy_app, {
                'write-affinity': 'r2',
                'write-affinity-node-count': '1',
                'replicas': '3'
            }, self.region2_model_name)
        logging.info('Proxy configs updated in both regions')
        container_name, obj_name, obj_replicas = swift_utils.create_object(
            self.swift_region1,
            self.region1_proxy_app,
            self.storage_topology,
            self.RESOURCE_PREFIX,
            model_name=self.region1_model_name)
        # Check object is accessible from other regions proxy.
        self.swift_region2.head_object(container_name, obj_name)
        # Check there is at least one replica in each region.
        self.assertEqual(sorted(obj_replicas.distinct_regions), [1, 2])
        # Check there are three relicas
        self.assertEqual(len(obj_replicas.all_zones), 3)
示例#4
0
 def test_two_regions_any_zones_three_replicas(self):
     """Create an object with three replicas across two regions."""
     swift_utils.apply_proxy_config(
         self.region1_proxy_app, {
             'write-affinity': 'r1, r2',
             'write-affinity-node-count': '1',
             'replicas': '3'
         }, self.region1_model_name)
     container_name, obj_name, obj_replicas = swift_utils.create_object(
         self.swift_region1,
         self.region1_proxy_app,
         self.storage_topology,
         self.RESOURCE_PREFIX,
         model_name=self.region1_model_name)
     # Check object is accessible from other regions proxy.
     self.swift_region2.head_object(container_name, obj_name)
     # Check there is at least one replica in each region.
     self.assertEqual(sorted(obj_replicas.distinct_regions), [1, 2])
     # Check there are three relicas
     self.assertEqual(len(obj_replicas.all_zones), 3)