Fix test_vnf_alarm_scale_with_instance_reservation
* Fix empty mgmt_ip_address handling. ast.literal_eval('{}') does not raise an exception. * Fix not-to-be-cleaned-up blazar hosts. No need to test affinity=True case so we just do with one host. * Fix req_amount Related-Bug: #1886213 Change-Id: Ief0c4388f80b179c098231081644d97a56bd1379
This commit is contained in:
parent
3053a4d429
commit
7e3f2d794d
|
@ -12,15 +12,14 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import ast
|
|
||||||
import time
|
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
import json
|
||||||
import testtools
|
import testtools
|
||||||
|
import time
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from blazarclient import exception
|
from blazarclient import exception
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
from tacker.plugins.common import constants as evt_constants
|
from tacker.plugins.common import constants as evt_constants
|
||||||
from tacker.tests import constants
|
from tacker.tests import constants
|
||||||
from tacker.tests.functional import base
|
from tacker.tests.functional import base
|
||||||
|
@ -126,20 +125,10 @@ class VnfTestReservationMonitor(base.BaseTackerTest):
|
||||||
vnf = self.client.show_vnf(vnf_id)['vnf']
|
vnf = self.client.show_vnf(vnf_id)['vnf']
|
||||||
# {"VDU1": ["10.0.0.14", "10.0.0.5"]}
|
# {"VDU1": ["10.0.0.14", "10.0.0.5"]}
|
||||||
if scale_type == 'scaling-in' and vdu_count == 0:
|
if scale_type == 'scaling-in' and vdu_count == 0:
|
||||||
try:
|
self.assertFalse(jsonutils.loads(vnf.get('mgmt_ip_address',
|
||||||
# After sacling-in the vnf['mgmt_ip_address'] will be the
|
'{}')),
|
||||||
# list containg null values. As vnf['mgmt_ip_address']
|
"Once scaling-in completes, mgmt_ip_address"
|
||||||
# is string so we can not access ip address list for VDU1
|
" should be empty.")
|
||||||
# so converting that into the dict using ast lib.
|
|
||||||
# If the list contains the null value then it will raise
|
|
||||||
# ValueError so on the basis of that we are confirming the
|
|
||||||
# scaling-in is successful.
|
|
||||||
ast.literal_eval(vnf['mgmt_ip_address'])
|
|
||||||
self.fail("Scaling-in should not contain "
|
|
||||||
"mgmt_ip_address")
|
|
||||||
except ValueError:
|
|
||||||
assert True, ("Management Ip address list for VDU1 "
|
|
||||||
"contains null values.")
|
|
||||||
elif scale_type == 'scaling-out':
|
elif scale_type == 'scaling-out':
|
||||||
self.assertEqual(vdu_count, len(json.loads(
|
self.assertEqual(vdu_count, len(json.loads(
|
||||||
vnf['mgmt_ip_address'])['VDU1']))
|
vnf['mgmt_ip_address'])['VDU1']))
|
||||||
|
@ -193,7 +182,7 @@ class VnfTestReservationMonitor(base.BaseTackerTest):
|
||||||
blazarclient = self.blazarclient()
|
blazarclient = self.blazarclient()
|
||||||
reservations = [{'disk_gb': 0,
|
reservations = [{'disk_gb': 0,
|
||||||
'vcpus': 1, 'memory_mb': 1,
|
'vcpus': 1, 'memory_mb': 1,
|
||||||
'amount': 1, 'affinity': False,
|
'amount': 2, 'affinity': True,
|
||||||
'resource_properties': '',
|
'resource_properties': '',
|
||||||
'resource_type': 'virtual:instance'}]
|
'resource_type': 'virtual:instance'}]
|
||||||
events = []
|
events = []
|
||||||
|
@ -208,6 +197,7 @@ class VnfTestReservationMonitor(base.BaseTackerTest):
|
||||||
blazar_host = blazarclient.host.create(
|
blazar_host = blazarclient.host.create(
|
||||||
hypervisor.hypervisor_hostname)
|
hypervisor.hypervisor_hostname)
|
||||||
host_added = True
|
host_added = True
|
||||||
|
break
|
||||||
except exception.BlazarClientException:
|
except exception.BlazarClientException:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue