| /////////////////////////////////////////////////////////////////////////////// |
| // // |
| // Copyright (c) 2000-2017 Ericsson Telecom AB // |
| // // |
| // 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 // |
| /////////////////////////////////////////////////////////////////////////////// |
| |
| /////////////////////////////////////////////////////////// |
| // Module: EPTF_LoadRegulator_Test |
| // |
| // Purpose: |
| // This module contains function definitions and testcases for testing EPTF Load Regulator |
| // |
| // Module Parameters: |
| // tsp_demoInterval - *float* - interval of testing, default: 30.0 |
| // tsp_demoLoadGenerationPeriod - *float* - load generation period, default: 0.1 |
| // tsp_demoSutLoadUpdatePeriod - *float* - update period for load measurement, default: 2.0 |
| // tsp_demoLoadToReach - *float* |
| // tsp_demoCpsToReach - *float* |
| // tsp_NetInterfaceName - *charstring* |
| // tsp_bandwidthToReach - *float* |
| // Module depends on: |
| // <EPTF_CLL_Base_Definitions> |
| // <EPTF_CLL_Base_Functions> |
| // <EPTF_CLL_LoadRegulator_Definitions> |
| // <EPTF_CLL_LoadRegulator_Functions> |
| // <EPTF_CLL_LoadRegulatorUI_Definitions> |
| // <EPTF_CLL_LoadRegulatorUI_Functions> |
| // <EPTF_CLL_HostAdmin_BaseDefinitions> |
| // <EPTF_CLL_HostAdmin_BaseFunctions> |
| // |
| // <EPTF_CLL_ExecCtrlUIHandler_Definitions> |
| // <EPTF_CLL_ExecCtrlUIHandler_Functions> |
| // <EPTF_CLL_ExecCtrl_Definitions> |
| // <EPTF_CLL_ExecCtrl_Functions> |
| // <EPTF_CLL_ExecCtrlClient_Functions> |
| // |
| // <EPTF_CLL_UIHandler_Definitions> |
| // <EPTF_CLL_UIHandler_WidgetFunctions> |
| // <EPTF_CLL_UIHandlerClient_Definitions> |
| // <EPTF_CLL_UIHandlerClient_Functions> |
| // |
| // <EPTF_CLL_LGenBase_ConfigDefinitions> |
| // <EPTF_CLL_LGenBase_ConfigFunctions> |
| // <EPTF_CLL_LGenBase_Definitions> |
| // <EPTF_CLL_LGenBase_Functions> |
| // |
| // <EPTF_CLL_Scheduler_Definitions> |
| // <EPTF_CLL_RBTScheduler_Definitions> |
| // <EPTF_CLL_RBTScheduler_Functions> |
| // <LOADMEASasp_Types> |
| // <LOADMEASasp_PortType> |
| // |
| // Current Owner: |
| // efloatt |
| // |
| // Last Review Date: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| |
| module EPTF_LoadRegulator_Test { |
| import from ttcn_ericsson_se_protocolModules_xtdp_xtdl all; |
| |
| import from EPTF_CLL_Variable_Functions all; |
| |
| import from EPTF_CLL_DataSource_Definitions all; |
| |
| //========================================================================= |
| // Import Part |
| //========================================================================= |
| import from EPTF_CLL_Base_Definitions all; |
| import from EPTF_CLL_Base_Functions all; |
| |
| import from EPTF_CLL_LoadRegulator_Definitions all; |
| import from EPTF_CLL_LoadRegulator_Functions all; |
| import from EPTF_CLL_LoadRegulatorUI_Definitions all; |
| import from EPTF_CLL_LoadRegulatorUI_Functions all; |
| |
| import from EPTF_CLL_HostAdmin_BaseDefinitions all; |
| import from EPTF_CLL_HostAdmin_BaseFunctions all; |
| |
| import from EPTF_CLL_ExecCtrlUIHandler_Definitions all; |
| import from EPTF_CLL_ExecCtrlUIHandler_Functions all; |
| import from EPTF_CLL_ExecCtrl_Definitions all; |
| import from EPTF_CLL_ExecCtrl_Functions all; |
| import from EPTF_CLL_ExecCtrlClient_Functions all; |
| |
| import from EPTF_CLL_UIHandler_Definitions all; |
| import from EPTF_CLL_UIHandler_WidgetFunctions all; |
| import from EPTF_CLL_UIHandlerClient_Definitions all; |
| import from EPTF_CLL_UIHandlerClient_Functions all; |
| |
| import from EPTF_CLL_LGenBase_ConfigDefinitions all; |
| import from EPTF_CLL_LGenBase_ConfigFunctions all; |
| import from EPTF_CLL_LGenBase_Definitions all; |
| import from EPTF_CLL_LGenBase_Functions all; |
| |
| import from EPTF_CLL_Scheduler_Definitions all; |
| |
| import from EPTF_CLL_RBTScheduler_Definitions all; |
| import from EPTF_CLL_RBTScheduler_Functions all; |
| |
| import from EPTF_CLL_DataSource_Functions all; |
| |
| |
| import from LOADMEASasp_Types all; |
| import from LOADMEASasp_PortType all; |
| //========================================================================= |
| // Module Parameters |
| //========================================================================= |
| modulepar float tsp_demoInterval := 300.0; |
| modulepar float tsp_demoLoadGenerationPeriod := 0.1; |
| modulepar float tsp_demoSutLoadUpdatePeriod := 2.0; |
| modulepar float tsp_demoLoadToReach := 25.0; |
| modulepar float tsp_demoCpsToReach := 10.0; |
| |
| modulepar charstring tsp_NetInterfaceName := "eth0"; |
| modulepar float tsp_bandwidthToReach := 150.0; // kB/s |
| |
| //========================================================================= |
| // Type Definitions |
| //========================================================================= |
| type record WeightedCpsElem { |
| float cps, |
| float weight, |
| boolean lockCps |
| } |
| |
| type record of WeightedCpsElem WeightedCpsList; |
| |
| type port Demo_PT message |
| { |
| inout charstring; |
| } with { extension "internal" } |
| |
| //========================================================================= |
| // Component Definitions |
| //========================================================================= |
| type component EPTF_LoadRegulator_Test_CT extends EPTF_LoadRegulator_CT { |
| var float v_clock := 1.0; |
| } |
| type component LoadRegulatorDemo_CT |
| extends EPTF_HostAdmin_Base_CT, EPTF_Scheduler_CT, EPTF_LoadRegulator_CT |
| { |
| var EPTF_Scheduler_ActionHandler v_myEventHandler; |
| port Demo_PT demo_PCO; |
| |
| // for weighted CPS: |
| var WeightedCpsList v_weightedCpsList := {} |
| |
| // for bandwidth limited traffic control: |
| port LOADMEASasp_PT loadMeas_PCO; |
| |
| var integer v_LoadRegulator_Test_generateEvent := -1; |
| var integer v_LoadRegulator_Test_updateEvent := -1; |
| } |
| |
| type component Repeater_CT |
| { |
| port Demo_PT demo_PCO; |
| } |
| |
| type component EPTF_LoadRegulator_Test_limitMax_CT extends |
| EPTF_Base_CT, |
| EPTF_LGenBase_CT, |
| // EPTF_LoggingUI_CT, |
| EPTF_ExecCtrl_UIHandler_CT, |
| EPTF_ExecCtrlClient_CT, |
| EPTF_UIHandler_CT, |
| EPTF_LoadRegulator_CT, |
| EPTF_LoadRegulatorUI_CT |
| { |
| var integer vc_numberOfStartTCs := 0; |
| var float vc_currentLoad := 0.1; |
| var float vc_loadStep := 0.025; |
| var integer vc_myBIdx := -1; |
| } |
| |
| //========================================================================= |
| // Functions |
| //========================================================================= |
| |
| //================================================== |
| // f_EPTF_LoadRegulator_Test_declareCompactFsmTable (Dummy) |
| //================================================== |
| function f_EPTF_LoadRegulator_Test_declareCompactFsmTable() |
| runs on EPTF_LoadRegulator_Test_limitMax_CT |
| return integer //fsmIdx |
| { |
| var EPTF_LGenBase_CompactFsmTable vl_fsmTable := |
| { |
| name:= "FSMName", |
| stateList:= {"idle"}, |
| timerList:= {}, |
| table := |
| { |
| { |
| eventToListen := {c_EPTF_LGenBase_bIdx,c_EPTF_LGenBase_inputIdx_testMgmt_startTC,fsm}, |
| cellRow := |
| { |
| //state[0]==idle |
| { |
| actionList := |
| { |
| {refers(f_EPTF_LoadRegulator_Test_step_dummy),{}} |
| }, |
| nextStateCalculation := omit, |
| nextState:= 0 |
| } |
| } |
| } |
| } |
| } |
| |
| var integer vl_dummy := f_EPTF_LGenBase_declareStep(c_EPTF_LGenBase_behavior, {"dummyStepName", refers(f_EPTF_LoadRegulator_Test_step_dummy)}); |
| |
| var integer vl_fsmIdx := f_EPTF_LGenBase_declareCompactFsmTable(vl_fsmTable); |
| return vl_fsmIdx; |
| } |
| |
| //================================================== |
| // f_EPTF_LoadRegulator_Test_step_dummy |
| //================================================== |
| function f_EPTF_LoadRegulator_Test_step_dummy(in EPTF_LGenBase_TestStepArgs pl_ptr) runs on EPTF_LoadRegulator_Test_limitMax_CT |
| { |
| log("\nFSM started: ", vc_numberOfStartTCs, "\n"); |
| vc_numberOfStartTCs := vc_numberOfStartTCs + 1; |
| } |
| |
| //////////////////////////////////////////////////////////////////////////////////// |
| // scheduling and event handling |
| |
| const integer c_actionId_generateLoad := 0; |
| const integer c_actionId_updateSutLoad := 1; |
| |
| function f_myEventHandler(in EPTF_ScheduledAction pl_action, in integer pl_eventIndex) |
| runs on LoadRegulatorDemo_CT return boolean |
| { |
| if (pl_action.actionId[0] == c_actionId_generateLoad) { |
| f_handleEvent_generateLoad(pl_action.when); |
| return true; |
| } |
| if (pl_action.actionId[0] == c_actionId_updateSutLoad) { |
| f_handleEvent_updateSutLoad(pl_action.when); |
| return true; |
| } |
| return false; |
| } |
| |
| function f_scheduleEvent_generateLoad(in float pl_when) |
| runs on LoadRegulatorDemo_CT |
| { |
| if(not f_EPTF_SchedulerComp_scheduleAction( |
| pl_when + tsp_demoLoadGenerationPeriod,v_myEventHandler,{c_actionId_generateLoad}, |
| v_LoadRegulator_Test_generateEvent |
| )) { |
| setverdict(fail,"scheduleAction failed"); |
| f_EPTF_Base_stop(); |
| } |
| } |
| |
| function f_scheduleEvent_updateSutLoad(in float pl_when) |
| runs on LoadRegulatorDemo_CT |
| { |
| if(not f_EPTF_SchedulerComp_scheduleAction( |
| pl_when + tsp_demoSutLoadUpdatePeriod,v_myEventHandler,{c_actionId_updateSutLoad}, |
| v_LoadRegulator_Test_updateEvent |
| )) { |
| setverdict(fail,"scheduleAction failed"); |
| f_EPTF_Base_stop(); |
| } |
| } |
| |
| |
| type octetstring SDP_Message; |
| |
| function f_SDP_enc_Message(in SDP_Message pl_msg) return charstring { |
| return oct2char(pl_msg); |
| } |
| |
| function f_SDP_dec_Message(in charstring pl_msg) return SDP_Message { |
| return char2oct(pl_msg); |
| } |
| |
| function f_handleEvent_generateLoad(in float pl_when) |
| runs on LoadRegulatorDemo_CT |
| { |
| var SDP_Message vl_SDP_Message := '000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F'O; |
| |
| // Note: this is not an accurate way of generating load. |
| var integer calls := float2int(f_EPTF_LoadRegulator_getCpsToReach() * tsp_demoLoadGenerationPeriod); |
| for(var integer i := 0; i < calls; i := i + 1) { |
| var charstring msg := f_SDP_enc_Message(vl_SDP_Message); |
| demo_PCO.send(msg); |
| } |
| |
| f_scheduleEvent_generateLoad(pl_when); |
| } |
| |
| function f_handleEvent_updateSutLoad(in float pl_when) |
| runs on LoadRegulatorDemo_CT |
| { |
| // log("f_handleEvent_updateSutLoad() called"); |
| f_EPTF_HostAdmin_Base_update(); |
| log("Tester host load: ", v_EPTF_HostAdmin_testerHostLoad); |
| |
| f_scheduleEvent_updateSutLoad(pl_when); |
| } |
| |
| // end of scheduling and event handling |
| //////////////////////////////////////////////////////////////////////////////////// |
| |
| function f_getSUTLoad() runs on LoadRegulatorDemo_CT return float |
| { |
| return v_EPTF_HostAdmin_testerHostLoad; |
| } |
| |
| function f_getSUTLoad_limitMaxTest() runs on EPTF_LoadRegulator_Test_limitMax_CT return float |
| { |
| if((vc_currentLoad < 1.501 and vc_currentLoad > 1.409) or (vc_currentLoad < 0.001 and vc_currentLoad > -0.001)) |
| { |
| vc_loadStep := vc_loadStep * -1.0; |
| } |
| |
| vc_currentLoad := vc_currentLoad + vc_loadStep; |
| |
| return vc_currentLoad; |
| } |
| |
| function f_repeater() runs on Repeater_CT |
| { |
| var charstring msg; |
| var SDP_Message SDP_msg; |
| |
| alt { |
| [] demo_PCO.receive(charstring:?) -> value msg { |
| SDP_msg := f_SDP_dec_Message(msg); |
| msg := f_SDP_enc_Message(SDP_msg); |
| demo_PCO.send(msg); |
| repeat; |
| } |
| } |
| } |
| // Post-calculate function for weighted CPS calculation. |
| function f_calcWeightedCpsList() |
| runs on LoadRegulatorDemo_CT |
| { |
| log(%definitionId&" called"); |
| |
| if(sizeof(v_weightedCpsList) == 0) { return; } |
| var float weightSum := 0.0; |
| var float cpsSum := f_EPTF_LoadRegulator_getCpsToReach(); |
| for(var integer i := 0; i < sizeof(v_weightedCpsList); i := i + 1) { |
| if(not v_weightedCpsList[i].lockCps) { |
| weightSum := weightSum + v_weightedCpsList[i].weight; |
| } else { |
| cpsSum := cpsSum - v_weightedCpsList[i].cps; |
| } |
| } |
| if(weightSum == 0.0) { |
| log("WARNING " & %definitionId & ": all CPS values are locked or the "& |
| "unlocked CPS values have a weight of 0.0."); |
| return; |
| } |
| if(cpsSum < 0.0) { |
| log("WARNING " & %definitionId & ": sum of locked CPS values already "& |
| "greater than CPS-to-reach."); |
| for(var integer i := 0; i < sizeof(v_weightedCpsList); i := i + 1) { |
| if(not v_weightedCpsList[i].lockCps) { |
| v_weightedCpsList[i].cps := 0.0; |
| } |
| } |
| return; |
| } |
| for(var integer i := 0; i < sizeof(v_weightedCpsList); i := i + 1) { |
| if(not v_weightedCpsList[i].lockCps) { |
| v_weightedCpsList[i].cps := |
| (v_weightedCpsList[i].weight * cpsSum) / weightSum; |
| } |
| } |
| |
| log(%definitionId&" finished. Weighted CPS list: ", v_weightedCpsList); |
| } |
| |
| function f_initNetMeas() runs on LoadRegulatorDemo_CT |
| { |
| map(self:loadMeas_PCO, system:loadMeas_PCO); |
| |
| var ASP_LOADMEAS vl_ASP_LOADMEAS; |
| |
| vl_ASP_LOADMEAS.loadType := NETWORK; |
| vl_ASP_LOADMEAS.msg := { setPeriod := { periodTime := tsp_EPTF_loadRegulator_updateTimeout/2.0 } }; |
| loadMeas_PCO.send(vl_ASP_LOADMEAS); |
| |
| vl_ASP_LOADMEAS := { loadType := NETWORK, msg := { setInterface:= { interface := tsp_NetInterfaceName } } }; |
| loadMeas_PCO.send(vl_ASP_LOADMEAS); |
| |
| vl_ASP_LOADMEAS.msg := { startMeas := {} }; |
| loadMeas_PCO.send(vl_ASP_LOADMEAS); |
| } |
| |
| function f_getBandwidthUsage() runs on LoadRegulatorDemo_CT return float |
| { |
| // var float upRate := getNetworkUploadSpeed(loadMeas_PCO); |
| var float downRate := getNetworkDownloadSpeed(loadMeas_PCO); |
| // return downRate + upRate; |
| return downRate; |
| } |
| |
| function f_cleanupNetMeas() runs on LoadRegulatorDemo_CT |
| { |
| unmap(self:loadMeas_PCO, system:loadMeas_PCO); |
| } |
| // cpsToReach si an output of the LoadRegulator - don't set it |
| /*function f_EPTF_LoadRegulator_setCpsToReach(in float pl_value) runs on EPTF_LoadRegulator_CT { |
| f_EPTF_LoadRegulator_getCpsToReach() := pl_value; |
| }*/ |
| function f_getMeasLoad() runs on EPTF_LoadRegulator_Test_CT return float { |
| |
| log("v_clock ", v_clock); |
| var float vl_return; |
| if (v_clock < 14.0) { |
| vl_return := v_clock; |
| } else if (v_clock < 20.0) { |
| vl_return := 14.0 - (v_clock - 14.0); |
| } else if (v_clock >= 20.0) { |
| vl_return := 8.0; |
| } |
| v_clock := v_clock + 1.0; |
| log("vl_return ", vl_return); |
| return vl_return; |
| } |
| |
| //========================================================================= |
| // Testcases |
| //========================================================================= |
| |
| testcase tc_LoadRegulator_demo() runs on LoadRegulatorDemo_CT |
| { |
| timer T_interval := tsp_demoInterval; |
| |
| log("**** creating repeater component"); |
| |
| var Repeater_CT rep := Repeater_CT.create; |
| connect(self:demo_PCO, rep:demo_PCO); |
| rep.start(f_repeater()); |
| |
| log("**** initializing HostAdmin_Base"); |
| |
| f_EPTF_Base_init_CT("Test"); |
| |
| log("**** initializing LoadRegulator"); |
| |
| f_EPTF_LoadRegulator_init_CT("LoadRegulator", refers(f_getSUTLoad)); |
| f_EPTF_LoadRegulator_setLoadToReach(tsp_demoLoadToReach); |
| |
| f_EPTF_HostAdmin_Base_init_CT("Test"); |
| |
| log("**** initializing Scheduler"); |
| |
| f_EPTF_Scheduler_init_CT(f_EPTF_Base_selfName()); |
| v_myEventHandler := refers(f_myEventHandler); |
| f_EPTF_SchedulerComp_refreshSnapshotTime(); |
| f_scheduleEvent_generateLoad(f_EPTF_SchedulerComp_snapshotTime()); |
| f_scheduleEvent_updateSutLoad(f_EPTF_SchedulerComp_snapshotTime()); |
| |
| log("**** entering main loop"); |
| |
| T_interval.start; |
| var charstring msg; |
| alt { |
| [] T_interval.timeout |
| { |
| f_EPTF_SchedulerComp_CancelEvent(v_LoadRegulator_Test_generateEvent); |
| f_EPTF_SchedulerComp_CancelEvent(v_LoadRegulator_Test_updateEvent); |
| setverdict(pass); |
| } |
| []demo_PCO.receive(charstring:?) -> value msg |
| { |
| var SDP_Message SDP_msg := f_SDP_dec_Message(msg); |
| repeat; |
| } |
| } |
| |
| log("**** performing cleanup"); |
| |
| rep.stop; |
| disconnect(self:demo_PCO, rep:demo_PCO); |
| |
| f_EPTF_Base_cleanup_CT(); |
| } |
| group dataSource{ |
| type component LoadRegulatorDS_CT extends LoadRegulatorDemo_CT, EPTF_DataSource_CT{ |
| } |
| |
| function f_LoadRegulator_DS_getDSVarId( |
| in charstring pl_element, |
| in charstring pl_ptcName := "") |
| runs on LoadRegulatorDS_CT |
| return integer{ |
| var charstring vl_varName; |
| var integer |
| vl_retCode :=f_EPTF_DataSource_getData( |
| pl_dataVarName := vl_varName, |
| pl_source := c_LoadRegulator_sourceId, |
| pl_ptcName := pl_ptcName, |
| pl_element := pl_element |
| ); |
| if(0 !=vl_retCode){ |
| setverdict(fail,"f_EPTF_DataSource_getData failed for ",pl_element); |
| f_EPTF_Base_stop(); |
| } |
| var integer vl_ret := |
| f_EPTF_Var_getId(vl_varName); |
| return vl_ret; |
| } |
| |
| testcase tc_LoadRegulator_DS() runs on LoadRegulatorDS_CT |
| { |
| f_EPTF_Base_init_CT("Test"); |
| f_EPTF_HostAdmin_Base_init_CT("Test"); |
| f_EPTF_DataSource_init_CT("Test"); |
| f_EPTF_Var_setSyncInterval(0.1); |
| //log("**** initializing LoadRegulator"); |
| f_EPTF_LoadRegulator_init_CT( |
| pl_selfName := "LoadRegulator", |
| pl_getSutLoad := refers(f_getSUTLoad), |
| pl_dataSource_compRef := self); |
| var integer vl_retCode := 0; |
| var integer vl_varIdComp_cpsToReach := f_EPTF_LoadRegulator_getVarRef_cpsToReach(); |
| var integer vl_varIdComp_loadToReach := f_EPTF_LoadRegulator_getVarRef_loadToReach(); |
| var integer vl_varIdComp_currentLoad := f_EPTF_LoadRegulator_getVarRef_currentLoad(); |
| var integer vl_varIdComp_loadIsStable := f_EPTF_LoadRegulator_getVarRef_loadIsStable(); |
| var integer vl_varIdComp_enabled := f_EPTF_LoadRegulator_getVarRef_enabled(); |
| timer t_guard; |
| t_guard.start( 10.1 ); |
| t_guard.timeout; |
| |
| var integer vl_varIdDS_cpsToReach := f_LoadRegulator_DS_getDSVarId(c_LoadRegulator_dataElement_cpsToReach, "Test") |
| var integer vl_varIdDS_loadToReach := f_LoadRegulator_DS_getDSVarId(c_LoadRegulator_dataElement_loadToReach, "Test") |
| var integer vl_varIdDS_currentLoad := f_LoadRegulator_DS_getDSVarId(c_LoadRegulator_dataElement_currentLoad, "Test") |
| var integer vl_varIdDS_loadIsStable := f_LoadRegulator_DS_getDSVarId(c_LoadRegulator_dataElement_loadIsStable, "Test") |
| var integer vl_varIdDS_enabled := f_LoadRegulator_DS_getDSVarId(c_LoadRegulator_dataElement_enabled, "Test") |
| |
| if(f_EPTF_Var_getBoolValue(vl_varIdComp_enabled) != f_EPTF_Var_getBoolValue(vl_varIdDS_enabled)){ |
| setverdict(fail,"enabled original content does not match."); |
| f_EPTF_Base_stop(fail) |
| } |
| if(f_EPTF_Var_getBoolValue(vl_varIdComp_loadIsStable) != f_EPTF_Var_getBoolValue(vl_varIdDS_loadIsStable)){ |
| setverdict(fail,"loadIsStable original content does not match."); |
| f_EPTF_Base_stop(fail) |
| } |
| if(f_EPTF_Var_getFloatValue(vl_varIdComp_loadToReach) != f_EPTF_Var_getFloatValue(vl_varIdDS_loadToReach)){ |
| setverdict(fail,"loadToReach original content does not match."); |
| f_EPTF_Base_stop(fail) |
| } |
| if(f_EPTF_Var_getFloatValue(vl_varIdComp_cpsToReach) != f_EPTF_Var_getFloatValue(vl_varIdDS_cpsToReach)){ |
| setverdict(fail,"cpsToReach original content does not match."); |
| f_EPTF_Base_stop(fail) |
| } |
| if(f_EPTF_Var_getFloatValue(vl_varIdComp_currentLoad) != f_EPTF_Var_getFloatValue(vl_varIdDS_currentLoad)){ |
| setverdict(fail,"loadToReach original content does not match."); |
| f_EPTF_Base_stop(fail) |
| } |
| |
| f_EPTF_Var_adjustContent(vl_varIdComp_cpsToReach,{floatVal := 11.1}); |
| f_EPTF_Var_adjustContent(vl_varIdComp_loadToReach,{floatVal := 11.2}); |
| f_EPTF_Var_adjustContent(vl_varIdComp_currentLoad,{floatVal := 11.3}); |
| f_EPTF_Var_adjustContent(vl_varIdComp_loadIsStable,{boolVal := not f_EPTF_Var_getBoolValue(vl_varIdComp_loadIsStable)}); |
| f_EPTF_Var_adjustContent(vl_varIdComp_enabled,{boolVal := not f_EPTF_Var_getBoolValue(vl_varIdComp_enabled)}); |
| |
| t_guard.start( 0.2 ); |
| t_guard.timeout; |
| |
| if(f_EPTF_Var_getBoolValue(vl_varIdComp_enabled) != f_EPTF_Var_getBoolValue(vl_varIdDS_enabled)){ |
| setverdict(fail,"enabled modified content does not match."); |
| f_EPTF_Base_stop(fail) |
| } |
| if(f_EPTF_Var_getBoolValue(vl_varIdComp_loadIsStable) != f_EPTF_Var_getBoolValue(vl_varIdDS_loadIsStable)){ |
| setverdict(fail,"loadIsStable modified content does not match."); |
| f_EPTF_Base_stop(fail) |
| } |
| if(f_EPTF_Var_getFloatValue(vl_varIdComp_loadToReach) != f_EPTF_Var_getFloatValue(vl_varIdDS_loadToReach)){ |
| setverdict(fail,"loadToReach modified content does not match."); |
| f_EPTF_Base_stop(fail) |
| } |
| if(f_EPTF_Var_getFloatValue(vl_varIdComp_cpsToReach) != f_EPTF_Var_getFloatValue(vl_varIdDS_cpsToReach)){ |
| setverdict(fail,"cpsToReach modified content does not match."); |
| f_EPTF_Base_stop(fail) |
| } |
| if(f_EPTF_Var_getFloatValue(vl_varIdComp_currentLoad) != f_EPTF_Var_getFloatValue(vl_varIdDS_currentLoad)){ |
| setverdict(fail,"loadToReach modified content does not match."); |
| f_EPTF_Base_stop(fail) |
| } |
| f_EPTF_Base_stop(pass); |
| } |
| |
| type component LoadRegulatorDS_GUI_CT extends EPTF_UIHandler_CT, LoadRegulatorDS_CT{ |
| } |
| testcase tc_LoadRegulator_DS_GUI() runs on LoadRegulatorDS_GUI_CT |
| { |
| const charstring c_gui := |
| "<Widgets xmlns='http://ttcn.ericsson.se/protocolModules/xtdp/xtdl'>"& |
| " <hbox flex='0.0' id='EPTF_LoadRegulatorUI_hboxId' orientation='vertical'>"& |
| " <label id='EPTF_LoadRegulatorUI_textlabelId' value='LoadRegulator'/>"& |
| " <tree hidecolumnpicker='true' id='EPTF_LoadRegulatorUI_treeId' rows=''>"& |
| " <treecols>"& |
| " <!--<treecol editable='false' flex='1.0' id='EPTF_LoadRegulatorUI_1colId' label='Regulator Name' widgetType='string'/>-->"& |
| " <treecol flex='1.0' id='EPTF_LoadRegulatorUI_2colId' label='Regulate Load' widgetType='checkBox'/>"& |
| " <treecol editable='false' flex='1.0' id='EPTF_LoadRegulatorUI_3colId' label='CPS to reach' widgetType='floatField'/>"& |
| " <treecol flex='1.0' id='EPTF_LoadRegulatorUI_4colId' label='Load to reach' widgetType='floatField'/>"& |
| " <treecol editable='false' flex='1.0' id='EPTF_LoadRegulatorUI_5colId' label='SUT load in %' widgetType='floatField'/>"& |
| " <treecol editable='false' flex='1.0' id='EPTF_LoadRegulatorUI_6colId' label='Load is stable' widgetType='checkBox'/>"& |
| " </treecols>"& |
| " <treechildren>"& |
| " <treeitem>"& |
| " <treerow>"& |
| " <!--<treecell id='%Regulator%.EPTF_LoadRegulatorUI_NameId' label='%Regulator%' />-->"& |
| " <treecell id='EPTF_LoadRegulatorUI_enabledId'>"& |
| " <externaldata element='Enabled' source='LoadRegulator' />"& |
| " </treecell>"& |
| " <treecell id='EPTF_LoadRegulatorUI_cpsToReachId'>"& |
| " <externaldata element='CpsToReach' source='LoadRegulator' />"& |
| " </treecell>"& |
| " <treecell id='EPTF_LoadRegulatorUI_loadToReachId'>"& |
| " <externaldata element='LoadToReach' source='LoadRegulator' />"& |
| " </treecell>"& |
| " <treecell id='EPTF_LoadRegulatorUI_currentLoadId'>"& |
| " <externaldata element='CurrentLoad' source='LoadRegulator' />"& |
| " </treecell>"& |
| " <treecell id='EPTF_LoadRegulatorUI_loadIsStableId'>"& |
| " <externaldata element='LoadIsStable' source='LoadRegulator' />"& |
| " </treecell>"& |
| " </treerow>"& |
| " </treeitem>"& |
| " </treechildren>"& |
| " </tree>"& |
| " </hbox>"& |
| "</Widgets> " |
| f_EPTF_Base_init_CT("Test"); |
| f_EPTF_HostAdmin_Base_init_CT("Test"); |
| f_EPTF_UIHandler_init_CT("Test",true); |
| f_EPTF_Var_setSyncInterval(0.1); |
| //log("**** initializing LoadRegulator"); |
| f_EPTF_LoadRegulator_init_CT( |
| pl_selfName := "LoadRegulator", |
| pl_getSutLoad := refers(f_getSUTLoad), |
| pl_dataSource_compRef := self); |
| timer t_guard; |
| t_guard.start( 0.1 ); |
| t_guard.timeout; |
| f_EPTF_UIHandler_clearGUI(); |
| f_EPTF_UIHandler_addWindow(); |
| f_EPTF_UIHandler_createGUI(c_gui) |
| t_guard.start( 0.2 ); |
| t_guard.timeout; |
| var integer vl_varIdComp_cpsToReach := f_EPTF_LoadRegulator_getVarRef_cpsToReach(); |
| var integer vl_varIdComp_loadToReach := f_EPTF_LoadRegulator_getVarRef_loadToReach(); |
| //var integer vl_varIdComp_currentLoad := f_EPTF_LoadRegulator_getVarRef_currentLoad(); |
| var integer vl_varIdComp_loadIsStable := f_EPTF_LoadRegulator_getVarRef_loadIsStable(); |
| var integer vl_varIdComp_enabled := f_EPTF_LoadRegulator_getVarRef_enabled(); |
| f_EPTF_Var_adjustContent(vl_varIdComp_cpsToReach,{floatVal := 11.1}); |
| f_EPTF_Var_adjustContent(vl_varIdComp_loadToReach,{floatVal := 11.2}); |
| //f_EPTF_Var_adjustContent(vl_varIdComp_currentLoad,{floatVal := 11.3});// this var is readonly! |
| v_EPTF_HostAdmin_testerHostLoad := 11.3; // set the measured load |
| f_EPTF_Var_adjustContent(vl_varIdComp_loadIsStable,{boolVal := true}); |
| f_EPTF_Var_adjustContent(vl_varIdComp_enabled,{boolVal := false}); |
| t_guard.start( 10.2 ); |
| t_guard.timeout; |
| var Widgets vl_received :=f_EPTF_UIHandler_XSD_decodeXUL(f_EPTF_UIHandler_snapshot()); |
| var template Widgets vl_expected := { |
| window := { |
| height := 386.000000, |
| id := "EPTF_Main_Window", |
| orientation := vertical, |
| title := "TTCN constructed window", |
| width := 820.000000, |
| image_list := { |
| }, |
| embeddedwidgets := { |
| embeddedwidget_list := { |
| { |
| hbox := { |
| disabled := omit, |
| disabledongui := *, |
| fixedposition := omit, |
| flex := 0.000000, |
| id := "EPTF_LoadRegulatorUI_hboxId", |
| orientation := vertical, |
| scrollable := omit, |
| embeddedwidgets := { |
| embeddedwidget_list := { |
| { |
| label_ := { |
| disabled := omit, |
| disabledongui := *, |
| flex := omit, |
| id := "EPTF_LoadRegulatorUI_textlabelId", |
| style := omit, |
| tooltiptext := omit, |
| value_ := "LoadRegulator", |
| externaldata := * |
| } |
| }, |
| { |
| tree := { |
| disabled := omit, |
| disabledongui := *, |
| flex := omit, |
| hidecolumnpicker := true, |
| id := "EPTF_LoadRegulatorUI_treeId", |
| rows := *, |
| treecols := { |
| treecolgroups := { |
| treecolgroup_list := { |
| { |
| treecol := { |
| align := omit, |
| disabledongui := *, |
| editable := omit, |
| flex := 1.000000, |
| id := "EPTF_LoadRegulatorUI_2colId", |
| label_ := "Regulate Load", |
| tooltiptext := omit, |
| treecellalign := omit, |
| widgetType := checkBox |
| } |
| }, |
| { |
| treecol := { |
| align := omit, |
| disabledongui := *, |
| editable := false, |
| flex := 1.000000, |
| id := "EPTF_LoadRegulatorUI_3colId", |
| label_ := "CPS to reach", |
| tooltiptext := omit, |
| treecellalign := omit, |
| widgetType := floatField |
| } |
| }, |
| { |
| treecol := { |
| align := omit, |
| disabledongui := *, |
| editable := omit, |
| flex := 1.000000, |
| id := "EPTF_LoadRegulatorUI_4colId", |
| label_ := "Load to reach", |
| tooltiptext := omit, |
| treecellalign := omit, |
| widgetType := floatField |
| } |
| }, |
| { |
| treecol := { |
| align := omit, |
| disabledongui := *, |
| editable := false, |
| flex := 1.000000, |
| id := "EPTF_LoadRegulatorUI_5colId", |
| label_ := "SUT load in %", |
| tooltiptext := omit, |
| treecellalign := omit, |
| widgetType := floatField |
| } |
| }, |
| { |
| treecol := { |
| align := omit, |
| disabledongui := *, |
| editable := false, |
| flex := 1.000000, |
| id := "EPTF_LoadRegulatorUI_6colId", |
| label_ := "Load is stable", |
| tooltiptext := omit, |
| treecellalign := omit, |
| widgetType := checkBox |
| } |
| } |
| } |
| } |
| }, |
| treechildren := { |
| treeitemgroups := { |
| treeitemgroup_list := { |
| { |
| treeitem := { |
| treerowgroups := { |
| treerowgroup_list := { |
| { |
| treerow := { |
| treecellgroups := { |
| treecellgroup_list := { |
| { |
| treecell := { |
| align := omit, |
| id := "EPTF_LoadRegulatorUI_enabledId", |
| imageid := omit, |
| label_ := "false", |
| tooltiptext := omit, |
| visible := omit, |
| externaldata := * |
| } |
| }, |
| { |
| treecell := { |
| align := omit, |
| id := "EPTF_LoadRegulatorUI_cpsToReachId", |
| imageid := omit, |
| label_ := "11.100000", |
| tooltiptext := omit, |
| visible := omit, |
| externaldata := * |
| } |
| }, |
| { |
| treecell := { |
| align := omit, |
| id := "EPTF_LoadRegulatorUI_loadToReachId", |
| imageid := omit, |
| label_ := "11.200000", |
| tooltiptext := omit, |
| visible := omit, |
| externaldata := * |
| } |
| }, |
| { |
| treecell := { |
| align := omit, |
| id := "EPTF_LoadRegulatorUI_currentLoadId", |
| imageid := omit, |
| label_ := pattern "11.*", |
| tooltiptext := omit, |
| visible := omit, |
| externaldata := * |
| } |
| }, |
| { |
| treecell := { |
| align := omit, |
| id := "EPTF_LoadRegulatorUI_loadIsStableId", |
| imageid := omit, |
| label_ := "true", |
| tooltiptext := omit, |
| visible := omit, |
| externaldata := * |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| if(not match ( vl_received, vl_expected )){ |
| setverdict(fail, match ( vl_received, vl_expected )); |
| } |
| f_EPTF_Base_stop(pass); |
| |
| } |
| }//group dataSource |
| |
| testcase tc_LoadRegulator_weightedCPS_demo() runs on LoadRegulatorDemo_CT |
| { |
| timer T_interval := tsp_demoInterval; |
| |
| log("**** creating repeater component"); |
| |
| var Repeater_CT rep := Repeater_CT.create; |
| connect(self:demo_PCO, rep:demo_PCO); |
| rep.start(f_repeater()); |
| |
| log("**** initializing HostAdmin_Base"); |
| |
| f_EPTF_Base_init_CT("Test"); |
| |
| log("**** initializing LoadRegulator"); |
| |
| f_EPTF_LoadRegulator_init_CT("LoadRegulator",refers(f_getSUTLoad), null, refers(f_calcWeightedCpsList)); |
| f_EPTF_LoadRegulator_setLoadToReach(tsp_demoLoadToReach); |
| v_weightedCpsList := { |
| { |
| cps := 10.0, |
| weight := 19.0, |
| lockCps := true |
| }, |
| { |
| cps := 10.0, |
| weight := 1.0, |
| lockCps := false |
| }, |
| { |
| cps := 10.0, |
| weight := 2.0, |
| lockCps := false |
| }, |
| { |
| cps := 10.0, |
| weight := 3.0, |
| lockCps := false |
| } |
| } |
| f_EPTF_HostAdmin_Base_init_CT("Test"); |
| |
| log("**** initializing Scheduler"); |
| |
| f_EPTF_Scheduler_init_CT(f_EPTF_Base_selfName()); |
| v_myEventHandler := refers(f_myEventHandler); |
| f_EPTF_SchedulerComp_refreshSnapshotTime(); |
| f_scheduleEvent_generateLoad(f_EPTF_SchedulerComp_snapshotTime()); |
| f_scheduleEvent_updateSutLoad(f_EPTF_SchedulerComp_snapshotTime()); |
| |
| log("**** entering main loop"); |
| |
| T_interval.start; |
| var charstring msg; |
| alt { |
| [] T_interval.timeout |
| { |
| setverdict(pass); |
| } |
| []demo_PCO.receive(charstring:?) -> value msg |
| { |
| var SDP_Message SDP_msg := f_SDP_dec_Message(msg); |
| repeat; |
| } |
| } |
| |
| log("**** performing cleanup"); |
| |
| rep.stop; |
| disconnect(self:demo_PCO, rep:demo_PCO); |
| |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| // note: this demo needs that the repeater and the demo component are running on different hosts! |
| // For this, start two host controllers on two hosts connecting to the same main controller. |
| // The first HC started will run the demo component and will regulate the load. |
| testcase tc_BandwidthLimitedTrafficControl_demo() runs on LoadRegulatorDemo_CT |
| { |
| timer T_interval := tsp_demoInterval; |
| |
| timer T_startup := 2.0; |
| T_startup.start; |
| T_startup.timeout; |
| |
| log("**** creating repeater component"); |
| |
| var Repeater_CT rep := Repeater_CT.create; |
| connect(self:demo_PCO, rep:demo_PCO); |
| rep.start(f_repeater()); |
| |
| log("**** initializing NET measure interface"); |
| |
| f_EPTF_Base_init_CT("Test"); |
| f_initNetMeas(); |
| f_EPTF_Base_registerCleanup(refers(f_cleanupNetMeas)); |
| |
| log("**** initializing LoadRegulator"); |
| |
| // f_EPTF_LoadRegulator_init_CT(refers(f_getBandwidthUsage), refers(f_calcNextCps_BW)); |
| f_EPTF_LoadRegulator_init_CT("LoadRegulator",refers(f_getBandwidthUsage)); |
| f_EPTF_LoadRegulator_setLoadToReach(tsp_bandwidthToReach); |
| |
| log("**** initializing Scheduler"); |
| |
| f_EPTF_Scheduler_init_CT(f_EPTF_Base_selfName()); |
| v_myEventHandler := refers(f_myEventHandler); |
| f_EPTF_SchedulerComp_refreshSnapshotTime(); |
| f_scheduleEvent_generateLoad(f_EPTF_SchedulerComp_snapshotTime()); |
| // f_scheduleEvent_updateSutLoad(f_EPTF_SchedulerComp_snapshotTime()); |
| |
| log("**** entering main loop"); |
| |
| T_interval.start; |
| var charstring msg; |
| alt { |
| [] T_interval.timeout |
| { |
| setverdict(pass); |
| } |
| []demo_PCO.receive(charstring:?) -> value msg |
| { |
| var SDP_Message SDP_msg := f_SDP_dec_Message(msg); |
| repeat; |
| } |
| } |
| |
| log("**** performing cleanup"); |
| |
| rep.stop; |
| disconnect(self:demo_PCO, rep:demo_PCO); |
| |
| f_EPTF_Base_cleanup_CT(); |
| } |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_LoadRegulator_Test_init_CT |
| // |
| // Purpose: |
| // to test f_EPTF_LoadRegulator_init_CT function |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // - init and start the regulator for severeal seconds, then call f_EPTF_Base_cleanup_CT() |
| // - init and start the regulator for severeal seconds |
| // - checks that cps2Reach value is different from the initiated one, then call f_EPTF_Base_cleanup_CT() |
| // Expected Result: |
| // - after cleanup the regulator initiated and running correctly |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_LoadRegulator_Test_init_CT() runs on EPTF_LoadRegulator_Test_CT { |
| |
| timer t_testDuration; |
| timer t_readCurrentLoad := 10.0; |
| // f_EPTF_LoadRegulator_setCpsToReach(12.0); |
| |
| t_testDuration.start(15.0); |
| f_EPTF_LoadRegulator_init_CT("LoadRegulator",refers(f_getMeasLoad)); |
| f_EPTF_LoadRegulator_setLoadToReach(12.0); |
| alt { |
| |
| [] t_testDuration.timeout { |
| setverdict(pass); |
| } |
| } |
| f_EPTF_Base_cleanup_CT(); |
| // f_EPTF_LoadRegulator_setCpsToReach(12.0); |
| f_EPTF_LoadRegulator_init_CT("LoadRegulator",refers(f_getMeasLoad)); |
| f_EPTF_LoadRegulator_setLoadToReach(12.0); |
| t_testDuration.start(20.0); |
| t_readCurrentLoad.start; |
| |
| alt { |
| [] t_readCurrentLoad.timeout { |
| t_readCurrentLoad.start; |
| if(f_EPTF_LoadRegulator_getCpsToReach() != 12.0) { |
| setverdict(pass) |
| } else { |
| log("Error, bad regulator behavior") |
| setverdict(fail); |
| } |
| repeat; |
| } |
| [] t_testDuration.timeout { |
| setverdict(pass); |
| } |
| } |
| f_EPTF_Base_cleanup_CT(); |
| |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_LoadRegulator_Test_exponentialSmoothingFunction |
| // |
| // Purpose: |
| // to test f_EPTF_LoadRegulator_exponentialSmoothingFunction function |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // - calls the function with 0.5 smoothing factor, checks the result |
| // - calls the function with 0.0 smoothing factor, checks the result |
| // - calls the function with 1.0 smoothing factor, checks the result |
| // |
| // Expected Result: |
| // - all returned value are the same as we ordered |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_LoadRegulator_Test_exponentialSmoothingFunction() runs on EPTF_LoadRegulator_Test_CT { |
| |
| var float vl_calculated := 1.0; |
| vl_calculated := f_EPTF_exponentialSmoothingFunction(2.0, vl_calculated, 0.5); |
| if (vl_calculated == 1.5) { |
| setverdict(pass); |
| } else { |
| log("Error: wrong calculated value: ", vl_calculated,", expected 1.5"); |
| setverdict(fail); |
| } |
| vl_calculated := f_EPTF_exponentialSmoothingFunction(2.0, vl_calculated, 0.0); |
| if (vl_calculated == 1.5) { |
| setverdict(pass); |
| } else { |
| log("Error: wrong calculated value: ", vl_calculated,", expected 1.0"); |
| setverdict(fail); |
| } |
| vl_calculated := f_EPTF_exponentialSmoothingFunction(2.0, vl_calculated, 1.0); |
| if (vl_calculated == 2.0) { |
| setverdict(pass); |
| } else { |
| log("Error: wrong calculated value: ", vl_calculated,", expected 2.0"); |
| setverdict(fail); |
| } |
| |
| } |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_LoadRegulator_Test_calculateNextCps |
| // |
| // Purpose: |
| // to test f_EPTF_LoadRegulator_calculateNextCps function |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // - sets CPS to reach to 8.0 |
| // - sets Load to reach to 8.0 |
| // - calls the f_EPTF_LoadRegulator_init_CT with smoothing factor 1.0 |
| // - checks that new CPS to reach is different from 8.0 durring the test |
| // - calls the cleanup function, than sets CPS and Load to 12.0 |
| // - calls the f_EPTF_LoadRegulator_init_CT with f_EPTF_LoadRegulator_getCpsToReach() function to calculate the next CPS |
| // - checks the new CPS value |
| // |
| // Expected Result: |
| // - new CPS is different from 8.0 |
| // - in the 2nd case the new CPS is 12.0 in every time |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_LoadRegulator_Test_calculateNextCps() runs on EPTF_LoadRegulator_Test_CT { |
| |
| timer t_testDuration := 30.0; |
| timer t_readCurrentLoad := tsp_EPTF_loadRegulator_updateTimeout; |
| var boolean vl_lower := false; |
| var boolean vl_higher := false; |
| |
| // f_EPTF_LoadRegulator_setCpsToReach(8.0); |
| f_EPTF_LoadRegulator_init_CT("LoadRegulator",refers(f_getMeasLoad), null,null,3,1.0,5.0,1.0); |
| // set loadToReach to 8.0 |
| f_EPTF_LoadRegulator_setLoadToReach(8.0); |
| // set initial CpsToReach to 8.0 |
| f_EPTF_Var_adjustContent(f_EPTF_LoadRegulator_getVarRef_cpsToReach(), {floatVal := 8.0}); |
| f_EPTF_Var_adjustContent(f_EPTF_LoadRegulator_getVarRef_enabled(), {boolVal := true}); |
| t_testDuration.start; |
| t_readCurrentLoad.start; |
| alt { |
| [] t_readCurrentLoad.timeout { |
| if(not vl_higher and f_EPTF_LoadRegulator_getCpsToReach() > 8.0) { |
| log("Cps2Reach higher: ", f_EPTF_LoadRegulator_getCpsToReach()); |
| vl_higher := true; |
| } |
| if(not vl_lower and f_EPTF_LoadRegulator_getCpsToReach() < 8.0) { |
| log("Cps2Reach lower: ", f_EPTF_LoadRegulator_getCpsToReach()); |
| vl_lower := true; |
| } |
| t_readCurrentLoad.start; |
| repeat; |
| } |
| [] t_testDuration.timeout { |
| if(vl_higher and vl_lower) { |
| setverdict(pass); |
| } else { |
| log("Error: calculated CPS is wrong"); |
| } |
| } |
| } |
| |
| f_EPTF_Base_cleanup_CT(); |
| // f_EPTF_LoadRegulator_setCpsToReach(12.0); |
| f_EPTF_LoadRegulator_init_CT(pl_selfName:="LoadRegulator",pl_getSutLoad:=refers(f_EPTF_LoadRegulator_getCpsToReach)); |
| // set loadToReach to 12.0 |
| f_EPTF_LoadRegulator_setLoadToReach(12.0); |
| // set initial CpsToReach to 12.0 |
| f_EPTF_Var_adjustContent(f_EPTF_LoadRegulator_getVarRef_cpsToReach(), {floatVal := 12.0}); |
| f_EPTF_Var_adjustContent(f_EPTF_LoadRegulator_getVarRef_enabled(), {boolVal := true}); |
| t_testDuration.start; |
| t_readCurrentLoad.start; |
| var boolean vl_regulationSuccessful := false; |
| alt { |
| [] t_readCurrentLoad.timeout { |
| action("f_EPTF_LoadRegulator_getCpsToReach(): ", f_EPTF_LoadRegulator_getCpsToReach()) |
| var float vl_currentCPSToReach := f_EPTF_LoadRegulator_getCpsToReach(); |
| if((vl_currentCPSToReach - 12.0)*(vl_currentCPSToReach - 12.0)<1e-10) { |
| vl_regulationSuccessful:=true; |
| action("Target load reached: 12.0"); |
| setverdict(pass); |
| } else { |
| t_readCurrentLoad.start; |
| repeat; |
| } |
| } |
| [] t_testDuration.timeout { |
| |
| } |
| } |
| if (not vl_regulationSuccessful) { |
| log("Error : wrong calculated CPS value: ", f_EPTF_LoadRegulator_getCpsToReach(), ", expected: 12.0"); |
| setverdict(fail); |
| } |
| |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_LoadRegulator_Test_calculateNextCps_limitMax |
| // |
| // Purpose: |
| // to test f_EPTF_LoadRegulator_calculateNextCps_limitMax function |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // - |
| // |
| // Expected Result: |
| // - |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_LoadRegulator_Test_calculateNextCps_limitMax() runs on EPTF_LoadRegulator_Test_limitMax_CT |
| { |
| // f_EPTF_Logging_init_CT("Test_Base"); |
| |
| f_EPTF_Base_init_CT("Test_Base"); |
| f_EPTF_UIHandler_init_CT("Test_Base", true); |
| |
| f_EPTF_UIHandler_clearGUI(); |
| var boolean vl_return := f_EPTF_UIHandler_addWindow(); |
| vl_return := f_EPTF_UIHandler_addMainTabbox(); |
| |
| f_EPTF_UIHandlerClient_init_CT("Test_Base", self); |
| |
| //----------------------------------------------------------------------------------- |
| var EPTF_LGenBase_TcMgmt_EntityGrpDeclaratorList vl_TSTM_EntityGrpDeclarators := {}; |
| var EPTF_LGenBase_TcMgmt_Scenarios2GrpList vl_TSTM_Scenarios2Grps := {}; |
| var EPTF_LGenBase_TcMgmt_tcTypeDeclaratorList vl_TSTM_tcTypeDeclarators2 := {}; |
| var EPTF_LGenBase_TcMgmt_ScenarioDeclaratorList vl_TSTM_ScenarioDeclarators2 := {}; |
| var EPTF_ExecCtrl_RegulatorNames vl_TSTM_RegulatorNames := {}; |
| var EPTF_ExecCtrl_RegulatedItems vl_TSTM_RegulatedItems := {}; |
| |
| vl_TSTM_tcTypeDeclarators2[sizeof(vl_TSTM_tcTypeDeclarators2)] := |
| { |
| name := "TCaseName", |
| fsmName := "FSMName", |
| entityType := "ETypeName", |
| customEntitySucc := "" |
| }; |
| |
| vl_TSTM_ScenarioDeclarators2[sizeof(vl_TSTM_ScenarioDeclarators2)] := |
| { |
| name := "SenarioName", |
| tcList := |
| { |
| { |
| tcName := "TCaseName", |
| startDelay := 0.0, |
| cpsToReach := 100.0, |
| enableEntities := true, |
| enable := true, |
| ranges := { }, |
| params := { }, |
| groupFinishConditions := omit, |
| entityFinishConditions := omit, |
| entityFinishActions := {}, |
| tcFinishActions := {} |
| } |
| } |
| }; |
| |
| vl_TSTM_EntityGrpDeclarators[sizeof(vl_TSTM_EntityGrpDeclarators)] := |
| { |
| name := "EGrpName", |
| eType := "ETypeName", |
| eCount := 10 |
| }; |
| |
| vl_TSTM_Scenarios2Grps[sizeof(vl_TSTM_Scenarios2Grps)] := |
| { |
| eGrpName := "EGrpName", |
| scenarioNames := { "SenarioName" } |
| }; |
| |
| vl_TSTM_RegulatorNames[sizeof(vl_TSTM_RegulatorNames)] := "Test_Base"; |
| |
| vl_TSTM_RegulatedItems[sizeof(vl_TSTM_RegulatedItems)] := |
| { |
| idName := |
| { |
| cps_TC := |
| { |
| eGrpName := "EGrpName", |
| scName := "SenarioName", |
| tcName := "TCaseName" |
| } |
| }, |
| weight := 1.0, |
| enabled := true, |
| regulatorName := "Test_Base" |
| }; |
| |
| f_EPTF_LGenBase_init("Test_Base", 100); |
| |
| vc_myBIdx := f_EPTF_LGenBase_declareBehaviorType |
| ("Test_Behavior", |
| 100, |
| null, |
| null, |
| null |
| ); |
| |
| var integer vl_eTypeIdx := f_EPTF_LGenBase_declareEntityType("ETypeName", {"Test_Behavior"}); |
| |
| f_EPTF_LoadRegulator_Test_declareCompactFsmTable(); |
| |
| f_EPTF_ExecCtrl_loadConfig |
| ( |
| pl_EPTF_LGenBase_TcMgmt_EntityGrpDeclaratorList := vl_TSTM_EntityGrpDeclarators, |
| pl_EPTF_LGenBase_TcMgmt_Scenarios2GrpList := vl_TSTM_Scenarios2Grps, |
| pl_EPTF_LGenBase_TcMgmt_tcTypeDeclaratorList := vl_TSTM_tcTypeDeclarators2, |
| pl_EPTF_LGenBase_TcMgmt_ScenarioDeclaratorList := vl_TSTM_ScenarioDeclarators2, |
| pl_EPTF_ExecCtrl_RegulatorNames := vl_TSTM_RegulatorNames, |
| pl_EPTF_ExecCtrl_RegulatedItems := vl_TSTM_RegulatedItems |
| ); |
| |
| f_EPTF_ExecCtrl_UIHandler_init_CT("Test_Base", 1, self, tsp_EPTF_GUI_Main_Tabbox_WidgetId); |
| |
| f_EPTF_ExecCtrlClient_init_CT("Test_Base", self, true, true); |
| //----------------------------------------------------------------------------------- |
| f_EPTF_LoadRegulator_init_CT(vl_TSTM_RegulatorNames[0], refers(f_getSUTLoad_limitMaxTest), refers(f_EPTF_LoadRegulator_calculateNextCps_limitMax), null, 3, 1.0, 5.0, 10.0, 0.0, 1.0); |
| |
| f_EPTF_LoadRegulator_setLoadToReach( 0.9 ); |
| f_EPTF_LoadRegulator_registerToExecCtrl(self); |
| //------------------------------------------------------------------------------------ |
| |
| // Initialize GUI |
| // f_EPTF_LoggingUI_init_CT("Test_Base", self, tsp_EPTF_GUI_Main_Tabbox_WidgetId); |
| |
| // Handle altsteps |
| f_EPTF_Base_wait4Shutdown(); |
| |
| f_EPTF_Base_stop(pass); |
| } |
| |
| group Help { |
| |
| type component LoadRegulator_HelpTest_CT extends EPTF_DataSource_CT, LoadRegulatorDemo_CT { |
| var boolean v_LoadRegulator_ready := false; |
| } |
| |
| function f_EPTF_LoadRegulator_Test_checkLoadRegulatorReady( |
| in charstring pl_source, |
| in charstring pl_ptcName |
| ) runs on LoadRegulator_HelpTest_CT { |
| if (pl_source==c_LoadRegulator_sourceId) { |
| v_LoadRegulator_ready := true; |
| } |
| } |
| |
| testcase tc_EPTF_LoadRegulator_Test_help() runs on LoadRegulator_HelpTest_CT { |
| f_EPTF_DataSource_init_CT("MTC"); |
| v_LoadRegulator_ready := false; |
| f_EPTF_DataSource_registerReadyCallback(refers(f_EPTF_LoadRegulator_Test_checkLoadRegulatorReady)); |
| |
| f_EPTF_LoadRegulator_init_CT("LoadRegulator_Test_help", refers(f_getSUTLoad), pl_dataSource_compRef := self); |
| |
| |
| timer T_guard, T_alt; |
| T_guard.start( 100.0 ); |
| T_alt.start( 0.0 ); |
| alt{ |
| [] T_guard.timeout{ |
| setverdict(fail,"Timeout during config"); |
| f_EPTF_Base_stopAll(); |
| } |
| [v_LoadRegulator_ready] T_alt.timeout{} |
| }; |
| |
| var charstring vl_helpTEXT; |
| var octetstring vl_helpJSON; |
| vl_helpTEXT := f_EPTF_DataSource_getHelpTEXT(c_LoadRegulator_sourceId); |
| action("Help for LoadRegulator: ", vl_helpTEXT); |
| if (vl_helpTEXT=="") { |
| setverdict(fail, "No help returned for ",v_LoadRegulator_ready); |
| f_EPTF_Base_stop(none); |
| } |
| vl_helpJSON := f_EPTF_DataSource_getHelpJSON(c_LoadRegulator_sourceId); |
| action("HelpJSON for LoadRegulator: ", vl_helpJSON); |
| |
| |
| setverdict(pass); |
| f_EPTF_Base_stop(none); |
| |
| |
| } |
| } //group Help |
| |
| control { |
| execute(tc_LoadRegulator_demo()); |
| execute(tc_LoadRegulator_weightedCPS_demo()); |
| // execute(tc_BandwidthLimitedTrafficControl_demo()); |
| execute(tc_EPTF_LoadRegulator_Test_init_CT()); |
| execute(tc_EPTF_LoadRegulator_Test_exponentialSmoothingFunction()); |
| execute(tc_EPTF_LoadRegulator_Test_calculateNextCps()); |
| execute(tc_LoadRegulator_DS()); |
| execute(tc_LoadRegulator_DS_GUI()); |
| |
| execute(tc_EPTF_LoadRegulator_Test_help()); |
| } |
| |
| } // module |
| |