X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=csit%2Flibraries%2FChangeCounter.robot;h=55e23983f20b3183839e7300759fc907d9d049f6;hb=ae47f944cd8a56bcc40c9bcd0172a0e04a2c208b;hp=d58ce1fc5c72ad2e4315402f48bd11146a7518ed;hpb=97b82df2a8571d0d125232058c798fe340bb07c9;p=integration%2Ftest.git diff --git a/csit/libraries/ChangeCounter.robot b/csit/libraries/ChangeCounter.robot index d58ce1fc5c..55e23983f2 100644 --- a/csit/libraries/ChangeCounter.robot +++ b/csit/libraries/ChangeCounter.robot @@ -1,24 +1,27 @@ *** Settings *** -Documentation Robot keyword library (Resource) for common handling of data change counter. +Documentation Robot keyword library (Resource) for common handling of data change counter. ... -... Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. +... Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. ... -... This program and the accompanying materials are made available under the -... terms of the Eclipse Public License v1.0 which accompanies this distribution, -... and is available at http://www.eclipse.org/legal/epl-v10.html +... This program and the accompanying materials are made available under the +... terms of the Eclipse Public License v1.0 which accompanies this distribution, +... and is available at http://www.eclipse.org/legal/epl-v10.html ... ... -... This resource creates a "default" session using TemplatedRequests.Create_Default_Session -... which points to (an analogue of) http://${ODL_SYSTEM_IP}:${RESTCONFPORT} -Library RequestsLibrary -Resource ${CURDIR}/CompareStream.robot -Resource ${CURDIR}/ScalarClosures.robot -Resource ${CURDIR}/TemplatedRequests.robot -Resource ${CURDIR}/WaitUtils.robot +... This resource creates a "default" session using TemplatedRequests.Create_Default_Session +... which points to (an analogue of) http://${ODL_SYSTEM_IP}:${RESTCONFPORT} + +Library RequestsLibrary +Resource ${CURDIR}/CompareStream.robot +Resource ${CURDIR}/ScalarClosures.robot +Resource ${CURDIR}/TemplatedRequests.robot +Resource ${CURDIR}/WaitUtils.robot + *** Variables *** -${CHANGE_COUNTER_TEMPLATE_FOLDER} ${CURDIR}/../variables/bgpuser -${CC_DATA_CHANGE_COUNTER_URL} /restconf/operational/data-change-counter:data-change-counter +${CHANGE_COUNTER_TEMPLATE_FOLDER} ${CURDIR}/../variables/bgpuser +${CC_DATA_CHANGE_COUNTER_URL} ${REST_API}/data-change-counter:data-change-counter?content=nonconfig + *** Keywords *** CC_Setup @@ -29,28 +32,34 @@ CC_Setup BuiltIn.Set_Suite_Variable ${ChangeCounter__getter} ${counter} Get_Change_Count - [Arguments] ${session}=operational [Documentation] GET data change request, assert status 200, return the value. - ${response} = RequestsLibrary.Get_Request ${session} ${CC_DATA_CHANGE_COUNTER_URL} - BuiltIn.Should_Be_Equal ${response.status_code} ${200} Got status: ${response.status_code} and message: ${response.text} + [Arguments] ${session}=operational + ${response} = RequestsLibrary.GET On Session ${session} url=${CC_DATA_CHANGE_COUNTER_URL} expected_status=200 # CompareStream.Set_Variable_If_At_Least_Else cannot be used direcly, because ${response.text}["data-change-counter"]["count"] would be # evaluated before the stream comparison and it causes failures - ${at_least_boron}= CompareStream.Set_Variable_If_At_Least_Boron ${True} ${False} - ${count} = BuiltIn.Run Keyword If ${at_least_boron} BuiltIn.Evaluate ${response.text}["data-change-counter"]["counter"][0]["count"] - ... ELSE BuiltIn.Evaluate ${response.text}["data-change-counter"]["count"] - [Return] ${count} + BuiltIn.Log ${response.text} + ${count} = BuiltIn.Evaluate + ... json.loads('${response.text}')["data-change-counter:data-change-counter"]["counter"][0]["count"] + ... modules=json + RETURN ${count} Reconfigure_Topology_Name - [Arguments] ${topology_name}=example-linkstate-topology [Documentation] Configure data change counter to count transactions affecting ... ${topology_name} instead of previously configured topology name. - &{mapping} Create Dictionary DEVICE_NAME=${DEVICE_NAME} TOPOLOGY_NAME=${topology_name} + [Arguments] ${topology_name}=example-linkstate-topology + &{mapping} = Create Dictionary DEVICE_NAME=${DEVICE_NAME} TOPOLOGY_NAME=${topology_name} TemplatedRequests.Put_As_Xml_Templated ${CHANGE_COUNTER_TEMPLATE_FOLDER}${/}change_counter mapping=${mapping} Wait_For_Change_Count_To_Become_Stable - [Arguments] ${timeout}=60s ${period}=1s ${repetitions}=4 ${count_to_overcome}=-1 [Documentation] Each ${period} get count. After ${repetitions} of constant value above ${count_to_overcome} within ${timeout}, Return validator output. Fail early on getter error. - ${validator} = WaitUtils.Create_Limiting_Stability_Safe_Stateful_Validator_From_Value_To_Overcome maximum_invalid=${count_to_overcome} - ${result} = WaitUtils.Wait_For_Getter_Error_Or_Safe_Stateful_Validator_Consecutive_Success timeout=${timeout} period=${period} count=${repetitions} getter=${ChangeCounter__getter} safe_validator=${validator} + [Arguments] ${timeout}=60s ${period}=1s ${repetitions}=4 ${count_to_overcome}=-1 + ${validator} = WaitUtils.Create_Limiting_Stability_Safe_Stateful_Validator_From_Value_To_Overcome + ... maximum_invalid=${count_to_overcome} + ${result} = WaitUtils.Wait_For_Getter_Error_Or_Safe_Stateful_Validator_Consecutive_Success + ... timeout=${timeout} + ... period=${period} + ... count=${repetitions} + ... getter=${ChangeCounter__getter} + ... safe_validator=${validator} ... initial_state=${count_to_overcome} - [Return] ${result} + RETURN ${result}