Пример #1
0
 def test_set_availability_zone_unicode_key(self):
     """Test set availability zone cache key is unicode."""
     service = self._create_service_with_topic('network', self.host)
     services = db.service_get_all(self.context)
     az.set_availability_zones(self.context, services)
     self.assertIsInstance(services[0]['host'], six.text_type)
     cached_key = az._make_cache_key(services[0]['host'])
     self.assertIsInstance(cached_key, str)
     self._destroy_service(service)
Пример #2
0
 def test_set_availability_zone_unicode_key(self):
     """Test set availability zone cache key is unicode."""
     service = self._create_service_with_topic('network', self.host)
     services = db.service_get_all(self.context)
     az.set_availability_zones(self.context, services)
     self.assertIsInstance(services[0]['host'], six.text_type)
     cached_key = az._make_cache_key(services[0]['host'])
     self.assertIsInstance(cached_key, str)
     self._destroy_service(service)
Пример #3
0
 def test_set_availability_zone_unicode_key(self):
     """Test set availability zone cache key is unicode."""
     service = self._create_service_with_topic('network', self.host)
     services = db.service_get_all(self.context)
     new_service = az.set_availability_zones(self.context, services)[0]
     self.assertEqual(type(services[0]['host']), unicode)
     cached_key = az._make_cache_key(services[0]['host'])
     self.assertEqual(type(cached_key), str)
     self._destroy_service(service)
 def test_set_availability_zone_unicode_key(self):
     """Test set availability zone cache key is unicode."""
     service = self._create_service_with_topic('network', self.host)
     services = db.service_get_all(self.context)
     new_service = az.set_availability_zones(self.context, services)[0]
     self.assertEqual(type(services[0]['host']), unicode)
     cached_key = az._make_cache_key(services[0]['host'])
     self.assertEqual(type(cached_key), str)
     self._destroy_service(service)
Пример #5
0
    def test_update_host_availability_zone_cache(self):
        """Test availability zone cache could be update."""
        service = self._create_service_with_topic('compute', self.host)

        # Create a new aggregate with an AZ and add the host to the AZ
        az_name = 'az1'
        cache_key = az._make_cache_key(self.host)
        agg_az1 = self._create_az('agg-az1', az_name)
        self._add_to_aggregate(service, agg_az1)
        az.update_host_availability_zone_cache(self.context, self.host)
        self.assertEqual('az1', az._get_cache().get(cache_key))
        az.update_host_availability_zone_cache(self.context, self.host, 'az2')
        self.assertEqual('az2', az._get_cache().get(cache_key))
Пример #6
0
    def test_update_host_availability_zone_cache(self):
        """Test availability zone cache could be update."""
        service = self._create_service_with_topic('compute', self.host)

        # Create a new aggregate with an AZ and add the host to the AZ
        az_name = 'az1'
        cache_key = az._make_cache_key(self.host)
        agg_az1 = self._create_az('agg-az1', az_name)
        self._add_to_aggregate(service, agg_az1)
        az.update_host_availability_zone_cache(self.context, self.host)
        self.assertEqual('az1', az._get_cache().get(cache_key))
        az.update_host_availability_zone_cache(self.context, self.host, 'az2')
        self.assertEqual('az2', az._get_cache().get(cache_key))