| /////////////////////////////////////////////////////////////////////////////// |
| // |
| // 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 |
| /////////////////////////////////////////////////////////////////////////////// |
| // |
| // File: EPTF_Applib_HTTP_Test_Application1_Functions.ttcn |
| // Rev: <RnXnn> |
| // Prodnr: CNL 113 618 |
| // Updated: 2012-02-23 |
| // Contact: http://ttcn.ericsson.se |
| /////////////////////////////////////////////////////////////////////////////// |
| |
| /////////////////////////////////////////////////////////// |
| // Module: EPTF_Applib_HTTP_Test_Application1_Functions |
| // |
| // Purpose: |
| // This module contains the functions to demo HTTP application |
| // |
| // Module Parameters: |
| // tsp_EPTF_HTTP_Test_Application1_numberOfLoadGens - *integer* - number of load generators |
| // tsp_EPTF_HTTP_Test_Responder_host - *charstring* - server simulator local IP address |
| // tsp_EPTF_HTTP_Test_Responder_port - *integer* - server simulator local port |
| // tsp_EPTF_HTTP_Test_Application1_host - *charstring* - HTTP application local IP address |
| // tsp_EPTF_HTTP_Test_Application1_port - *integer* - HTTP application local port |
| // |
| // Module depends on: |
| // <EPTF_CLL_Common_Definitions> |
| // |
| // <EPTF_CLL_Base_Functions> |
| // |
| // <EPTF_CLL_LGenBase_Definitions> |
| // |
| // <EPTF_CLL_LGenBase_ConfigDefinitions> |
| // |
| // <EPTF_CLL_LGenBase_ConfigFunctions> |
| // |
| // <EPTF_CLL_LGenBase_TrafficFunctions> |
| // |
| // <EPTF_CLL_HashMapInt2Int_Functions> |
| // |
| // <EPTF_CLL_Variable_Functions> |
| // |
| // <EPTF_CLL_FBQ_Functions> |
| // |
| // <EPTF_Applib_HTTP_Test_Application1_Definitions> |
| // |
| // <EPTF_HTTP_Transport_Definitions> |
| // |
| // <EPTF_HTTP_Transport_Functions> |
| // |
| // <EPTF_HTTP_Definitions> |
| // |
| // <EPTF_HTTP_Functions> |
| // |
| // Current Owner: |
| // EAKOPER |
| // |
| // Last Review Date: |
| // 2009-03-11 |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| |
| module EPTF_Applib_HTTP_Test_Application1_Functions { |
| |
| //========================================================================= |
| // Import Part |
| //========================================================================= |
| import from EPTF_CLL_Common_Definitions all; |
| import from EPTF_CLL_Base_Functions all; |
| import from EPTF_CLL_LGenBase_Definitions all; |
| import from EPTF_CLL_LGenBase_ConfigDefinitions all; |
| import from EPTF_CLL_LGenBase_ConfigFunctions all; |
| import from EPTF_CLL_LGenBase_TrafficFunctions all; |
| import from EPTF_CLL_HashMapInt2Int_Functions all; |
| import from EPTF_CLL_Variable_Functions all; |
| import from EPTF_CLL_FBQ_Functions all; |
| |
| import from EPTF_Applib_HTTP_Test_Application1_Definitions all; |
| |
| import from EPTF_HTTP_Transport_Definitions all; |
| import from EPTF_HTTP_Transport_Functions all; |
| import from EPTF_HTTP_Definitions all; |
| import from EPTF_HTTP_Functions all; |
| |
| //========================================================================= |
| // Module parameters |
| //========================================================================= |
| modulepar integer tsp_EPTF_HTTP_Test_Application1_numberOfLoadGens := 1; |
| modulepar charstring tsp_EPTF_HTTP_Test_Responder_host := "159.107.193.33"; |
| modulepar integer tsp_EPTF_HTTP_Test_Responder_port := 4000; |
| modulepar charstring tsp_EPTF_HTTP_Test_Application1_host := "159.107.193.33"; |
| modulepar integer tsp_EPTF_HTTP_Test_Application1_port := 5000; |
| |
| //========================================================================= |
| // Functions |
| //========================================================================= |
| // checks state of a port in a group (pl_group, pl_port) |
| // pl_state - port state |
| // pl_connId - connection id |
| // pl_c2g - should be in connection id 2 group id HashMap |
| // pl_c2p - should be in connection id 2 port id HashMap |
| // pl_busyState - should be busy in portStateQueue (meaning free/busy for sending) |
| function f_EPTF_HTTP_Test_Application1_checkPortState( |
| in integer pl_group, |
| in integer pl_port, |
| in EPTF_HTTP_Transport_ConnectionState pl_state, |
| in integer pl_connId, |
| in boolean pl_c2g, |
| in boolean pl_c2p, |
| in boolean pl_busyState) |
| runs on EPTF_HTTP_Test_Application1_LocalCT return boolean |
| { |
| log("Checking port state for :", pl_group, " / ", pl_port); |
| |
| var boolean vl_found; |
| var integer vl_result, vl_connId; |
| var EPTF_HTTP_Transport_ConnectionState vl_state; |
| |
| if (pl_group == -1 or pl_group >= sizeof(v_EPTF_HTTP_Transport_portDB)) { |
| log("Port database (GROUP) is wrong!"); |
| setverdict(fail); |
| return false; |
| } |
| |
| if (pl_port == -1 or pl_port >= sizeof(v_EPTF_HTTP_Transport_portDB[pl_group].portDatabase)) { |
| log("Port database (PORT) is wrong!"); |
| setverdict(fail); |
| return false; |
| } |
| |
| log(v_EPTF_HTTP_Transport_portDB[pl_group].portDatabase[pl_port]); |
| |
| vl_state := v_EPTF_HTTP_Transport_portDB[pl_group].portDatabase[pl_port].state; |
| if (vl_state != pl_state) |
| { |
| log("Inconsistent port state: ", vl_state, " instead of: ", pl_state); |
| setverdict(fail); |
| return false; |
| } |
| |
| vl_connId := v_EPTF_HTTP_Transport_portDB[pl_group].portDatabase[pl_port].connectionId; |
| if (pl_connId == -1 and vl_connId != pl_connId) |
| { |
| log("Inconsistent connnection id: ", vl_connId, " instead of: ", pl_connId); |
| setverdict(fail); |
| return false; |
| } |
| |
| if (pl_connId != -1 and vl_connId <= 0) |
| { |
| log("Inconsistent connnection id: ", vl_connId, " instead of a positive value!"); |
| setverdict(fail); |
| return false; |
| } |
| |
| vl_found := f_EPTF_int2int_HashMap_Find(v_EPTF_HTTP_Transport_connId2GroupId_HM, |
| vl_connId, vl_result); |
| |
| if (vl_found != pl_c2g) { |
| if (pl_c2g) { |
| log("Group id not found in Conn2Grp HM for connection (", |
| vl_connId, "), but it should be there!"); |
| } else { |
| log("Group id found in Conn2Grp HM for connection (", |
| vl_connId, "), but it shouldn't be there!"); |
| } |
| setverdict(fail); |
| return false; |
| } |
| |
| vl_found := f_EPTF_int2int_HashMap_Find(v_EPTF_HTTP_Transport_connId2PortId_HM, |
| vl_connId, vl_result); |
| |
| if (vl_found != pl_c2p) { |
| if (pl_c2p) { |
| log("Port id not found in Conn2Grp HM for connection (", |
| vl_connId, "), but it should be there!"); |
| } else { |
| log("Port id found in Conn2Grp HM for connection (", |
| vl_connId, "), but it shouldn't be there!"); |
| } |
| setverdict(fail); |
| return false; |
| } |
| |
| vl_found := f_EPTF_FBQ_itemIsBusy(pl_port, v_EPTF_HTTP_Transport_portDB[pl_group].portStateQueue); |
| if (pl_busyState != vl_found) { |
| if (vl_found) { |
| log("Port is busy for sending!"); |
| } |
| else { |
| log("Port is free for sending!"); |
| } |
| setverdict(fail); |
| return false; |
| } |
| |
| return true; |
| } |
| |
| function f_EPTF_HTTP_Test_Application1_checkResponses( |
| in integer pl_selfId, |
| in integer pl_succ) |
| runs on EPTF_HTTP_Test_Application1_CT |
| { |
| var EPTF_CharstringList vl_strList := {}; |
| |
| log("Self ID: ", pl_selfId, " and request number: ", pl_succ); |
| |
| for (var integer i := 0; i < pl_succ; i := i + 1) { |
| vl_strList[i] := "<A" & int2str(v_EPTF_HTTP_selfId) & |
| "." & int2str(i) & ">"; |
| } |
| |
| if (not match(v_HTTP1_strList, vl_strList)) { |
| log("Responses are inconsistenct!"); |
| log(match(v_HTTP1_strList, vl_strList)); |
| setverdict(fail); |
| } |
| } |
| |
| function f_EPTF_HTTP_Test_Application1_step_recordAnswer( |
| in EPTF_LGenBase_TestStepArgs pl_ptr) |
| runs on EPTF_HTTP_Test_Application1_CT |
| { |
| if (ischosen(v_EPTF_HTTP_incomingMessage.response)) { |
| log(v_EPTF_HTTP_incomingMessage); |
| v_HTTP1_strList[sizeof(v_HTTP1_strList)] := |
| v_EPTF_HTTP_incomingMessage.response.body; |
| log(v_HTTP1_strList); |
| |
| f_EPTF_Var_adjustContent( v_sizeofAnswers_idx, |
| { intVal := f_EPTF_Var_getIntValue(v_sizeofAnswers_idx) + 1 }); |
| f_EPTF_Var_refreshContent(v_sizeofAnswers_idx); |
| } |
| else { |
| f_EPTF_HTTP_error(%definitionId & ": Invalid resonse message received: " & |
| log2str(v_EPTF_HTTP_incomingMessage)); |
| } |
| } |
| |
| function f_EPTF_HTTP_Test_Application1_step_wrongState( |
| in EPTF_LGenBase_TestStepArgs pl_ptr) |
| runs on EPTF_HTTP_Test_Application1_CT |
| { |
| var integer eIdx := pl_ptr.eIdx; |
| var integer fIdx := pl_ptr.refContext.fCtxIdx; |
| |
| select (pl_ptr.refContext.fRefArgs[0]) |
| { |
| case (0) { |
| f_EPTF_HTTP_error("TrafficCaseStarted event received in Wait state for entity/fsm: " & |
| int2str(eIdx) & " / " & int2str(fIdx)); |
| } |
| case (1) { |
| f_EPTF_HTTP_error("StartTC event received in Wait state for entity/fsm: " & |
| int2str(eIdx) & " / " & int2str(fIdx)); |
| } |
| case (2) { |
| f_EPTF_HTTP_error("Message received event received in Idle state for entity/fsm: " & |
| int2str(eIdx) & " / " & int2str(fIdx)); |
| } |
| case (3) { |
| f_EPTF_HTTP_error("TIMEOUT timer timed out in Idle state for entity/fsm: " & |
| int2str(eIdx) & " / " & int2str(fIdx)); |
| } |
| } |
| } |
| |
| function f_EPTF_HTTP_Test_Application1_step_rightState( |
| in EPTF_LGenBase_TestStepArgs pl_ptr) |
| runs on EPTF_HTTP_Test_Application1_CT |
| { |
| var integer eIdx := pl_ptr.eIdx; |
| var integer fIdx := pl_ptr.refContext.fCtxIdx; |
| |
| select (pl_ptr.refContext.fRefArgs[0]) |
| { |
| case (0) { |
| f_EPTF_HTTP_debug("TrafficCaseStarted event received in Idle state for entity/fsm: " & |
| int2str(eIdx) & " / " & int2str(fIdx)); |
| } |
| case (1) { |
| f_EPTF_HTTP_debug("StartTC event received in Idle state for entity/fsm: " & |
| int2str(eIdx) & " / " & int2str(fIdx)); |
| } |
| case (2) { |
| f_EPTF_HTTP_debug("Message received event received in Wait state for entity/fsm: " & |
| int2str(eIdx) & " / " & int2str(fIdx)); |
| } |
| case (3) { |
| f_EPTF_HTTP_debug("TIMEOUT timer timed out in Wait state for entity/fsm: " & |
| int2str(eIdx) & " / " & int2str(fIdx)); |
| } |
| } |
| } |
| |
| function f_EPTF_HTTP_Test_Application1_step_enableStateCheck( |
| in EPTF_LGenBase_TestStepArgs pl_ptr) |
| runs on EPTF_HTTP_Test_Application1_CT |
| { |
| v_stateCheckEnabled := true; |
| } |
| |
| function f_EPTF_HTTP_Test_Application1_step_disableStateCheck( |
| in EPTF_LGenBase_TestStepArgs pl_ptr) |
| runs on EPTF_HTTP_Test_Application1_CT |
| { |
| v_stateCheckEnabled := false; |
| } |
| |
| function f_EPTF_HTTP_Test_Application1_step_checkPortState( |
| in EPTF_LGenBase_TestStepArgs pl_ptr) |
| runs on EPTF_HTTP_Test_Application1_LocalCT |
| { |
| if (not v_stateCheckEnabled) { |
| f_EPTF_HTTP_warning(%definitionId & ": State check disabled!"); |
| return; |
| }; |
| |
| var integer vl_grpIdx; |
| |
| select (pl_ptr.refContext.fRefArgs[0]) |
| { |
| case (0) |
| { |
| if (v_globalMode) { vl_grpIdx := 0; } else { vl_grpIdx := pl_ptr.eIdx; }; |
| |
| if (v_portMode) |
| { |
| if (not f_EPTF_HTTP_Test_Application1_checkPortState(vl_grpIdx, 0, OPENED, vl_grpIdx+1, true, true, false)) { f_EPTF_Base_stopAll(); } |
| } |
| else { |
| var integer vl_connId; |
| for (var integer i := 0; i < v_numOfPorts; i := i + 1) |
| { |
| vl_connId := (vl_grpIdx * v_numOfPorts) + i + 1; |
| if (not f_EPTF_HTTP_Test_Application1_checkPortState(vl_grpIdx, i, OPENED, vl_connId, true, true, false)) { f_EPTF_Base_stopAll(); } |
| } |
| } |
| } |
| case (1) |
| { |
| //log(v_EPTF_HTTP_ConnId2EIdx); |
| //log(v_EPTF_HTTP_ConnId2FIdx); |
| |
| if (v_globalMode) { vl_grpIdx := 0; } else { vl_grpIdx := pl_ptr.eIdx; }; |
| |
| if (v_portMode) |
| { |
| v_portStates[vl_grpIdx][0] := true; |
| |
| if (not f_EPTF_HTTP_Test_Application1_checkPortState(vl_grpIdx, 0, OPENED, vl_grpIdx+1, true, true, true)) { f_EPTF_Base_stopAll(); } |
| } |
| else { |
| var integer vl_port; |
| f_EPTF_FBQ_getBusyTailIdx(vl_port,v_EPTF_HTTP_Transport_portDB[vl_grpIdx].portStateQueue); // must be called after send message |
| log("Busy tail: ", vl_port); |
| |
| v_portStates[vl_grpIdx][vl_port] := true; |
| |
| var integer vl_connId; |
| for (var integer i := 0; i < v_numOfPorts; i := i + 1) |
| { |
| vl_connId := (vl_grpIdx * v_numOfPorts) + i + 1; |
| |
| |
| if (v_portStates[vl_grpIdx][i]) { |
| if (not f_EPTF_HTTP_Test_Application1_checkPortState(vl_grpIdx, i, OPENED, vl_connId, true, true, v_portStates[vl_grpIdx][i])) |
| { |
| f_EPTF_Base_stopAll(); |
| } |
| } |
| else { |
| if (v_iConnClose) { |
| if (not f_EPTF_HTTP_Test_Application1_checkPortState(vl_grpIdx, i, IDLE, -1, false, false, v_portStates[vl_grpIdx][i])) |
| { |
| f_EPTF_Base_stopAll(); |
| } |
| } |
| } |
| |
| } |
| } |
| } |
| case (2) |
| { |
| if (v_globalMode) { vl_grpIdx := 0; } else { vl_grpIdx := pl_ptr.eIdx; }; |
| |
| if (v_portMode) |
| { |
| v_portStates[vl_grpIdx][0] := false; |
| |
| if (v_iConnClose) { |
| if (not f_EPTF_HTTP_Test_Application1_checkPortState(vl_grpIdx, 0, IDLE, -1, false, false, false)) { f_EPTF_Base_stopAll(); } |
| } |
| else { |
| if (not f_EPTF_HTTP_Test_Application1_checkPortState(vl_grpIdx, 0, OPENED, vl_grpIdx+1, true, true, false)) { f_EPTF_Base_stopAll(); } |
| } |
| } |
| else |
| { |
| var integer vl_connId, vl_port; |
| f_EPTF_FBQ_getFreeTailIdx(vl_port,v_EPTF_HTTP_Transport_portDB[vl_grpIdx].portStateQueue); |
| log("Free tail: ", vl_port); |
| |
| v_portStates[vl_grpIdx][vl_port] := false; |
| |
| for (var integer i := 0; i < v_numOfPorts; i := i + 1) |
| { |
| if (v_iConnClose) |
| { |
| if (not f_EPTF_HTTP_Test_Application1_checkPortState(vl_grpIdx, i, IDLE, -1, false, false, v_portStates[vl_grpIdx][i])) { f_EPTF_Base_stopAll(); } |
| } |
| else |
| { |
| vl_connId := (vl_grpIdx * v_numOfPorts) + i + 1; |
| if (not f_EPTF_HTTP_Test_Application1_checkPortState(vl_grpIdx, i, OPENED, vl_connId, true, true, v_portStates[vl_grpIdx][i])) { f_EPTF_Base_stopAll(); } |
| } |
| } |
| } |
| } |
| case (3) |
| { |
| f_EPTF_HTTP_debug("Do nothing!"); |
| } |
| } |
| } |
| |
| function f_EPTF_HTTP_Test_Application1_createPort( |
| in integer pl_idx, |
| in boolean pl_iCO, |
| in boolean pl_iCC) |
| runs on EPTF_HTTP_Test_Application1_LocalCT return EPTF_HTTP_Transport_PortMode |
| { |
| var EPTF_HTTP_Transport_PortMode vl_connObj := |
| { |
| name := "MyPort." & int2str(pl_idx), |
| localHostInformation := {tsp_EPTF_HTTP_Test_Application1_host, tsp_EPTF_HTTP_Test_Application1_port + pl_idx + 100 * v_tcIdx}, |
| remoteHostInformation := {tsp_EPTF_HTTP_Test_Responder_host, tsp_EPTF_HTTP_Test_Responder_port + v_tcIdx}, |
| instantConnOpen := pl_iCO, |
| instantConnClose := pl_iCC, |
| useSSL := false, |
| userFunctions := omit |
| }; |
| |
| return vl_connObj; |
| } |
| |
| function f_EPTF_HTTP_Test_Application1_createGroup( |
| in integer pl_idx, |
| in integer pl_nOPs, |
| in boolean pl_iCO, |
| in boolean pl_iCC) |
| runs on EPTF_HTTP_Test_Application1_LocalCT return EPTF_HTTP_Transport_GroupMode |
| { |
| var EPTF_HTTP_Transport_GroupMode vl_connObj := { |
| name := "MyGroup." & int2str(pl_idx), |
| |
| localHostInformation := {tsp_EPTF_HTTP_Test_Application1_host, tsp_EPTF_HTTP_Test_Application1_port + pl_nOPs * pl_idx + 100 * v_tcIdx}, |
| remoteHostInformation := {tsp_EPTF_HTTP_Test_Responder_host, tsp_EPTF_HTTP_Test_Responder_port + v_tcIdx}, |
| |
| numberOfPorts := pl_nOPs, |
| localportStep := 1, |
| remoteportStep := 0, |
| |
| instantConnOpen := pl_iCO, |
| instantConnClose := pl_iCC, |
| useSSL := false, |
| userFunctions := omit |
| } |
| |
| return vl_connObj; |
| } |
| |
| function f_EPTF_HTTP_Test_Application1_createScenarios( |
| in integer pl_selfid, |
| in integer pl_numEntities, |
| out integer pl_egIdx, |
| out integer pl_scIdx, |
| out integer pl_tcIdx, |
| in boolean pl_globalMode, |
| in boolean pl_remote) |
| runs on EPTF_HTTP_Test_Application1_CT |
| { |
| f_EPTF_HTTP_debug("### " & %definitionId & "()"); |
| |
| var integer vl_noIntWarning; |
| var EPTF_IntegerList v_noIntListWarning; |
| var charstring vl_prefix := "HTTP1_"; |
| var charstring vl_name := vl_prefix & "APPL." & int2str(pl_selfid); |
| var charstring vl_tcname := vl_prefix & "SendReceive"; |
| var float vl_startDelay := int2float(pl_selfid); |
| log("Start delay: ", vl_startDelay); |
| |
| f_EPTF_HTTP_debug("Configuring traffic properties ..."); |
| |
| // Creating trafic manually (no execution control) |
| vl_noIntWarning := f_EPTF_LGenBase_declareEntityType( |
| vl_name & "ET", { c_EPTF_HTTP_myBName }); |
| vl_noIntWarning := f_EPTF_LGenBase_createEntityGroup( |
| {vl_name & "EG", vl_name & "ET", pl_numEntities}); |
| |
| vl_noIntWarning := f_EPTF_LGenBase_declareTcType2(valueof( |
| t_HTTP_defaultTC(vl_tcname & "TC", vl_tcname & "FSM", vl_name & "ET"))); |
| vl_noIntWarning := f_EPTF_LGenBase_declareScenarioType2(valueof( |
| t_HTTP_defaultSC(vl_tcname & "SC", { valueof(t_HTTP_defaultTCofSC(vl_tcname & "TC", vl_startDelay, 1.0)) } ))); |
| f_EPTF_LGenBase_createScenario2EntityGroup({vl_name & "EG", vl_tcname & "SC"}); |
| |
| var integer vl_groupIdx:=f_EPTF_LGenBase_entityGrpNameIndex(vl_name & "EG"); |
| var integer vl_groupBaseOffsetIdx:= f_EPTF_LGenBase_getEGrpBaseOffset(vl_groupIdx); |
| |
| var charstring vl_body := ""; |
| if (pl_globalMode) |
| { |
| for (var integer i := vl_groupBaseOffsetIdx; i < vl_groupBaseOffsetIdx + pl_numEntities; i := i + 1) |
| { |
| vl_body := "<A" & int2str(v_EPTF_HTTP_selfId) & "." & int2str(i) & ">"; |
| |
| f_EPTF_HTTP_setEntityContext (i, |
| "POST", |
| "http://responder.com", |
| 1, |
| 1, |
| f_EPTF_HTTP_createContextLengthHeaderLine(vl_body), |
| 0, |
| -, |
| { charVal := vl_body }); |
| } |
| }else{ |
| if (pl_remote) |
| { |
| for (var integer i := vl_groupBaseOffsetIdx; i < vl_groupBaseOffsetIdx + pl_numEntities; i := i + 1) |
| { |
| vl_body := "<A" & int2str(v_EPTF_HTTP_selfId) & "." & int2str(i) & ">"; |
| |
| f_EPTF_HTTP_setEntityContext (i, |
| "POST", |
| "http://responder.com", |
| 1, |
| 1, |
| f_EPTF_HTTP_createContextLengthHeaderLine(vl_body), |
| 5*v_EPTF_HTTP_selfId + i, |
| -, |
| { charVal := vl_body }); |
| } |
| } |
| for (var integer i := vl_groupBaseOffsetIdx; i < vl_groupBaseOffsetIdx + pl_numEntities; i := i + 1) |
| { |
| vl_body := "<A" & int2str(v_EPTF_HTTP_selfId) & "." & int2str(i) & ">"; |
| |
| f_EPTF_HTTP_setEntityContext (i, |
| "POST", |
| "http://responder.com", |
| 1, |
| 1, |
| f_EPTF_HTTP_createContextLengthHeaderLine(vl_body), |
| i, |
| -, |
| { charVal := vl_body }); |
| } |
| } |
| |
| pl_egIdx := f_EPTF_LGenBase_entityGrpNameIndex(vl_name & "EG"); |
| pl_scIdx := f_EPTF_LGenBase_scenarioNameIndex(vl_tcname & "SC"); |
| pl_tcIdx := f_EPTF_LGenBase_trafficCaseId(vl_name & "EG", vl_tcname & "SC", vl_tcname & "TC"); |
| } |
| |
| function f_EPTF_HTTP_Test_Application1_HTTP1_createConnectionObjects() |
| runs on EPTF_HTTP_Test_Application1_LocalCT |
| { |
| var integer vl_connObjIdx, i, j; |
| |
| f_EPTF_HTTP_Transport_debug(%definitionId & ": Starting ..."); |
| |
| if (v_portMode) |
| { |
| f_EPTF_HTTP_Transport_debug(%definitionId & ": Port mode"); |
| |
| if (v_globalMode) |
| { |
| f_EPTF_HTTP_Transport_debug(%definitionId & ": One port for all entities"); |
| |
| vl_connObjIdx := f_EPTF_HTTP_LocalTransport_newPort(f_EPTF_HTTP_Test_Application1_createPort(0, v_iConnOpen, v_iConnClose)); |
| |
| if (v_iConnOpen) { |
| if (not f_EPTF_HTTP_Test_Application1_checkPortState(0, 0, IDLE, -1, false, false, false)) { f_EPTF_Base_stopAll(); } |
| v_portStates[0][0] := false; |
| } |
| else { |
| if (not f_EPTF_HTTP_Test_Application1_checkPortState(0, 0, OPENED, 1, true, true, false)) { f_EPTF_Base_stopAll(); } |
| v_portStates[0][0] := false; |
| }; |
| } |
| else |
| { |
| f_EPTF_HTTP_Transport_debug(%definitionId & ": Different ports for entities"); |
| |
| for (i := 0; i < v_numEntities; i := i + 1) |
| { |
| vl_connObjIdx := f_EPTF_HTTP_LocalTransport_newPort(f_EPTF_HTTP_Test_Application1_createPort(i, v_iConnOpen, v_iConnClose)); |
| |
| if (v_iConnOpen) { |
| if (not f_EPTF_HTTP_Test_Application1_checkPortState(i, 0, IDLE, -1, false, false, false)) { f_EPTF_Base_stopAll(); } |
| v_portStates[i][0] := false; |
| } |
| else { |
| if (not f_EPTF_HTTP_Test_Application1_checkPortState(i, 0, OPENED, i+1, true, true, false)) { f_EPTF_Base_stopAll(); } |
| v_portStates[i][0] := false; |
| }; |
| } |
| } |
| } |
| else |
| { |
| f_EPTF_HTTP_Transport_debug(%definitionId & ": Group mode"); |
| |
| if (v_globalMode) |
| { |
| f_EPTF_HTTP_Transport_debug(%definitionId & ": One port for all entities"); |
| |
| vl_connObjIdx := f_EPTF_HTTP_LocalTransport_newPortGroup(f_EPTF_HTTP_Test_Application1_createGroup(0, v_numOfPorts, v_iConnOpen, v_iConnClose)); |
| |
| if (v_iConnOpen) { |
| for (i := 0; i < v_numOfPorts; i := i + 1) { |
| if (not f_EPTF_HTTP_Test_Application1_checkPortState(0, i, IDLE, -1, false, false, false)) { f_EPTF_Base_stopAll(); } |
| v_portStates[0][i] := false; |
| } |
| } |
| else { |
| for (i := 0; i < v_numOfPorts; i := i + 1) { |
| if (not f_EPTF_HTTP_Test_Application1_checkPortState(0, i, OPENED, i+1, true, true, false)) { f_EPTF_Base_stopAll(); } |
| v_portStates[0][i] := false; |
| } |
| }; |
| } |
| else |
| { |
| f_EPTF_HTTP_Transport_debug(%definitionId & ": Different ports for entities"); |
| |
| for (i := 0; i < v_numEntities; i := i + 1) { |
| vl_connObjIdx := f_EPTF_HTTP_LocalTransport_newPortGroup(f_EPTF_HTTP_Test_Application1_createGroup(i, v_numOfPorts, v_iConnOpen, v_iConnClose)); |
| |
| if (v_iConnOpen) { |
| for (j := 0; j < v_numOfPorts; j := j + 1) { |
| if (not f_EPTF_HTTP_Test_Application1_checkPortState(i, j, IDLE, -1, false, false, false)) { f_EPTF_Base_stopAll(); } |
| v_portStates[i][j] := false; |
| } |
| } |
| else { |
| for (j := 0; j < v_numOfPorts; j := j + 1) { |
| if (not f_EPTF_HTTP_Test_Application1_checkPortState(i, j, OPENED, (i*v_numOfPorts)+j+1, true, true, false)) { f_EPTF_Base_stopAll(); } |
| v_portStates[i][j] := false; |
| } |
| }; |
| } |
| } |
| } |
| } |
| |
| function f_EPTF_HTTP_Test_Application1_LocalBehavior( |
| in integer pl_tcIdx, |
| in integer pl_selfid, |
| in integer pl_numEntities, |
| in boolean pl_portMode, |
| in boolean pl_globalMode, |
| in integer pl_numOfPorts, |
| in boolean pl_iConnOpen, |
| in boolean pl_iConnClose, |
| in float pl_runningTime, |
| in float pl_responderRunningTime) |
| runs on EPTF_HTTP_Test_Application1_LocalCT |
| { |
| f_EPTF_HTTP_debug("### " & %definitionId & "()"); |
| |
| var integer vl_noIntWarning, vl_egIdx, vl_scIdx, vl_TCIdx; |
| var EPTF_IntegerList vl_noIntListWarning; |
| var charstring vl_prefix := "HTTP1_"; |
| var charstring vl_name := vl_prefix & "APPL." & int2str(pl_selfid); |
| var charstring vl_tcname := vl_prefix & "SendReceive"; |
| |
| v_tcIdx := pl_tcIdx; |
| |
| v_numEntities := pl_numEntities; |
| v_portMode := pl_portMode; |
| v_globalMode := pl_globalMode; |
| v_numOfPorts := pl_numOfPorts; |
| v_iConnOpen := pl_iConnOpen; |
| v_iConnClose := pl_iConnClose; |
| |
| // Initialize applib |
| f_EPTF_HTTP_init(vl_name, pl_selfid, vl_prefix); |
| |
| // Application steps |
| vl_noIntWarning := f_EPTF_LGenBase_declareFunction("RecordAnswer", |
| {testStepFunction := refers(f_EPTF_HTTP_Test_Application1_step_recordAnswer)}); |
| vl_noIntWarning := f_EPTF_LGenBase_declareFunction("WrongState", |
| {testStepFunction := refers(f_EPTF_HTTP_Test_Application1_step_wrongState)}); |
| vl_noIntWarning := f_EPTF_LGenBase_declareFunction("RightState", |
| {testStepFunction := refers(f_EPTF_HTTP_Test_Application1_step_rightState)}); |
| vl_noIntWarning := f_EPTF_LGenBase_declareFunction("CheckState", |
| {testStepFunction := refers(f_EPTF_HTTP_Test_Application1_step_checkPortState)}); |
| vl_noIntWarning := f_EPTF_LGenBase_declareFunction("DisableState", |
| {testStepFunction := refers(f_EPTF_HTTP_Test_Application1_step_disableStateCheck)}); |
| vl_noIntWarning := f_EPTF_LGenBase_declareFunction("EnableState", |
| {testStepFunction := refers(f_EPTF_HTTP_Test_Application1_step_enableStateCheck)}); |
| |
| // Initialize transport |
| vl_noIntWarning := f_EPTF_HTTP_LocalTransport_init_CT(vl_name, |
| refers(f_EPTF_HTTP_messageReceived), |
| refers(f_EPTF_HTTP_eventReceived), |
| refers(f_EPTF_HTTP_socketErrorReceived)); |
| |
| f_EPTF_HTTP_setSendRequestFunction(refers(f_EPTF_HTTP_LocalTransport_sendMessage)); |
| f_EPTF_HTTP_setConnectionCloseFunction(refers(f_EPTF_HTTP_LocalTransport_connectionClose)); |
| f_EPTF_HTTP_setConnectionOpenFunction(refers(f_EPTF_HTTP_LocalTransport_connectionOpen)); |
| f_EPTF_HTTP_setConnectionHalfCloseFunction(refers(f_EPTF_HTTP_LocalTransport_connectionHalfClose)); |
| f_EPTF_HTTP_setClosePortOfUserFunction(refers(f_EPTF_HTTP_LocalTransport_closePortOfUser)); |
| f_EPTF_HTTP_setFreePortOfUserFunction(refers(f_EPTF_HTTP_LocalTransport_freePortOfUser)); |
| |
| f_EPTF_Var_newInt("NumberOfReceivedAnswers", 0, v_sizeofAnswers_idx); |
| |
| if (pl_tcIdx == 16) { // TC 16 is the index of the reconnect test traffic case (no state check performed) |
| vl_noIntListWarning := f_EPTF_LGenBase_TcMgmt_declareCompactFsmTables( |
| f_EPTF_HTTP_Test_Application1_HTTP1_CreateBasicFSM_Local_RECONNECTTEST(vl_tcname & "FSM")); |
| } else { |
| vl_noIntListWarning := f_EPTF_LGenBase_TcMgmt_declareCompactFsmTables( |
| f_EPTF_HTTP_Test_Application1_HTTP1_CreateBasicFSM_Local(vl_tcname & "FSM")); |
| } |
| |
| |
| f_EPTF_HTTP_Test_Application1_createScenarios(pl_selfid, pl_numEntities, vl_egIdx, vl_scIdx, vl_TCIdx, pl_globalMode, false); |
| |
| f_EPTF_HTTP_debug("numEntities: "&log2str(pl_numEntities)&"eGrpIdx: "&log2str(vl_egIdx)&" scIdx: "&log2str(vl_scIdx)); |
| |
| f_EPTF_HTTP_debug("getEGrpBaseOffset: "&log2str(f_EPTF_LGenBase_getEGrpBaseOffset(vl_egIdx))); |
| |
| f_EPTF_HTTP_Test_Application1_HTTP1_createConnectionObjects(); |
| |
| f_EPTF_LGenBase_enableScenarioOnEntityGroup(vl_egIdx, vl_scIdx, true); |
| |
| f_EPTF_HTTP_debug("Entering main altstep ..."); |
| |
| timer t_guard := pl_runningTime; |
| t_guard.start; |
| |
| alt { |
| [] t_guard.timeout { f_EPTF_HTTP_debug("Timer timed out!"); } |
| } |
| |
| f_EPTF_LGenBase_stopScenarioByIdx(vl_egIdx, vl_scIdx); |
| |
| f_EPTF_HTTP_debug("Responses: " & log2str(v_HTTP1_strList)); |
| |
| if (pl_tcIdx != 16) { // TC 16 is the index of the reconnect test traffic case (no state check performed) |
| var integer vl_nofStarts := f_EPTF_LGenBase_getTcStarts(vl_TCIdx); |
| var integer vl_nofSucc := f_EPTF_LGenBase_getTcSuccesses(vl_TCIdx); |
| var integer vl_nofFails := f_EPTF_LGenBase_getTcFails(vl_TCIdx); |
| |
| f_EPTF_HTTP_debug("Number of starts: " & int2str(vl_nofStarts)); |
| f_EPTF_HTTP_debug("Number of successful: " & int2str(vl_nofSucc)); |
| f_EPTF_HTTP_debug("Number of fails: " & int2str(vl_nofFails)); |
| |
| if (vl_nofStarts != vl_nofSucc + vl_nofFails) |
| { |
| //wait for pending |
| timer t_wait := 2.0; |
| t_wait.start; |
| t_wait.timeout; |
| } |
| |
| f_EPTF_HTTP_Test_Application1_checkResponses(pl_selfid, vl_nofSucc); |
| } |
| |
| f_EPTF_HTTP_debug("Quitting load generator ..."); |
| |
| setverdict(pass); |
| |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| function f_EPTF_HTTP_Test_Application1_RemoteBehavior( |
| in integer pl_selfid, |
| in integer pl_numEntities, |
| in boolean pl_globalMode, |
| in float pl_runningTime, |
| in float pl_responderRunningTime) |
| runs on EPTF_HTTP_Test_Application1_RemoteCT |
| { |
| f_EPTF_HTTP_debug("### " & %definitionId & "()"); |
| |
| var integer vl_noIntWarning, vl_egIdx, vl_scIdx, vl_tcIdx; |
| var charstring vl_prefix := "HTTP1_"; |
| var charstring vl_name := vl_prefix & "APPL." & int2str(pl_selfid); |
| var charstring vl_tcname := vl_prefix & "SendReceive"; |
| |
| log("Applib init ..."); |
| |
| // Initialize applib |
| f_EPTF_HTTP_init(vl_name, pl_selfid, vl_prefix); |
| |
| log("Steps ..."); |
| |
| // Application steps |
| vl_noIntWarning := f_EPTF_LGenBase_declareFunction("RecordAnswer", |
| {testStepFunction := refers(f_EPTF_HTTP_Test_Application1_step_recordAnswer)}); |
| vl_noIntWarning := f_EPTF_LGenBase_declareFunction("WrongState", |
| {testStepFunction := refers(f_EPTF_HTTP_Test_Application1_step_wrongState)}); |
| vl_noIntWarning := f_EPTF_LGenBase_declareFunction("RightState", |
| {testStepFunction := refers(f_EPTF_HTTP_Test_Application1_step_rightState)}); |
| //f_EPTF_LGenBase_declareFunction("CheckState", |
| // {testStepFunction := refers(f_EPTF_HTTP_Test_Application1_step_checkPortState)}); |
| vl_noIntWarning := f_EPTF_LGenBase_declareFunction("DisableState", |
| {testStepFunction := refers(f_EPTF_HTTP_Test_Application1_step_disableStateCheck)}); |
| vl_noIntWarning := f_EPTF_LGenBase_declareFunction("EnableState", |
| {testStepFunction := refers(f_EPTF_HTTP_Test_Application1_step_enableStateCheck)}); |
| |
| log("Remote init ..."); |
| |
| // Initialize transport |
| vl_noIntWarning := f_EPTF_HTTP_RemoteTransport_init_CT(vl_name, |
| refers(f_EPTF_HTTP_messageReceived), |
| refers(f_EPTF_HTTP_eventReceived), |
| refers(f_EPTF_HTTP_socketErrorReceived)); |
| |
| log("Reset funcs ..."); |
| |
| f_EPTF_HTTP_setSendRequestFunction(refers(f_EPTF_HTTP_RemoteTransport_sendMessage)); |
| f_EPTF_HTTP_setConnectionCloseFunction(refers(f_EPTF_HTTP_RemoteTransport_connectionClose)); |
| f_EPTF_HTTP_setConnectionOpenFunction(refers(f_EPTF_HTTP_RemoteTransport_connectionOpen)); |
| f_EPTF_HTTP_setConnectionHalfCloseFunction(refers(f_EPTF_HTTP_RemoteTransport_connectionHalfClose)); |
| f_EPTF_HTTP_setClosePortOfUserFunction(refers(f_EPTF_HTTP_RemoteTransport_closePortOfUser)); |
| f_EPTF_HTTP_setFreePortOfUserFunction(refers(f_EPTF_HTTP_RemoteTransport_freePortOfUser)); |
| |
| f_EPTF_Var_newInt("NumberOfReceivedAnswers", 0, v_sizeofAnswers_idx); |
| |
| //f_EPTF_HTTP_Test_Application1_HTTP1_createConnectionObjects(); |
| |
| log("FSM ..."); |
| |
| var EPTF_IntegerList vl_noIntListWarning := f_EPTF_LGenBase_TcMgmt_declareCompactFsmTables( |
| f_EPTF_HTTP_Test_Application1_HTTP1_CreateBasicFSM_Remote(vl_tcname & "FSM")); |
| |
| log("Scaneraios ..."); |
| |
| f_EPTF_HTTP_Test_Application1_createScenarios(pl_selfid, pl_numEntities, vl_egIdx, vl_scIdx, vl_tcIdx, pl_globalMode, true); |
| |
| log("Enable scenarios ..."); |
| |
| f_EPTF_LGenBase_enableScenarioOnEntityGroup(vl_egIdx, vl_scIdx, true); |
| |
| f_EPTF_HTTP_debug("Entity context database: " & log2str(v_EPTF_HTTP_contexts)); |
| |
| f_EPTF_HTTP_debug("Entering main altstep ..."); |
| |
| timer t_guard := pl_runningTime; |
| t_guard.start; |
| |
| alt { |
| [] t_guard.timeout { f_EPTF_HTTP_debug("Timer timed out!"); } |
| } |
| |
| f_EPTF_LGenBase_stopScenarioByIdx(vl_egIdx, vl_scIdx); |
| |
| //f_EPTF_HTTP_RemoteTransport_cleanup_CT(); |
| |
| f_EPTF_HTTP_debug("Responses: " & log2str(v_HTTP1_strList)); |
| |
| var integer vl_nofStarts := f_EPTF_LGenBase_getTcStarts(vl_tcIdx); |
| var integer vl_nofSucc := f_EPTF_LGenBase_getTcSuccesses(vl_tcIdx); |
| var integer vl_nofFails := f_EPTF_LGenBase_getTcFails(vl_tcIdx); |
| |
| f_EPTF_HTTP_debug("Number of starts: " & int2str(vl_nofStarts)); |
| f_EPTF_HTTP_debug("Number of successful: " & int2str(vl_nofSucc)); |
| f_EPTF_HTTP_debug("Number of fails: " & int2str(vl_nofFails)); |
| |
| f_EPTF_HTTP_Test_Application1_checkResponses(pl_selfid, vl_nofSucc); |
| |
| f_EPTF_HTTP_debug("Quitting load generator ..."); |
| |
| f_EPTF_Base_cleanup_CT(); |
| |
| setverdict(pass); |
| } |
| |
| function f_EPTF_HTTP_Test_Application1_Mapper_Behavior( |
| in EPTF_HTTP_Test_Application1_RemoteCTList pl_comps, |
| in integer pl_tcIdx, |
| in integer pl_numEntities, |
| in boolean pl_portMode, |
| in boolean pl_globalMode, |
| in integer pl_numOfPorts, |
| in boolean pl_iConnOpen, |
| in boolean pl_iConnClose, |
| in float pl_runningTime) |
| runs on EPTF_HTTP_Test_Application1_MapperCT |
| { |
| f_EPTF_HTTP_Transport_debug("### " & %definitionId & "()"); |
| |
| v_tcIdx := pl_tcIdx; |
| |
| v_numEntities := 2*pl_numEntities; // wired in for two lgens only |
| v_portMode := pl_portMode; |
| v_globalMode := pl_globalMode; |
| v_numOfPorts := pl_numOfPorts; |
| v_iConnOpen := pl_iConnOpen; |
| v_iConnClose := pl_iConnClose; |
| |
| var integer i, j, vl_initResult := |
| f_EPTF_HTTP_Mapper_init_CT("HTTP1_MAPPER"); |
| |
| var EPTF_HTTP_Mapper_RoutingList vl_rInfo; |
| |
| f_EPTF_HTTP_Test_Application1_HTTP1_createConnectionObjects(); |
| |
| // set routing |
| if (pl_globalMode) |
| { |
| var EPTF_IntegerList vl_comps := {}; |
| for (i := 0; i < sizeof(pl_comps); i := i + 1) { |
| vl_comps[i] := f_EPTF_Base_upcast(pl_comps[i]); |
| } |
| |
| vl_rInfo := {{0, vl_comps}}; |
| f_EPTF_HTTP_Transport_debug("Routing info: " & log2str(vl_rInfo)); |
| } |
| else { |
| |
| var integer vl_size := sizeof(v_EPTF_HTTP_Transport_portDB); // better with FBQ but ok for test |
| var integer vl_psize := float2int(int2float(vl_size) / int2float(sizeof(pl_comps))); |
| |
| log(vl_size); |
| log(vl_psize); |
| |
| if (vl_size == 0) { vl_size := 1; }; |
| |
| for (j:= 0; j < sizeof(pl_comps); j := j + 1) |
| { |
| for (i := j*vl_psize; i < (j+1)*vl_psize; i := i + 1) |
| { |
| vl_rInfo[i].groupId := i; |
| vl_rInfo[i].compIdList := { f_EPTF_Base_upcast(pl_comps[j]) }; |
| } |
| } |
| f_EPTF_HTTP_Transport_debug("Routing info: " & log2str(vl_rInfo)); |
| } |
| |
| f_EPTF_HTTP_Mapper_setRouting(vl_rInfo); |
| |
| f_EPTF_HTTP_Transport_debug("Entering main altstep ..."); |
| |
| timer t_guard := pl_runningTime; |
| t_guard.start; |
| |
| alt { |
| [] t_guard.timeout { f_EPTF_HTTP_Transport_debug("Timer timed out!"); } |
| } |
| |
| setverdict(pass); |
| |
| f_EPTF_HTTP_Transport_debug("Quitting mapper ..."); |
| |
| //f_EPTF_Base_stopRemote(mtc); |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| template EPTF_HTTP_Transport_PortGroup t_expectedPortGroup1 := { |
| name := "MyGroup", |
| |
| baseLocalHostInformation := { "127.0.0.1", 4000 }, |
| baseRemoteHostInformation := { "127.0.0.1", 5000 }, |
| |
| currentPortId := ?, |
| |
| numberOfPorts := 2, |
| localportStep := 1, |
| remoteportStep := 0, |
| |
| portDatabase := { |
| { |
| groupIndex := 0, |
| portIndex := 0, |
| connectionId := -1, |
| sessionId := -1, |
| portId := -1, |
| localhostInfoIdx := 0, |
| remotehostInfoIdx := 0, |
| state := IDLE, |
| portType := OUTGOING_PORT, |
| buffer := false, |
| messageBuffer := omit |
| }, |
| { |
| groupIndex := 0, |
| portIndex := 1, |
| connectionId := -1, |
| sessionId := -1, |
| portId := -1, |
| localhostInfoIdx := 1, |
| remotehostInfoIdx := 0, |
| state := IDLE, |
| portType := OUTGOING_PORT, |
| buffer := false, |
| messageBuffer := omit |
| } |
| }, |
| |
| listeningPortIdx := -1, |
| |
| defaultFIdx := 0, |
| |
| portQueue := ?, |
| portStateQueue := ?, |
| |
| useSSL := false, |
| instantConnOpen := true, |
| instantConnClose := true, |
| buffer := false |
| }; |
| |
| template EPTF_HTTP_Transport_PortGroup t_expectedPortGroup4 modifies t_expectedPortGroup1 := { |
| name := "MyPort", |
| |
| numberOfPorts := 1, |
| localportStep := 0, |
| remoteportStep := 0, |
| |
| portDatabase := { |
| { |
| groupIndex := 1, |
| portIndex := 0, |
| connectionId := -1, |
| sessionId := -1, |
| portId := -1, |
| localhostInfoIdx := 0, |
| remotehostInfoIdx := 0, |
| state := IDLE, |
| portType := OUTGOING_PORT, |
| buffer := false, |
| messageBuffer := omit |
| } |
| }, |
| |
| defaultFIdx := 2 |
| } |
| |
| template EPTF_HTTP_Transport_PortGroup t_expectedPortGroup5 modifies t_expectedPortGroup1 := { |
| name := "MyPort2", |
| |
| numberOfPorts := 1, |
| localportStep := 0, |
| remoteportStep := 0, |
| |
| portDatabase := { |
| { |
| groupIndex := 2, |
| portIndex := 0, |
| connectionId := -1, |
| sessionId := -1, |
| portId := -1, |
| localhostInfoIdx := 0, |
| remotehostInfoIdx := 0, |
| state := IDLE, |
| portType := OUTGOING_PORT, |
| buffer := false, |
| messageBuffer := omit |
| } |
| }, |
| |
| defaultFIdx := 2 |
| } |
| |
| template EPTF_HTTP_Transport_PortGroup t_expectedPortGroup2 modifies t_expectedPortGroup1 := { |
| numberOfPorts := 3, |
| portDatabase := { |
| { |
| groupIndex := 0, |
| portIndex := 0, |
| connectionId := -1, |
| sessionId := -1, |
| portId := -1, |
| localhostInfoIdx := 0, |
| remotehostInfoIdx := 0, |
| state := IDLE, |
| portType := OUTGOING_PORT, |
| buffer := false, |
| messageBuffer := omit |
| }, |
| { |
| groupIndex := 0, |
| portIndex := 1, |
| connectionId := -1, |
| sessionId := -1, |
| portId := -1, |
| localhostInfoIdx := 1, |
| remotehostInfoIdx := 0, |
| state := IDLE, |
| portType := OUTGOING_PORT, |
| buffer := false, |
| messageBuffer := omit |
| }, |
| { |
| groupIndex := 0, |
| portIndex := 2, |
| connectionId := -1, |
| sessionId := -1, |
| portId := -1, |
| localhostInfoIdx := 2, |
| remotehostInfoIdx := 0, |
| state := IDLE, |
| portType := OUTGOING_PORT, |
| buffer := false, |
| messageBuffer := omit |
| } |
| } |
| }; |
| |
| template EPTF_HTTP_Transport_PortGroup t_expectedPortGroup3 modifies t_expectedPortGroup1 := { |
| portDatabase := { |
| { |
| groupIndex := -1, |
| portIndex := -1, |
| connectionId := -1, |
| sessionId := -1, |
| portId := -1, |
| localhostInfoIdx := -1, |
| remotehostInfoIdx := -1, |
| state := IDLE, |
| portType := OUTGOING_PORT, |
| buffer := false, |
| messageBuffer := omit |
| }, |
| { |
| groupIndex := 0, |
| portIndex := 1, |
| connectionId := -1, |
| sessionId := -1, |
| portId := -1, |
| localhostInfoIdx := 1, |
| remotehostInfoIdx := 0, |
| state := IDLE, |
| portType := OUTGOING_PORT, |
| buffer := false, |
| messageBuffer := omit |
| }, |
| { |
| groupIndex := 0, |
| portIndex := 2, |
| connectionId := -1, |
| sessionId := -1, |
| portId := -1, |
| localhostInfoIdx := 2, |
| remotehostInfoIdx := 0, |
| state := IDLE, |
| portType := OUTGOING_PORT, |
| buffer := false, |
| messageBuffer := omit |
| } |
| } |
| }; |
| |
| template EPTF_HTTP_Transport_PortGroupList t_expectedPortDB1( |
| template EPTF_HTTP_Transport_PortGroupList pl_groups) := pl_groups; |
| |
| |
| function f_EPTF_HTTP_Test_Application1_Mapper_Behavior_CheckRandomAPI( |
| in float pl_runningTime) |
| runs on EPTF_HTTP_Test_Application1_MapperCT |
| { |
| f_EPTF_HTTP_Transport_debug("### " & %definitionId & "()"); |
| |
| var boolean vl_pass := true; |
| var integer i, j, vl_initResult := |
| f_EPTF_HTTP_Mapper_init_CT("HTTP1_MAPPER"); |
| |
| f_EPTF_HTTP_Transport_debug("Entering main altstep ..."); |
| |
| timer t_guard := pl_runningTime; |
| t_guard.start; |
| |
| alt { |
| [] t_guard.timeout { f_EPTF_HTTP_Transport_debug("Timer timed out!"); } |
| } |
| |
| f_EPTF_HTTP_Mapper_cleanup_CT(); |
| |
| f_EPTF_HTTP_Transport_debug("Quitting mapper ..."); |
| |
| if (vl_pass) { setverdict(pass); }; |
| } |
| |
| function f_EPTF_HTTP_Test_Application1_Mapper_Behavior_CheckAPI( |
| in float pl_runningTime) |
| runs on EPTF_HTTP_Test_Application1_MapperCT |
| { |
| f_EPTF_HTTP_Transport_debug("### " & %definitionId & "()"); |
| |
| var boolean vl_pass := true; |
| var integer i, j, vl_initResult := |
| f_EPTF_HTTP_Mapper_init_CT("HTTP1_MAPPER"); |
| |
| var EPTF_HTTP_Test_Valid vl_validation; |
| timer t_guard := pl_runningTime; |
| t_guard.start; |
| |
| alt { |
| [] v_validation_PCO.receive(EPTF_HTTP_Test_Valid:?) -> value vl_validation |
| { |
| select (vl_validation.step) { |
| case (0) |
| { |
| log(v_EPTF_HTTP_Transport_portDB); |
| |
| if (not match(v_EPTF_HTTP_Transport_portDB, t_expectedPortDB1({ t_expectedPortGroup1 }))) { |
| log("Database inconsistency after addition to v_EPTF_HTTP_Transport_portDB!"); |
| log(match(v_EPTF_HTTP_Transport_portDB, t_expectedPortDB1({ t_expectedPortGroup1 }))); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| |
| v_validation_PCO.send(EPTF_HTTP_Test_Status:READY); |
| } |
| case (1) |
| { |
| log(v_EPTF_HTTP_Transport_portDB); |
| |
| if (not match(v_EPTF_HTTP_Transport_portDB, t_expectedPortDB1({ t_expectedPortGroup2 }))) { |
| log("Database inconsistency after addition to v_EPTF_HTTP_Transport_portDB!"); |
| log(match(v_EPTF_HTTP_Transport_portDB, t_expectedPortDB1({ t_expectedPortGroup2 }))); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| } |
| case (2) |
| { |
| log(v_EPTF_HTTP_Transport_portDB); |
| |
| if (not match(v_EPTF_HTTP_Transport_portDB, t_expectedPortDB1({ t_expectedPortGroup3 }))) { |
| log("Database inconsistency after delete to v_EPTF_HTTP_Transport_portDB!"); |
| log(match(v_EPTF_HTTP_Transport_portDB, t_expectedPortDB1({ t_expectedPortGroup3 }))); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| } |
| case (3) |
| { |
| log(v_EPTF_HTTP_Transport_portDB); |
| |
| if (not match(v_EPTF_HTTP_Transport_portDB, t_expectedPortDB1({ t_expectedPortGroup3, t_expectedPortGroup4, t_expectedPortGroup5 }))) { |
| log("Database inconsistency after addition to v_EPTF_HTTP_Transport_portDB!"); |
| log(match(v_EPTF_HTTP_Transport_portDB, t_expectedPortDB1({ t_expectedPortGroup3, t_expectedPortGroup4, t_expectedPortGroup5 }))); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| } |
| } |
| |
| v_validation_PCO.send(EPTF_HTTP_Test_Status:READY) |
| repeat; |
| } |
| [] v_validation_PCO.receive{repeat;} |
| [] t_guard.timeout { f_EPTF_HTTP_Transport_debug("Timer timed out!"); } |
| } |
| |
| f_EPTF_HTTP_Mapper_cleanup_CT(); |
| |
| f_EPTF_HTTP_Transport_debug("Quitting mapper ..."); |
| |
| if (vl_pass) { setverdict(pass); }; |
| } |
| |
| function f_EPTF_HTTP_Test_Application1_HTTP1_CreateBasicFSM_Local( |
| in charstring pl_name) |
| runs on EPTF_HTTP_Test_Application1_LocalCT |
| return EPTF_LGenBase_TcMgmt_CompactFsmTableDeclaratorList |
| { |
| return { |
| { name := pl_name, |
| stateList := { "idle", "wait" }, |
| timerList := { { name := "TIMEOUT", startValue := 1.0 } }, |
| table := { |
| /* |
| // TC tarted event |
| { |
| eventToListen := { c_EPTF_LGenBase_behavior, c_EPTF_LGenBase_inputName_testMgmt_trafficCaseStarted, fsm }, |
| cellRow := { |
| // state == idle |
| { { |
| { "RightState", { stepContextArgs := { 0 } } }, |
| { c_EPTf_EPTF_HTTP_Test_Application1_stepName_openConnection, { stepContextArgs := {} } }, |
| { "CheckState", { stepContextArgs := { 0 } } } |
| }, omit, omit }, |
| // state == wait |
| { { |
| { "WrongState", { stepContextArgs := { 0 } } } |
| }, omit, "idle" } |
| } |
| }, |
| */ |
| // start TC event |
| { |
| eventToListen := { c_EPTF_LGenBase_behavior, c_EPTF_LGenBase_inputName_testMgmt_startTC, fsm }, |
| cellRow := { |
| // state == idle |
| { { |
| { "RightState", { stepContextArgs := { 1 } } }, |
| { c_EPTF_HTTP_stepName_sendRequest, { stepContextArgs := {} } }, |
| { "CheckState", { stepContextArgs := { 1 } } } |
| }, omit, "wait" }, |
| // state == wait |
| { { |
| { "WrongState", { stepContextArgs := { 1 } } } |
| }, omit, "idle" } |
| } |
| }, |
| |
| // answer OK event |
| { |
| eventToListen := { c_EPTF_HTTP_myBName, c_EPTF_HTTP_inputName_responseCharReceived, fsm }, |
| cellRow := { |
| // state == idle |
| { { |
| { "WrongState", { stepContextArgs := { 2 } } } |
| }, omit, omit }, |
| // state == wait |
| { { |
| { "RightState", { stepContextArgs := { 2 } } }, |
| { "RecordAnswer", { stepContextArgs := {} } }, |
| { "CheckState", { stepContextArgs := { 2 } } }, |
| { c_EPTF_LGenBase_StepFunction_trafficSuccess, { stepContextArgs := {} } } |
| }, omit, "idle" } |
| } |
| }, |
| |
| // timeout event |
| { |
| eventToListen := { c_EPTF_LGenBase_specialBName_timerTimeout, "TIMEOUT", fsm }, |
| cellRow := { |
| // state == idle |
| { { |
| { "WrongState", { stepContextArgs := { 3 } } } |
| }, omit, "idle" }, |
| // state == wait |
| { { |
| { "RightState", { stepContextArgs := { 3 } } }, |
| { c_EPTF_HTTP_stepName_handleTimeout, { stepContextArgs := {} } }, |
| { c_EPTF_HTTP_stepName_cleanUpContext, { stepContextArgs := {} } }, |
| { c_EPTF_LGenBase_StepFunction_trafficFailed, { stepContextArgs := {} } } |
| }, omit, "idle" } |
| } |
| }, |
| |
| // connection closed event |
| { |
| eventToListen := { c_EPTF_HTTP_myBName, c_EPTF_HTTP_inputName_connectionClosed, fsm }, |
| cellRow := { |
| // state == idle |
| { { |
| { "DisableState", { stepContextArgs := { } } } |
| }, omit, omit }, |
| // state == wait |
| { { |
| { "DisableState", { stepContextArgs := { } } } |
| }, omit, omit } |
| } |
| }, |
| |
| // connection opened event |
| { |
| eventToListen := { c_EPTF_HTTP_myBName, c_EPTF_HTTP_inputName_connectionOpened, fsm }, |
| cellRow := { |
| // state == idle |
| { { |
| { "EnableState", { stepContextArgs := { } } } |
| }, omit, omit }, |
| // state == wait |
| { { |
| { "EnableState", { stepContextArgs := { } } } |
| }, omit, omit } |
| } |
| }, |
| |
| // stop TC event |
| { |
| eventToListen := { c_EPTF_LGenBase_behavior, c_EPTF_LGenBase_inputName_testMgmt_stopTC, fsm }, |
| cellRow := { |
| // state == idle |
| { { |
| { c_EPTF_HTTP_stepName_cleanUpContext, { stepContextArgs := {} } } , |
| { c_EPTF_LGenBase_StepFunction_entityStopped, { stepContextArgs := { } } } |
| }, omit, "idle" }, |
| // state == wait |
| { { |
| { c_EPTF_HTTP_stepName_cleanUpContext, { stepContextArgs := {} } } , |
| { c_EPTF_LGenBase_StepFunction_entityStopped, { stepContextArgs := { } } } |
| }, omit, "idle" } |
| } |
| } |
| } |
| } |
| } |
| } |
| |
| function f_EPTF_HTTP_Test_Application1_HTTP1_CreateBasicFSM_Local_RECONNECTTEST( |
| in charstring pl_name) |
| runs on EPTF_HTTP_Test_Application1_LocalCT |
| return EPTF_LGenBase_TcMgmt_CompactFsmTableDeclaratorList |
| { |
| return { |
| { name := pl_name, |
| stateList := { "idle", "wait" }, |
| timerList := { { name := "TIMEOUT", startValue := 1.0 } }, |
| table := { |
| /* |
| // TC tarted event |
| { |
| eventToListen := { c_EPTF_LGenBase_behavior, c_EPTF_LGenBase_inputName_testMgmt_trafficCaseStarted, fsm }, |
| cellRow := { |
| // state == idle |
| { { |
| { "RightState", { stepContextArgs := { 0 } } }, |
| { c_EPTf_EPTF_HTTP_Test_Application1_stepName_openConnection, { stepContextArgs := {} } }, |
| { "CheckState", { stepContextArgs := { 0 } } } |
| }, omit, omit }, |
| // state == wait |
| { { |
| { "WrongState", { stepContextArgs := { 0 } } } |
| }, omit, "idle" } |
| } |
| }, |
| */ |
| // start TC event |
| { |
| eventToListen := { c_EPTF_LGenBase_behavior, c_EPTF_LGenBase_inputName_testMgmt_startTC, fsm }, |
| cellRow := { |
| // state == idle |
| { { |
| { "RightState", { stepContextArgs := { 1 } } }, |
| { c_EPTF_HTTP_stepName_sendRequest, { stepContextArgs := {} } }//, |
| //{ "CheckState", { stepContextArgs := { 1 } } } |
| }, omit, "wait" }, |
| // state == wait |
| { { |
| { "WrongState", { stepContextArgs := { 1 } } } |
| }, omit, "idle" } |
| } |
| }, |
| |
| // answer OK event |
| { |
| eventToListen := { c_EPTF_HTTP_myBName, c_EPTF_HTTP_inputName_responseCharReceived, fsm }, |
| cellRow := { |
| // state == idle |
| { { |
| { "WrongState", { stepContextArgs := { 2 } } } |
| }, omit, omit }, |
| // state == wait |
| { { |
| { "RightState", { stepContextArgs := { 2 } } }, |
| { "RecordAnswer", { stepContextArgs := {} } }, |
| //{ "CheckState", { stepContextArgs := { 2 } } }, |
| { c_EPTF_LGenBase_StepFunction_trafficSuccess, { stepContextArgs := {} } } |
| }, omit, "idle" } |
| } |
| }, |
| |
| // timeout event |
| { |
| eventToListen := { c_EPTF_LGenBase_specialBName_timerTimeout, "TIMEOUT", fsm }, |
| cellRow := { |
| // state == idle |
| { { |
| { "WrongState", { stepContextArgs := { 3 } } } |
| }, omit, "idle" }, |
| // state == wait |
| { { |
| { "RightState", { stepContextArgs := { 3 } } }, |
| { c_EPTF_HTTP_stepName_cleanUpContext, { stepContextArgs := {} } } , |
| { c_EPTF_HTTP_stepName_handleTimeout, { stepContextArgs := {} } }, |
| { c_EPTF_LGenBase_StepFunction_trafficFailed, { stepContextArgs := {} } } |
| }, omit, "idle" } |
| } |
| }, |
| |
| // connection closed event |
| { |
| eventToListen := { c_EPTF_HTTP_myBName, c_EPTF_HTTP_inputName_connectionClosed, fsm }, |
| cellRow := { |
| // state == idle |
| { { |
| { "DisableState", { stepContextArgs := { } } } |
| }, omit, omit }, |
| // state == wait |
| { { |
| { "DisableState", { stepContextArgs := { } } } |
| }, omit, omit } |
| } |
| }, |
| |
| // connection opened event |
| { |
| eventToListen := { c_EPTF_HTTP_myBName, c_EPTF_HTTP_inputName_connectionOpened, fsm }, |
| cellRow := { |
| // state == idle |
| { { |
| { "EnableState", { stepContextArgs := { } } } |
| }, omit, omit }, |
| // state == wait |
| { { |
| { "EnableState", { stepContextArgs := { } } } |
| }, omit, omit } |
| } |
| }, |
| |
| // stop TC event |
| { |
| eventToListen := { c_EPTF_LGenBase_behavior, c_EPTF_LGenBase_inputName_testMgmt_stopTC, fsm }, |
| cellRow := { |
| // state == idle |
| { { |
| { c_EPTF_HTTP_stepName_cleanUpContext, { stepContextArgs := {} } } , |
| { c_EPTF_LGenBase_StepFunction_entityStopped, { stepContextArgs := { } } } |
| }, omit, "idle" }, |
| // state == wait |
| { { |
| { c_EPTF_HTTP_stepName_cleanUpContext, { stepContextArgs := {} } } , |
| { c_EPTF_LGenBase_StepFunction_entityStopped, { stepContextArgs := { } } } |
| }, omit, "idle" } |
| } |
| } |
| } |
| } |
| } |
| } |
| |
| function f_EPTF_HTTP_Test_Application1_HTTP1_CreateBasicFSM_Remote( |
| in charstring pl_name) |
| runs on EPTF_HTTP_Test_Application1_RemoteCT |
| return EPTF_LGenBase_TcMgmt_CompactFsmTableDeclaratorList |
| { |
| return { |
| { name := pl_name, |
| stateList := { "idle", "wait" }, |
| timerList := { { name := "TIMEOUT", startValue := 1.0 } }, |
| table := { |
| /* |
| // TC tarted event |
| { |
| eventToListen := { c_EPTF_LGenBase_behavior, c_EPTF_LGenBase_inputName_testMgmt_trafficCaseStarted, fsm }, |
| cellRow := { |
| // state == idle |
| { { |
| { "RightState", { stepContextArgs := { 0 } } }, |
| { c_EPTf_EPTF_HTTP_Test_Application1_stepName_openConnection, { stepContextArgs := {} } }, |
| { "CheckState", { stepContextArgs := { 0 } } } |
| }, omit, omit }, |
| // state == wait |
| { { |
| { "WrongState", { stepContextArgs := { 0 } } } |
| }, omit, "idle" } |
| } |
| }, |
| */ |
| // start TC event |
| { |
| eventToListen := { c_EPTF_LGenBase_behavior, c_EPTF_LGenBase_inputName_testMgmt_startTC, fsm }, |
| cellRow := { |
| // state == idle |
| { { |
| { "RightState", { stepContextArgs := { 1 } } }, |
| { c_EPTF_HTTP_stepName_sendRequest, { stepContextArgs := {} } }//, |
| //{ "CheckState", { stepContextArgs := { 1 } } } |
| }, omit, "wait" }, |
| // state == wait |
| { { |
| { "WrongState", { stepContextArgs := { 1 } } } |
| }, omit, "idle" } |
| } |
| }, |
| |
| // answer OK event |
| { |
| eventToListen := { c_EPTF_HTTP_myBName, c_EPTF_HTTP_inputName_responseCharReceived, fsm }, |
| cellRow := { |
| // state == idle |
| { { |
| { "WrongState", { stepContextArgs := { 2 } } } |
| }, omit, omit }, |
| // state == wait |
| { { |
| { "RightState", { stepContextArgs := { 2 } } }, |
| { "RecordAnswer", { stepContextArgs := {} } }, |
| //{ "CheckState", { stepContextArgs := { 2 } } }, |
| { c_EPTF_LGenBase_StepFunction_trafficSuccess, { stepContextArgs := {} } } |
| }, omit, "idle" } |
| } |
| }, |
| |
| // timeout event |
| { |
| eventToListen := { c_EPTF_LGenBase_specialBName_timerTimeout, "TIMEOUT", fsm }, |
| cellRow := { |
| // state == idle |
| { { |
| { "WrongState", { stepContextArgs := { 3 } } } |
| }, omit, "idle" }, |
| // state == wait |
| { { |
| { "RightState", { stepContextArgs := { 3 } } }, |
| { c_EPTF_HTTP_stepName_handleTimeout, { stepContextArgs := {} } }, |
| { c_EPTF_HTTP_stepName_cleanUpContext, { stepContextArgs := {} } } , |
| { c_EPTF_LGenBase_StepFunction_trafficFailed, { stepContextArgs := {} } } |
| }, omit, "idle" } |
| } |
| }, |
| |
| // connection closed event |
| { |
| eventToListen := { c_EPTF_HTTP_myBName, c_EPTF_HTTP_inputName_connectionClosed, fsm }, |
| cellRow := { |
| // state == idle |
| { { |
| { "DisableState", { stepContextArgs := { } } } |
| }, omit, omit }, |
| // state == wait |
| { { |
| { "DisableState", { stepContextArgs := { } } } |
| }, omit, omit } |
| } |
| }, |
| |
| // connection opened event |
| { |
| eventToListen := { c_EPTF_HTTP_myBName, c_EPTF_HTTP_inputName_connectionOpened, fsm }, |
| cellRow := { |
| // state == idle |
| { { |
| { "EnableState", { stepContextArgs := { } } } |
| }, omit, omit }, |
| // state == wait |
| { { |
| { "EnableState", { stepContextArgs := { } } } |
| }, omit, omit } |
| } |
| }, |
| |
| // stop TC event |
| { |
| eventToListen := { c_EPTF_LGenBase_behavior, c_EPTF_LGenBase_inputName_testMgmt_stopTC, fsm }, |
| cellRow := { |
| // state == idle |
| { { |
| { c_EPTF_HTTP_stepName_cleanUpContext, { stepContextArgs := {} } } , |
| { c_EPTF_LGenBase_StepFunction_entityStopped, { stepContextArgs := { } } } |
| }, omit, "idle" }, |
| // state == wait |
| { { |
| { c_EPTF_HTTP_stepName_cleanUpContext, { stepContextArgs := {} } } , |
| { c_EPTF_LGenBase_StepFunction_entityStopped, { stepContextArgs := { } } } |
| }, omit, "idle" } |
| } |
| } |
| } |
| } |
| } |
| } |
| |
| } |