blob: adca02048d0d1faddf9806321d83d942584df3da [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_CS_Test_Tescases
//
// Purpose:
// This module contains testcases for testing EPTF Central Scheduling.
//
// Module Parameters:
// -
// Module depends on:
//
// Current Owner:
// Balazs Barcsik (ebalbar)
//
// Last Review Date:
// -
//
// Detailed Comments:
// -
///////////////////////////////////////////////////////////
module EPTF_CS_Test_Tescases
{
//=========================================================================
// Import Part
//=========================================================================
// Central scheduling behavior
import from EPTF_CLL_CS_Definitions all;
import from EPTF_CLL_CSAdmin_Functions all;
//import from CBE_Compat_Definitions all;
// UIHandler
import from EPTF_CLL_UIHandler_Definitions all;
import from EPTF_CLL_UIHandler_WidgetFunctions all;
import from XTDP_PDU_Defs all;
// Exectrl
import from EPTF_CLL_ExecCtrl_Definitions all;
import from EPTF_CLL_ExecCtrl_Functions all;
import from EPTF_CLL_ExecCtrlUIHandler_Definitions all;
import from EPTF_CLL_ExecCtrlUIHandler_Functions all;
//My Test
import from EPTF_CS_Test_Definitions all;
import from EPTF_CS_Test_Functions all;
//related
import from EPTF_CLL_Common_Definitions all;
import from EPTF_CLL_Base_Functions all;
import from EPTF_CLL_DataSource_Functions all;
import from EPTF_CLL_DataSource_Definitions all;
import from EPTF_CLL_Variable_Definitions all;
import from EPTF_CLL_Variable_Functions all;
//=========================================================================
// Module Parameters
//=========================================================================
//modulepar boolean tsp_use_HostAdmins := true;
//modulepar boolean tsp_use_LoadRegulator := true;
modulepar integer tsp_nof_A_CS_Admins := 1; // set to 0 to disable Stack A
//modulepar integer tsp_nof_B_CS_Admins := 1; // set to 0 to disable Stack B
modulepar EPTF_CharstringList tsp_CS_Admin_A_HostList := {}
//modulepar EPTF_CharstringList tsp_CS_Admin_B_HostList := {}
modulepar float tsp_demoInterval := 60.0; // Max running time
modulepar boolean tsp_useLoadBalancing_A := false;
//modulepar boolean tsp_useLoadBalancing_B := false;
modulepar charstring tsp_CS_guiXmlName := "CentralScheduling_Gui.xml"
//=========================================================================
// Testcases
//=========================================================================
testcase tc_EPTF_CS_Test_Admin_behavior() runs on EPTF_CS_ApplAdminBase_CT {
timer T_watchdog := tsp_demoInterval;
f_EPTF_Base_init_CT("Test_Admin_behavior");
var EPTF_ExecCtrl_CT vc_execCtrl := EPTF_ExecCtrl_CT.create("ExecCtrl");
vc_execCtrl.start(f_LGen_Test_ExecCtrlbehavior("ExecCtrl", tsp_nof_A_CS_Admins));
for(var integer i := 0; i < tsp_nof_A_CS_Admins; i := i + 1) {
var CS_ApplAdmin_Test_CT vc_CS_Admin_A := CS_ApplAdmin_Test_CT.create("CS_Admin");
vc_CS_Admin_A.start(f_EPTF_CS_Test_behavior("CS_Admin_A." & int2str(i), i, vc_execCtrl,false));
}
T_watchdog.start;
alt {
[] any component.done { setverdict(fail); }
[] T_watchdog.timeout { setverdict(pass); }
}
f_EPTF_Base_cleanup_CT();
// all component.done;
}
testcase tc_EPTF_CS_Test_Admin_init() runs on EPTF_CS_ApplAdminBase_CT {
timer T_watchdog := 10.0;
f_EPTF_Base_init_CT("Admin_init");
var EPTF_ExecCtrl_CT vc_execCtrl := EPTF_ExecCtrl_CT.create("ExecCtrl");
vc_execCtrl.start(f_LGen_Test_ExecCtrlbehavior("ExecCtrl", 1));
for(var integer i := 0; i < 1; i := i + 1) {
var CS_ApplAdmin_Test_CT vc_CS_Admin_A := CS_ApplAdmin_Test_CT.create("CS_Admin");
vc_CS_Admin_A.start(f_EPTF_CS_Test_behavior("CS_Admin_A." & int2str(i), i, vc_execCtrl,false));
}
T_watchdog.start;
alt {
[] any component.done { setverdict(fail); }
[] T_watchdog.timeout { setverdict(pass); }
}
f_EPTF_Base_cleanup_CT();
all component.done;
vc_execCtrl := EPTF_ExecCtrl_CT.create("ExecCtrl2");
f_EPTF_Base_init_CT("Admin_init2");
vc_execCtrl.start(f_LGen_Test_ExecCtrlbehavior("ExecCtrl2", 1));
for(var integer i := 0; i < 1; i := i + 1) {
var CS_ApplAdmin_Test_CT vc_CS_Admin_A := CS_ApplAdmin_Test_CT.create("CS_Admin2");
vc_CS_Admin_A.start(f_EPTF_CS_Test_behavior("CS_Admin_A2." & int2str(i), i, vc_execCtrl,false));
}
T_watchdog.start;
alt {
//[] any component.done { setverdict(fail); }
[] T_watchdog.timeout { setverdict(pass); }
}
f_EPTF_Base_cleanup_CT();
}
testcase tc_EPTF_CS_Test_declareTrafficCase() runs on EPTF_CS_ApplAdminBase_CT {
timer T_watchdog := 10.0;
f_EPTF_Base_init_CT("Test_declareTrafficCase");
var EPTF_ExecCtrl_CT vc_execCtrl := EPTF_ExecCtrl_CT.create("ExecCtrl");
vc_execCtrl.start(f_LGen_Test_ExecCtrlbehavior("ExecCtrl", 1));
for(var integer i := 0; i < 1; i := i + 1) {
var CS_ApplAdmin_Test_CT vc_CS_Admin_A := CS_ApplAdmin_Test_CT.create("CS_Admin");
vc_CS_Admin_A.start(f_EPTF_CS_Test_declareTrafficCase("CS_Admin_A." & int2str(i), i, vc_execCtrl,false));
}
T_watchdog.start;
alt {
[] any component.done { setverdict(fail); }
[] T_watchdog.timeout { setverdict(pass); }
}
f_EPTF_Base_cleanup_CT();
}
testcase tc_EPTF_CS_Test_getCompRefOfSelectedLGen() runs on EPTF_CS_ApplAdminBase_CT {
timer T_watchdog := tsp_demoInterval;
f_EPTF_Base_init_CT("getCompRefOfSelectedLGen");
var EPTF_ExecCtrl_CT vc_execCtrl := EPTF_ExecCtrl_CT.create("ExecCtrl");
vc_execCtrl.start(f_LGen_Test_ExecCtrlbehavior("ExecCtrl", 2));
for(var integer i := 0; i < 2; i := i + 1) {
var CS_ApplAdmin_Test_CT vc_CS_Admin_A := CS_ApplAdmin_Test_CT.create("CS_Admin."& int2str(i));
vc_CS_Admin_A.start(f_EPTF_CS_Test_getCompRefOfSelectedLGen("CS_Admin." & int2str(i), i, vc_execCtrl,false));
}
T_watchdog.start;
alt {
[] any component.done { setverdict(fail); }
[] T_watchdog.timeout { setverdict(pass); }
}
f_EPTF_Base_cleanup_CT();
}
testcase tc_EPTF_CS_Test_HL26276() runs on EPTF_UIHandler_CT
{
timer T_watchdog := tsp_demoInterval;
f_EPTF_UIHandler_init_CT("MTC", true);
f_EPTF_UIHandler_clearGUI();
f_EPTF_UIHandler_addWindow();
f_EPTF_UIHandler_addMainTabbox();
var EPTF_ExecCtrl_UIHandler_CT vl_execCtrl := EPTF_ExecCtrl_UIHandler_CT.create("ExecCtrl");
vl_execCtrl.start(f_EPTF_ExecCtrl_UIHandler_behavior("ExecCtrl",
1, mtc, tsp_EPTF_GUI_Main_Tabbox_WidgetId));
var CS_ApplAdmin_Test_UIHandler_CT vl_CS_Admin_A := CS_ApplAdmin_Test_UIHandler_CT.create("CS_Admin");
vl_CS_Admin_A.start(f_EPTF_CS_Test_HL26276("CS_Admin", 0, vl_execCtrl, mtc, true));
T_watchdog.start;
alt {
[] any component.done { setverdict(fail); }
[] T_watchdog.timeout { setverdict(pass); }
}
f_EPTF_Base_cleanup_CT();
}
type component SYSTEM_CT extends EPTF_UIHandler_CT, EPTF_Var_CT
{
var integer v_startBecauseDSIsReady := 0;
}
function f_EPTF_CS_Test_DataSourceClientReady(
in charstring pl_source,
in charstring pl_ptcName)
runs on SYSTEM_CT{
action("Ready received");
v_startBecauseDSIsReady := v_startBecauseDSIsReady + 1;
}
function f_EPTF_CS_Test_requestDataAndCheck( in charstring pl_elementName,
in EPTF_CharstringList pl_result, //this is an iterator result
in EPTF_DataSource_Params pl_params := {},
in boolean pl_dataElement := false,
in charstring pl_dataElementResult := "", //this is a datalemenet result
in boolean pl_negateResult := false) runs on SYSTEM_CT {
var charstring vl_varName;
var charstring vl_dataProviderName := c_EPTF_CS_DataSource_sourceId;
var integer vl_retCode := 0;
vl_retCode :=f_EPTF_DataSource_getData(
pl_dataVarName := vl_varName,
pl_source := vl_dataProviderName,
pl_ptcName := "",
pl_element := pl_elementName,
pl_params := pl_params
);
if (pl_dataElement == false){
if (0!=vl_retCode) {
setverdict(fail,"Cannot get iterator for dataSource := "&vl_dataProviderName&", ptcName :=", f_EPTF_Base_selfName() & ", element := " & pl_elementName);
return;
};
var integer vl_varIdx := f_EPTF_Var_getId(vl_varName);
var EPTF_CharstringList vl_iList := f_EPTF_Var_getCharstringlistValue(vl_varIdx);
if ((pl_negateResult == false and sizeof(vl_iList) != sizeof(pl_result)) or (pl_negateResult == true and sizeof(vl_iList) == sizeof(pl_result))){
setverdict(fail, pl_elementName & ": Result is: " & log2str(pl_result) & " instead of "& log2str(vl_iList));
return;
}
var integer vl_bool := 0;
for(var integer i := 0; i < sizeof(vl_iList); i := i + 1){
vl_bool := 0;
for(var integer j := 0; j < sizeof(pl_result); j := j + 1){
if (vl_iList[i] == pl_result[j]){
vl_bool := vl_bool + 1;
continue;
}
}
if(vl_bool != 1){
for(var integer k := 0; k < sizeof(vl_iList); k := k + 1){
if(vl_iList[i] == vl_iList[k]){ vl_bool := vl_bool - 1;}
}
if((vl_bool != 0 and pl_negateResult == false) or (vl_bool == 0 and pl_negateResult == true)){
setverdict(fail,pl_elementName & ": Result is: " & log2str(vl_iList) & " instead of "& log2str(pl_result));
return;
}
}
}
} else {
if (0!=vl_retCode) {
setverdict(fail,"Cannot get dataElement for dataSource := "&vl_dataProviderName&", ptcName :=", f_EPTF_Base_selfName() & ", element := " & pl_elementName);
return;
};
var integer vl_varIdx := f_EPTF_Var_getId(vl_varName);
var EPTF_Var_DirectContent vl_content;
f_EPTF_Var_getContent(vl_varIdx, vl_content)
if(ischosen(vl_content.floatVal)){
if((pl_negateResult and pl_dataElementResult == log2str(vl_content.floatVal)) or (pl_negateResult == false and pl_dataElementResult != log2str(vl_content.floatVal))) {
setverdict(fail,pl_elementName & ": Result is: " & log2str(vl_content.floatVal) & " instead of "& pl_dataElementResult);
return;
}
}
if(ischosen(vl_content.charstringVal)){
if((pl_negateResult and pl_dataElementResult == log2str(vl_content.charstringVal)) or (pl_negateResult == false and pl_dataElementResult != log2str(vl_content.charstringVal))){
setverdict(fail,pl_elementName & ": Result is: " & vl_content.charstringVal & " instead of "& pl_dataElementResult);
return;
}
}
if(ischosen(vl_content.intVal)){
if((pl_negateResult and pl_dataElementResult == log2str(vl_content.intVal)) or (pl_negateResult == false and pl_dataElementResult != log2str(vl_content.intVal))){
setverdict(fail,pl_elementName & ": Result is: " & log2str(vl_content.intVal) & " instead of "& pl_dataElementResult);
return;
}
}
if(ischosen(vl_content.boolVal)){
if((pl_negateResult and pl_dataElementResult == log2str(vl_content.boolVal)) or (pl_negateResult == false and pl_dataElementResult != log2str(vl_content.boolVal))){
setverdict(fail,pl_elementName & ": Result is: " & log2str(vl_content.boolVal) & " instead of "& pl_dataElementResult);
return;
}
}
if(ischosen(vl_content.statusLEDVal)){
if((pl_negateResult and pl_dataElementResult == log2str(vl_content.statusLEDVal)) or (pl_negateResult == false and pl_dataElementResult != log2str(vl_content.statusLEDVal))){
setverdict(fail,pl_elementName & ": Result is: " & log2str(vl_content.statusLEDVal) & " instead of "& pl_dataElementResult);
return;
}
}
}
}
//================================================================
// f_EPTF_CS_Test_wrongDataRequest
//================================================================
function f_EPTF_CS_Test_wrongDataRequest(in charstring pl_elementName,
in EPTF_DataSource_Params pl_params := {})
runs on SYSTEM_CT
{
f_EPTF_UIHandler_init_CT("MTC", true);
f_EPTF_DataSource_registerReadyCallback(refers(f_EPTF_CS_Test_DataSourceClientReady ));
f_EPTF_UIHandler_clearGUI();
f_EPTF_UIHandler_addWindow();
f_EPTF_UIHandler_addMainTabbox();
var EPTF_ExecCtrl_UIHandler_CT vl_execCtrl := EPTF_ExecCtrl_UIHandler_CT.create("ExecCtrl");
vl_execCtrl.start(f_EPTF_ExecCtrl_UIHandler_behavior("ExecCtrl", 1, mtc, ""));
for(var integer i := 0; i < tsp_nof_A_CS_Admins; i := i + 1) {
var CS_ApplAdmin_Test_CT vl_CS_Admin_A := CS_ApplAdmin_Test_CT.create("CS_Admin");
vl_CS_Admin_A.start(f_EPTF_CS_Test_behavior("CS_Admin_A." & int2str(i), i, vl_execCtrl,true, mtc));
}
timer T_guard, T_alt;
T_guard.start( 50.0 );
T_alt.start( 0.0 );
alt{
[] T_guard.timeout{
setverdict(fail,"Timeout during config");
f_EPTF_Base_stopAll();
}
[v_startBecauseDSIsReady > 0] T_alt.timeout{}
};
timer T_wait;
T_wait.start( 10.0 );
T_wait.timeout;
var charstring vl_varName;
var charstring vl_dataProviderName := c_EPTF_CS_DataSource_sourceId;
var integer vl_retCode := 0;
vl_retCode :=f_EPTF_DataSource_getData(
pl_dataVarName := vl_varName,
pl_source := vl_dataProviderName,
pl_ptcName := "",
pl_element := pl_elementName,
pl_params := pl_params
);
if (0!=vl_retCode) {
setverdict(pass, "DataSource query failed as expected with wrong data, dataSource := "&vl_dataProviderName& ", element := " & pl_elementName);
}else
{
setverdict(fail, "DataSource query was succesfull but it shouldn't have been with these values ,
dataSource := "&vl_dataProviderName& ", element := " & pl_elementName& ", params := "&log2str(pl_params));
}
f_EPTF_Base_cleanup_CT();
setverdict(pass);
}
testcase tc_EPTF_CS_dataSource_test()
runs on SYSTEM_CT
{
f_EPTF_UIHandler_init_CT("MTC", true);
f_EPTF_DataSource_registerReadyCallback(refers(f_EPTF_CS_Test_DataSourceClientReady ));
f_EPTF_UIHandler_clearGUI();
f_EPTF_UIHandler_addWindow();
f_EPTF_UIHandler_addMainTabbox();
var EPTF_ExecCtrl_UIHandler_CT vl_execCtrl := EPTF_ExecCtrl_UIHandler_CT.create("ExecCtrl");
vl_execCtrl.start(f_EPTF_ExecCtrl_UIHandler_behavior("ExecCtrl", 1, mtc, ""));
for(var integer i := 0; i < tsp_nof_A_CS_Admins; i := i + 1) {
var CS_ApplAdmin_Test_CT vl_CS_Admin_A := CS_ApplAdmin_Test_CT.create("CS_Admin");
vl_CS_Admin_A.start(f_EPTF_CS_Test_behavior("CS_Admin_A." & int2str(i), i, vl_execCtrl,true, mtc));
}
timer T_guard, T_alt;
T_guard.start( 50.0 );
T_alt.start( 0.0 );
alt{
[] T_guard.timeout{
setverdict(fail,"Timeout during config");
f_EPTF_Base_stopAll();
}
[v_startBecauseDSIsReady > 0] T_alt.timeout{}
};
timer T_wait;
T_wait.start( 10.0 );
T_wait.timeout;
f_EPTF_CS_Test_requestDataAndCheck( c_EPTF_CS_AvgLGenUsage, { }, {}, true, "40.000000", false);
f_EPTF_CS_Test_requestDataAndCheck( c_EPTF_CS_MaxLGenUsage, { }, {}, true, "0.000000", false);
f_EPTF_Base_cleanup_CT();
setverdict(pass);
}
testcase tc_EPTF_CS_customGUI_test() runs on SYSTEM_CT
{
timer T_watchdog := tsp_demoInterval;
f_EPTF_UIHandler_init_CT("MTC", true);
f_EPTF_UIHandler_clearGUI();
f_EPTF_UIHandler_addWindow();
var EPTF_ExecCtrl_UIHandler_CT vl_execCtrl := EPTF_ExecCtrl_UIHandler_CT.create("ExecCtrl");
vl_execCtrl.start(f_EPTF_ExecCtrl_UIHandler_behavior("ExecCtrl",
1, mtc, ""));
for(var integer i := 0; i < tsp_nof_A_CS_Admins; i := i + 1) {
var CS_ApplAdmin_Test_CT vl_CS_Admin_A := CS_ApplAdmin_Test_CT.create("CS_Admin");
vl_CS_Admin_A.start(f_EPTF_CS_Test_behavior("CS_Admin_A." & int2str(i), i, vl_execCtrl,true, mtc));
}
timer T_wait;
T_wait.start( 5.0 );
T_wait.timeout;
f_EPTF_UIHandler_createGUIFromFile(tsp_CS_guiXmlName, tsp_EPTF_GUI_Main_Window_WidgetId);
T_wait.start( 5.0 );
T_wait.timeout;
f_EPTF_Base_cleanup_CT();
setverdict(pass);
}
///////////////////////////////////////////////////////////
// Testcase: tc_EPTF_DS_Neg_WrongAvgLGenUsage
//
// Purpose:
// This is a fake negative test case.
// It tests the DataSourceClient function of Central Scheduling with this wrong request:
// Data Element: c_EPTF_CS_AvgLGenUsage
// Params: too many params
// A proper warning message should appear.
//
///////////////////////////////////////////////////////////
testcase tc_EPTF_DS_Neg_WrongAvgLGenUsage() runs on SYSTEM_CT
{
f_EPTF_CS_Test_wrongDataRequest(c_EPTF_CS_AvgLGenUsage, {{"nonexistent", "Nonexists"}});
}
///////////////////////////////////////////////////////////
// Testcase: tc_EPTF_DS_Neg_WrongMaxLGenUsage
//
// Purpose:
// This is a fake negative test case.
// It tests the DataSourceClient function of Central Scheduling with this wrong request:
// Data Element: c_EPTF_CS_MaxLGenUsage
// Params: too many params
// A proper warning message should appear.
//
///////////////////////////////////////////////////////////
testcase tc_EPTF_DS_Neg_WrongMaxLGenUsage() runs on SYSTEM_CT
{
f_EPTF_CS_Test_wrongDataRequest(c_EPTF_CS_MaxLGenUsage, {{"nonexistent", "Nonexists"}});
}
//=========================================================================
// Control
//=========================================================================
control {
execute(tc_EPTF_CS_Test_Admin_behavior());
execute(tc_EPTF_CS_Test_Admin_init());
execute(tc_EPTF_CS_Test_declareTrafficCase());
execute(tc_EPTF_CS_Test_getCompRefOfSelectedLGen());
execute(tc_EPTF_CS_Test_HL26276());
execute(tc_EPTF_CS_dataSource_test());
execute(tc_EPTF_DS_Neg_WrongAvgLGenUsage());
execute(tc_EPTF_DS_Neg_WrongMaxLGenUsage());
}
} // end of module