blob: 8ccf0126eee5540ac2b55e9201886f5efc87a24d [file] [log] [blame]
///////////////////////////////////////////////////////////////////////////////
// //
// Copyright (c) 2000-2019 Ericsson Telecom AB //
// //
// All rights reserved. This program and the accompanying materials //
// are made available under the terms of the Eclipse Public License v2.0 //
// which accompanies this distribution, and is available at //
// https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html //
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// Module: EPTF_StatHandler_Test_Testcases
//
// Purpose:
// This module contains basic tests for the EPTF StatHandler feature.
//
// Module depends on:
// <EPTF_CLL_StatHandler_Definitions>
// <EPTF_CLL_StatHandler_Functions>
// <EPTF_CLL_StatHandlerClient_Definitions>
// <EPTF_CLL_StatHandlerClient_Functions>
// <EPTF_CLL_StatHandlerLogging_Definitions>
// <EPTF_CLL_StatHandlerLogging_Functions>
// <EPTF_CLL_StatHandlerUI_Definitions>
// <EPTF_CLL_StatHandlerUI_Functions>
// <EPTF_CLL_Base_Functions>
// <EPTF_CLL_Common_Definitions>
// <EPTF_CLL_UIHandler_Definitions>
// <EPTF_CLL_UIHandler_WidgetFunctions>
// <EPTF_CLL_UIHandlerClient_Definitions>
// <EPTF_CLL_UIHandlerClient_Functions>
// <EPTF_CLL_Logging_Functions>
// <EPTF_CLL_LoggingUI_Definitions>
// <EPTF_CLL_LoggingUI_Functions>
// <EPTF_CLL_LoggingUIClient_Functions>
// <EPTF_CLL_Variable_Definitions>
// <EPTF_CLL_Variable_Functions>
// <XTDP_PDU_Defs>
//
// Module Parameters:
// -
//
// Current Owner:
// Jeno Balasko (ETHBAAT)
//
// Last Review Date:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////////
module EPTF_StatHandler_Test_Testcases {
import from EPTF_CLL_StatHandler_Definitions all;
import from EPTF_CLL_StatHandler_Functions all;
import from EPTF_CLL_StatHandlerClient_Definitions all;
import from EPTF_CLL_StatHandlerClient_Functions all;
import from EPTF_CLL_StatHandlerLogging_Definitions all;
import from EPTF_CLL_StatHandlerLogging_Functions all;
import from EPTF_CLL_StatHandlerUI_Definitions all;
import from EPTF_CLL_StatHandlerUI_Functions all;
import from EPTF_CLL_Base_Functions all;
import from EPTF_CLL_Common_Definitions 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_Logging_Functions all;
import from EPTF_CLL_LoggingUI_Definitions all;
import from EPTF_CLL_LoggingUI_Functions all;
import from EPTF_CLL_LoggingUIClient_Functions all;
import from EPTF_CLL_Variable_Definitions all;
import from EPTF_CLL_Variable_Functions all;
import from EPTF_StatHandler_Test_Definitions all;
import from EPTF_StatHandler_Test_Functions all;
import from EPTF_CLL_DataSource_Definitions all;
import from EPTF_CLL_DataSource_Functions all;
group StatHandler_BasicTest {
group StatHandler_BasicTest_AutoDisconnect {
function f_StatHandler_testAutoDisconnect_Client(in EPTF_StatHandler_CTList pl_servers)
runs on EPTF_StatHandlerClient_CT
{
f_EPTF_StatHandlerClient_init_CT("f_StatHandler_testAutoDisconnect_Client", pl_servers[0]);
var integer vl_idx1 := -1;
f_EPTF_Var_newInt("var1", 10, vl_idx1);
for(var integer i := 0; i < sizeof(pl_servers); i := i + 1) {
f_EPTF_StatHandlerClient_declareStat("MyStat", c_EPTF_StatHandler_Method_Sum, {intVal:=0}, pl_servers[i]);
f_EPTF_StatHandlerClient_registerStat_IntSum("var1", "MyStat", sampledAtSync, true, null, pl_servers[i]);
}
f_EPTF_Var_adjustContent(vl_idx1, {intVal:=11});
f_EPTF_Base_wait4Shutdown();
}
function f_StatHandler_testAutoDisconnect_Server(in charstring pl_name)
runs on EPTF_StatHandler_CT
{
f_EPTF_StatHandler_init_CT(pl_name);
f_EPTF_Base_wait4Shutdown();
}
testcase tc_StatHandler_testAutoDisconnect()
runs on EPTF_StatHandler_CT
{
f_EPTF_StatHandler_init_CT("tc_StatHandler_testAutoDisconnect");
var EPTF_StatHandler_CTList vl_servers := {self};
vl_servers[1] := EPTF_StatHandler_CT.create;
vl_servers[2] := EPTF_StatHandler_CT.create;
vl_servers[1].start(f_StatHandler_testAutoDisconnect_Server("server2"));
vl_servers[2].start(f_StatHandler_testAutoDisconnect_Server("server3"));
var EPTF_StatHandlerClient_CT vl_client := EPTF_StatHandlerClient_CT.create;
vl_client.start(f_StatHandler_testAutoDisconnect_Client(vl_servers));
f_StatHandler_Test_wait(tsp_EPTF_StatHandlerClient_autoDisconnectTimeout + 2.0);
f_EPTF_Base_cleanup_CT();
setverdict(pass);
}
} // group StatHandler_BasicTest_AutoDisconnect
group ResetStat {
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_Test_resetStatistics
//
// Purpose:
// Tests reset feature.
// 1. Init a server
// 2. Init n clients
// 3. Create a stat from the clients
// 4. Subscribe for the statistics
// 5. Init n pieces of clients, pass to each the sample value and the number of samples
// Each client register a variable with initial value and modifies it after waiting "sync interval+0.1s"
// 6. After 4*sync.time get the value of the stat
// 7. Check if the value is the expected
// 8. resets the satistic by it's name
// 9. Checks the statistic valaue again
// 10. Modifies one of the statistic variables to a small number (0.02s)
// 11. Waits 4*sync.time get the value of the stat
// 12. Checks the statistic valaue again to be the modified value
///////////////////////////////////////////////////////////
testcase tc_StatHandler_Test_resetStatistics() runs on EPTF_StatHandlerClient_CT {
var charstring vl_myStatName:="MyStat";
f_EPTF_StatHandlerClient_init_CT(c_myStatHandlerClient);
var EPTF_StatHandler_CT vlc_shServer:= EPTF_StatHandler_CT.create;
vlc_shServer.start(f_EPTF_StatHandler_Test_MasterBehavior(c_myStatHandlerMaster));
//==== Statistics part ====
var charstring vl_statMethod := c_EPTF_StatHandler_Method_Max;
var boolean vl_success:=f_EPTF_StatHandlerClient_declareStat(vl_myStatName, vl_statMethod, {floatVal:=0.0}, vlc_shServer);
if(not vl_success) { f_EPTF_Base_stop(fail); }
var charstring vl_statVarRef:=f_EPTF_StatHandlerClient_getStatVariableRef(vl_myStatName, vlc_shServer);
var integer vl_statVarIdx:=-1;
var EPTF_Var_DirectContent vl_statValue;
f_EPTF_Var_subscribeRemote(vlc_shServer,vl_statVarRef,sampledAtSync,vl_statVarIdx);
log(">>>vl_statVarRef: ", vl_statVarRef," vl_statVarIdx: ",vl_statVarIdx);
if(not( vl_statVarRef==vl_myStatName and vl_statVarIdx>=0) ){ f_EPTF_Base_stop(fail); }
var EPTF_StatHandler_Test_ShClients vlc_shClients :={}
var EPTF_FloatList vl_samplesList :={}
for(var integer i:=1;i<=tsp_StatHandler_Test_nofClients;i:=i+1) {
vlc_shClients[i]:= EPTF_StatHandlerClient_CT.create;
vl_samplesList[i]:= rnd();
vlc_shClients[i].start(f_StatHandler_Test_generalClient(
c_myStatHandlerClient&int2str(i),
vl_myStatName,
vl_statMethod,
{floatlistVal:={vl_samplesList[i]}}, //sample value
-1, //nofSample
vlc_shServer));
}//for
var integer vl_localProviderVarIdx;
var charstring vl_localProviderVarName := "providerVarName";
f_EPTF_Var_newFloat(vl_localProviderVarName, 0.0, vl_localProviderVarIdx);
f_EPTF_StatHandlerClient_registerStat({vl_localProviderVarName}, vl_myStatName, sampledAtSync, -, self, vlc_shServer);
f_StatHandler_Test_wait(tsp_EPTF_Var_SyncInterval + 1.0);
//====checks init value:=====
f_EPTF_Var_getContent(vl_statVarIdx, vl_statValue);
log(">>>vl_statValue: ",vl_statValue, " Expected value: ", 1.0);
f_EPTF_StatHandler_Test_checkFloatEquality( vl_statValue.floatVal, 1.0, 0.001);
//====Calculates stat:=====
var float vl_max:=vl_samplesList[1];
//var integer vl_totalSamples:=0;
//vl_sum:=0.0; vl_totalSamples:=0
for(var integer i:=1;i<=tsp_StatHandler_Test_nofClients;i:=i+1) {
if(vl_max<vl_samplesList[i]) { vl_max:=vl_samplesList[i]}
}
//======== Check the modified stat (y=x, x:=i, mean[i]=1 where i is the i.node======
f_StatHandler_Test_wait(4.0*tsp_EPTF_Var_SyncInterval+1.0);
f_EPTF_Var_getContent(vl_statVarIdx,vl_statValue);
log(">>>vl_statValue: ",vl_statValue," Expected value: ", vl_max);
f_EPTF_StatHandler_Test_checkFloatEquality( vl_statValue.floatVal, vl_max , 0.001);
//====Reseting stat:=====
var boolean vl_res := f_EPTF_StatHandlerClient_resetStatistics(vl_myStatName, vlc_shServer);
if (not vl_res) {
log(">>>can't reset stat");
}
f_StatHandler_Test_wait(4.0*tsp_EPTF_Var_SyncInterval+1.0);
f_EPTF_Var_getContent(vl_statVarIdx,vl_statValue);
log(">>>vl_statValue after reset: ",vl_statValue," Expected value: ", 0.0);
f_EPTF_StatHandler_Test_checkFloatEquality(vl_statValue.floatVal, 0.0 , 0.001);
f_EPTF_Var_adjustContent(vl_localProviderVarIdx, {floatVal:=0.02});
f_StatHandler_Test_wait(4.0*tsp_EPTF_Var_SyncInterval+1.0);
f_EPTF_Var_getContent(vl_statVarIdx,vl_statValue);
log(">>>vl_statValue: ",vl_statValue," Expected value: ", 0.02);
f_EPTF_StatHandler_Test_checkFloatEquality(vl_statValue.floatVal, 0.02 , 0.001);
f_EPTF_Base_cleanup_CT();
}//tc_
}
group StatHandler_BasicTest_UI {
testcase tc_StatHandler_Test_GUI()
runs on SYSTEM_CT
{
var SYSTEM_CT vlc_mycomp:=SYSTEM_CT.create;
vlc_mycomp.start(f_StatHandler_Test_UI_Gui());
f_StatHandler_Test_wait(11.0);
f_EPTF_Base_cleanup_CT();
//if reached this point:
setverdict(pass);
}
testcase tc_StatHandler_Test_customGUI()
runs on SYSTEM_CT
{
var SYSTEM_CT vlc_mycomp:=SYSTEM_CT.create;
vlc_mycomp.start(f_StatHandler_Test_UI_customGui());
f_StatHandler_Test_wait(11.0);
f_EPTF_Base_cleanup_CT();
//if reached this point:
setverdict(pass);
}
testcase tc_StatHandler_Test_dataSourceTest()
runs on SYSTEM_CT
{
var SYSTEM_CT vlc_mycomp:=SYSTEM_CT.create;
vlc_mycomp.start(f_StatHandler_Test_dataSourceTest());
f_StatHandler_Test_wait(11.0);
f_EPTF_Base_cleanup_CT();
//if reached this point:
setverdict(pass);
}
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_DS_Neg_WrongResetComponent
//
// Purpose:
// This is a fake negative test case.
// It tests the DataSourceClient function of StatHandler with this wrong request:
// Data Element: dataElementResetComponent
// Params: too many params
// A proper warning message should appear.
//
///////////////////////////////////////////////////////////
testcase tc_StatHandler_DS_Neg_WrongResetComponent() runs on SYSTEM_CT
{
f_EPTF_StatHandler_Test_wrongDataRequest(c_StatHandler_dataElementResetComponent,
{{"nonexistent", "DefaultEGrp"}});
}
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_DS_Neg_WrongResetAll
//
// Purpose:
// This is a fake negative test case.
// It tests the DataSourceClient function of StatHandler with this wrong request:
// Data Element: dataElementResetAll
// Params: too many params
// A proper warning message should appear.
//
///////////////////////////////////////////////////////////
testcase tc_StatHandler_DS_Neg_WrongResetAll() runs on SYSTEM_CT
{
f_EPTF_StatHandler_Test_wrongDataRequest(c_StatHandler_dataElementResetAll,
{{"nonexistent", "DefaultEGrp"}});
}
} // group StatHandler_BasicTest_UI
group StatHandler_BasicTest_Mean {
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_Test_testMean
//
// Purpose:
// To demo and to test the statistics "Mean" in a simple case
//
// Requirement:
// -
//
// Action:
// The testcase runs on EPTF_StatHandler_CT
//
// Expected Result: The tc is passed if all checks are true
//
///////////////////////////////////////////////////////////
testcase tc_StatHandler_Test_testMean()
runs on EPTF_StatHandler_CT
{
var EPTF_FloatList vl_samples := { 34.0, 27.0, 45.0, 55.0, 22.0, 34.0 };
var EPTF_FloatList vl_samples_part1 := { 34.0, 27.0 };
var EPTF_FloatList vl_samples_part2 := { 45.0, 55.0, 22.0, 34.0 };
f_EPTF_StatHandler_init_CT("MTC");
var EPTF_StatHandlerClient_CT vl_client1 := EPTF_StatHandlerClient_CT.create;
vl_client1.start(f_StatHandler_Test_clientMean(
"StatHandler_Test_clientMean1",
f_StatHandler_Test_getMean(vl_samples_part1),
sizeof(vl_samples_part1),
self));
f_StatHandler_Test_wait(tsp_EPTF_Var_SyncInterval+0.1);
var EPTF_StatHandlerClient_CT vl_client2 := EPTF_StatHandlerClient_CT.create;
vl_client2.start(f_StatHandler_Test_clientMean(
"StatHandler_Test_clientMean2",
f_StatHandler_Test_getMean(vl_samples_part2),
sizeof(vl_samples_part2),
self));
f_StatHandler_Test_wait(tsp_EPTF_Var_SyncInterval + 1.0);
var EPTF_Var_DirectContent vl_content;
f_EPTF_Var_getContent(f_EPTF_Var_getId("MyMean"), vl_content);
var float vl_mean := f_StatHandler_Test_getMean(vl_samples);
var float vl_maxRoundError := 0.000001;
if(vl_content.floatVal > vl_mean-vl_maxRoundError and
vl_content.floatVal < vl_mean+vl_maxRoundError) {
setverdict(pass);
} else {
setverdict(fail);
}
f_EPTF_Base_cleanup_CT();
}
} // group StatHandler_BasicTest_Mean
} // group StatHandler_BasicTest
//================================================================
// Regression Test
//================================================================
group RegressionTest {
//================================================================
// Init and Cleanup Test
//================================================================
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_Test_masterInitCleanup
//
// Purpose:
// To test f_EPTF_StatHandler_init_CT and f_EPTF_Base_cleanup_CT
//
// Requirement:
// -
//
// Action:
// The testcase runs on EPTF_StatHandler_CT
//
// Expected Result: The tc is passed if all checks are true
//
///////////////////////////////////////////////////////////
// FIXME: removed because of private component variables
/* testcase tc_StatHandler_Test_masterInitCleanup() runs on EPTF_StatHandler_CT {
f_EPTF_StatHandler_init_CT(c_myTestName);
f_EPTF_StatHandler_Test_checkMasterInit(c_myTestName);
f_EPTF_Base_cleanup_CT();
f_EPTF_StatHandler_Test_checkMasterCleanup(c_myTestName);
f_EPTF_StatHandler_init_CT(c_myTestName);
f_EPTF_StatHandler_Test_checkMasterInit(c_myTestName);
f_EPTF_Base_cleanup_CT();
f_EPTF_StatHandler_Test_checkMasterCleanup(c_myTestName)
}//tc
*/
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_Test_clientInitCleanup
//
// Purpose:
// To test f_EPTF_StatHandlerClient_init_CT
//
// Requirement:
// -
//
// Action:
// The testcase runs on EPTF_StatMeasure_Test_CT. Steps:
//
// Expected Result: The tc is passed if all checks are true
//
///////////////////////////////////////////////////////////
// FIXME: removed because of private component variables
/* testcase tc_StatHandler_Test_clientInitCleanup() runs on EPTF_StatHandlerClient_CT {
f_EPTF_StatHandlerClient_init_CT(c_myTestName);
f_EPTF_StatHandler_Test_checkClientInit(c_myTestName);
f_EPTF_Base_cleanup_CT();
f_EPTF_StatHandler_Test_checkClientCleanup(c_myTestName);
f_EPTF_StatHandlerClient_init_CT(c_myTestName);
f_EPTF_StatHandler_Test_checkClientInit(c_myTestName);
f_EPTF_Base_cleanup_CT();
f_EPTF_StatHandler_Test_checkClientCleanup(c_myTestName);
}//tc_
*/
//================================================================
// Testcases for Stat Handler Master
//================================================================
//--not implemented--
//================================================================
// Testcases for Stat Handler Client
//================================================================
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_Test_declareStat
//
// Purpose:
// To test f_EPTF_StatHandlerClient_declareStat and f_EPTF_StatHandlerClient_getStatVariableRef.
//
// Requirement:
// -
//
// Action:
// The testcase runs on EPTF_StatHandlerClient_CT.
// 1. Init the client
// 2. creates and starts the server
// 3. Declare a new stat as "Mean"
// 4. Check if the variable reference of the stat can be retrieved
// 5. Check if it is possible to subscribe for the variable reference
// Expected Result: The tc is passed if all checks are true
//
///////////////////////////////////////////////////////////
testcase tc_StatHandler_Test_declareStat() runs on EPTF_StatHandlerClient_CT {
var charstring vl_myStatName:="MyStat";
f_EPTF_StatHandlerClient_init_CT(c_myStatHandlerClient);
var EPTF_StatHandler_CT vlc_shServer:= EPTF_StatHandler_CT. create;
vlc_shServer.start(f_EPTF_StatHandler_Test_MasterBehavior(c_myStatHandlerMaster));
var boolean vl_success:=f_EPTF_StatHandlerClient_declareStat(vl_myStatName,"Mean", {floatVal:=0.0},vlc_shServer);
if(not vl_success) {
setverdict(fail);
} else {
var charstring vl_statVarRef:=f_EPTF_StatHandlerClient_getStatVariableRef(vl_myStatName,vlc_shServer);
var integer vl_statVarIdx:=-1;
f_EPTF_Var_subscribeRemote(vlc_shServer,vl_statVarRef,realtime,vl_statVarIdx);
log(">>>vl_statVarRef: ", vl_statVarRef," vl_statVarIdx: ",vl_statVarIdx);
if(vl_statVarRef==vl_myStatName and vl_statVarIdx>=0) {
setverdict(pass);
} else {
setverdict(fail);
}
}
f_EPTF_Base_cleanup_CT();
}//tc
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_Test_mean
//
// Purpose:
// To test f_EPTF_StatHandlerClient_registerStat_mean
//
// Requirement:
// -
//
// Action:
// The testcase runs on EPTF_StatHandlerClient_CT.
// 1 The testcase runs on EPTF_StatHandlerClient_CT. The steps are
// 2 Inits the client
// 3 Creates and Inits a server
// 4 Declares a new stat as "Mean"
// 5 Checks if the variable reference of the stat can be retrieved
// 6 Checks if it is possible to subscribe for the variable reference
// 7 Registers n pieces of statistics source
// 8 Calculates the expected result
// 9 Get the content and compare with the expected results
// Expected Result: The tc is passed if all checks are true
//
///////////////////////////////////////////////////////////
testcase tc_StatHandler_Test_mean() runs on EPTF_StatHandlerClient_CT {
var charstring vl_myStatName:="MyStat";
f_EPTF_StatHandlerClient_init_CT(c_myStatHandlerClient);
var EPTF_StatHandler_CT vlc_shServer:= EPTF_StatHandler_CT. create;
vlc_shServer.start(f_EPTF_StatHandler_Test_MasterBehavior(c_myStatHandlerMaster));
//==== Statistics part ====
var charstring vl_statMethod := "Mean";
var boolean vl_success:=f_EPTF_StatHandlerClient_declareStat(vl_myStatName,vl_statMethod, {floatVal:=0.0},vlc_shServer);
if(not vl_success) { f_EPTF_Base_stop(fail); }
var charstring vl_statVarRef:=f_EPTF_StatHandlerClient_getStatVariableRef(vl_myStatName,vlc_shServer);
var integer vl_statVarIdx:=-1;
var EPTF_Var_DirectContent vl_statValue;
f_EPTF_Var_subscribeRemote(vlc_shServer,vl_statVarRef,sampledAtSync,vl_statVarIdx);
log(">>>vl_statVarRef: ", vl_statVarRef," vl_statVarIdx: ",vl_statVarIdx);
if(not( vl_statVarRef==vl_myStatName and vl_statVarIdx>=0) ){ f_EPTF_Base_stop(fail); }
var EPTF_IntegerList vl_varIdxs :={}, vl_samplesIdxs:={};
var float vl_value:=0.0, vl_sum:=0.0;
var integer vl_totalSamples:=0;
var integer vl_samples:=0;
var charstring vl_varName:="", vl_samplesName:=""
//register variables:
for(var integer i:=1;i<=tsp_StatHandler_Test_nofClients;i:=i+1) {
vl_varName:="floatVal_"&int2str(i);
vl_samplesName:="samples_"&int2str(i);
f_EPTF_Var_newFloat(vl_varName,1.0, vl_varIdxs[i]);
f_EPTF_Var_newInt( vl_samplesName, i, vl_samplesIdxs[i]);
f_EPTF_StatHandlerClient_registerStat(
{vl_varName, vl_samplesName},
vl_myStatName,
sampledAtSync,
true, //wait
self,
vlc_shServer);
}//for
//======== Check the init stat (y=x, x:=i, mean[i]=1 where i is the i.node======
f_StatHandler_Test_wait(2.0*tsp_EPTF_Var_SyncInterval+0.1);
f_EPTF_Var_getContent(vl_statVarIdx,vl_statValue);
log(">>>vl_statValue: ",vl_statValue); //expected:1.0
f_EPTF_StatHandler_Test_checkFloatEquality( vl_statValue.floatVal, 1.0, 0.001);
//======== Stat for y=x*x, x=i mean[i]=i where i is the i. node ================
//modify:
vl_sum:=0.0; vl_totalSamples:=0
for(var integer i:=1;i<=tsp_StatHandler_Test_nofClients;i:=i+1) {
vl_value:=int2float(i)
f_EPTF_Var_adjustContent(vl_varIdxs[i],{floatVal:=vl_value});
vl_sum:=vl_sum+vl_value*vl_value; //vl_value==vl_samplesIdxs[i]
vl_totalSamples:=vl_totalSamples+i;
}
vl_sum:=vl_sum/int2float(vl_totalSamples);
//wait:
f_StatHandler_Test_wait(2.0*tsp_EPTF_Var_SyncInterval+0.1);
//check:
f_EPTF_Var_getContent(vl_statVarIdx,vl_statValue);
log(">>>vl_statValue 2: ",vl_statValue);
log(">>>Expected value: ",vl_sum);
f_EPTF_StatHandler_Test_checkFloatEquality( vl_statValue.floatVal, vl_sum, 0.001);
//======== Stat for y=rnd(), x=i mean[i]=rnd() where i is the i. node ================
log("========= Random statistics=========");
vl_sum:=0.0; vl_totalSamples:=0;
for(var integer i:=1;i<=tsp_StatHandler_Test_nofClients;i:=i+1) {
vl_value:=rnd()/int2float(i);
f_EPTF_Var_adjustContent(vl_varIdxs[i],{floatVal:=vl_value});
vl_sum:=vl_sum+vl_value*int2float(i); //vl_value==vl_samplesIdxs[i]
vl_totalSamples:=vl_totalSamples+i;
}
vl_sum:=vl_sum/int2float(vl_totalSamples);
f_StatHandler_Test_wait(5.1);
f_EPTF_Var_getContent(vl_statVarIdx,vl_statValue);
log(">>>vl_statValue 3: ",vl_statValue); //expected:1.0
log(">>>Expected value: ",vl_sum);
f_EPTF_StatHandler_Test_checkFloatEquality( vl_statValue.floatVal, vl_sum, 0.001);
f_EPTF_Base_cleanup_CT();
}//tc
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_Test_mean_moreClients
//
// Purpose:
// To test f_EPTF_StatHandlerClient_registerStat
//
// Requirement:
// -
//
// Action:
// The testcase runs on EPTF_StatHandlerClient_CT.
// 1. Init a server
// 2. Init n clients
// 3. Create a stat from the client
// 4. Subscribe for the statistics
// 5. Init n pieces of clients, pass to each the sample value and the number of samples
// Each client register a variable with initial value and modifies it after waiting "sync interval+0.1s"
// 6. After 2*sync.time get the value of the stat
// 4. Check if the value is the expected
// Expected Result: The tc is passed if the checks is true
//
///////////////////////////////////////////////////////////
testcase tc_StatHandler_Test_mean_moreClients() runs on EPTF_StatHandlerClient_CT {
var charstring vl_myStatName:="MyStat";
f_EPTF_StatHandlerClient_init_CT(c_myStatHandlerClient);
var EPTF_StatHandler_CT vlc_shServer:= EPTF_StatHandler_CT. create;
vlc_shServer.start(f_EPTF_StatHandler_Test_MasterBehavior(c_myStatHandlerMaster));
//==== Statistics part ====
var charstring vl_statMethod := c_EPTF_StatHandler_Method_Mean;
var boolean vl_success:=f_EPTF_StatHandlerClient_declareStat(vl_myStatName,vl_statMethod, {floatVal:=0.0},vlc_shServer);
if(not vl_success) { f_EPTF_Base_stop(fail); }
var charstring vl_statVarRef:=f_EPTF_StatHandlerClient_getStatVariableRef(vl_myStatName,vlc_shServer);
var integer vl_statVarIdx:=-1;
var EPTF_Var_DirectContent vl_statValue;
f_EPTF_Var_subscribeRemote(vlc_shServer,vl_statVarRef,sampledAtSync,vl_statVarIdx);
log(">>>vl_statVarRef: ", vl_statVarRef," vl_statVarIdx: ",vl_statVarIdx);
if(not( vl_statVarRef==vl_myStatName and vl_statVarIdx>=0) ){ f_EPTF_Base_stop(fail); }
var EPTF_StatHandler_Test_ShClients vlc_shClients :={}
var EPTF_FloatList vl_samplesList :={}
for(var integer i:=1;i<=tsp_StatHandler_Test_nofClients;i:=i+1) {
vlc_shClients[i]:= EPTF_StatHandlerClient_CT.create;
vl_samplesList[i]:= int2float(i);
vlc_shClients[i].start(f_StatHandler_Test_generalClient(
c_myStatHandlerClient&int2str(i),
vl_myStatName,
vl_statMethod,
{ floatlistVal:={vl_samplesList[i]}}, //sample value
i, //nofSample
vlc_shServer));
}//for
f_StatHandler_Test_wait(tsp_EPTF_Var_SyncInterval + 1.0);
//====checks init value:=====
f_EPTF_Var_getContent(vl_statVarIdx,vl_statValue);
log(">>>vl_statValue: ",vl_statValue);
log(">>>Expected value: ",1.0)
f_EPTF_StatHandler_Test_checkFloatEquality( vl_statValue.floatVal, 1.0, 0.001);
//====Calculates stat:=====
var float vl_sum:=0.0;
var integer vl_totalSamples:=0;
vl_sum:=0.0; vl_totalSamples:=0
for(var integer i:=1;i<=tsp_StatHandler_Test_nofClients;i:=i+1) {
vl_sum:=vl_sum+vl_samplesList[i]*int2float(i); //vl_value==vl_samplesIdxs[i]
vl_totalSamples:=vl_totalSamples+i;
}
vl_sum:=vl_sum/int2float(vl_totalSamples);
//======== Check the modified stat (y=x, x:=i, mean[i]=1 where i is the i.node======
f_StatHandler_Test_wait(4.0*tsp_EPTF_Var_SyncInterval+1.0);
f_EPTF_Var_getContent(vl_statVarIdx,vl_statValue);
log(">>>vl_statValue: ",vl_statValue," Expected value: ",vl_sum);
f_EPTF_StatHandler_Test_checkFloatEquality( vl_statValue.floatVal, vl_sum, 0.001);
f_EPTF_Base_cleanup_CT();
}//tc_
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_Test_globalAverage_moreClients
//
// Purpose:
// To test global average calculation
//
// Requirement:
// -
//
// Action:
// The testcase runs on EPTF_StatHandlerClient_CT.
// 1. Init a server
// 2. Init n clients
// 3. Create a stat from the client
// 4. Subscribe for the statistics
// 5. Init n pieces of clients, pass to each the sample value and the number of samples
// Each client register a variable with initial value and modifies it after waiting "sync interval+0.1s"
// 6. After 2*sync.time+1.0 sec get the value of the stat
// 4. Check if the value is the expected
// Expected Result: The tc is passed if the checks is true
//
///////////////////////////////////////////////////////////
testcase tc_StatHandler_Test_globalAverage_moreClients() runs on EPTF_StatHandlerClient_CT {
var charstring vl_myStatName:="MyStat";
f_EPTF_StatHandlerClient_init_CT(c_myStatHandlerClient);
var EPTF_StatHandler_CT vlc_shServer:= EPTF_StatHandler_CT. create;
vlc_shServer.start(f_EPTF_StatHandler_Test_MasterBehavior(c_myStatHandlerMaster));
//==== Statistics part ====
var charstring vl_statMethod := c_EPTF_StatHandler_Method_GlobalAverage;
var boolean vl_success:=f_EPTF_StatHandlerClient_declareStat(vl_myStatName,vl_statMethod, {floatVal:=0.0},vlc_shServer);
if(not vl_success) { f_EPTF_Base_stop(fail); }
var charstring vl_statVarRef:=f_EPTF_StatHandlerClient_getStatVariableRef(vl_myStatName,vlc_shServer);
var integer vl_statVarIdx:=-1;
var EPTF_Var_DirectContent vl_statValue;
f_EPTF_Var_subscribeRemote(vlc_shServer,vl_statVarRef,sampledAtSync,vl_statVarIdx);
log(">>>vl_statVarRef: ", vl_statVarRef," vl_statVarIdx: ",vl_statVarIdx);
if(not( vl_statVarRef==vl_myStatName and vl_statVarIdx>=0) ){ f_EPTF_Base_stop(fail); }
var EPTF_StatHandler_Test_ShClients vlc_shClients :={}
var EPTF_FloatList vl_samplesList :={}
for(var integer i:=1;i<=tsp_StatHandler_Test_nofClients;i:=i+1) {
vlc_shClients[i]:= EPTF_StatHandlerClient_CT.create;
vl_samplesList[i]:= int2float(i);
vlc_shClients[i].start(f_StatHandler_Test_generalClient(
c_myStatHandlerClient&int2str(i),
vl_myStatName,
vl_statMethod,
{ floatlistVal:={vl_samplesList[i]}}, //sample value
i, //nofSample
vlc_shServer));
}//for
f_StatHandler_Test_wait(tsp_EPTF_Var_SyncInterval + 1.0);
var integer vl_totalSamples:=0;
//==calulates init stat:==
for(var integer i:=1;i<=tsp_StatHandler_Test_nofClients;i:=i+1) {
vl_totalSamples:=vl_totalSamples+i;
}
//====checks init value:=====
f_EPTF_Var_getContent(vl_statVarIdx,vl_statValue);
log(">>>vl_statValue: ",vl_statValue);
log(">>>Expected value: ",int2float(tsp_StatHandler_Test_nofClients)/int2float(vl_totalSamples))
f_EPTF_StatHandler_Test_checkFloatEquality(
vl_statValue.floatVal, int2float(tsp_StatHandler_Test_nofClients)/int2float(vl_totalSamples), 0.001);
//====Calculates final stat:=====
var float vl_sum:=0.0;
vl_sum:=0.0;
for(var integer i:=1;i<=tsp_StatHandler_Test_nofClients;i:=i+1) {
vl_sum:=vl_sum+vl_samplesList[i]; //vl_value==vl_samplesIdxs[i]
}
vl_sum:=vl_sum/int2float(vl_totalSamples);
//======== Check the modified stat (y=x, x:=i, mean[i]=1 where i is the i.node======
f_StatHandler_Test_wait(4.0*tsp_EPTF_Var_SyncInterval+1.0);
f_EPTF_Var_getContent(vl_statVarIdx,vl_statValue);
log(">>>vl_statValue: ",vl_statValue," Expected value: ",vl_sum);
f_EPTF_StatHandler_Test_checkFloatEquality( vl_statValue.floatVal, vl_sum, 0.001);
f_EPTF_Base_cleanup_CT();
}//tc_
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_Test_min_moreClients
//
// Purpose:
// To test f_EPTF_StatHandlerClient_registerStat
//
// Requirement:
// -
//
// Action:
// The testcase runs on EPTF_StatHandlerClient_CT.
// 1. Init a server
// 2. Init n clients
// 3. Create a stat from the client
// 4. Subscribe for the statistics
// 5. Init n pieces of clients, pass to each the sample value and the number of samples
// Each client register a variable with initial value and modifies it after waiting "sync interval+0.1s"
// 6. After 2*sync.time+1.0 sec get the value of the stat
// 4. Check if the value is the expected
// Expected Result: The tc is passed if the checks is true
//
///////////////////////////////////////////////////////////
testcase tc_StatHandler_Test_min_moreClients() runs on EPTF_StatHandlerClient_CT {
var charstring vl_myStatName:="MyStat";
f_EPTF_StatHandlerClient_init_CT(c_myStatHandlerClient);
var EPTF_StatHandler_CT vlc_shServer:= EPTF_StatHandler_CT. create;
vlc_shServer.start(f_EPTF_StatHandler_Test_MasterBehavior(c_myStatHandlerMaster));
//==== Statistics part ====
var charstring vl_statMethod := "Min";// c_EPTF_StatHandler_Method_Min
var boolean vl_success:=f_EPTF_StatHandlerClient_declareStat(vl_myStatName,vl_statMethod, {floatVal:=0.0},vlc_shServer);
if(not vl_success) { f_EPTF_Base_stop(fail); }
var charstring vl_statVarRef:=f_EPTF_StatHandlerClient_getStatVariableRef(vl_myStatName,vlc_shServer);
var integer vl_statVarIdx:=-1;
var EPTF_Var_DirectContent vl_statValue;
f_EPTF_Var_subscribeRemote(vlc_shServer,vl_statVarRef,sampledAtSync,vl_statVarIdx);
log(">>>vl_statVarRef: ", vl_statVarRef," vl_statVarIdx: ",vl_statVarIdx);
if(not( vl_statVarRef==vl_myStatName and vl_statVarIdx>=0) ){ f_EPTF_Base_stop(fail); }
var EPTF_StatHandler_Test_ShClients vlc_shClients :={}
var EPTF_FloatList vl_samplesList :={}
for(var integer i:=1;i<=tsp_StatHandler_Test_nofClients;i:=i+1) {
vlc_shClients[i]:= EPTF_StatHandlerClient_CT.create;
vl_samplesList[i]:= rnd();
vlc_shClients[i].start(f_StatHandler_Test_generalClient(
c_myStatHandlerClient&int2str(i),
vl_myStatName,
vl_statMethod,
{ floatlistVal:={vl_samplesList[i]}}, //sample value
-1, //nofSample
vlc_shServer));
}//for
f_StatHandler_Test_wait(tsp_EPTF_Var_SyncInterval + 1.0);
//====checks init value:=====
f_EPTF_Var_getContent(vl_statVarIdx, vl_statValue);
log(">>>vl_statValue: ",vl_statValue, " Expected value: ", 1.0);
f_EPTF_StatHandler_Test_checkFloatEquality( vl_statValue.floatVal, 1.0, 0.001);
//====Calculates stat:=====
var float vl_min:=vl_samplesList[1];
//var integer vl_totalSamples:=0;
//vl_sum:=0.0; vl_totalSamples:=0
for(var integer i:=1;i<=tsp_StatHandler_Test_nofClients;i:=i+1) {
if(vl_min>vl_samplesList[i]) { vl_min:=vl_samplesList[i]}
}
//======== Check the modified stat (y=x, x:=i, mean[i]=1 where i is the i.node======
f_StatHandler_Test_wait(4.0*tsp_EPTF_Var_SyncInterval+1.0);
f_EPTF_Var_getContent(vl_statVarIdx,vl_statValue);
log(">>>vl_statValue: ",vl_statValue," Expected value: ", vl_min);
f_EPTF_StatHandler_Test_checkFloatEquality( vl_statValue.floatVal, vl_min , 0.001);
f_EPTF_Base_cleanup_CT();
}//tc_
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_Test_intMin_moreClients
//
// Purpose:
// To test f_EPTF_StatHandlerClient_registerStat
//
// Requirement:
// -
//
// Action:
// The testcase runs on EPTF_StatHandlerClient_CT.
// 1. Init a server
// 2. Init n clients
// 3. Create a stat from the client
// 4. Subscribe for the statistics
// 5. Init n pieces of clients, pass to each the sample value and the number of samples
// Each client register a variable with initial value and modifies it after waiting "sync interval+0.1s"
// 6. After 2*sync.time+1.0 sec get the value of the stat
// 4. Check if the value is the expected
// Expected Result: The tc is passed if the checks is true
//
///////////////////////////////////////////////////////////
testcase tc_StatHandler_Test_intMin_moreClients() runs on EPTF_StatHandlerClient_CT {
var charstring vl_myStatName:="MyStat";
f_EPTF_StatHandlerClient_init_CT(c_myStatHandlerClient);
var EPTF_StatHandler_CT vlc_shServer:= EPTF_StatHandler_CT. create;
vlc_shServer.start(f_EPTF_StatHandler_Test_MasterBehavior(c_myStatHandlerMaster));
//==== Statistics part ====
var charstring vl_statMethod := "Min";// c_EPTF_StatHandler_Method_Min
var boolean vl_success:=f_EPTF_StatHandlerClient_declareStat(vl_myStatName,vl_statMethod, {intVal:=0},vlc_shServer);
if(not vl_success) { f_EPTF_Base_stop(fail); }
var charstring vl_statVarRef:=f_EPTF_StatHandlerClient_getStatVariableRef(vl_myStatName,vlc_shServer);
var integer vl_statVarIdx:=-1;
var EPTF_Var_DirectContent vl_statValue;
f_EPTF_Var_subscribeRemote(vlc_shServer,vl_statVarRef,sampledAtSync,vl_statVarIdx);
log(">>>vl_statVarRef: ", vl_statVarRef," vl_statVarIdx: ",vl_statVarIdx);
if(not( vl_statVarRef==vl_myStatName and vl_statVarIdx>=0) ){ f_EPTF_Base_stop(fail); }
var EPTF_StatHandler_Test_ShClients vlc_shClients :={}
var EPTF_IntegerList vl_samplesList :={-1}
for(var integer i:=1;i<=tsp_StatHandler_Test_nofClients;i:=i+1) {
vlc_shClients[i]:= EPTF_StatHandlerClient_CT.create;
vl_samplesList[i]:= i;
vlc_shClients[i].start(f_StatHandler_Test_generalClient(
c_myStatHandlerClient&int2str(i),
vl_myStatName,
vl_statMethod,
{ intVal:=vl_samplesList[i]},//sample value
-1, //nofSample
vlc_shServer));
}//for
f_StatHandler_Test_wait(4.0*tsp_EPTF_Var_SyncInterval+1.0);
//====checks init value:=====
f_EPTF_Var_getContent(vl_statVarIdx, vl_statValue);
log(">>>vl_statValue: ",vl_statValue, " Expected value: ", 1 );
//f_EPTF_StatHandler_Test_checkFloatEquality( vl_statValue.integerlistVal, 1.0, 0.001);
//====Calculates stat:=====
var integer vl_min:=vl_samplesList[1];
//var integer vl_totalSamples:=0;
//vl_sum:=0.0; vl_totalSamples:=0
for(var integer i:=1;i<=tsp_StatHandler_Test_nofClients;i:=i+1) {
if(vl_min>vl_samplesList[i]) { vl_min:=vl_samplesList[i]}
}
//======== Check the modified stat (y=x, x:=i, mean[i]=1 where i is the i.node======
f_StatHandler_Test_wait(4.0*tsp_EPTF_Var_SyncInterval+1.0);
f_EPTF_Var_getContent(vl_statVarIdx,vl_statValue);
log(">>>Sample values: ", vl_samplesList);
log(">>>vl_statValue: ",vl_statValue," Expected value: ", vl_min);
f_EPTF_StatHandler_Test_setverdictFromBool(ischosen(vl_statValue.intVal) and vl_statValue.intVal==vl_min);
f_EPTF_Base_cleanup_CT();
}//tc_
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_Test_max_moreClients
//
// Purpose:
// To test f_EPTF_StatHandlerClient_registerStat
//
// Requirement:
// -
//
// Action:
// The testcase runs on EPTF_StatHandlerClient_CT.
// 1. Init a server
// 2. Init n clients
// 3. Create a stat from the client
// 4. Subscribe for the statistics
// 5. Init n pieces of clients, pass to each the sample value and the number of samples
// Each client register a variable with initial value and modifies it after waiting "sync interval+0.1s"
// 6. After 2*sync.time get the value of the stat
// 4. Check if the value is the expected
// Expected Result: The tc is passed if the checks is true
//
///////////////////////////////////////////////////////////
testcase tc_StatHandler_Test_max_moreClients() runs on EPTF_StatHandlerClient_CT {
var charstring vl_myStatName:="MyStat";
f_EPTF_StatHandlerClient_init_CT(c_myStatHandlerClient);
var EPTF_StatHandler_CT vlc_shServer:= EPTF_StatHandler_CT. create;
vlc_shServer.start(f_EPTF_StatHandler_Test_MasterBehavior(c_myStatHandlerMaster));
//==== Statistics part ====
var charstring vl_statMethod := c_EPTF_StatHandler_Method_Max;
var boolean vl_success:=f_EPTF_StatHandlerClient_declareStat(vl_myStatName,vl_statMethod, {floatVal:=0.0},vlc_shServer);
if(not vl_success) { f_EPTF_Base_stop(fail); }
var charstring vl_statVarRef:=f_EPTF_StatHandlerClient_getStatVariableRef(vl_myStatName,vlc_shServer);
var integer vl_statVarIdx:=-1;
var EPTF_Var_DirectContent vl_statValue;
f_EPTF_Var_subscribeRemote(vlc_shServer,vl_statVarRef,sampledAtSync,vl_statVarIdx);
log(">>>vl_statVarRef: ", vl_statVarRef," vl_statVarIdx: ",vl_statVarIdx);
if(not( vl_statVarRef==vl_myStatName and vl_statVarIdx>=0) ){ f_EPTF_Base_stop(fail); }
var EPTF_StatHandler_Test_ShClients vlc_shClients :={}
var EPTF_FloatList vl_samplesList :={}
for(var integer i:=1;i<=tsp_StatHandler_Test_nofClients;i:=i+1) {
vlc_shClients[i]:= EPTF_StatHandlerClient_CT.create;
vl_samplesList[i]:= rnd();
vlc_shClients[i].start(f_StatHandler_Test_generalClient(
c_myStatHandlerClient&int2str(i),
vl_myStatName,
vl_statMethod,
{floatlistVal:={vl_samplesList[i]}}, //sample value
-1, //nofSample
vlc_shServer));
}//for
f_StatHandler_Test_wait(tsp_EPTF_Var_SyncInterval + 1.0);
//====checks init value:=====
f_EPTF_Var_getContent(vl_statVarIdx, vl_statValue);
log(">>>vl_statValue: ",vl_statValue, " Expected value: ", 1.0);
f_EPTF_StatHandler_Test_checkFloatEquality( vl_statValue.floatVal, 1.0, 0.001);
//====Calculates stat:=====
var float vl_max:=vl_samplesList[1];
//var integer vl_totalSamples:=0;
//vl_sum:=0.0; vl_totalSamples:=0
for(var integer i:=1;i<=tsp_StatHandler_Test_nofClients;i:=i+1) {
if(vl_max<vl_samplesList[i]) { vl_max:=vl_samplesList[i]}
}
//======== Check the modified stat (y=x, x:=i, mean[i]=1 where i is the i.node======
f_StatHandler_Test_wait(4.0*tsp_EPTF_Var_SyncInterval+1.0);
f_EPTF_Var_getContent(vl_statVarIdx,vl_statValue);
log(">>>vl_statValue: ",vl_statValue," Expected value: ", vl_max);
f_EPTF_StatHandler_Test_checkFloatEquality( vl_statValue.floatVal, vl_max , 0.001);
f_EPTF_Base_cleanup_CT();
}//tc_
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_Test_intMax_moreClients
//
// Purpose:
// To test f_EPTF_StatHandlerClient_registerStat
//
// Requirement:
// -
//
// Action:
// The testcase runs on EPTF_StatHandlerClient_CT.
// 1. Init a server
// 2. Init n clients
// 3. Create a stat from the client
// 4. Subscribe for the statistics
// 5. Init n pieces of clients, pass to each the sample value and the number of samples
// Each client register a variable with initial value and modifies it after waiting "sync interval+0.1s"
// 6. After 2*sync.time get the value of the stat
// 4. Check if the value is the expected
// Expected Result: The tc is passed if the checks is true
//
///////////////////////////////////////////////////////////
testcase tc_StatHandler_Test_intMax_moreClients() runs on EPTF_StatHandlerClient_CT {
var charstring vl_myStatName:="MyStat";
f_EPTF_StatHandlerClient_init_CT(c_myStatHandlerClient);
var EPTF_StatHandler_CT vlc_shServer:= EPTF_StatHandler_CT. create;
vlc_shServer.start(f_EPTF_StatHandler_Test_MasterBehavior(c_myStatHandlerMaster));
//==== Statistics part ====
var charstring vl_statMethod := "Max";// c_EPTF_StatHandler_Method_Min
var boolean vl_success:=f_EPTF_StatHandlerClient_declareStat(vl_myStatName,vl_statMethod, {intVal:=0},vlc_shServer);
if(not vl_success) { f_EPTF_Base_stop(fail); }
var charstring vl_statVarRef:=f_EPTF_StatHandlerClient_getStatVariableRef(vl_myStatName,vlc_shServer);
var integer vl_statVarIdx:=-1;
var EPTF_Var_DirectContent vl_statValue;
f_EPTF_Var_subscribeRemote(vlc_shServer,vl_statVarRef,sampledAtSync,vl_statVarIdx);
//log(">>>vl_statVarRef: ", vl_statVarRef," vl_statVarIdx: ",vl_statVarIdx);
if(not( vl_statVarRef==vl_myStatName and vl_statVarIdx>=0) ){ f_EPTF_Base_stop(fail); }
var EPTF_StatHandler_Test_ShClients vlc_shClients :={}
var EPTF_IntegerList vl_samplesList :={-1}
for(var integer i:=1;i<=tsp_StatHandler_Test_nofClients;i:=i+1) {
vlc_shClients[i]:= EPTF_StatHandlerClient_CT.create;
vl_samplesList[i]:= i;
vlc_shClients[i].start(f_StatHandler_Test_generalClient(
c_myStatHandlerClient&int2str(i),
vl_myStatName,
vl_statMethod,
{ intVal:=vl_samplesList[i]},//sample value
-1, //nofSample
vlc_shServer));
}//for
f_StatHandler_Test_wait(tsp_EPTF_Var_SyncInterval + 1.0);
//====checks init value:=====
f_EPTF_Var_getContent(vl_statVarIdx, vl_statValue);
log(">>>vl_statValue: ",vl_statValue, " Expected value: ", 0);
f_EPTF_StatHandler_Test_setverdictFromBool(ischosen(vl_statValue.intVal) and vl_statValue.intVal==0);
//====Calculates stat:=====
var integer vl_max:=vl_samplesList[1];
//var integer vl_totalSamples:=0;
//vl_sum:=0.0; vl_totalSamples:=0
for(var integer i:=1;i<=tsp_StatHandler_Test_nofClients;i:=i+1) {
if(vl_max<vl_samplesList[i]) { vl_max:=vl_samplesList[i]}
}
//======== Check the modified stat (y=x, x:=i, mean[i]=1 where i is the i.node======
f_StatHandler_Test_wait(4.0*tsp_EPTF_Var_SyncInterval+1.0);
f_EPTF_Var_getContent(vl_statVarIdx,vl_statValue);
log(">>>Sample values: ", vl_samplesList);
log(">>>vl_statValue: ",vl_statValue," Expected value: ", vl_max);
f_EPTF_StatHandler_Test_setverdictFromBool(ischosen(vl_statValue.intVal) and vl_statValue.intVal==vl_max);
f_EPTF_Base_cleanup_CT();
}//tc_
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_Test_sum_moreClients
//
// Purpose:
// To test f_EPTF_StatHandlerClient_registerStat
//
// Requirement:
// -
//
// Action:
// The testcase runs on EPTF_StatHandlerClient_CT.
// 1. Init a server
// 2. Init n clients
// 3. Create a stat from the client
// 4. Subscribe for the statistics
// 5. Init n pieces of clients, pass to each the sample value and the number of samples
// Each client register a variable with initial value and modifies it after waiting "sync interval+0.1s"
// 6. After 2*sync.time get the value of the stat
// 4. Check if the value is the expected
// Expected Result: The tc is passed if the checks is true
//
///////////////////////////////////////////////////////////
testcase tc_StatHandler_Test_sum_moreClients() runs on EPTF_StatHandlerClient_CT {
var charstring vl_myStatName:="MyStat";
f_EPTF_StatHandlerClient_init_CT(c_myStatHandlerClient);
var EPTF_StatHandler_CT vlc_shServer:= EPTF_StatHandler_CT. create;
vlc_shServer.start(f_EPTF_StatHandler_Test_MasterBehavior(c_myStatHandlerMaster));
//==== Statistics part ====
var charstring vl_statMethod := c_EPTF_StatHandler_Method_Sum;
var boolean vl_success:=f_EPTF_StatHandlerClient_declareStat(vl_myStatName,vl_statMethod, {floatVal:=0.0},vlc_shServer);
if(not vl_success) { f_EPTF_Base_stop(fail); }
var charstring vl_statVarRef:=f_EPTF_StatHandlerClient_getStatVariableRef(vl_myStatName,vlc_shServer);
var integer vl_statVarIdx:=-1;
var EPTF_Var_DirectContent vl_statValue;
f_EPTF_Var_subscribeRemote(vlc_shServer,vl_statVarRef,sampledAtSync,vl_statVarIdx);
log(">>>vl_statVarRef: ", vl_statVarRef," vl_statVarIdx: ",vl_statVarIdx);
if(not( vl_statVarRef==vl_myStatName and vl_statVarIdx>=0) ){ f_EPTF_Base_stop(fail); }
var EPTF_StatHandler_Test_ShClients vlc_shClients :={}
var EPTF_FloatList vl_samplesList :={}
for(var integer i:=1;i<=tsp_StatHandler_Test_nofClients;i:=i+1) {
vlc_shClients[i]:= EPTF_StatHandlerClient_CT.create;
vl_samplesList[i]:= rnd();
vlc_shClients[i].start(f_StatHandler_Test_generalClient(
c_myStatHandlerClient&int2str(i),
vl_myStatName,
vl_statMethod,
{floatlistVal:={vl_samplesList[i]}}, //sample value
-1, //nofSample
vlc_shServer));
}//for
f_StatHandler_Test_wait(tsp_EPTF_Var_SyncInterval + 1.0);
//====checks init value:=====
f_EPTF_Var_getContent(vl_statVarIdx, vl_statValue);
log(">>>vl_statValue: ",vl_statValue, " Expected value: ", 1.0);
f_EPTF_StatHandler_Test_checkFloatEquality( vl_statValue.floatVal, 1.0*int2float(tsp_StatHandler_Test_nofClients), 0.001);
//====Calculates stat:=====
var float vl_sum:=0.0;
//var integer vl_totalSamples:=0;
//vl_sum:=0.0; vl_totalSamples:=0
for(var integer i:=1;i<=tsp_StatHandler_Test_nofClients;i:=i+1) {
vl_sum:=vl_sum+vl_samplesList[i];
}
//======== Check the modified stat (y=x, x:=i, mean[i]=1 where i is the i.node======
f_StatHandler_Test_wait(4.0*tsp_EPTF_Var_SyncInterval+1.0);
f_EPTF_Var_getContent(vl_statVarIdx,vl_statValue);
log(">>>vl_statValue: ",vl_statValue," Expected value: ", vl_sum);
f_EPTF_StatHandler_Test_checkFloatEquality( vl_statValue.floatVal, vl_sum , 0.001);
f_EPTF_Base_cleanup_CT();
}//tc_
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_Test_intSum_moreClients
//
// Purpose:
// To test inSum statistics
//
// Requirement:
// -
//
// Action:
// The testcase runs on EPTF_StatHandlerClient_CT.
// 1. Init a server
// 2. Init n clients
// 3. Create a stat from the client
// 4. Subscribe for the statistics
// 5. Init n pieces of clients, pass to each the sample value and the number of samples
// Each client register a variable with initial value and modifies it after waiting "sync interval+0.1s"
// 6. After 2*sync.time get the value of the stat
// 4. Check if the value is the expected
// Expected Result: The tc is passed if the checks is true
//
///////////////////////////////////////////////////////////
testcase tc_StatHandler_Test_intSum_moreClients() runs on EPTF_StatHandlerClient_CT {
var charstring vl_myStatName:="MyStat";
f_EPTF_StatHandlerClient_init_CT(c_myStatHandlerClient);
var EPTF_StatHandler_CT vlc_shServer:= EPTF_StatHandler_CT. create;
vlc_shServer.start(f_EPTF_StatHandler_Test_MasterBehavior(c_myStatHandlerMaster));
//==== Statistics part ====
var charstring vl_statMethod := "Sum";// c_EPTF_StatHandler_Method_Min
var boolean vl_success:=f_EPTF_StatHandlerClient_declareStat(vl_myStatName,vl_statMethod, {intVal:=0},vlc_shServer);
if(not vl_success) { f_EPTF_Base_stop(fail); }
var charstring vl_statVarRef:=f_EPTF_StatHandlerClient_getStatVariableRef(vl_myStatName,vlc_shServer);
var integer vl_statVarIdx:=-1;
var EPTF_Var_DirectContent vl_statValue;
f_EPTF_Var_subscribeRemote(vlc_shServer,vl_statVarRef,sampledAtSync,vl_statVarIdx);
if(not( vl_statVarRef==vl_myStatName and vl_statVarIdx>=0) ){ f_EPTF_Base_stop(fail); }
var EPTF_StatHandler_Test_ShClients vlc_shClients :={}
var EPTF_IntegerList vl_samplesList :={-1}
for(var integer i:=1;i<=tsp_StatHandler_Test_nofClients;i:=i+1) {
vlc_shClients[i]:= EPTF_StatHandlerClient_CT.create;
vl_samplesList[i]:= i;
vlc_shClients[i].start(f_StatHandler_Test_generalClient(
c_myStatHandlerClient&int2str(i),
vl_myStatName,
vl_statMethod,
{ intVal:=vl_samplesList[i]},//sample value
-1, //nofSample
vlc_shServer));
}//for
//===waits==
f_StatHandler_Test_wait(tsp_EPTF_Var_SyncInterval + 1.0);
//====checks the init value:=====
f_EPTF_Var_getContent(vl_statVarIdx, vl_statValue);
log(">>>vl_statValue: ",vl_statValue, " Expected value: ", 0);
f_EPTF_StatHandler_Test_setverdictFromBool(ischosen(vl_statValue.intVal) and vl_statValue.intVal==0);
//====Calculates stat:=====
var integer vl_sum:=0;
for(var integer i:=1;i<=tsp_StatHandler_Test_nofClients;i:=i+1) {
vl_sum:=vl_sum+vl_samplesList[i];
}
//======== Check the modified stat (y=x, x:=i, mean[i]=1 where i is the i.node======
f_StatHandler_Test_wait(4.0*tsp_EPTF_Var_SyncInterval+1.0);
f_EPTF_Var_getContent(vl_statVarIdx,vl_statValue);
log(">>>Sample values: ", vl_samplesList);
log(">>>vl_statValue: ",vl_statValue," Expected value: ", vl_sum);
f_EPTF_StatHandler_Test_setverdictFromBool(ischosen(vl_statValue.intVal) and vl_statValue.intVal==vl_sum);
f_EPTF_Base_cleanup_CT();
}//tc_
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_Test_standardDev_moreClients
//
// Purpose:
// To test stat standard deviation (more exactly the variance) calculation
//
// Requirement:
// -
//
// Action:
// The testcase runs on EPTF_StatHandlerClient_CT.
// 1. Init a server
// 2. Init n clients
// 3. Create a stat from the client
// 4. Subscribe for the statistics
// 5. Init n pieces of clients, pass to each the sample value and the number of samples
// Each client register a variable with initial value and modifies it after waiting "sync interval+0.1s"
// 6. After 2*sync.time get the value of the stat
// 4. Check if the value is the expected
// Basic infos about the stat:
// The "Client i" contains the average and variance of i piece of samples
// Expected Result: The tc is passed if the checks is true
//
///////////////////////////////////////////////////////////
//Status: under debugging
testcase tc_StatHandler_Test_standardDev_moreClients() runs on EPTF_StatHandlerClient_CT {
var charstring vl_myStatName:="MyStat";
f_EPTF_StatHandlerClient_init_CT(c_myStatHandlerClient);
var EPTF_StatHandler_CT vlc_shServer:= EPTF_StatHandler_CT. create;
vlc_shServer.start(f_EPTF_StatHandler_Test_MasterBehavior(c_myStatHandlerMaster));
//==== Statistics part ====
var charstring vl_statMethod := c_EPTF_StatHandler_Method_StandardDev;
var boolean vl_success:=f_EPTF_StatHandlerClient_declareStat(vl_myStatName,vl_statMethod, {floatVal:=0.0},vlc_shServer);
if(not vl_success) { f_EPTF_Base_stop(fail); }
var charstring vl_statVarRef:=f_EPTF_StatHandlerClient_getStatVariableRef(vl_myStatName,vlc_shServer);
var integer vl_statVarIdx:=-1;
var EPTF_Var_DirectContent vl_statValue;
f_EPTF_Var_subscribeRemote(vlc_shServer,vl_statVarRef,sampledAtSync,vl_statVarIdx);
log(">>>vl_statVarRef: ", vl_statVarRef," vl_statVarIdx: ",vl_statVarIdx);
if(not( vl_statVarRef==vl_myStatName and vl_statVarIdx>=0) ){ f_EPTF_Base_stop(fail); }
//=== Creates samples====
//Takes i pieces into samples "i", then calculates the mean, noSamples and standardDev(i)
//o.items are dummies:
var EPTF_FloatList vl_samples:={0.0}, vl_meanList :={0.0}, vl_standardDevList:={0.0}, vl_varianceList:={0.0};//variance:= stdev*stdev
var EPTF_FloatList vl_tmpList:={0.0};
var integer vl_totalNofSamples:=0;
var EPTF_StatHandler_Test_ShClients vlc_shClients :={}
var float vl_diff:=0.0;
for(var integer i:=1;i<=tsp_StatHandler_Test_nofClients;i:=i+1) {
vlc_shClients[i]:= EPTF_StatHandlerClient_CT.create;
//==Calculates mean:==
vl_meanList[i]:=0.0;
vl_tmpList:={}
for(var integer j:=1;j<=i;j:=j+1) {
vl_tmpList[j]:=int2float(j); //or rnd()
vl_meanList[i]:=vl_meanList[i]+ vl_tmpList[j];
vl_samples[vl_totalNofSamples+j]:=vl_tmpList[j];
}
vl_meanList[i]:=vl_meanList[i]/int2float(i);
//=== calculates (local) variance*N ===
vl_varianceList[i]:=0.0;
for(var integer j:=1;j<=i;j:=j+1) {
vl_diff:=vl_meanList[i]-vl_tmpList[j];
vl_varianceList[i]:=vl_varianceList[i]+vl_diff*vl_diff;
}
//vl_varianceList[i]:=vl_varianceList[i]/int2float(i);
vlc_shClients[i].start(f_StatHandler_Test_generalClient(
c_myStatHandlerClient&int2str(i),
vl_myStatName,
vl_statMethod,
{ floatlistVal:={vl_meanList[i],vl_varianceList[i]} },
i, //nofSample
vlc_shServer));
vl_totalNofSamples:=vl_totalNofSamples+i;
}//for
f_StatHandler_Test_wait(tsp_EPTF_Var_SyncInterval + 1.0);
//====checks init value:=====
f_EPTF_Var_getContent(vl_statVarIdx,vl_statValue);
f_EPTF_StatHandler_Test_checkFloatEquality( vl_statValue.floatVal, 0.0, 0.001);
//====Calculates stat:=====
if(vl_totalNofSamples!=sizeof(vl_samples)-1){
setverdict(fail);
}
var float vl_sum:=0.0;
for(var integer i:=1;i<=vl_totalNofSamples;i:=i+1) {
vl_sum:=vl_sum+vl_samples[i];
}//for
vl_sum:=vl_sum/int2float(vl_totalNofSamples); //= Total mean
var float vl_expectedVariance:=0.0;
for(var integer i:=1;i<=vl_totalNofSamples;i:=i+1) {
vl_diff:=vl_sum-vl_samples[i];
vl_expectedVariance:=vl_expectedVariance+vl_diff*vl_diff;
}
vl_expectedVariance:=vl_expectedVariance/int2float(vl_totalNofSamples);
f_StatHandler_Test_wait(4.0*tsp_EPTF_Var_SyncInterval+1.0);
f_EPTF_Var_getContent(vl_statVarIdx,vl_statValue);
log(">>>Expected mean: ", vl_sum, " vl_totalNofSamples: ",vl_totalNofSamples)
log(">>>vl_statValue: ",vl_statValue," Expected variance: ",vl_expectedVariance);
log(">>>Variance calculated by StatHandler (and me): ", vl_statValue.floatVal/int2float(vl_totalNofSamples));
f_EPTF_StatHandler_Test_checkFloatEquality( vl_statValue.floatVal/int2float(vl_totalNofSamples), vl_expectedVariance, 0.001);
f_EPTF_Base_cleanup_CT();
}//tc_
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_Test_density_moreClients_realtime
//
// Purpose:
// To test density calculation in case of subscription mode "realtime"
//
// Requirement:
// -
//
// Action:
// The testcase runs on EPTF_StatHandlerClient_CT.
// 1. Init a server
// 2. Init n clients
// 3. Create a stat from the client
// 4. Subscribe for the statistics
// 5. Init n pieces of clients, pass to each the sample value and the number of samples
// Each client register a variable with initial value and modifies it after waiting "sync interval+0.1s"
// 6. After 2*sync.time get the value of the stat
// 4. Check if the value is the expected
// Basic infos about the stat:
// The "Client i" contains the densitye of i piece of samples
// Expected Result: The tc is passed if the checks is true
//
///////////////////////////////////////////////////////////
//Status:Ready
testcase tc_StatHandler_Test_density_moreClients_realtime() runs on EPTF_StatHandlerClient_CT {
f_StatHandler_Test_density(realtime)
}//tc_
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_Test_density_moreClients_sampled
//
// Purpose:
// To test density calculation in case of subscription mode "sampled"
//
// Requirement:
// -
//
// Action:
// The testcase runs on EPTF_StatHandlerClient_CT.
// 1. Init a server
// 2. Init n clients
// 3. Create a stat from the client
// 4. Subscribe for the statistics
// 5. Init n pieces of clients, pass to each the sample value and the number of samples
// Each client register a variable with initial value and modifies it after waiting "sync interval+0.1s"
// 6. After 2*sync.time get the value of the stat
// 4. Check if the value is the expected
// Basic infos about the stat:
// The "Client i" contains the densitye of i piece of samples
// Expected Result: The tc is passed if the checks is true
//
///////////////////////////////////////////////////////////
//Status:Ready
testcase tc_StatHandler_Test_density_moreClients_sampled() runs on EPTF_StatHandlerClient_CT {
f_StatHandler_Test_density(sampled)
}//tc_
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_Test_density_moreClients_sampledAtSync
//
// Purpose:
// To test density calculation in case of subscription mode "sampledAtSync"
//
// Requirement:
// -
//
// Action:
// The testcase runs on EPTF_StatHandlerClient_CT.
// 1. Init a server
// 2. Init n clients
// 3. Create a stat from the client
// 4. Subscribe for the statistics
// 5. Init n pieces of clients, pass to each the sample value and the number of samples
// Each client register a variable with initial value and modifies it after waiting "sync interval+0.1s"
// 6. After 2*sync.time get the value of the stat
// 4. Check if the value is the expected
// Basic infos about the stat:
// The "Client i" contains the densitye of i piece of samples
// Expected Result: The tc is passed if the checks is true
//
///////////////////////////////////////////////////////////
//Status:Ready
testcase tc_StatHandler_Test_density_moreClients_sampledAtSync() runs on EPTF_StatHandlerClient_CT {
f_StatHandler_Test_density(sampledAtSync);
}//tc_
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_Test_density_moreClients_timeLine
//
// Purpose:
// To test density calculation in case of subscription mode "timeLine"
//
// Requirement:
// -
//
// Action:
// The testcase runs on EPTF_StatHandlerClient_CT.
// 1. Init a server
// 2. Init n clients
// 3. Create a stat from the client
// 4. Subscribe for the statistics
// 5. Init n pieces of clients, pass to each the sample value and the number of samples
// Each client register a variable with initial value and modifies it after waiting "sync interval+0.1s"
// 6. After 2*sync.time get the value of the stat
// 4. Check if the value is the expected
// Basic infos about the stat:
// The "Client i" contains the densitye of i piece of samples
// Expected Result: The tc is passed if the checks is true
//
///////////////////////////////////////////////////////////
//Status:Started
testcase tc_StatHandler_Test_density_moreClients_timeLine() runs on EPTF_StatHandlerClient_CT {
f_StatHandler_Test_density(timeLine);
}//tc_
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_Test_percentile95_HK48363
//
// Purpose:
// Test for TR HK48363.
//
// Requirement:
// -
//
// Detailed Comments:
// StatHandler causes dynamic test case error if percentile95 provider has no boundaries.
//
///////////////////////////////////////////////////////////
testcase tc_StatHandler_Test_percentile95_HK48363()
runs on EPTF_StatHandler_CT
{
f_EPTF_StatHandler_init_CT("server");
var EPTF_StatHandlerClient_CT cl := EPTF_StatHandlerClient_CT.create;
cl.start(f_StatHandler_Test_percentile95_client_HK48363(self));
timer T:=tsp_EPTF_Var_SyncInterval + 1.0;
T.start;
T.timeout;
f_EPTF_Base_cleanup_CT();
}
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_Test_percentileP_HK48363
//
// Purpose:
// Test for TR HK48363.
//
// Requirement:
// -
//
// Detailed Comments:
// StatHandler causes dynamic test case error if percentile95 provider has no boundaries.
// This test checks whether percentileP works well
//
///////////////////////////////////////////////////////////
testcase tc_StatHandler_Test_percentileP_HK48363()
runs on EPTF_StatHandler_CT
{
f_EPTF_StatHandler_init_CT("server");
var EPTF_StatHandlerClient_CT cl := EPTF_StatHandlerClient_CT.create;
cl.start(f_StatHandler_Test_percentileP_client_HK48363(self));
timer T:=tsp_EPTF_Var_SyncInterval + 1.0;
T.start;
T.timeout;
f_EPTF_Base_cleanup_CT();
}
group RegisterAggregatedStat {
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_Test_registerAggregatedStat_min
//
// Purpose:
// Test for registration of aggregated stats as data source to another aggregated stat
//
// Requirement:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
testcase tc_StatHandler_Test_registerAggregatedStat_min()
runs on EPTF_StatHandler_CT
{
f_EPTF_StatHandler_init_CT("server");
var EPTF_StatHandlerClient_CT cl := EPTF_StatHandlerClient_CT.create;
cl.start(f_StatHandler_Test_registerAggregatedStat_min_client(self));
timer T:=5.0 * tsp_EPTF_Var_SyncInterval + 1.0;
T.start;
T.timeout;
f_EPTF_Base_cleanup_CT();
}
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_Test_registerAggregatedStat_mean
//
// Purpose:
// Test for registration of aggregated stats as data source to another aggregated stat
//
// Requirement:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
testcase tc_StatHandler_Test_registerAggregatedStat_mean()
runs on EPTF_StatHandler_CT
{
f_EPTF_StatHandler_init_CT("server");
var EPTF_StatHandlerClient_CT cl := EPTF_StatHandlerClient_CT.create;
cl.start(f_StatHandler_Test_registerAggregatedStat_mean_client(self));
timer T:=3.0 * tsp_EPTF_Var_SyncInterval + 1.0;
T.start;
T.timeout;
f_EPTF_Base_cleanup_CT();
}
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_Test_registerAggregatedStat_standardDev
//
// Purpose:
// Test for registration of aggregated stats as data source to another aggregated stat
//
// Requirement:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
testcase tc_StatHandler_Test_registerAggregatedStat_standardDev()
runs on EPTF_StatHandler_CT
{
f_EPTF_StatHandler_init_CT("server");
var EPTF_StatHandlerClient_CT cl := EPTF_StatHandlerClient_CT.create;
cl.start(f_StatHandler_Test_registerAggregatedStat_standardDev_client(self));
timer T:=3.0 * tsp_EPTF_Var_SyncInterval + 1.0;
T.start;
T.timeout;
f_EPTF_Base_cleanup_CT();
}
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_Test_registerAggregatedStat_globalAverage
//
// Purpose:
// Test for registration of aggregated stats as data source to another aggregated stat
//
// Requirement:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
testcase tc_StatHandler_Test_registerAggregatedStat_globalAverage()
runs on EPTF_StatHandler_CT
{
f_EPTF_StatHandler_init_CT("server");
var EPTF_StatHandlerClient_CT cl := EPTF_StatHandlerClient_CT.create;
cl.start(f_StatHandler_Test_registerAggregatedStat_globalAverage_client(self));
timer T:=3.0 * tsp_EPTF_Var_SyncInterval + 1.0;
T.start;
T.timeout;
f_EPTF_Base_cleanup_CT();
}
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_Test_registerAggregatedStat_density
//
// Purpose:
// Test for registration of aggregated stats as data source to another aggregated stat
//
// Requirement:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
testcase tc_StatHandler_Test_registerAggregatedStat_density()
runs on EPTF_StatHandler_CT
{
f_EPTF_StatHandler_init_CT("server");
var EPTF_StatHandlerClient_CT cl := EPTF_StatHandlerClient_CT.create;
cl.start(f_StatHandler_Test_registerAggregatedStat_density_client(self));
timer T:=3.0 * tsp_EPTF_Var_SyncInterval + 1.0;
T.start;
T.timeout;
f_EPTF_Base_cleanup_CT();
}
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_Test_registerAggregatedStat_percentile95
//
// Purpose:
// Test for registration of aggregated stats as data source to another aggregated stat
//
// Requirement:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
testcase tc_StatHandler_Test_registerAggregatedStat_percentile95()
runs on EPTF_StatHandler_CT
{
f_EPTF_StatHandler_init_CT("server");
var EPTF_StatHandlerClient_CT cl := EPTF_StatHandlerClient_CT.create;
cl.start(f_StatHandler_Test_registerAggregatedStat_percentile95_client(self));
timer T:=3.0 * tsp_EPTF_Var_SyncInterval + 1.0;
T.start;
T.timeout;
f_EPTF_Base_cleanup_CT();
}
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_Test_registerAggregatedStat_percentileP
//
// Purpose:
// Test for registration of aggregated stats as data source to another aggregated stat
//
// Requirement:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
testcase tc_StatHandler_Test_registerAggregatedStat_percentileP()
runs on EPTF_StatHandler_CT
{
f_EPTF_StatHandler_init_CT("server");
var EPTF_StatHandlerClient_CT cl := EPTF_StatHandlerClient_CT.create;
cl.start(f_StatHandler_Test_registerAggregatedStat_percentileP_client(self));
timer T:=3.0 * tsp_EPTF_Var_SyncInterval + 1.0;
T.start;
T.timeout;
f_EPTF_Base_cleanup_CT();
}
} // group RegisterAggregatedStat
group RegisterMeasuredStat
{
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_Test_registerMeasuredStat_max
//
// Purpose:
// Test for registration of StatMeasure stats as data source to an aggregated stat
//
// Requirement:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
testcase tc_StatHandler_Test_registerMeasuredStat_max()
runs on EPTF_StatHandler_CT
{
f_EPTF_StatHandler_init_CT("server");
var EPTF_StatHandlerClient_CT cl := EPTF_StatHandlerClient_CT.create;
cl.start(f_StatHandler_Test_registerMeasuredStat_max_client(self));
timer T:=3.0 * tsp_EPTF_Var_SyncInterval + 1.0;
T.start;
T.timeout;
f_EPTF_Base_cleanup_CT();
}
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_Test_registerMeasuredStat_mean
//
// Purpose:
// Test for registration of StatMeasure stats as data source to an aggregated stat
//
// Requirement:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
testcase tc_StatHandler_Test_registerMeasuredStat_mean()
runs on EPTF_StatHandler_CT
{
f_EPTF_StatHandler_init_CT("server");
var EPTF_StatHandlerClient_CT cl := EPTF_StatHandlerClient_CT.create;
cl.start(f_StatHandler_Test_registerMeasuredStat_mean_client(self));
timer T:=3.0 * tsp_EPTF_Var_SyncInterval + 1.0;
T.start;
T.timeout;
f_EPTF_Base_cleanup_CT();
}
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_Test_registerMeasuredStat_standardDev
//
// Purpose:
// Test for registration of StatMeasure stats as data source to an aggregated stat
//
// Requirement:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
testcase tc_StatHandler_Test_registerMeasuredStat_standardDev()
runs on EPTF_StatHandler_CT
{
f_EPTF_StatHandler_init_CT("server");
var EPTF_StatHandlerClient_CT cl := EPTF_StatHandlerClient_CT.create;
cl.start(f_StatHandler_Test_registerMeasuredStat_standardDev_client(self));
timer T:=3.0 * tsp_EPTF_Var_SyncInterval + 1.0;
T.start;
T.timeout;
f_EPTF_Base_cleanup_CT();
}
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_Test_registerMeasuredStat_density
//
// Purpose:
// Test for registration of StatMeasure stats as data source to an aggregated stat
//
// Requirement:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
testcase tc_StatHandler_Test_registerMeasuredStat_density()
runs on EPTF_StatHandler_CT
{
f_EPTF_StatHandler_init_CT("server");
var EPTF_StatHandlerClient_CT cl := EPTF_StatHandlerClient_CT.create;
cl.start(f_StatHandler_Test_registerMeasuredStat_density_client(self));
timer T:=3.0 * tsp_EPTF_Var_SyncInterval + 1.0;
T.start;
T.timeout;
f_EPTF_Base_cleanup_CT();
}
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_Test_registerMeasuredStat_percentile95
//
// Purpose:
// Test for registration of StatMeasure stats as data source to an aggregated stat
//
// Requirement:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
testcase tc_StatHandler_Test_registerMeasuredStat_percentile95()
runs on EPTF_StatHandler_CT
{
f_EPTF_StatHandler_init_CT("server");
var EPTF_StatHandlerClient_CT cl := EPTF_StatHandlerClient_CT.create;
cl.start(f_StatHandler_Test_registerMeasuredStat_percentile95_client(self));
/* timer T:=3.0 * (tsp_EPTF_Var_SyncInterval + tsp_EPTF_Var_refreshSubscribersPeriod) + 1.0;
T.start;
T.timeout;*/
cl.done;
f_EPTF_Base_cleanup_CT();
}
///////////////////////////////////////////////////////////
// Testcase: tc_StatHandler_Test_registerMeasuredStat_percentileP
//
// Purpose:
// Test for registration of StatMeasure stats as data source to an aggregated stat
//
// Requirement:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
testcase tc_StatHandler_Test_registerMeasuredStat_percentileP()
runs on EPTF_StatHandler_CT
{
f_EPTF_StatHandler_init_CT("server");
var EPTF_StatHandlerClient_CT cl := EPTF_StatHandlerClient_CT.create;
cl.start(f_StatHandler_Test_registerMeasuredStat_percentileP_client(self));
/* timer T:=3.0 * (tsp_EPTF_Var_SyncInterval + tsp_EPTF_Var_refreshSubscribersPeriod) + 1.0;
T.start;
T.timeout;*/
cl.done;
f_EPTF_Base_cleanup_CT();
}
} // group RegisterMeasuredStat
function f_runStatHandler()
runs on EPTF_StatHandler_CT{
f_EPTF_Base_init_CT("bubu")
f_EPTF_StatHandler_init_CT("server");
f_EPTF_StatHandler_getId("mikkamakka")
f_EPTF_Base_cleanup_CT();
}
testcase tc_StatHandler_Test_useComponentName()
runs on SYSTEM_CT
{
f_EPTF_Base_init_CT("sys")
var EPTF_StatHandler_CT vl_comp := EPTF_StatHandler_CT.create;
vl_comp.start( f_runStatHandler() );
vl_comp.done
var EPTF_StatHandler_CT vl_comp2 := EPTF_StatHandler_CT.create;
vl_comp2.start( f_runStatHandler() );
vl_comp2.done
f_EPTF_Base_cleanup_CT();
setverdict(pass)
}
group Help {
type component StatHandler_HelpTest_CT extends EPTF_DataSource_CT, EPTF_StatHandler_CT {
var boolean v_StatHandler_ready := false;
}
function f_EPTF_StatHandler_Test_checkStatHandlerReady(
in charstring pl_source,
in charstring pl_ptcName
) runs on StatHandler_HelpTest_CT {
if (pl_source==c_StatHandler_DataSource_sourceId) {
v_StatHandler_ready := true;
}
}
function f_EPTF_StatHandler_Test_helpCheck(in charstring pl_source := "", in charstring pl_element := "", in charstring pl_expectedPattern := "") runs on StatHandler_HelpTest_CT {
var charstring vl_helpTEXT;
var octetstring vl_helpJSON;
vl_helpTEXT := f_EPTF_DataSource_getHelpTEXT(pl_source, pl_element);
action("Help for "&pl_source&": ", vl_helpTEXT);
if (pl_expectedPattern!="") {
// check if the TEXT help contains the pattern:
if(not match(vl_helpTEXT,pattern pl_expectedPattern)) {
setverdict(fail,"The TEXT help does not match the expected pattern: ", match(vl_helpTEXT,pattern pl_expectedPattern));
f_EPTF_Base_stop(none);
}
}
vl_helpJSON := f_EPTF_DataSource_getHelpJSON(pl_source,pl_element);
action("HelpJSON for "&pl_source&": ", vl_helpJSON);
}
testcase tc_EPTF_StatHandler_Test_help() runs on StatHandler_HelpTest_CT {
f_EPTF_DataSource_init_CT("MTC");
v_StatHandler_ready := false;
f_EPTF_DataSource_registerReadyCallback(refers(f_EPTF_StatHandler_Test_checkStatHandlerReady));
f_EPTF_StatHandler_init_CT("StatHandler_Test_help", 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_StatHandler_ready] T_alt.timeout{}
};
// StatHandler
f_EPTF_StatHandler_Test_helpCheck(pl_source := c_StatHandler_DataSource_sourceId,pl_expectedPattern := "*Source: \""&c_StatHandler_DataSource_sourceId&"\"\n\n*DataElement: \"help\"*")
setverdict(pass);
f_EPTF_Base_stop(none);
}
} //group Help
}//RegressionTest
control
{
execute(tc_StatHandler_testAutoDisconnect());
execute(tc_StatHandler_Test_GUI());
execute(tc_StatHandler_Test_testMean());
//===Regression:===
// FIXME: removed because of private component variables
// execute(tc_StatHandler_Test_masterInitCleanup());
// FIXME: removed because of private component variables
// execute(tc_StatHandler_Test_clientInitCleanup());
execute(tc_StatHandler_Test_declareStat());
execute(tc_StatHandler_Test_mean());
execute(tc_StatHandler_Test_mean_moreClients());
execute(tc_StatHandler_Test_globalAverage_moreClients());
execute(tc_StatHandler_Test_min_moreClients());
execute(tc_StatHandler_Test_intMin_moreClients());
execute(tc_StatHandler_Test_max_moreClients());
execute(tc_StatHandler_Test_intMax_moreClients());
execute(tc_StatHandler_Test_sum_moreClients());
execute(tc_StatHandler_Test_intSum_moreClients());
execute(tc_StatHandler_Test_standardDev_moreClients());
execute(tc_StatHandler_Test_density_moreClients_realtime());
execute(tc_StatHandler_Test_density_moreClients_sampled());
execute(tc_StatHandler_Test_density_moreClients_sampledAtSync());
execute(tc_StatHandler_Test_density_moreClients_timeLine());
execute(tc_StatHandler_Test_percentile95_HK48363());
execute(tc_StatHandler_Test_registerAggregatedStat_min());
execute(tc_StatHandler_Test_registerAggregatedStat_mean());
execute(tc_StatHandler_Test_registerAggregatedStat_standardDev());
execute(tc_StatHandler_Test_registerAggregatedStat_globalAverage());
execute(tc_StatHandler_Test_registerAggregatedStat_density());
execute(tc_StatHandler_Test_registerAggregatedStat_percentile95());
execute(tc_StatHandler_Test_registerAggregatedStat_percentileP());
execute(tc_StatHandler_Test_registerMeasuredStat_max());
execute(tc_StatHandler_Test_registerMeasuredStat_mean());
execute(tc_StatHandler_Test_registerMeasuredStat_standardDev());
execute(tc_StatHandler_Test_registerMeasuredStat_density());
execute(tc_StatHandler_Test_registerMeasuredStat_percentile95());
execute(tc_StatHandler_Test_registerMeasuredStat_percentileP());
execute(tc_StatHandler_Test_useComponentName());
execute(tc_StatHandler_Test_dataSourceTest());
execute(tc_StatHandler_Test_resetStatistics());
execute(tc_StatHandler_DS_Neg_WrongResetComponent());
execute(tc_StatHandler_DS_Neg_WrongResetAll());
execute(tc_EPTF_StatHandler_Test_help());
}
} // end of module