Ejemplo n.º 1
0
 def test_rdir_repartition(self):
     client = RdirDispatcher({'namespace': self.ns})
     all_rawx = client.assign_all_rawx()
     by_rdir = dict()
     total = 0
     for rawx in all_rawx:
         count = by_rdir.get(rawx['rdir']['addr'], 0)
         total += 1
         by_rdir[rawx['rdir']['addr']] = count + 1
     avg = total / float(len(by_rdir))
     print "Ideal number of bases per rdir: ", avg
     print "Current repartition: ", by_rdir
     for count in by_rdir.itervalues():
         self.assertLessEqual(count, avg + 1)
Ejemplo n.º 2
0
 def test_rdir_repartition(self):
     # FIXME(FVE): this test will fail if run after self._flush_cs('rawx')
     client = RdirDispatcher({'namespace': self.ns})
     self._reload_proxy()
     all_rawx = client.assign_all_rawx()
     self.assertGreater(len(all_rawx), 0)
     by_rdir = dict()
     total = 0
     for rawx in all_rawx:
         count = by_rdir.get(rawx['rdir']['addr'], 0)
         total += 1
         by_rdir[rawx['rdir']['addr']] = count + 1
     avg = total / float(len(by_rdir))
     print("Ideal number of bases per rdir: ", avg)
     print("Current repartition: ", by_rdir)
     for count in by_rdir.values():
         self.assertLessEqual(count, avg + 1)
Ejemplo n.º 3
0
    def test_link_rdir_to_zero_scored_rawx(self):
        client = RdirClient({'namespace': self.ns})
        disp = RdirDispatcher({'namespace': self.ns})

        # Register a service, with score locked to zero
        new_rawx = self._srv('rawx', {'tag.loc': 'whatever'})
        new_rawx['score'] = 0
        self._register_srv(new_rawx)
        self._reload_proxy()

        all_rawx = disp.assign_all_rawx()
        all_rawx_keys = [x['addr'] for x in all_rawx]
        self.assertIn(new_rawx['addr'], all_rawx_keys)
        rdir_addr = client._get_rdir_addr(new_rawx['addr'])
        self.assertIsNotNone(rdir_addr)
        try:
            self.api.unlink('_RDIR', new_rawx['addr'], 'rdir')
            self.api.delete('_RDIR', new_rawx['addr'])
            # self._flush_cs('rawx')
        except Exception:
            pass
Ejemplo n.º 4
0
    def test_link_rdir_to_zero_scored_rawx(self):
        disp = RdirDispatcher({'namespace': self.ns},
                              pool_manager=self.http_pool)

        # Register a service, with score locked to zero
        new_rawx = self._srv('rawx', {'tag.loc': _fake_location})
        new_rawx['score'] = 0
        self._register_srv(new_rawx)
        self._reload_proxy()

        all_rawx = disp.assign_all_rawx()
        all_rawx_keys = [x['addr'] for x in all_rawx]
        self.assertIn(new_rawx['addr'], all_rawx_keys)
        rdir_addr = disp.rdir._get_rdir_addr(new_rawx['addr'])
        self.assertIsNotNone(rdir_addr)
        try:
            self.api.unlink(RDIR_ACCT, new_rawx['addr'], 'rdir')
            self.api.delete(RDIR_ACCT, new_rawx['addr'])
            # self._flush_cs('rawx')
        except Exception:
            pass