| /////////////////////////////////////////////////////////////////////////////// |
| // // |
| // 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_HostAdmin_demo |
| // |
| // Purpose: |
| // This module contains function definitions for testing EPTF Load measurement |
| // |
| // Module Parameters: |
| // tsp_demoInterval - *float* - interval of testing, default: 30.0 |
| // tsp_demoRefreshPeriod - *float* - local-measurement refresh period, default: 2.0 |
| // tsp_demoHost - *charstring* - remote-measurement hostname or IP address, default: 127.0.0.1 |
| // |
| // Module depends on: |
| // <EPTF_CLL_HostAdmin_BaseDefinitions> |
| // <EPTF_CLL_HostAdmin_BaseFunctions> |
| // <EPTF_CLL_HostAdmin_Definitions> |
| // <EPTF_CLL_HostAdmin_Functions> |
| // <EPTF_CLL_Variable_Definitions> |
| // <EPTF_CLL_Variable_Functions> |
| // <EPTF_CLL_Base_Definitions> |
| // <EPTF_CLL_Base_Functions> |
| // <EPTF_CLL_Common_Definitions> |
| // <EPTF_CLL_HostAdminUI_Definitions> |
| // <EPTF_CLL_HostAdminUI_Functions> |
| // <EPTF_CLL_UIHandler_Definitions> |
| // <EPTF_CLL_UIHandler_WidgetFunctions> |
| // |
| // Current Owner: |
| // Gabor Tatarka (egbotat) |
| // Bence Molnar (ebenmol) |
| // |
| // Last Review Date: |
| // 2008-02-14 |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| |
| module EPTF_HostAdmin_demo { |
| |
| import from EPTF_CLL_HostAdmin_BaseDefinitions all; |
| import from EPTF_CLL_HostAdmin_Definitions all; |
| |
| import from EPTF_CLL_HostAdminServer_Definitions all; |
| import from EPTF_CLL_HostAdminServer_Functions all; |
| |
| import from EPTF_CLL_Variable_Definitions all; |
| |
| import from EPTF_CLL_Base_Definitions 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; |
| |
| modulepar float tsp_demoInterval := 30.0; |
| modulepar float tsp_demoRefreshPeriod := 2.0; |
| modulepar charstring tsp_demoHost := "127.0.0.1"; |
| modulepar EPTF_CharstringList tsp_uiDemoHostList := {}; |
| |
| |
| type component HostAdminDemo_CT extends EPTF_Var_CT |
| { |
| var EPTF_HostAdmin_CT hostAdm; |
| |
| var integer v_testerHostLoad_k := -1; |
| var integer v_numCPUs_k := -1; |
| var EPTF_IntegerList v_CPULoads_k := {}; |
| var integer v_physicalMemory_k := -1; |
| var integer v_freeMemory_k := -1; |
| } |
| |
| type component HostAdminLocalDemo_CT extends EPTF_HostAdmin_Base_CT |
| { |
| } |
| |
| |
| const charstring c_hostAdmin_name := "HostAdmin_test" |
| |
| function f_demo_load(in charstring pl_selfName, in float pl_desiredLoad) |
| runs on EPTF_Base_CT |
| { |
| if(pl_desiredLoad > 0.99) { |
| action("desired load is bigger than 0.99, using 0.99"); |
| pl_desiredLoad := 0.99; |
| } |
| |
| f_EPTF_Base_init_CT(pl_selfName); |
| timer T; |
| var integer i; |
| var integer vl_lim := 1000; |
| var float vl_elapsed := 0.0; |
| while(vl_elapsed < 0.1) { |
| vl_lim := vl_lim * 10; |
| T.start(100.0); |
| for(i:=0; i<vl_lim; i:=i+1) { |
| var charstring vl_dummy := log2str(i); |
| } |
| vl_elapsed := T.read; |
| T.stop; |
| } |
| var float vl_idle := 1.0 - pl_desiredLoad; |
| const float cl_timeBase := 0.1; |
| var float vl_idleTime := cl_timeBase * vl_idle; |
| var float vl_loadTime := cl_timeBase * pl_desiredLoad; |
| action("time elapsed for ", vl_lim, " cycles: ", vl_elapsed); |
| vl_lim := float2int((vl_loadTime / vl_elapsed) * int2float(vl_lim)); |
| action("vl_lim: ", vl_lim); |
| T.start(vl_idleTime); |
| alt { |
| []T.timeout { |
| timer T_meas := 100.0; |
| T_meas.start; |
| for(i:=0; i<vl_lim; i:=i+1) { |
| var charstring vl_dummy := log2str(i); |
| } |
| vl_elapsed := T_meas.read; |
| T_meas.stop; |
| vl_idleTime := (vl_elapsed / pl_desiredLoad) * vl_idle; |
| // action(vl_idleTime); |
| T.start(vl_idleTime); |
| repeat; |
| } |
| } |
| } |
| |
| |
| type component SYSTEM_CT extends EPTF_UIHandler_CT, EPTF_HostAdminServer_CT |
| { |
| } |
| |
| |
| group HostAdminServer { |
| |
| modulepar charstring tsp_HostAdmin_DS_guiXmlName := "gui.xml"; |
| |
| type record HostLoadProcCfg { |
| charstring hostName optional, |
| float desiredLoad |
| } |
| type record of HostLoadProcCfg HostLoadProcCfgList |
| |
| modulepar HostLoadProcCfgList tsp_StartProcessesWithLoad := { |
| { |
| hostName := omit, |
| desiredLoad := 0.25 |
| } |
| } |
| |
| testcase tc_HostAdminServer() |
| runs on SYSTEM_CT |
| { |
| var integer i := 0; |
| f_EPTF_UIHandler_init_CT("MTC", true); |
| f_EPTF_UIHandler_clearGUI(); |
| |
| f_EPTF_HostAdminServer_init_CT("MTC", mtc); |
| |
| for(i:=0;i<lengthof(tsp_StartProcessesWithLoad);i:=i+1) { |
| var EPTF_Base_CT vl_load; |
| if(ispresent(tsp_StartProcessesWithLoad[i].hostName)) { |
| var charstring vl_bugfix := tsp_StartProcessesWithLoad[i].hostName; // TITAN 1.8.pl6 bug, see HO69261 |
| vl_load := EPTF_Base_CT.create(-, vl_bugfix); |
| } else { |
| vl_load := EPTF_Base_CT.create; |
| } |
| vl_load.start(f_demo_load("load_"&int2str(i), tsp_StartProcessesWithLoad[i].desiredLoad)); |
| } |
| |
| timer T1 := 5.0; |
| T1.start; |
| T1.timeout; |
| |
| f_EPTF_UIHandler_createGUIFromFile(tsp_HostAdmin_DS_guiXmlName); |
| |
| timer T2 := tsp_demoInterval; |
| T2.start; |
| T2.timeout; |
| |
| f_EPTF_Base_stop(pass); |
| } |
| |
| } // group HostAdminServer |
| |
| } // module |
| |