コード例 #1
0
ファイル: test_standard.py プロジェクト: ArdanaCLM/swiftlm
 def test_override_replica_count_on_upgrade(self):
     options = DummyInputOptions()
     config_paths = CloudMultiSite(options)
     input_model = ServersModel('standard', 'ccp',
                                config=safe_load(standard_input_model),
                                consumes_model=standard_swf_rng_consumes)
     ring_model = RingSpecifications('standard', 'ccp',
                                     model=safe_load(standard_input_model))
     num_devices = input_model.get_num_devices('account')
     # Change the model to have too high a replica count
     account_ring_model = ring_model.get_control_plane_rings(
         'standard', 'ccp').get_ringspec('account')
     account_ring_model['replication_policy']['replica_count'] = \
         num_devices + 1
     # The fake pre-mitaka rings also have a high replica count
     rings = FakeRingBuilder(self.builder_dir,
                             ['account', 'container', 'object-0'],
                             replica_count=num_devices + 1)
     drive_configurations = dummy_osconfig_load(
         standard_drive_configurations)
     delta = RingDelta()
     try:
         # stop_on_warnings is True in unit tests
         generate_delta(config_paths, input_model, ring_model, rings,
                        drive_configurations, options, delta)
         self.assertTrue(False, msg='should not get here')
     except SwiftModelException:
         options.dry_run = True
         cmds = rebalance(delta, rings, options)
         self.assertTrue('account.builder'
                         ' set_replicas %s' % num_devices in
                         ' '.join(cmds))
コード例 #2
0
ファイル: test_standard.py プロジェクト: ArdanaCLM/swiftlm
 def test_override_replica_count_on_install(self):
     options = DummyInputOptions()
     config_paths = CloudMultiSite(options)
     input_model = ServersModel('standard', 'ccp',
                                config=safe_load(standard_input_model),
                                consumes_model=standard_swf_rng_consumes)
     ring_model = RingSpecifications('standard', 'ccp',
                                     model=safe_load(standard_input_model))
     num_devices = input_model.get_num_devices('account')
     # Change the model to have too high a replica count
     account_ring_model = ring_model.get_control_plane_rings(
         'standard', 'ccp').get_ringspec('account')
     account_ring_model['replication_policy']['replica_count'] = \
         num_devices + 1
     rings = RingBuilder(self.builder_dir, False)
     drive_configurations = dummy_osconfig_load(
         standard_drive_configurations)
     delta = RingDelta()
     options.stop_on_warnings = False
     generate_delta(config_paths, input_model, ring_model, rings,
                    drive_configurations, options, delta)
     options.dry_run = True
     cmds = rebalance(delta, rings, options)
     self.assertTrue('account.builder'
                     ' create 17 %s 24' % float(num_devices) in
                     ' '.join(cmds))
コード例 #3
0
ファイル: test_ring_model.py プロジェクト: ArdanaCLM/swiftlm
 def test_replication_replica_count(self):
     ring_model = RingSpecifications('my_cloud',
                                     'my_control_plane',
                                     model=safe_load(ringspec_simple))
     self.assertEquals(
         ring_model.get_control_plane_rings(
             'my_cloud',
             'my_control_plane').get_ringspec('account').replica_count, 1.0)
     self.assertEquals(
         ring_model.get_control_plane_rings(
             'my_cloud',
             'my_control_plane').get_ringspec('container').replica_count,
         2.0)
     self.assertEquals(
         ring_model.get_control_plane_rings(
             'my_cloud',
             'my_control_plane').get_ringspec('object-0').replica_count,
         3.0)
     self.assertEquals(
         ring_model.get_control_plane_rings(
             'my_cloud',
             'my_control_plane').get_ringspec('object-1').replica_count,
         14.0)
コード例 #4
0
ファイル: test_ring_model.py プロジェクト: ArdanaCLM/swiftlm
 def test_null_region_zones(self):
     scenarios = [
         ('my_cloud', 'my_control_plane', 'account', ['any'], -1, None),
         ('my_cloud', 'my_control_plane', 'container', ['any'], -1, -1),
     ]
     ring_model = RingSpecifications('my_cloud',
                                     'my_control_plane',
                                     model=safe_load(ringspec_null_zones))
     for scenario in scenarios:
         cl, cp, rng, rck, rv, rz = scenario
         r, z = ring_model.get_control_plane_rings(cl, cp).get_region_zone(
             rng, rck)
         self.assertEquals((cl, cp, rng, rck, r, z),
                           (cl, cp, rng, rck, rv, rz))
コード例 #5
0
ファイル: test_ring_model.py プロジェクト: ArdanaCLM/swiftlm
 def test_region_zones(self):
     scenarios = [
         ('my_cloud', 'my_control_plane', 'container', ['sg21'], 2, -1),
         ('my_cloud', 'my_control_plane', 'container',
          ['other21', 'sg21', 'other22'], 2, -1),
         ('my_cloud', 'my_control_plane', 'object-0', ['sg31'], 3, -1),
         ('my_cloud', 'my_control_plane', 'object-0',
          ['other31', 'sg31', 'other32'], 3, -1),
         ('my_cloud', 'my_control_plane', 'object-0', ['junk1',
                                                       'junk2'], None, -1),
         ('my_cloud', 'my_control_plane', 'container', [], None, -1),
     ]
     ring_model = RingSpecifications('my_cloud',
                                     'my_control_plane',
                                     model=safe_load(ringspec_region_zones))
     for scenario in scenarios:
         cl, cp, rng, rck, rv, rz = scenario
         r, z = ring_model.get_control_plane_rings(cl, cp).get_region_zone(
             rng, rck)
         self.assertEquals((cl, cp, rng, rck, r, z),
                           (cl, cp, rng, rck, rv, rz))