aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfujinhua <fu.jinhua@zte.com.cn>2018-01-10 13:03:48 +0800
committerfujinhua <fu.jinhua@zte.com.cn>2018-01-10 13:10:07 +0800
commit86e75c99036204b83fb40eca9dafdb46ee0aa087 (patch)
tree419c42232e4bd912aaa7e9d1037ab1da57a1abe5
parent9a778cccb79c4b5f279b03b8a78387a212d100a3 (diff)
Refactor ns scale UT cases of vfc-nfvo-lcm
Fix input params Change-Id: I90a24fe2c94a1e6bf6c506798e6d00570af90de4 Issue-ID: VFC-654 Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
-rw-r--r--lcm/ns/tests/test_ns_manual_scale.py63
1 files changed, 27 insertions, 36 deletions
diff --git a/lcm/ns/tests/test_ns_manual_scale.py b/lcm/ns/tests/test_ns_manual_scale.py
index f1e9e061..21ec981b 100644
--- a/lcm/ns/tests/test_ns_manual_scale.py
+++ b/lcm/ns/tests/test_ns_manual_scale.py
@@ -35,56 +35,42 @@ class TestNsManualScale(TestCase):
self.job_id = JobUtil.create_job("NS", JOB_TYPE.MANUAL_SCALE_VNF, self.ns_inst_id)
self.client = Client()
- self.context = '{"vnfs": ["a", "b"], "sfcs": ["c"], "vls": ["d", "e", "f"]}'
NSInstModel(id=self.ns_inst_id, name="abc", nspackage_id="7", nsd_id="111").save()
def tearDown(self):
NSInstModel.objects.filter().delete()
- """
- @mock.patch.object(restcall, 'call_req')
- @mock.patch.object(toscautil, 'convert_nsd_model')
- def test_ns_instant_ok(self, mock_convert_nsd_model, mock_call_req):
- mock_convert_nsd_model.return_value = self.context
- mock_vals = {
- "/api/catalog/v1/csars/7/files?relativePath=abc.yaml":
- [0, '{"downloadUri":"http://test.yaml", "localPath":"./test.yaml"}', '200'],
- "/api/tosca/v1/indirect/plan":
- [0, '{"description":"", "metadata":{}, "nodes":[]}', '200'],
- "/api/catalog/v1/servicetemplates/2/operations":
- [0, '[{"name":"LCM", "processId":"{http://www.open-o.org/tosca/nfv/2015/12}init-16"}]', '200'],
- "/api/wso2bpel/v1/process/instance":
- [0, '{"status": 1}', '200']}
-
- def side_effect(*args):
- return mock_vals[args[4]]
-
- mock_call_req.side_effect = side_effect
-
- data = {'iaUrl': "", 'vnfmId': "", 'context': "{\"e\":{\"f\":\"4\"}}", 'statusUrl': "",
- 'serviceTemplateId': "", 'roUrl': "", 'containerapiUrl': "", 'flavor': "",
- 'nsInstanceId': "123", 'instanceId': "234", 'resourceUrl': "", 'callbackId': "",
- 'additionalParamForVnf': "[{\"b\":1},{\"c\":{\"d\":\"2\"}}]",
- 'additionalParamForNs': "[{\"a\":3},{\"e\":{\"f\":\"4\"}}]", 'flavorParams': ""}
- resp = self.client.post("/api/nslcm/v1/ns/123/instantiate", data, format='json')
- self.assertEqual(resp.status_code, status.HTTP_200_OK)
- """
@mock.patch.object(NSManualScaleService, 'run')
def test_ns_manual_scale(self, mock_run):
data = {
'nsdid': self.nsd_id,
'nsname': 'ns',
- 'description': 'description'}
+ 'description': 'description',
+ "scaleNsByStepsData": [{
+ "scaleNsByStepsData": [{
+ "aspectId": "1",
+ "numberOfSteps": 1,
+ "scalingDirection": "0"
+ }]
+ }]
+ }
response = self.client.post("/api/nslcm/v1/ns/%s/scale" % self.nsd_id, data=data)
self.failUnlessEqual(status.HTTP_202_ACCEPTED, response.status_code)
@mock.patch.object(restcall, 'call_req')
def test_ns_manual_scale_thread(self, mock_call):
-
data = {
'nsdid': self.nsd_id,
'nsname': 'ns',
- 'description': 'description'}
+ 'description': 'description',
+ "scaleNsByStepsData": [{
+ "scaleNsByStepsData": [{
+ "aspectId": "1",
+ "numberOfSteps": 1,
+ "scalingDirection": "0"
+ }]
+ }]
+ }
NSManualScaleService(self.ns_inst_id, data, self.job_id).run()
self.assertTrue(NSInstModel.objects.get(id=self.ns_inst_id).status, NS_INST_STATUS.ACTIVE)
@@ -105,14 +91,19 @@ class TestNsManualScale(TestCase):
@mock.patch.object(NSManualScaleService, 'start')
def test_ns_manual_scale_non_existing_nsd_id(self, mock_start):
mock_start.side_effect = NSLCMException("NS scale failed.")
-
nsd_id = '1111'
-
data = {
'nsdid': nsd_id,
'nsname': 'ns',
- 'description': 'description'}
-
+ 'description': 'description',
+ "scaleNsByStepsData": [{
+ "scaleNsByStepsData": [{
+ "aspectId": "1",
+ "numberOfSteps": 1,
+ "scalingDirection": "0"
+ }]
+ }]
+ }
response = self.client.post("/api/nslcm/v1/ns/%s/scale" % nsd_id, data=data)
self.assertEqual(response.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR)
self.assertIn("error", response.data)