| /////////////////////////////////////////////////////////////////////////////// |
| // // |
| // 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_LGenBasePerformTest_LoadTestResources |
| // |
| // Purpose: |
| // This module provides functions for testing LGenBase |
| // |
| // Module depends on: |
| // - |
| // |
| // Current Owner: |
| // Laszlo Skumat (ELSZSKU) |
| // |
| // Last Review Date: |
| // 2008-09-11 |
| // |
| // Detailed Comments: |
| // Provide functions to test LGenBase |
| // |
| // |
| /////////////////////////////////////////////////////////////// |
| module EPTF_LGenBasePerformTest_LoadTestResources |
| { |
| //import from EPTF_LGenBasePerformTest_MTASDefinitions all |
| //import from EPTF_LGenBasePerformTest_MTASFunctions all |
| import from EPTF_LGenBasePerformTest_LoadMTCDefinitions all |
| import from EPTF_LGenBasePerformTest_LoadLGenFunctions all |
| import from EPTF_LGenBasePerformTest_LoadLGenDefinitions all |
| import from EPTF_LGenBasePerformTest_LoadMessages all |
| import from EPTF_LGenBasePerformTest_MTCFunctions all |
| //import from EPTF_CLL_LGenBase_Definitions all |
| //import from EPTF_CLL_LGenBaseStats_Definitions all |
| //import from EPTF_CLL_LGenBaseStats_Functions all |
| import from EPTF_CLL_Base_Functions all |
| import from EPTF_CLL_Variable_Functions all |
| import from EPTF_CLL_Variable_Definitions all |
| import from PIPEasp_Types all |
| import from TCCFileIO_Functions all |
| #ifdef R3 |
| import from EPTF_CLL_Common_Definitions all |
| import from EPTF_CLL_LGenBase_ConfigDefinitions all; |
| import from EPTF_CLL_LGenBase_ConfigFunctions all |
| #endif |
| #ifdef R2 |
| import from EPTF_CLL_Definitions all |
| #endif |
| |
| import from ttcn_ericsson_se_TitanSim_Perftest all; |
| import from TestResultGen all; |
| |
| modulepar integer tsp_loadMeasureCount := 10 |
| modulepar float tsp_loadMeasurePeriod := 1.0 |
| |
| |
| modulepar integer tsp_measureTrafficECount := 10000 |
| modulepar integer tsp_numLgens := 1 |
| |
| function f_LGenBasePerformTest_LoadMTC_prepare() |
| runs on EPTF_LGenBasePerformTest_LoadMTC_CT { |
| v_LGenBasePerformTest_MTCLoadMessages_finished := false |
| f_EPTF_Var_init_CT("MTCLoad_CT"); |
| map(self:v_pipe_PCO, system:v_pipe_PCO) |
| const ASP_PLineMode c_pLineMode := { lineMode := true }; |
| v_pipe_PCO.send(c_pLineMode); |
| } |
| |
| modulepar float tsp_measurementDelay := 1.0 |
| modulepar integer tsp_CPUMeasureCount := 10 |
| |
| function f_LGenBasePerformTest_LoadMTC_measureTrafficCPU( |
| in integer pl_eCount, |
| in float pl_cps2reach, |
| in charstring pl_tc2start, |
| inout float pl_measuredCPS) |
| runs on EPTF_LGenBasePerformTest_LoadMTC_CT |
| return float{ |
| var float vl_ret := 100.0 |
| //Start LGens |
| vc_performTestCt := |
| EPTF_LGenBasePerformTest_LoadLGen_CT.create |
| vc_performTestCt.start(f_EPTF_LGenBasePerformTest_LoadLGen_startTrafficMeasCPU( |
| "LoadLGen", pl_eCount, 0, pl_cps2reach, pl_tc2start)); |
| connect(self:v_LGenBasePerformTest_MTCLoadMessagesPort,vc_performTestCt:v_LGenBasePerformTest_MTCLoadMessagesPort); |
| //Measure |
| timer t_guard |
| t_guard.start( tsp_LGenBasePerformTest_LoadLGenGuard ) |
| var LGenBasePerformTest_LoadMessage vl_msg |
| var EPTF_LGenBasePerformTest_LoadLGen_CT vl_sender |
| var charstring vl_lgenPID := "" |
| var float vl_cpuUsage := 0.0 |
| alt |
| { |
| [] v_LGenBasePerformTest_MTCLoadMessagesPort.receive(t_LoadMessage_eGrpCreated) -> value vl_msg sender vl_sender{ |
| vl_lgenPID := vl_msg.varId.pID |
| } |
| [] t_guard.timeout{ setverdict(fail) } |
| } |
| if(vl_lgenPID != ""){ |
| timer t_measurementDelay |
| var integer vl_i := 0 |
| while ( vl_i < tsp_CPUMeasureCount and fail != getverdict){ |
| t_measurementDelay.start(tsp_measurementDelay) |
| t_guard.start( tsp_LGenBasePerformTest_LoadLGenGuard ); |
| alt |
| { |
| [] t_measurementDelay.timeout{ |
| t_guard.stop |
| var float vl_temp := f_EPTF_LGenBasePerformanceTest_getCPUsage(vl_lgenPID) |
| //action("CPU Usage:",vl_temp) |
| |
| vl_cpuUsage := vl_cpuUsage + vl_temp |
| setverdict(pass) |
| } |
| [] t_guard.timeout{ setverdict(fail) } |
| }; |
| vl_i := vl_i+1 |
| } |
| t_measurementDelay.start( tsp_runAfter ) |
| t_measurementDelay.timeout |
| vl_msg.stopLGen := {}; |
| v_LGenBasePerformTest_MTCLoadMessagesPort.send(vl_msg); |
| v_LGenBasePerformTest_MTCLoadMessagesPort.receive(LGenBasePerformTest_LoadMessage:?) -> value vl_msg |
| if(not ischosen(vl_msg.measuredCPS)){ |
| setverdict(fail) |
| }else{ |
| pl_measuredCPS := pl_measuredCPS + vl_msg.measuredCPS.cps |
| } |
| vl_ret := vl_cpuUsage/int2float(tsp_CPUMeasureCount) |
| //action("Average CPU Usage:",vl_ret) |
| } |
| disconnect(self:v_LGenBasePerformTest_MTCLoadMessagesPort,vc_performTestCt:v_LGenBasePerformTest_MTCLoadMessagesPort); |
| return vl_ret |
| } |
| |
| function f_LGenBasePerformTest_LoadMTC_cleanup() |
| runs on EPTF_LGenBasePerformTest_LoadMTC_CT { |
| unmap(self:v_pipe_PCO, system:v_pipe_PCO); |
| f_EPTF_Base_cleanup_CT() |
| } |
| modulepar float tsp_cps2reach := 100.0 |
| modulepar float tsp_runAfter := 0.0 |
| modulepar EPTF_FloatList tsp_cpsList := {1000.0, 10000.0, 50000.0} |
| |
| testcase tc_loadResources() |
| runs on EPTF_LGenBasePerformTest_LoadMTC_CT { |
| f_LGenBasePerformTest_LoadMTC_prepare(); |
| var charstring vl_start_time := f_TestResultGen_getCurrentTime(); |
| for ( var integer vl_i := 0; vl_i < sizeof(tsp_cpsList) ; vl_i := vl_i+1 ){ |
| f_loadResources(vl_start_time,tsp_cpsList[vl_i]) |
| } |
| f_LGenBasePerformTest_LoadMTC_cleanup() |
| } |
| |
| function f_loadResources(in charstring pl_start_time, in float pl_cps) |
| runs on EPTF_LGenBasePerformTest_LoadMTC_CT { |
| var Testresult vl_testResult; |
| vl_testResult.name := "LGenBase Load Resources"; |
| vl_testResult.purpose := "To measure the CPU load for given CPS"; |
| f_TestResultGen_getEnvironment(vl_testResult.environment); |
| vl_testResult.parameter_list := { |
| {name := "Target CPS", unit := "call/sec", base := float2str(pl_cps) } |
| }; |
| // var charstring vl_startTime := f_getTimeFormatted(f_time(), "%c"); |
| var charstring vl_start_time := f_TestResultGen_getCurrentTime(); |
| vl_testResult.start_time := vl_start_time; |
| |
| var float vl_cpu := 0.0 |
| var float vl_cps := 0.0 |
| const integer c_count := 5 |
| for ( var integer vl_i := 0; vl_i < c_count ; vl_i := vl_i+1 ) |
| { |
| vl_cpu := vl_cpu + f_LGenBasePerformTest_LoadMTC_measureTrafficCPU( |
| tsp_measureTrafficECount, |
| pl_cps, |
| "simpleResponse", |
| vl_cps) |
| } |
| vl_testResult.end_time := f_TestResultGen_getCurrentTime(); |
| |
| action("Global average CPU Usage:",vl_cpu/int2float(c_count)) |
| var integer vl_f := f_FIO_open_append_wronly(tsp_resultFile) |
| f_FIO_write_text(vl_f,"\nCPU Usage:\t"&log2str(vl_cpu/int2float(c_count))&"\n") |
| f_FIO_write_text(vl_f,"Required CPS:\t"&log2str(pl_cps)&"\n") |
| f_FIO_write_text_flush(vl_f,"Measured CPS:\t"&log2str(vl_cps/int2float(c_count))&"\n") |
| f_FIO_close(vl_f) |
| |
| vl_testResult.result_list := { |
| { |
| name := "Global average CPU Usage", |
| unit := "%", |
| base := float2str(vl_cpu/int2float(c_count)) |
| }, |
| { |
| name := "Measured CPS", |
| unit := "call/sec", |
| base := float2str(vl_cps/int2float(c_count)) |
| } |
| }; |
| f_TestResultGen_appendResult("LGenBase_LoadResources"&pl_start_time&".xml", vl_testResult); |
| }
|
| } // end of module
|
| |