示例#1
0
    def test_set_weight_with_step(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))
        rings = FakeRingBuilder(self.builder_dir,
                                ['account', 'container', 'object-0'],
                                3.0)
        drive_configurations = dummy_osconfig_load(
            standard_drive_configurations)
        delta = RingDelta()
        generate_delta(config_paths, input_model, ring_model, rings,
                       drive_configurations, options, delta)
        # Load the fake builder rings with the delta i.e., make it look as
        # though we had just done a rebalance() using input model
        rings.load_fake_ring_data(delta)

        # Change the weights to a small value
        rings.fake_set_weights(1.0)

        # This make delta has a weight_step
        options.weight_step = '10.0'
        delta = RingDelta()
        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  set_weight'
                        ' 192.168.245.2/disk0 11.00' in ' '.join(cmds))

        # Go through another cycle -- update as though last step built
        # the rings - use small step
        rings = FakeRingBuilder(self.builder_dir,
                                ['account', 'container', 'object-0'],
                                3.0)
        rings.load_fake_ring_data(delta)
        options.weight_step = '1.0'
        delta = RingDelta()
        generate_delta(config_paths, input_model, ring_model, rings,
                       drive_configurations, options, delta)
        cmds = rebalance(delta, rings, options)
        self.assertTrue('account.builder  set_weight'
                        ' 192.168.245.2/disk0 12.00' in ' '.join(cmds))

        # Go through another cycle -- the step is large enough that final
        # target weight is reached
        rings = FakeRingBuilder(self.builder_dir,
                                ['account', 'container', 'object-0'],
                                3.0)
        rings.load_fake_ring_data(delta)
        options.weight_step = '10.0'
        delta = RingDelta()
        generate_delta(config_paths, input_model, ring_model, rings,
                       drive_configurations, options, delta)
        cmds = rebalance(delta, rings, options)
        self.assertTrue('account.builder  set_weight'
                        ' 192.168.245.2/disk0 18.63' in ' '.join(cmds))
示例#2
0
    def test_set_weight_down(self):

        options = DummyInputOptions()
        input_model = InputModel(config=safe_load(padawan_input_model),
                                 hosts_fd=padawan_net_hosts,
                                 consumes=padawan_swf_rng_consumes)
        ring_model = RingSpecifications(model=safe_load(
                                        padawan_input_model))
        rings = FakeRingBuilder(self.builder_dir, 'regionone',
                                ['account', 'container', 'object-0'],
                                3.0)
        drive_configurations = dummy_osconfig_load(
            padawan_drive_configurations)
        delta = RingDelta()
        generate_delta(input_model, ring_model, rings,
                       drive_configurations, options, delta)
        # Load the fake builder rings with the delta i.e., make it look as
        # though we had just done a rebalance() using input model
        rings.load_fake_ring_data(delta)

        # Change the weights to a large value
        rings.fake_set_weights(30.0)

        # This make delta has a weight_step
        options.weight_step = '10.0'
        delta = RingDelta()
        generate_delta(input_model, ring_model, rings,
                       drive_configurations, options, delta)
        cmds = rebalance(delta, rings, True)
        self.assertTrue('account.builder  set_weight'
                        ' 192.168.245.2/disk0 20.00' in ' '.join(cmds))

        # Go through another cycle -- update as though last step built
        # the rings - use small step
        rings = FakeRingBuilder(self.builder_dir, 'regionone',
                                ['account', 'container', 'object-0'],
                                3.0)
        rings.load_fake_ring_data(delta)
        options.weight_step = '1.0'
        delta = RingDelta()
        generate_delta(input_model, ring_model, rings,
                       drive_configurations, options, delta)
        cmds = rebalance(delta, rings, True)
        self.assertTrue('account.builder  set_weight'
                        ' 192.168.245.2/disk0 19.00' in ' '.join(cmds))

        # Go through another cycle -- the step is large enough that final
        # target weight is reached
        rings = FakeRingBuilder(self.builder_dir, 'regionone',
                                ['account', 'container', 'object-0'],
                                3.0)
        rings.load_fake_ring_data(delta)
        options.weight_step = '10.0'
        delta = RingDelta()
        generate_delta(input_model, ring_model, rings,
                       drive_configurations, options, delta)
        cmds = rebalance(delta, rings, True)
        self.assertTrue('account.builder  set_weight'
                        ' 192.168.245.2/disk0 18.63' in ' '.join(cmds))
示例#3
0
    def test_set_weight_down(self):

        options = DummyInputOptions()
        input_model = InputModel(config=safe_load(padawan_input_model),
                                 hosts_fd=padawan_net_hosts,
                                 consumes=padawan_swf_rng_consumes)
        ring_model = RingSpecifications(model=safe_load(padawan_input_model))
        rings = FakeRingBuilder(self.builder_dir, 'regionone',
                                ['account', 'container', 'object-0'], 3.0)
        drive_configurations = dummy_osconfig_load(
            padawan_drive_configurations)
        delta = RingDelta()
        generate_delta(input_model, ring_model, rings, drive_configurations,
                       options, delta)
        # Load the fake builder rings with the delta i.e., make it look as
        # though we had just done a rebalance() using input model
        rings.load_fake_ring_data(delta)

        # Change the weights to a large value
        rings.fake_set_weights(30.0)

        # This make delta has a weight_step
        options.weight_step = '10.0'
        delta = RingDelta()
        generate_delta(input_model, ring_model, rings, drive_configurations,
                       options, delta)
        cmds = rebalance(delta, rings, True)
        self.assertTrue('account.builder  set_weight'
                        ' 192.168.245.2/disk0 20.00' in ' '.join(cmds))

        # Go through another cycle -- update as though last step built
        # the rings - use small step
        rings = FakeRingBuilder(self.builder_dir, 'regionone',
                                ['account', 'container', 'object-0'], 3.0)
        rings.load_fake_ring_data(delta)
        options.weight_step = '1.0'
        delta = RingDelta()
        generate_delta(input_model, ring_model, rings, drive_configurations,
                       options, delta)
        cmds = rebalance(delta, rings, True)
        self.assertTrue('account.builder  set_weight'
                        ' 192.168.245.2/disk0 19.00' in ' '.join(cmds))

        # Go through another cycle -- the step is large enough that final
        # target weight is reached
        rings = FakeRingBuilder(self.builder_dir, 'regionone',
                                ['account', 'container', 'object-0'], 3.0)
        rings.load_fake_ring_data(delta)
        options.weight_step = '10.0'
        delta = RingDelta()
        generate_delta(input_model, ring_model, rings, drive_configurations,
                       options, delta)
        cmds = rebalance(delta, rings, True)
        self.assertTrue('account.builder  set_weight'
                        ' 192.168.245.2/disk0 18.63' in ' '.join(cmds))
示例#4
0
    def test_set_weight_no_step(self):
        options = DummyInputOptions()
        input_model = InputModel(config=safe_load(padawan_input_model),
                                 hosts_fd=padawan_net_hosts,
                                 consumes=padawan_swf_rng_consumes)
        ring_model = RingSpecifications(model=safe_load(padawan_input_model))
        rings = FakeRingBuilder(self.builder_dir, 'regionone',
                                ['account', 'container', 'object-0'], 3.0)
        drive_configurations = dummy_osconfig_load(
            padawan_drive_configurations)
        delta = RingDelta()
        generate_delta(input_model, ring_model, rings, drive_configurations,
                       options, delta)
        # Load the fake builder rings with the delta i.e., make it look as
        # though we had just done a rebalance() using input model
        rings.load_fake_ring_data(delta)

        # Change the weights to a small value
        rings.fake_set_weights(1.0)

        # make a new delta and rebalance
        delta = RingDelta()
        generate_delta(input_model, ring_model, rings, drive_configurations,
                       options, delta)
        cmds = rebalance(delta, rings, True)
        self.assertTrue('account.builder  set_weight'
                        ' 192.168.245.2/disk0 18.63' in ' '.join(cmds))
示例#5
0
    def test_noop(self):
        options = DummyInputOptions()
        input_model = InputModel(config=safe_load(padawan_input_model),
                                 hosts_fd=padawan_net_hosts,
                                 consumes=padawan_swf_rng_consumes)
        ring_model = RingSpecifications(model=safe_load(padawan_input_model))
        rings = FakeRingBuilder(
            self.builder_dir, 'regionone',
            ['account', 'container', 'object-0', 'object-1'], 3.0)
        drive_configurations = dummy_osconfig_load(
            padawan_drive_configurations)
        delta = RingDelta()
        generate_delta(input_model, ring_model, rings, drive_configurations,
                       options, delta)
        # Load the fake builder rings with the delta i.e., make it look as
        # though we had just done a rebalance() using input model
        rings.load_fake_ring_data(delta)

        # make a new delta and rebalance
        delta = RingDelta()
        generate_delta(input_model, ring_model, rings, drive_configurations,
                       options, delta)
        cmds = rebalance(delta, rings, True)
        # account, container, object-0:
        #     3 x rebalance (only) (which is point of this test)
        # object-1 has
        #     1 x set replica count
        #     2 x set weights
        #     1 x rebalance
        # total: 7
        self.assertTrue(len(cmds) == 7)
示例#6
0
 def test_change_replica_count(self):
     options = DummyInputOptions()
     input_model = InputModel(config=safe_load(padawan_input_model),
                              hosts_fd=padawan_net_hosts,
                              consumes=padawan_swf_rng_consumes)
     ring_model = RingSpecifications(model=safe_load(padawan_input_model))
     rings = FakeRingBuilder(self.builder_dir, 'regionone', ['container'],
                             4.0)
     drive_configurations = dummy_osconfig_load(
         padawan_drive_configurations)
     delta = RingDelta()
     generate_delta(input_model, ring_model, rings, drive_configurations,
                    options, delta)
     cmds = rebalance(delta, rings, True)
     # Fake container ring has replica-count of 4.0, check that we
     # change it to match the model (3.0)
     self.assertTrue(
         verb_ringname_args_in_cmds('set_replicas', 'container.builder',
                                    ['3.0'], cmds))
     # Validate we don't attempt to re-create container
     self.assertTrue(not verb_ringname_args_in_cmds(
         'create', 'container.builder', None, cmds))
     # Validate other rings are created
     self.assertTrue(
         verb_ringname_args_in_cmds('create', 'account.builder',
                                    ['17', '3.0', '24'], cmds))
     self.assertTrue(
         verb_ringname_args_in_cmds('create', 'object-0.builder',
                                    ['17', '3.0', '24'], cmds))
示例#7
0
 def test_add_servers(self):
     # This test uses same process as test_build_rings() above -- so it
     # appears as though all servers are being added to an existing
     # system. With --weight-step=10, the resulting weights are limited
     # to 10.0
     options = DummyInputOptions()
     input_model = InputModel(config=safe_load(padawan_input_model),
                              hosts_fd=padawan_net_hosts,
                              consumes=padawan_swf_rng_consumes)
     ring_model = RingSpecifications(model=safe_load(
                                     padawan_input_model))
     rings = RingBuilder(self.builder_dir, False)
     drive_configurations = dummy_osconfig_load(
         padawan_drive_configurations)
     # Set limit to weight
     options.weight_step = '10'
     delta = RingDelta()
     generate_delta(input_model, ring_model, rings,
                    drive_configurations, options, delta)
     cmds = rebalance(delta, rings, True)
     self.assertTrue('--device disk0'
                     ' --meta padawan-ccp-c1-m3:disk0:/dev/sdc'
                     ' --weight 10.00' in ' '.join(cmds))
     self.assertTrue('--device lvm0 --meta'
                     ' padawan-ccp-c1-m2:lvm0:/dev/hlm-vg/LV_SWFAC'
                     ' --weight 10.00' in ' '.join(cmds))
示例#8
0
    def test_set_weight_no_step(self):
        options = DummyInputOptions()
        input_model = InputModel(config=safe_load(padawan_input_model),
                                 hosts_fd=padawan_net_hosts,
                                 consumes=padawan_swf_rng_consumes)
        ring_model = RingSpecifications(model=safe_load(
                                        padawan_input_model))
        rings = FakeRingBuilder(self.builder_dir, 'regionone',
                                ['account', 'container', 'object-0'],
                                3.0)
        drive_configurations = dummy_osconfig_load(
            padawan_drive_configurations)
        delta = RingDelta()
        generate_delta(input_model, ring_model, rings,
                       drive_configurations, options, delta)
        # Load the fake builder rings with the delta i.e., make it look as
        # though we had just done a rebalance() using input model
        rings.load_fake_ring_data(delta)

        # Change the weights to a small value
        rings.fake_set_weights(1.0)

        # make a new delta and rebalance
        delta = RingDelta()
        generate_delta(input_model, ring_model, rings,
                       drive_configurations, options, delta)
        cmds = rebalance(delta, rings, True)
        self.assertTrue('account.builder  set_weight'
                        ' 192.168.245.2/disk0 18.63' in ' '.join(cmds))
示例#9
0
    def test_noop(self):
        options = DummyInputOptions()
        input_model = InputModel(config=safe_load(padawan_input_model),
                                 hosts_fd=padawan_net_hosts,
                                 consumes=padawan_swf_rng_consumes)
        ring_model = RingSpecifications(model=safe_load(
                                        padawan_input_model))
        rings = FakeRingBuilder(self.builder_dir, 'regionone',
                                ['account', 'container', 'object-0',
                                 'object-1'],
                                3.0)
        drive_configurations = dummy_osconfig_load(
            padawan_drive_configurations)
        delta = RingDelta()
        generate_delta(input_model, ring_model, rings,
                       drive_configurations, options, delta)
        # Load the fake builder rings with the delta i.e., make it look as
        # though we had just done a rebalance() using input model
        rings.load_fake_ring_data(delta)

        # make a new delta and rebalance
        delta = RingDelta()
        generate_delta(input_model, ring_model, rings,
                       drive_configurations, options, delta)
        cmds = rebalance(delta, rings, True)
        # account, container, object-0:
        #     3 x rebalance (only) (which is point of this test)
        # object-1 has
        #     1 x set replica count
        #     2 x set weights
        #     1 x rebalance
        # total: 7
        self.assertTrue(len(cmds) == 7)
示例#10
0
 def test_change_replica_count(self):
     options = DummyInputOptions()
     input_model = InputModel(config=safe_load(padawan_input_model),
                              hosts_fd=padawan_net_hosts,
                              consumes=padawan_swf_rng_consumes)
     ring_model = RingSpecifications(model=safe_load(
                                     padawan_input_model))
     rings = FakeRingBuilder(self.builder_dir, 'regionone', ['container'],
                             4.0)
     drive_configurations = dummy_osconfig_load(
         padawan_drive_configurations)
     delta = RingDelta()
     generate_delta(input_model, ring_model, rings,
                    drive_configurations, options, delta)
     cmds = rebalance(delta, rings, True)
     # Fake container ring has replica-count of 4.0, check that we
     # change it to match the model (3.0)
     self.assertTrue(verb_ringname_args_in_cmds('set_replicas',
                                                'container.builder',
                                                ['3.0'], cmds))
     # Validate we don't attempt to re-create container
     self.assertTrue(not verb_ringname_args_in_cmds('create',
                                                    'container.builder',
                                                    None, cmds))
     # Validate other rings are created
     self.assertTrue(verb_ringname_args_in_cmds('create',
                                                'account.builder',
                                                ['17', '3.0', '24'], cmds))
     self.assertTrue(verb_ringname_args_in_cmds('create',
                                                'object-0.builder',
                                                ['17', '3.0', '24'], cmds))
示例#11
0
 def test_add_servers(self):
     # This test uses same process as test_build_rings() above -- so it
     # appears as though all servers are being added to an existing
     # system. With --weight-step=10, the resulting weights are limited
     # to 10.0
     options = DummyInputOptions()
     input_model = InputModel(config=safe_load(padawan_input_model),
                              hosts_fd=padawan_net_hosts,
                              consumes=padawan_swf_rng_consumes)
     ring_model = RingSpecifications(model=safe_load(padawan_input_model))
     rings = RingBuilder(self.builder_dir, False)
     drive_configurations = dummy_osconfig_load(
         padawan_drive_configurations)
     # Set limit to weight
     options.weight_step = '10'
     delta = RingDelta()
     generate_delta(input_model, ring_model, rings, drive_configurations,
                    options, delta)
     cmds = rebalance(delta, rings, True)
     self.assertTrue('--device disk0'
                     ' --meta padawan-ccp-c1-m3:disk0:/dev/sdc'
                     ' --weight 10.00' in ' '.join(cmds))
     self.assertTrue('--device lvm0 --meta'
                     ' padawan-ccp-c1-m2:lvm0:/dev/hlm-vg/LV_SWFAC'
                     ' --weight 10.00' in ' '.join(cmds))
示例#12
0
 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))
示例#13
0
 def test_add_servers(self):
     # This test uses same process as test_build_rings() above -- so it
     # appears as though all servers are being added to an existing
     # system. With --weight-step=10, the resulting weights are limited
     # to 10.0
     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))
     rings = RingBuilder(self.builder_dir, False)
     drive_configurations = dummy_osconfig_load(
         standard_drive_configurations)
     # Set limit to weight
     options.weight_step = '10'
     delta = RingDelta()
     generate_delta(config_paths, input_model, ring_model, rings,
                    drive_configurations, options, delta)
     options.dry_run = True
     cmds = rebalance(delta, rings, options)
     self.assertTrue('--device disk0'
                     ' --meta standard-ccp-c1-m3:disk0:/dev/sdc'
                     ' --weight 10.00' in ' '.join(cmds))
     self.assertTrue('--device lvm0 --meta'
                     ' standard-ccp-c1-m2:lvm0:/dev/ardana-vg/LV_SWFAC'
                     ' --weight 10.00' in ' '.join(cmds))
示例#14
0
 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))
示例#15
0
    def test_set_weight_removing(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))
        rings = FakeRingBuilder(self.builder_dir,
                                ['account', 'container', 'object-0'],
                                3.0)
        drive_configurations = dummy_osconfig_load(
            standard_drive_configurations)
        delta = RingDelta()
        generate_delta(config_paths, input_model, ring_model, rings,
                       drive_configurations, options, delta)
        # Load the fake builder rings with the delta i.e., make it look as
        # though we had just done a rebalance() using input model
        rings.load_fake_ring_data(delta)

        # Set standard-ccp-c1-m3 (92.168.245.2) to removing
        for server in input_model.servers:
            if server.get('ardana_ansible_host') == 'standard-ccp-c1-m3':
                server['pass_through'] = {'swift': {'remove': True}}
        self.assertTrue(input_model.server_removing('standard-ccp-c1-m3'))

        # make a new delta and rebalance
        delta = RingDelta()
        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  remove'
                        ' 192.168.245.2/disk0' in ' '.join(cmds))
示例#16
0
    def test_set_weight_large_step(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))
        rings = FakeRingBuilder(self.builder_dir,
                                ['account', 'container', 'object-0'],
                                3.0)
        drive_configurations = dummy_osconfig_load(
            standard_drive_configurations)
        options.weight_step = 999999
        delta = RingDelta()
        generate_delta(config_paths, input_model, ring_model, rings,
                       drive_configurations, options, delta)
        # Load the fake builder rings with the delta i.e., make it look as
        # though we had just done a rebalance() using input model
        rings.load_fake_ring_data(delta)

        # Change the weights to a small value
        rings.fake_set_weights(1.0)

        # make a new delta and rebalance
        delta = RingDelta()
        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  set_weight'
                        ' 192.168.245.2/disk0 18.63' in ' '.join(cmds))
示例#17
0
 def test_build_rings(self):
     options = DummyInputOptions()
     input_model = InputModel(config=safe_load(padawan_input_model),
                              hosts_fd=padawan_net_hosts,
                              consumes=padawan_swf_rng_consumes)
     ring_model = RingSpecifications(model=safe_load(padawan_input_model))
     rings = RingBuilder(self.builder_dir, False)
     drive_configurations = dummy_osconfig_load(
         padawan_drive_configurations)
     delta = RingDelta()
     generate_delta(input_model, ring_model, rings, drive_configurations,
                    options, delta)
     cmds = rebalance(delta, rings, True)
     assert_cmds_are_same(self, expected_cmds, cmds)
示例#18
0
 def test_build_rings(self):
     options = DummyInputOptions()
     input_model = InputModel(config=safe_load(padawan_input_model),
                              hosts_fd=padawan_net_hosts,
                              consumes=padawan_swf_rng_consumes)
     ring_model = RingSpecifications(model=safe_load(
                                     padawan_input_model))
     rings = RingBuilder(self.builder_dir, False)
     drive_configurations = dummy_osconfig_load(
         padawan_drive_configurations)
     delta = RingDelta()
     generate_delta(input_model, ring_model, rings,
                    drive_configurations, options, delta)
     cmds = rebalance(delta, rings, True)
     assert_cmds_are_same(self, expected_cmds, cmds)
示例#19
0
 def test_build_limit_ring(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))
     rings = RingBuilder(self.builder_dir, False)
     drive_configurations = dummy_osconfig_load(
         standard_drive_configurations)
     delta = RingDelta()
     generate_delta(config_paths, input_model, ring_model, rings,
                    drive_configurations, options, delta)
     options.dry_run = True
     options.limit_ring = 'object-1'
     cmds = rebalance(delta, rings, options)
     self.assertEqual(len(cmds), 4)
示例#20
0
 def test_change_replica_count_min_part_hours(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))
     rings = FakeRingBuilder(self.builder_dir,
                             ['container'], replica_count=4.0,
                             min_part_hours=6)
     drive_configurations = dummy_osconfig_load(
         standard_drive_configurations)
     delta = RingDelta()
     generate_delta(config_paths, input_model, ring_model, rings,
                    drive_configurations, options, delta)
     options.dry_run = True
     cmds = rebalance(delta, rings, options)
     # Fake container ring has replica-count of 4.0, check that we
     # change it to match the model (3.0)
     self.assertTrue(verb_ringname_args_in_cmds('set_replicas',
                                                'container.builder',
                                                ['3.0'], cmds))
     # Fake container ring has min-part-hours of 6, check that we
     # change it to match the model (24)
     self.assertTrue(verb_ringname_args_in_cmds('set_min_part_hours',
                                                'container.builder',
                                                ['24'], cmds))
     # Validate we don't attempt to re-create container
     self.assertTrue(not verb_ringname_args_in_cmds('create',
                                                    'container.builder',
                                                    None, cmds))
     # Validate other rings are created
     self.assertTrue(verb_ringname_args_in_cmds('create',
                                                'account.builder',
                                                ['17', '3.0', '24'], cmds))
     self.assertTrue(verb_ringname_args_in_cmds('create',
                                                'object-0.builder',
                                                ['17', '3.0', '24'], cmds))
示例#21
0
 def test_build_rings(self):
     options = DummyInputOptions()
     config_paths = CloudMultiSite(options)
     input_model = ServersModel('standard', 'ccp',
                                config=safe_load(standard_input_model),
                                consumes_model=standard_swf_rng_consumes)
     # Use rings from configuration-data object
     ring_model = RingSpecifications('standard', 'ccp',
                                     model=None)
     ring_model.load_configuration('standard', 'ccp',
                                   safe_load(standard_configuration_data))
     rings = RingBuilder(self.builder_dir, False)
     drive_configurations = dummy_osconfig_load(
         standard_drive_configurations)
     delta = RingDelta()
     generate_delta(config_paths, input_model, ring_model, rings,
                    drive_configurations, options, delta)
     options.dry_run = True
     # Validate pretend has no effect since all rings are new
     options.pretend_min_part_hours_passed = True
     cmds = rebalance(delta, rings, options)
     assert_cmds_are_same(self, expected_cmds, cmds)
示例#22
0
    def test_noop(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))
        rings = FakeRingBuilder(self.builder_dir,
                                ['account', 'container', 'object-0',
                                 'object-1'],
                                3.0)
        drive_configurations = dummy_osconfig_load(
            standard_drive_configurations)
        delta = RingDelta()
        generate_delta(config_paths, input_model, ring_model, rings,
                       drive_configurations, options, delta)
        # Load the fake builder rings with the delta i.e., make it look as
        # though we had just done a rebalance() using input model
        rings.load_fake_ring_data(delta)

        # make a new delta and rebalance
        delta = RingDelta()
        generate_delta(config_paths, input_model, ring_model, rings,
                       drive_configurations, options, delta)
        options.dry_run = True
        cmds = rebalance(delta, rings, options)
        # account, container, object-0:
        #     3 x rebalance (only) (which is point of this test)
        # object-1 has
        #     1 x set replica count
        #     1 x set min part hours
        #     2 x set weights
        #     1 x rebalance
        # total: 8
        self.assertTrue(len(cmds) == 8)