mirror of
				https://github.com/Telecominfraproject/oopt-gnpy.git
				synced 2025-10-30 17:47:50 +00:00 
			
		
		
		
	JSON: ensure that node constraints use correct indexing
The program currently ignores the explicit `index` and reads the constraints in the JSON order of the list. However in general, it is not guaranteed that constraints are listed in order. Signed-off-by: EstherLerouzic <esther.lerouzic@orange.com> Change-Id: Icefe271f5801cf9f7b43311c6666556564587c65 Signed-off-by: Jan Kundrát <jan.kundrat@telecominfraproject.com>
This commit is contained in:
		 EstherLerouzic
					EstherLerouzic
				
			
				
					committed by
					
						 Jan Kundrát
						Jan Kundrát
					
				
			
			
				
	
			
			
			 Jan Kundrát
						Jan Kundrát
					
				
			
						parent
						
							e381138320
						
					
				
				
					commit
					1bcb3ce25c
				
			| @@ -547,7 +547,7 @@ def requests_from_json(json_data, equipment): | ||||
|         params['format'] = params['trx_mode'] | ||||
|         params['spacing'] = req['path-constraints']['te-bandwidth']['spacing'] | ||||
|         try: | ||||
|             nd_list = req['explicit-route-objects']['route-object-include-exclude'] | ||||
|             nd_list = sorted(req['explicit-route-objects']['route-object-include-exclude'], key=lambda x: x['index']) | ||||
|         except KeyError: | ||||
|             nd_list = [] | ||||
|         params['nodes_list'] = [n['num-unnum-hop']['node-id'] for n in nd_list] | ||||
|   | ||||
| @@ -506,3 +506,71 @@ def test_eqpt_creation(tmpdir): | ||||
|     # check that all amp in the converted files corresponds to an eqpt line | ||||
|     for ampuid in jsonconverted.keys(): | ||||
|         assert ampuid in possiblename | ||||
|  | ||||
|  | ||||
| def test_service_json_constraint_order(): | ||||
|     """test that the constraints are read in correct order""" | ||||
|  | ||||
|     unsorted_request = { | ||||
|         "request-id": "unsorted", | ||||
|         "source": "trx Brest_KLA", | ||||
|         "destination": "trx Vannes_KBE", | ||||
|         "src-tp-id": "trx Brest_KLA", | ||||
|         "dst-tp-id": "trx Vannes_KBE", | ||||
|         "bidirectional": False, | ||||
|         "path-constraints": { | ||||
|             "te-bandwidth": { | ||||
|                 "technology": "flexi-grid", | ||||
|                 "trx_type": "Voyager", | ||||
|                 "trx_mode": "mode 1", | ||||
|                 "spacing": 50000000000.0, | ||||
|                 "output-power": 0.001, | ||||
|                 "path_bandwidth": 10000000000.0 | ||||
|             } | ||||
|         }, | ||||
|         "explicit-route-objects": { | ||||
|             "route-object-include-exclude": [ | ||||
|                 { | ||||
|                     "explicit-route-usage": "route-include-ero", | ||||
|                     "index": 2, | ||||
|                     "num-unnum-hop": { | ||||
|                         "node-id": "roadm Lorient_KMA", | ||||
|                         "link-tp-id": "link-tp-id is not used", | ||||
|                         "hop-type": "STRICT" | ||||
|                     } | ||||
|                 }, | ||||
|                 { | ||||
|                     "explicit-route-usage": "route-include-ero", | ||||
|                     "index": 3, | ||||
|                     "num-unnum-hop": { | ||||
|                         "node-id": "roadm Vannes_KBE", | ||||
|                         "link-tp-id": "link-tp-id is not used", | ||||
|                         "hop-type": "STRICT" | ||||
|                     } | ||||
|                 }, | ||||
|                 { | ||||
|                     "explicit-route-usage": "route-include-ero", | ||||
|                     "index": 1, | ||||
|                     "num-unnum-hop": { | ||||
|                         "node-id": "roadm Lannion_CAS", | ||||
|                         "link-tp-id": "link-tp-id is not used", | ||||
|                         "hop-type": "LOOSE" | ||||
|                     } | ||||
|                 }, | ||||
|                 { | ||||
|                     "explicit-route-usage": "route-include-ero", | ||||
|                     "index": 0, | ||||
|                     "num-unnum-hop": { | ||||
|                         "node-id": "roadm Brest_KLA", | ||||
|                         "link-tp-id": "link-tp-id is not used", | ||||
|                         "hop-type": "STRICT" | ||||
|                     } | ||||
|                 } | ||||
|             ] | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     data = {'path-request': [unsorted_request]} | ||||
|     rqs = requests_from_json(data, equipment) | ||||
|     assert rqs[0].nodes_list == ['roadm Brest_KLA', 'roadm Lannion_CAS', 'roadm Lorient_KMA', 'roadm Vannes_KBE'] | ||||
|     assert rqs[0].loose_list == ['STRICT', 'LOOSE', 'STRICT', 'STRICT'] | ||||
|   | ||||
		Reference in New Issue
	
	Block a user