Skip to content

Commit

Permalink
changes in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Polina-Gubina committed Nov 3, 2021
1 parent 9dfc43d commit 9169621
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 57 deletions.
3 changes: 2 additions & 1 deletion octavia_proxy/api/v2/controllers/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ def _graph_create(self, session, lb, pool, hm=None, members=None,
driver.name, driver.loadbalancer_delete,
context.session,
lb, cascade=True)
raise Exception("Pool creation failed")
raise Exception('Pool {pool} creation failed'.format(
pool=pool.name))

new_hm = None
if hm:
Expand Down
55 changes: 1 addition & 54 deletions octavia_proxy/tests/functional/api/v2/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
_network = None
_sdk = None
_lb = None
_ecs = None
_keypair = None
_port = None
CIDR = '192.168.0.0/16'


def _destroy_lb(_lb: dict):
Expand All @@ -49,19 +45,6 @@ def _destroy_lb(_lb: dict):
pass


def _destroy_ecs(self):

if not self._sdk_connection:
self._sdk_connection = self._get_sdk_connection()
if _ecs:
self._sdk_connection.compute.delete_server(_ecs.id)
if _port:
self._sdk_connection.network.delete_port(_port.id)
if _keypair:
self._sdk_connection.compute.delete_keypair(
_keypair.id)


class BaseAPITest(base.TestCase):

BASE_PATH = '/v2'
Expand Down Expand Up @@ -154,10 +137,6 @@ def tearDown(self):

@classmethod
def tearDownClass(cls):
try:
_destroy_ecs()
except Exception:
pass
try:
_destroy_lb(_lb)
except Exception:
Expand All @@ -171,7 +150,7 @@ def _get_sdk_connection(self):

def _create_network(self):
global _network
cidr = CIDR
cidr = '192.168.0.0/16'
ipv4 = 4
router_name = 'octavia-proxy-test-router'
net_name = 'octavia-proxy-test-net'
Expand Down Expand Up @@ -223,38 +202,6 @@ def _create_lb(self):
_lb = response.json.get('loadbalancer')
return _lb

def _create_ecs(self):
global _ecs
global _keypair
global _port
ecs_name = 'octavia-proxy-test-ecs'
image = "Standard_CentOS_Stream_latest"
flavor = "s2.medium.1"
keyname = "octavia-proxy-test-keypair"
portname = "octavia-proxy-test-port"

if not self._sdk_connection:
self._sdk_connection = self._get_sdk_connection()
if not _keypair:
_keypair = self._sdk_connection.compute.\
create_keypair(name=keyname)
if not _port:
_port = self._sdk_connection.compute.create_post(
name=portname, network_id=self._network["network_id"])
if not _ecs:
flavor = self._sdk_connection.compute.find_flavor(flavor)
image = self._sdk_connection.compute.find_image(image)
network_id = self._network["network_id"]
ecs = self._sdk_connection.compute.\
create_server(name=ecs_name, image_id=image.id,
flavor_id=flavor.id, wait=True,
networks=[{"uuid": network_id}],
key_name=_keypair.name,
nics=[{'fixed_ip': _port.address}])
cr_ecs = self._sdk_connection.compute.find_server(ecs.id)
_ecs = cr_ecs
return _ecs

def _make_app(self):
# Note: we need to set argv=() to stop the wsgi setup_app from
# pulling in the testing tool sys.argv
Expand Down
7 changes: 5 additions & 2 deletions octavia_proxy/tests/functional/api/v2/test_load_balancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ def test_create_with_tags(self, **optionals):
self.delete(self.LB_PATH.format(lb_id=self.api_lb.get('id')))

def test_complex_create_v2_0(self, **optionals):
# ecs = self._create_ecs()
lb_json = {'name': 'test4',
'vip_subnet_id': self._network['subnet_id'],
'project_id': self.project_id,
Expand All @@ -114,7 +113,9 @@ def test_complex_create_v2_0(self, **optionals):
"protocol": "HTTP",
"healthmonitor": {"type": "HTTP", "delay": "3",
"max_retries": 2,
"timeout": 1}
"timeout": 1},
"members": [{"address": "192.168.115.184",
"protocol_port": "80"}]
}]
}
lb_json.update(optionals)
Expand All @@ -125,10 +126,12 @@ def test_complex_create_v2_0(self, **optionals):
pools = self.api_lb['pools']
hm = pools[0]['healthmonitor']
default_pool = listeners[0]["default_pool_id"]
members = pools[0]['members']
self.assertTrue(listeners)
self.assertTrue(pools)
self.assertTrue(hm)
self.assertTrue(default_pool)
self.assertTrue(members)
self.delete(self.LB_PATH.format(lb_id=self.api_lb.get('id')),
params={'cascade': True})

Expand Down

0 comments on commit 9169621

Please sign in to comment.