Exemple #1
0
 def test_bootstrap_3_services(self):
     self.cs_client.generate_services(3)
     mapping = PrefixMapping(self.m0_client, self.cs_client)
     mapping.bootstrap()
     n_pfx_by_svc = mapping.count_pfx_by_svc()
     for count in n_pfx_by_svc.itervalues():
         self.assertIn(count, range(PrefixMapping.TOTAL_PREFIXES - 5000,
                                    PrefixMapping.TOTAL_PREFIXES + 5000))
Exemple #2
0
 def test_bootstrap_3_services(self):
     self.cs_client.generate_services(3)
     mapping = PrefixMapping(self.ns, conscience_client=self.cs_client)
     mapping.bootstrap()
     n_pfx_by_svc = mapping.count_pfx_by_svc()
     for count in n_pfx_by_svc.itervalues():
         self.assertIn(
             count,
             range(PrefixMapping.TOTAL_PREFIXES - 5000,
                   PrefixMapping.TOTAL_PREFIXES + 5000))
Exemple #3
0
 def test_bootstrap_20_services(self):
     n = 20
     replicas = 3
     self.cs_client.generate_services(n, locations=10)
     mapping = PrefixMapping(self.m0_client, self.cs_client,
                             replicas=replicas)
     mapping.bootstrap()
     n_pfx_by_svc = mapping.count_pfx_by_svc()
     ideal = PrefixMapping.TOTAL_PREFIXES * replicas / n
     arange = range(int(ideal * 0.8), int(ideal * 1.2))
     print "Ideal: ", ideal
     for count in n_pfx_by_svc.itervalues():
         self.assertIn(count, arange)
Exemple #4
0
 def test_bootstrap_20_services(self):
     n = 20
     replicas = 3
     self.cs_client.generate_services(n, locations=10)
     mapping = PrefixMapping(self.ns,
                             replicas=replicas,
                             conscience_client=self.cs_client)
     mapping.bootstrap()
     n_pfx_by_svc = mapping.count_pfx_by_svc()
     ideal = PrefixMapping.TOTAL_PREFIXES * replicas / n
     arange = range(int(ideal * 0.8), int(ideal * 1.2))
     print "Ideal: ", ideal
     for count in n_pfx_by_svc.itervalues():
         self.assertIn(count, arange)
Exemple #5
0
 def make_mapping(self, replicas=3, digits=None):
     mapping = PrefixMapping(self.m0_client,
                             self.cs_client,
                             replicas=replicas,
                             digits=digits,
                             logger=logging.getLogger('test'))
     return mapping
 def make_mapping(self, replicas=3, digits=None):
     mapping = PrefixMapping(self.m0_client,
                             self.cs_client,
                             replicas=replicas,
                             digits=digits,
                             logger=self.logger)
     return mapping
Exemple #7
0
 def get_prefix_mapping(self, parsed_args):
     meta0_client = self.app.client_manager.admin.meta0
     conscience_client = self.app.client_manager.admin.cluster
     return PrefixMapping(meta0_client,
                          conscience_client,
                          replicas=parsed_args.replicas,
                          logger=self.log)
Exemple #8
0
 def test_bootstrap_3_services_rebalanced(self):
     self.cs_client.generate_services(3)
     mapping = PrefixMapping(self.ns, conscience_client=self.cs_client)
     mapping.bootstrap()
     mapping.rebalance()
     n_pfx_by_svc = mapping.count_pfx_by_svc()
     for count in n_pfx_by_svc.itervalues():
         self.assertEqual(PrefixMapping.TOTAL_PREFIXES, count)
Exemple #9
0
    def get_prefix_mapping(self, parsed_args):
        from oio.directory.meta0 import PrefixMapping

        meta0_client = self.app.client_manager.directory.meta0
        conscience_client = self.app.client_manager.directory.cluster
        digits = self.app.client_manager.meta1_digits
        return PrefixMapping(meta0_client, conscience_client,
                             replicas=parsed_args.replicas,
                             digits=digits,
                             min_dist=parsed_args.min_dist,
                             logger=self.log)
Exemple #10
0
 def test_bootstrap_3_services_rebalanced(self):
     self.cs_client.generate_services(3)
     mapping = PrefixMapping(self.m0_client, self.cs_client)
     mapping.bootstrap()
     mapping.rebalance()
     n_pfx_by_svc = mapping.count_pfx_by_svc()
     for count in n_pfx_by_svc.itervalues():
         self.assertEqual(PrefixMapping.TOTAL_PREFIXES, count)
 def test_bootstrap_20_services_rebalanced(self):
     n = 20
     replicas = 3
     self.cs_client.generate_services(n, locations=7)
     mapping = PrefixMapping(self.m0_client,
                             self.cs_client,
                             replicas=replicas)
     mapping.bootstrap()
     mapping.rebalance()
     self.assertTrue(mapping.check_replicas())
     n_pfx_by_svc = mapping.count_pfx_by_svc()
     ideal = PrefixMapping.TOTAL_PREFIXES * replicas / n
     arange = range(int(ideal * 0.95), int(ideal * 1.05))
     print "Ideal: ", ideal
     for count in n_pfx_by_svc.itervalues():
         self.assertIn(count, arange)
Exemple #12
0
    def test_decommission(self):
        n = 20
        replicas = 3
        self.cs_client.generate_services(n, locations=7)
        mapping = PrefixMapping(self.ns,
                                replicas=replicas,
                                conscience_client=self.cs_client)
        mapping.bootstrap()
        mapping.rebalance()
        self.assertTrue(mapping.check_replicas())
        n_pfx_by_svc = mapping.count_pfx_by_svc()
        ideal = PrefixMapping.TOTAL_PREFIXES * replicas / n
        arange = range(int(ideal * 0.95), int(ideal * 1.05))
        print "Ideal: ", ideal
        for svc1, count in n_pfx_by_svc.iteritems():
            print svc1, count

        svc = mapping.services.values()[0]
        svc["score"] = 0
        print "Decommissioning ", svc["addr"]
        mapping.decommission(svc)
        self.assertTrue(mapping.check_replicas())
        ideal = PrefixMapping.TOTAL_PREFIXES * replicas / (n - 1)
        arange = range(int(ideal * 0.95), int(ideal * 1.05))
        print "Ideal: ", ideal
        n_pfx_by_svc = mapping.count_pfx_by_svc()
        for svc1, count in n_pfx_by_svc.iteritems():
            print svc1, count
        for svc1, count in n_pfx_by_svc.iteritems():
            if svc1 == svc["addr"]:
                self.assertEqual(0, count)
            else:
                self.assertIn(count, arange)
Exemple #13
0
    def test_decommission(self):
        n = 20
        replicas = 3
        self.cs_client.generate_services(n, locations=7)
        mapping = PrefixMapping(self.m0_client, self.cs_client,
                                replicas=replicas)
        mapping.bootstrap()
        mapping.rebalance()
        self.assertTrue(mapping.check_replicas())
        n_pfx_by_svc = mapping.count_pfx_by_svc()
        ideal = PrefixMapping.TOTAL_PREFIXES * replicas / n
        arange = range(int(ideal * 0.95), int(ideal * 1.05))
        print "Ideal: ", ideal
        for svc1, count in n_pfx_by_svc.iteritems():
            print svc1, count

        svc = mapping.services.values()[0]
        svc["score"] = 0
        print "Decommissioning ", svc["addr"]
        mapping.decommission(svc)
        self.assertTrue(mapping.check_replicas())
        ideal = PrefixMapping.TOTAL_PREFIXES * replicas / (n-1)
        arange = range(int(ideal * 0.95), int(ideal * 1.05))
        print "Ideal: ", ideal
        n_pfx_by_svc = mapping.count_pfx_by_svc()
        for svc1, count in n_pfx_by_svc.iteritems():
            print svc1, count
        for svc1, count in n_pfx_by_svc.iteritems():
            if svc1 == svc["addr"]:
                self.assertEqual(0, count)
            else:
                self.assertIn(count, arange)
Exemple #14
0
 def get_prefix_mapping(self, parsed_args):
     return PrefixMapping(parsed_args.ns,
                          replicas=parsed_args.replicas,
                          logger=self.log)