Fix boto method
Due to the ongoing refactoring, ec2_service option of boto method was forgotten and is never used in the code. The patch adds it back and moves the functionality of configure_boto method to set_default_tempest_options one. Change-Id: Ic92f647fd7ad8d40c7393949716990243a401ba7 Story: 2002120 Task: 19799
This commit is contained in:
parent
b8f5b25728
commit
ee518bf91f
@ -13,14 +13,16 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from config_tempest.services.base import Service
|
||||
|
||||
def configure_boto(conf, ec2_service=None, s3_service=None):
|
||||
"""Set boto URLs based on discovered APIs.
|
||||
|
||||
:type ec2_service: config_tempest.services.base.Service
|
||||
:type s3_service: config_tempest.services.base.Service
|
||||
"""
|
||||
if ec2_service:
|
||||
conf.set('boto', 'ec2_url', ec2_service.service_url)
|
||||
if s3_service:
|
||||
conf.set('boto', 's3_url', s3_service.service_url)
|
||||
class Ec2Service(Service):
|
||||
|
||||
def set_default_tempest_options(self, conf):
|
||||
conf.set('boto', 'ec2_url', self.service_url)
|
||||
|
||||
|
||||
class S3Service(Service):
|
||||
|
||||
def set_default_tempest_options(self, conf):
|
||||
conf.set('boto', 's3_url', self.service_url)
|
||||
|
@ -32,7 +32,9 @@ service_dict = {'compute': ComputeService,
|
||||
'network': NetworkService,
|
||||
'object-store': ObjectStorageService,
|
||||
'volumev3': volume.VolumeService,
|
||||
'identity': IdentityService}
|
||||
'identity': IdentityService,
|
||||
'ec2': boto.Ec2Service,
|
||||
's3': boto.S3Service}
|
||||
|
||||
|
||||
class Services(object):
|
||||
@ -214,8 +216,6 @@ class Services(object):
|
||||
ceilometer.check_ceilometer_service(self._conf,
|
||||
self._clients.service_client)
|
||||
|
||||
boto.configure_boto(self._conf, s3_service=self.get_service("s3"))
|
||||
|
||||
horizon.configure_horizon(self._conf)
|
||||
|
||||
for service, codename in C.SERVICE_NAMES.iteritems():
|
||||
|
@ -13,35 +13,49 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import ConfigParser
|
||||
import logging
|
||||
import mock
|
||||
|
||||
from config_tempest.services import base
|
||||
from config_tempest.services import boto
|
||||
from config_tempest.tempest_conf import TempestConf
|
||||
from config_tempest.tests.base import BaseServiceTest
|
||||
from config_tempest.services.services import Services
|
||||
from config_tempest.tests.base import BaseConfigTempestTest
|
||||
|
||||
# disable logging when running unit tests
|
||||
logging.disable(logging.CRITICAL)
|
||||
|
||||
|
||||
class TestBotoService(BaseServiceTest):
|
||||
def setUp(self):
|
||||
super(TestBotoService, self).setUp()
|
||||
self.conf = TempestConf()
|
||||
self.es2 = base.Service("ec2",
|
||||
self.FAKE_URL,
|
||||
self.FAKE_TOKEN,
|
||||
disable_ssl_validation=False)
|
||||
self.s3 = base.Service("s3",
|
||||
self.FAKE_URL,
|
||||
self.FAKE_TOKEN,
|
||||
disable_ssl_validation=False)
|
||||
class TestEc2Service(BaseConfigTempestTest):
|
||||
|
||||
def test_configure_boto(self):
|
||||
boto.configure_boto(self.conf)
|
||||
self._assert_conf_get_not_raises(ConfigParser.NoSectionError,
|
||||
"boto",
|
||||
"ec2_url")
|
||||
self._assert_conf_get_not_raises(ConfigParser.NoSectionError,
|
||||
"boto",
|
||||
"s3_url")
|
||||
boto.configure_boto(self.conf, self.es2, self.s3)
|
||||
self.assertEqual(self.conf.get("boto", "ec2_url"), self.FAKE_URL)
|
||||
self.assertEqual(self.conf.get("boto", "s3_url"), self.FAKE_URL)
|
||||
FAKE_URL = "http://10.200.16.10:8774/"
|
||||
|
||||
@mock.patch('config_tempest.services.services.Services.discover')
|
||||
def setUp(self, mock_discover):
|
||||
super(TestEc2Service, self).setUp()
|
||||
conf = self._get_conf('v2', 'v3')
|
||||
self.clients = self._get_clients(conf)
|
||||
self.Services = Services(self.clients, conf, self._get_creds(conf))
|
||||
|
||||
def test_set_default_tempest_options(self):
|
||||
service_class = self.Services.get_service_class("ec2")
|
||||
service = service_class("ec2", self.FAKE_URL, self.clients, False)
|
||||
service.set_default_tempest_options(self.Services._conf)
|
||||
ec2_url = self.Services._conf.get("boto", "ec2_url")
|
||||
self.assertEqual(ec2_url, self.FAKE_URL)
|
||||
|
||||
|
||||
class TestS3Service(BaseConfigTempestTest):
|
||||
|
||||
FAKE_URL = "http://10.200.16.10:8774/"
|
||||
|
||||
@mock.patch('config_tempest.services.services.Services.discover')
|
||||
def setUp(self, mock_discover):
|
||||
super(TestS3Service, self).setUp()
|
||||
conf = self._get_conf('v2', 'v3')
|
||||
self.clients = self._get_clients(conf)
|
||||
self.Services = Services(self.clients, conf, self._get_creds(conf))
|
||||
|
||||
def test_set_default_tempest_options(self):
|
||||
service_class = self.Services.get_service_class("s3")
|
||||
service = service_class("s3", self.FAKE_URL, self.clients, False)
|
||||
service.set_default_tempest_options(self.Services._conf)
|
||||
ec2_url = self.Services._conf.get("boto", "s3_url")
|
||||
self.assertEqual(ec2_url, self.FAKE_URL)
|
||||
|
Loading…
Reference in New Issue
Block a user