| /////////////////////////////////////////////////////////////////////////////// |
| // |
| // 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_Testcases.ttcn |
| // Rev: <RnXnn> |
| // Prodnr: CNL 113 618 |
| // Updated: 2009-01-08 |
| // Contact: http://ttcn.ericsson.se |
| /////////////////////////////////////////////////////////////////////////////// |
| |
| /////////////////////////////////////////////////////////// |
| // Module: EPTF_Applib_HTTP_Test_Testcases |
| // |
| // Purpose: |
| // HTTP application library testcases |
| // |
| // Module Parameters: |
| // tsp_EPTF_HTTP_Test_Responder_host - *charstring* - host IP address of responder component |
| // tsp_EPTF_HTTP_Test_Application1_host - *charstring* - host IP address of application1 component |
| // tsp_Application2_host - *charstring* - host IP address of application2 component |
| // tsp_EPTF_HTTP_Test_Responder_port - *charstring* - host port of responder component |
| // tsp_EPTF_HTTP_Test_NonExistent_host - *charstring* - a non existent host IP address |
| // |
| // Module depends on: |
| // <EPTF_CLL_HashMapInt2Int_Functions> |
| // |
| // <EPTF_CLL_HashMapStr2Int_Functions> |
| // |
| // <EPTF_CLL_FBQ_Functions> |
| // |
| // <EPTF_CLL_Base_Functions> |
| // |
| // <EPTF_CLL_Logging_Definitions> |
| // |
| // <EPTF_CLL_Logging_Functions> |
| // |
| // <IPL4asp_Types> |
| // |
| // <EPTF_HTTP_Definitions> |
| // |
| // <EPTF_HTTP_Functions> |
| // |
| // <EPTF_HTTP_Transport_Definitions> |
| // |
| // <EPTF_HTTP_Transport_Functions> |
| // |
| // <EPTF_Applib_HTTP_Test_Application1_Definitions> |
| // |
| // <EPTF_Applib_HTTP_Test_Application1_Functions> |
| // |
| // <EPTF_Applib_HTTP_Test_Definitions> |
| // |
| // <EPTF_Applib_HTTP_Test_Functions> |
| // |
| // <EPTF_Applib_HTTP_Test_Templates> |
| // |
| // |
| // Current Owner: |
| // EAKOPER |
| // |
| // Last Review Date: |
| // 2009-01-09 |
| // |
| // Detailed Comments: |
| // - |
| // |
| /////////////////////////////////////////////////////////// |
| module EPTF_Applib_HTTP_Test_Testcases { |
| |
| //========================================================================= |
| // Import Part |
| //========================================================================= |
| import from EPTF_CLL_HashMapInt2Int_Functions all; |
| import from EPTF_CLL_HashMapStr2Int_Functions all; |
| import from EPTF_CLL_FBQ_Functions all; |
| import from EPTF_CLL_Base_Functions all; |
| import from EPTF_CLL_Variable_Functions all; |
| import from EPTF_CLL_Logging_Definitions all; |
| import from EPTF_CLL_Logging_Functions all; |
| import from IPL4asp_Types all; |
| |
| import from EPTF_HTTP_Definitions all; |
| import from EPTF_HTTP_Functions all; |
| import from EPTF_HTTP_Transport_Definitions all; |
| import from EPTF_HTTP_Transport_Functions all; |
| |
| import from EPTF_Applib_HTTP_Test_Application1_Definitions all; |
| import from EPTF_Applib_HTTP_Test_Application1_Functions all; |
| import from EPTF_Applib_HTTP_Test_Definitions all; |
| import from EPTF_Applib_HTTP_Test_Functions all; |
| import from EPTF_Applib_HTTP_Test_Templates all; |
| |
| //========================================================================= |
| // Module paramers |
| //========================================================================= |
| 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; |
| modulepar charstring tsp_EPTF_HTTP_Test_NonExistent_host := "159.1.1.1"; |
| |
| //modulepar integer tsp_runningTime := 60; |
| //modulepar integer tsp_QPS := 500; |
| //modulepar integer tsp_rangeHi := 3000; |
| |
| //========================================================================= |
| // Testcases |
| //========================================================================= |
| |
| ////========================================================================= |
| // test of new port connection object |
| // test of creation, deletion, database consistency and open/close |
| testcase tc_EPTF_HTTP_Test_test1() |
| runs on EPTF_HTTP_Test_LocalAPI_CT |
| { |
| log("=============================="); |
| log("<< Starting test case 1 ... >>"); |
| log("=============================="); |
| log(""); |
| |
| var EPTF_HTTP_HostInformation vl_local, vl_remote; |
| var integer vl_group, vl_dummy; |
| var boolean vl_pass := true; |
| |
| // init base component |
| vl_dummy := f_EPTF_HTTP_LocalTransport_init_CT("EPTF_HTTP_Transport"); |
| |
| if ("LALA.0" != f_EPTF_HTTP_LocalTransport_createUniqueGroupName("LALA")) { |
| log("Creation of unique name failed"); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| |
| // init testcase |
| vl_local := { "127.0.0.1", 5000 }; |
| vl_remote := { "127.0.0.1", 4000 }; |
| |
| vl_group := f_EPTF_HTTP_LocalTransport_newPort( |
| {"MyLittlePorty", vl_local, vl_remote, true, false, false, omit}); |
| |
| if (vl_pass and vl_group != 0) { |
| log("Wrong group id acquired! (", vl_group, ")"); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| |
| // check local host information in database |
| if (vl_pass and not f_EPTF_str2int_HashMap_Find(v_EPTF_HTTP_Transport_localHostHashMap, |
| vl_local.hostIPAddress&int2str(vl_local.hostPort), |
| vl_dummy)) |
| { |
| log("Adding local host information to database has failed! (", vl_local, ")"); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| |
| // check remote host information in database |
| if (vl_pass and not f_EPTF_str2int_HashMap_Find(v_EPTF_HTTP_Transport_remoteHostHashMap, |
| vl_local.hostIPAddress&int2str(vl_remote.hostPort), |
| vl_dummy)) |
| { |
| log("Adding remote host information to database has failed! (", vl_remote, ")"); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| |
| // Check created database |
| if (vl_pass) |
| { |
| template EPTF_HTTP_Transport_PortGroupList t_expectedPortDB1 := { { |
| name := "MyLittlePorty", |
| baseLocalHostInformation := vl_local, |
| baseRemoteHostInformation := vl_remote, |
| |
| currentPortId := ?, |
| |
| numberOfPorts := 1, |
| localportStep := 0, |
| remoteportStep := 0, |
| |
| portDatabase := { |
| { |
| groupIndex := 0, |
| portIndex := 0, |
| connectionId := -1, |
| sessionId := ?, |
| portId := -1, |
| localhostInfoIdx := 0, |
| remotehostInfoIdx := 0, |
| state := IDLE, |
| portType := OUTGOING_PORT, |
| buffer := false, |
| messageBuffer := omit |
| } |
| }, |
| |
| listeningPortIdx := -1, |
| |
| defaultFIdx := 1, |
| |
| portQueue := ?, |
| portStateQueue := ?, |
| |
| useSSL := false, |
| instantConnOpen := true, |
| instantConnClose := false, |
| buffer := false |
| } }; |
| |
| if (not match(v_EPTF_HTTP_Transport_portDB, t_expectedPortDB1)) { |
| log("Database inconsistency after addition to v_EPTF_HTTP_Transport_portDB!"); |
| log(match(v_EPTF_HTTP_Transport_portDB, t_expectedPortDB1)); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| } |
| |
| if (vl_pass) |
| { |
| template EPTF_HTTP_Transport_PortGroupList t_expectedPortDB2 := { { |
| name := "", |
| baseLocalHostInformation := { "", -1 }, |
| baseRemoteHostInformation := { "", -1 }, |
| |
| currentPortId := ?, |
| numberOfPorts := 0, |
| localportStep := -1, |
| remoteportStep := -1, |
| |
| portDatabase := { }, |
| |
| listeningPortIdx := -1, |
| |
| defaultFIdx := -1, |
| |
| portQueue := ?, |
| portStateQueue := ?, |
| |
| useSSL := false, |
| instantConnOpen := false, |
| instantConnClose := false, |
| buffer := false |
| } }; |
| |
| f_EPTF_HTTP_LocalTransport_deletePort(vl_group); |
| |
| if (not match(v_EPTF_HTTP_Transport_portDB, t_expectedPortDB2)) { |
| log("Database inconsistency after deletion from v_EPTF_HTTP_Transport_portDB!"); |
| log(match(v_EPTF_HTTP_Transport_portDB, t_expectedPortDB2)); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| |
| // check local host information in database (must not be deleted after removal of port) |
| if (vl_pass and not f_EPTF_str2int_HashMap_Find(v_EPTF_HTTP_Transport_localHostHashMap, |
| vl_local.hostIPAddress&int2str(vl_local.hostPort), |
| vl_dummy)) |
| { |
| log("Local host information has been removed from database! (", vl_local, ")"); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| |
| // check remote host information in database (must not be deleted after removal of port) |
| if (vl_pass and not f_EPTF_str2int_HashMap_Find(v_EPTF_HTTP_Transport_remoteHostHashMap, |
| vl_local.hostIPAddress&int2str(vl_remote.hostPort), |
| vl_dummy)) |
| { |
| log("Remote host information has been removed from database! (", vl_remote, ")"); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| } |
| var integer vl_sessionId := 1; |
| if (vl_pass and f_EPTF_HTTP_LocalTransport_connectionOpen(vl_group, vl_sessionId)) { |
| log("Connection open successful after deletion of connection object!"); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| |
| if (vl_pass) { |
| f_EPTF_HTTP_LocalTransport_connectionClose(vl_group); // no ret value, check no dynamic error |
| f_EPTF_HTTP_LocalTransport_deletePort(vl_group); |
| } |
| |
| if (f_EPTF_FBQ_itemIsBusy(vl_group, v_EPTF_HTTP_Transport_groupQueue)) { |
| log("Group not deleted properly!"); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| |
| f_EPTF_Base_cleanup_CT(); |
| |
| if (vl_pass) { setverdict(pass); }; |
| |
| } |
| |
| ////========================================================================= |
| // test of new group connection object |
| // test of creation, deletion, database consistency and open/close |
| testcase tc_EPTF_HTTP_Test_test2() |
| runs on EPTF_HTTP_Test_LocalAPI_CT |
| { |
| log("=============================="); |
| log("<< Starting test case 2 ... >>"); |
| log("=============================="); |
| log(""); |
| |
| var EPTF_HTTP_HostInformation vl_local, vl_remote; |
| var integer vl_group, vl_dummy; |
| var boolean vl_pass := true; |
| |
| // init base component |
| v_noIntWarning := f_EPTF_HTTP_LocalTransport_init_CT("EPTF_HTTP_Transport"); |
| |
| // init testcase |
| vl_local := { "127.0.0.1", 5000 }; |
| vl_remote := { "127.0.0.1", 4000 }; |
| |
| vl_group := f_EPTF_HTTP_LocalTransport_newPortGroup( |
| {"MyLittleGroupy", vl_local, vl_remote, 3, 2, 0, true, false, false, omit}); |
| |
| if (vl_pass and vl_group != 0) { |
| log("Wrong group id acquired! (", vl_group, ")"); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| |
| // check local host information in database |
| if (vl_pass and not f_EPTF_str2int_HashMap_Find(v_EPTF_HTTP_Transport_localHostHashMap, |
| vl_local.hostIPAddress&int2str(vl_local.hostPort), |
| vl_dummy)) |
| { |
| log("Adding local host information to database has failed! (", vl_local, ")"); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| |
| // check remote host information in database |
| if (vl_pass and not f_EPTF_str2int_HashMap_Find(v_EPTF_HTTP_Transport_remoteHostHashMap, |
| vl_local.hostIPAddress&int2str(vl_remote.hostPort), |
| vl_dummy)) |
| { |
| log("Adding remote host information to database has failed! (", vl_remote, ")"); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| |
| // Check created database |
| if (vl_pass) |
| { |
| template EPTF_HTTP_Transport_PortGroupList t_expectedPortDB1 := { { |
| name := "MyLittleGroupy", |
| baseLocalHostInformation := vl_local, |
| baseRemoteHostInformation := vl_remote, |
| |
| currentPortId := ?, |
| |
| numberOfPorts := 3, |
| localportStep := 2, |
| 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 |
| }, |
| { |
| groupIndex := 0, |
| portIndex := 2, |
| connectionId := -1, |
| sessionId := -1, |
| portId := -1, |
| localhostInfoIdx := 2, |
| remotehostInfoIdx := 0, |
| state := IDLE, |
| portType := OUTGOING_PORT, |
| buffer := false, |
| messageBuffer := omit |
| } |
| }, |
| |
| listeningPortIdx := -1, |
| |
| defaultFIdx := 0, |
| |
| portQueue := ?, |
| portStateQueue := ?, |
| |
| useSSL := false, |
| instantConnOpen := true, |
| instantConnClose := false, |
| buffer := false |
| } }; |
| |
| if (not match(v_EPTF_HTTP_Transport_portDB, t_expectedPortDB1)) { |
| log("Database inconsistency after addition to v_EPTF_HTTP_Transport_portDB!"); |
| log(match(v_EPTF_HTTP_Transport_portDB, t_expectedPortDB1)); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| } |
| |
| if (vl_pass) |
| { |
| template EPTF_HTTP_Transport_PortGroupList t_expectedPortDB2 := { { |
| name := "", |
| baseLocalHostInformation := { "", -1 }, |
| baseRemoteHostInformation := { "", -1 }, |
| |
| currentPortId := ?, |
| |
| numberOfPorts := 0, |
| localportStep := -1, |
| remoteportStep := -1, |
| |
| portDatabase := { }, |
| |
| listeningPortIdx := -1, |
| |
| defaultFIdx := -1, |
| |
| portQueue := ?, |
| portStateQueue := ?, |
| |
| useSSL := false, |
| instantConnOpen := false, |
| instantConnClose := false, |
| buffer := false |
| } }; |
| |
| f_EPTF_HTTP_LocalTransport_deletePort(vl_group); |
| |
| if (not match(v_EPTF_HTTP_Transport_portDB, t_expectedPortDB2)) { |
| log("Database inconsistency after deletion from v_EPTF_HTTP_Transport_portDB!"); |
| log(match(v_EPTF_HTTP_Transport_portDB, t_expectedPortDB2)); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| |
| // check local host information in database (must not be deleted after removal of port) |
| if (vl_pass and not f_EPTF_str2int_HashMap_Find(v_EPTF_HTTP_Transport_localHostHashMap, |
| vl_local.hostIPAddress&int2str(vl_local.hostPort), |
| vl_dummy)) |
| { |
| log("Local host information has been removed from database! (", vl_local, ")"); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| |
| // check remote host information in database (must not be deleted after removal of port) |
| if (vl_pass and not f_EPTF_str2int_HashMap_Find(v_EPTF_HTTP_Transport_remoteHostHashMap, |
| vl_local.hostIPAddress&int2str(vl_remote.hostPort), |
| vl_dummy)) |
| { |
| log("Remote host information has been removed from database! (", vl_remote, ")"); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| } |
| var integer vl_sessionId := 1; |
| if (vl_pass and f_EPTF_HTTP_LocalTransport_connectionOpen(vl_group, vl_sessionId)) { |
| log("Connection open successful after deletion of connection object!"); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| |
| if (vl_pass) { |
| f_EPTF_HTTP_LocalTransport_connectionClose(vl_group); // no ret value, check no dznamic errorohh |
| f_EPTF_HTTP_LocalTransport_deletePortGroup(vl_group); |
| } |
| |
| if (f_EPTF_FBQ_itemIsBusy(vl_group, v_EPTF_HTTP_Transport_groupQueue)) { |
| log("Group not deleted properly!"); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| |
| f_EPTF_Base_cleanup_CT(); |
| |
| if (vl_pass) { setverdict(pass); }; |
| } |
| testcase tc_EPTF_HTTP_Test_test3() |
| runs on EPTF_HTTP_Test_RemoteAPI_CT |
| { |
| log("=============================="); |
| log("<< Starting test case 3 ... >>"); |
| log("=============================="); |
| log(""); |
| |
| timer t_guard := 2.0; |
| timer t_wait := 1.0; |
| |
| f_EPTF_HTTP_init( |
| "APPL1_LGEN", |
| 1, |
| "HTTP1_", |
| 0); //, pl_bind, pl_reset, pl_unbind); |
| |
| // Initialize transport |
| v_noIntWarning := f_EPTF_HTTP_RemoteTransport_init_CT("RemoteVagyokRagyogok", |
| refers(f_EPTF_HTTP_messageReceived), |
| refers(f_EPTF_HTTP_eventReceived), |
| refers(f_EPTF_HTTP_socketErrorReceived)); |
| |
| 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)); |
| |
| var EPTF_HTTP_Test_Application1_MapperCT vl_mapper_comp; |
| |
| vl_mapper_comp := EPTF_HTTP_Test_Application1_MapperCT.create("MapperVagyokRagyogok"); |
| |
| connect(self:v_EPTF_HTTP_RemoteTransport_commPort, |
| vl_mapper_comp:v_EPTF_HTTP_Mapper_commPort); |
| connect(self:v_validation_PCO, |
| vl_mapper_comp:v_validation_PCO); |
| |
| vl_mapper_comp.start( |
| f_EPTF_HTTP_Test_Application1_Mapper_Behavior_CheckAPI(10.0)); |
| |
| var EPTF_HTTP_Transport_GroupMode vl_group := { |
| name := "MyGroup", |
| |
| localHostInformation := { "127.0.0.1", 4000 }, |
| remoteHostInformation := { "127.0.0.1", 5000 }, |
| |
| numberOfPorts := 2, |
| localportStep := 1, |
| remoteportStep := 0, |
| |
| instantConnOpen := true, |
| instantConnClose := true, |
| useSSL := false, |
| userFunctions := omit |
| }; |
| |
| var EPTF_HTTP_Transport_PortMode vl_port := |
| { |
| name := "MyPort", |
| localHostInformation := { "127.0.0.1", 4000 }, |
| remoteHostInformation := { "127.0.0.1", 5000 }, |
| instantConnOpen := true, |
| instantConnClose := true, |
| useSSL := false, |
| userFunctions := omit |
| }; |
| |
| var integer vl_groupId; |
| var boolean vl_pass := true; |
| vl_groupId := f_EPTF_HTTP_RemoteTransport_newPortGroup(vl_group) |
| |
| if (vl_pass and vl_groupId != 0) { |
| log("Group creation unsuccessful! Acquired id: ", vl_groupId); |
| setverdict(fail); |
| vl_pass := false; |
| } |
| |
| if (vl_pass) { |
| f_EPTF_HTTP_RemoteTransport_deletePortGroup(vl_groupId); |
| vl_groupId := f_EPTF_HTTP_RemoteTransport_newPortGroup(vl_group); |
| |
| if (vl_groupId != 0) { |
| log("Group creation unsuccessful! Acquired id: ", vl_groupId) |
| setverdict(fail); |
| vl_pass := false; |
| } |
| } |
| |
| v_validation_PCO.send(EPTF_HTTP_Test_Valid:{0, vl_groupId}) |
| t_guard.start; |
| alt{ |
| [] v_validation_PCO.receive(EPTF_HTTP_Test_Status:READY){t_guard.stop;} |
| [] t_guard.timeout{ |
| log("Validation timer timeout! "); |
| setverdict(fail); |
| } |
| } |
| // Mapper side validation 1 comes here |
| |
| if (vl_pass) { |
| if (not f_EPTF_HTTP_RemoteTransport_addPortToGroup(vl_groupId)) { |
| log("Port addition unsuccessful to group: ", vl_groupId); |
| setverdict(fail); |
| vl_pass := false; |
| } |
| } |
| |
| v_validation_PCO.send(EPTF_HTTP_Test_Valid:{1, vl_groupId}) |
| t_guard.start; |
| alt{ |
| [] v_validation_PCO.receive(EPTF_HTTP_Test_Status:READY){t_guard.stop;} |
| [] t_guard.timeout{ |
| log("Validation timer timeout! "); |
| setverdict(fail); |
| } |
| } |
| |
| // Mapper side validation 2 comes here |
| |
| if (vl_pass) { |
| f_EPTF_HTTP_RemoteTransport_removePortFromGroup(vl_groupId); |
| } |
| |
| t_wait.start; |
| t_wait.timeout; |
| |
| v_validation_PCO.send(EPTF_HTTP_Test_Valid:{2, vl_groupId}) |
| t_guard.start; |
| alt{ |
| [] v_validation_PCO.receive(EPTF_HTTP_Test_Status:READY){t_guard.stop;} |
| [] t_guard.timeout{ |
| log("Validation timer timeout! "); |
| setverdict(fail); |
| } |
| } |
| |
| // Mapper side validation 3 comes here |
| |
| if (vl_pass) { |
| vl_groupId := f_EPTF_HTTP_RemoteTransport_newPort(vl_port) |
| |
| if (vl_groupId != 1) { |
| log("Port creation unsuccessful! Acquired id: ", vl_groupId); |
| setverdict(fail); |
| vl_pass := false; |
| } |
| } |
| |
| if (vl_pass) { |
| f_EPTF_HTTP_RemoteTransport_deletePort(vl_groupId); |
| vl_groupId := f_EPTF_HTTP_RemoteTransport_newPort(vl_port); |
| |
| if (vl_groupId != 1) { |
| log("Port recreation unsuccessful!"); |
| setverdict(fail); |
| vl_pass := false; |
| } |
| } |
| |
| if (vl_pass) { |
| vl_port.name := "MyPort2"; |
| vl_groupId := f_EPTF_HTTP_RemoteTransport_newPort(vl_port); |
| |
| if (vl_groupId != 2) { |
| log("Port creation unsuccessful!"); |
| setverdict(fail); |
| vl_pass := false; |
| } |
| } |
| |
| v_validation_PCO.send(EPTF_HTTP_Test_Valid:{3, vl_groupId}) |
| t_guard.start; |
| alt{ |
| [] v_validation_PCO.receive(EPTF_HTTP_Test_Status:READY){t_guard.stop;} |
| [] t_guard.timeout{ |
| log("Validation timer timeout! "); |
| setverdict(fail); |
| } |
| } |
| |
| f_EPTF_Base_cleanup_CT(); |
| |
| setverdict(pass); |
| |
| } |
| |
| // test random remote API usage |
| // no validation, testcase passes if it stops without errors |
| testcase tc_EPTF_HTTP_Test_test4() |
| runs on EPTF_HTTP_Test_RemoteAPI_CT |
| { |
| log("=============================="); |
| log("<< Starting test case 4 ... >>"); |
| log("=============================="); |
| log(""); |
| |
| f_EPTF_HTTP_init( |
| "APPL1_LGEN", |
| 1, |
| "HTTP1_", |
| 0); //, pl_bind, pl_reset, pl_unbind); |
| |
| // Initialize transport |
| |
| v_noIntWarning := f_EPTF_HTTP_RemoteTransport_init_CT("RemoteVagyokRagyogok", |
| refers(f_EPTF_HTTP_messageReceived), |
| refers(f_EPTF_HTTP_eventReceived), |
| refers(f_EPTF_HTTP_socketErrorReceived)); |
| |
| 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)); |
| |
| var EPTF_HTTP_Test_Application1_MapperCT vl_mapper_comp; |
| |
| vl_mapper_comp := EPTF_HTTP_Test_Application1_MapperCT.create("MapperVagyokRagyogok"); |
| |
| connect(self:v_EPTF_HTTP_RemoteTransport_commPort, |
| vl_mapper_comp:v_EPTF_HTTP_Mapper_commPort); |
| |
| vl_mapper_comp.start( |
| f_EPTF_HTTP_Test_Application1_Mapper_Behavior_CheckRandomAPI(10.0)); |
| |
| var EPTF_HTTP_Transport_GroupMode vl_group := { |
| name := omit, |
| |
| localHostInformation := { "127.0.0.1", 4000 }, |
| remoteHostInformation := { "127.0.0.1", 5000 }, |
| |
| numberOfPorts := 2, |
| localportStep := 1, |
| remoteportStep := 0, |
| |
| instantConnOpen := true, |
| instantConnClose := true, |
| useSSL := false, |
| userFunctions := omit |
| }; |
| |
| var EPTF_HTTP_Transport_PortMode vl_port := |
| { |
| name := omit, |
| localHostInformation := { "127.0.0.1", 4000 }, |
| remoteHostInformation := { "127.0.0.1", 5000 }, |
| instantConnOpen := true, |
| instantConnClose := true, |
| useSSL := false, |
| userFunctions := omit |
| }; |
| |
| var integer i, op; |
| var integer vl_grpId, vl_hPort := 0; |
| |
| for (i := 0; i < 1000; i := i + 1) |
| { |
| op := float2int(12.999 * rnd()); |
| |
| select(op) |
| { |
| case (0) { // new group |
| vl_group.numberOfPorts := float2int(5.0 * rnd()) + 1; |
| vl_group.localportStep := float2int(2.0 * rnd()) + 1; |
| |
| if (f_EPTF_HTTP_RemoteTransport_newPortGroup(vl_group) != -1) { |
| vl_hPort := vl_hPort + 1; |
| } |
| } |
| case (1) { // new port |
| if (f_EPTF_HTTP_RemoteTransport_newPort(vl_port) != -1) { |
| vl_hPort := vl_hPort + 1; |
| } |
| } |
| case (2) { // delete group |
| if (vl_hPort > 0) { vl_hPort := vl_hPort - 1; }; |
| |
| vl_grpId := float2int(1.2 * rnd() * int2float(vl_hPort)); // 1.2 for chance to have bad IDs |
| f_EPTF_HTTP_RemoteTransport_deletePortGroup(vl_grpId); |
| } |
| case (3) { // delete port |
| if (vl_hPort > 0) { vl_hPort := vl_hPort - 1; }; |
| |
| vl_grpId := float2int(1.2 * rnd() * int2float(vl_hPort)); // 1.2 for chance to have bad IDs |
| f_EPTF_HTTP_RemoteTransport_deletePort(vl_grpId); |
| } |
| case (4) { // add port to group |
| vl_grpId := float2int(rnd() * int2float(vl_hPort)); |
| v_noBoolWarning := |
| f_EPTF_HTTP_RemoteTransport_addPortToGroup(vl_grpId); |
| } |
| case (5) { // remove port from port |
| vl_grpId := float2int(rnd() * int2float(vl_hPort)); |
| f_EPTF_HTTP_RemoteTransport_removePortFromGroup(vl_grpId); |
| } |
| case (6) { // remove port from port again |
| vl_grpId := float2int(rnd() * int2float(vl_hPort)); |
| f_EPTF_HTTP_RemoteTransport_removePortFromGroup(vl_grpId); |
| } |
| case (7) { // remove port from port again |
| vl_grpId := float2int(rnd() * int2float(vl_hPort)); |
| var integer vl_sessionId := 1; |
| v_noBoolWarning := |
| f_EPTF_HTTP_RemoteTransport_connectionOpen(vl_grpId,vl_sessionId); |
| } |
| case (8) { // remove port from port again |
| vl_grpId := float2int(rnd() * int2float(vl_hPort)); |
| f_EPTF_HTTP_RemoteTransport_connectionClose(vl_grpId); |
| } |
| case (9) { // remove port from port again |
| vl_grpId := float2int(rnd() * int2float(vl_hPort)); |
| f_EPTF_HTTP_RemoteTransport_connectionHalfClose(vl_grpId); |
| } |
| case (10) { // remove port from port again |
| vl_grpId := float2int(rnd() * int2float(vl_hPort)); |
| f_EPTF_HTTP_RemoteTransport_sendMessage(vl_grpId, 0, char2oct("ABCD")); |
| } |
| case (11) { // close port of user |
| vl_grpId := float2int(rnd() * int2float(vl_hPort)); |
| f_EPTF_HTTP_RemoteTransport_closePortOfUser(vl_grpId, 0); |
| } |
| case (12) { // free port of user |
| vl_grpId := float2int(rnd() * int2float(vl_hPort)); |
| f_EPTF_HTTP_RemoteTransport_freePortOfUser(vl_grpId, 0); |
| } |
| case else { |
| log("Wrong operation!"); |
| } |
| } |
| } |
| |
| f_EPTF_Base_cleanup_CT(); |
| |
| setverdict(pass); |
| } |
| |
| ////========================================================================= |
| // real connection test for port object |
| // instant open / close / open for single port |
| testcase tc_EPTF_HTTP_Test_test5() |
| runs on EPTF_HTTP_Test_LocalAPI_CT |
| { |
| log("=============================="); |
| log("<< Starting test case 5 ... >>"); |
| log("=============================="); |
| log(""); |
| |
| var EPTF_HTTP_HostInformation vl_local, vl_remote; |
| var integer vl_group, vl_dummy, vl_tcIdx := 5; |
| var boolean vl_bNoW, vl_pass := true; |
| |
| // create components |
| f_EPTF_HTTP_Test_createResponder(vl_tcIdx, 12.0); |
| |
| // init base component |
| v_noIntWarning := f_EPTF_HTTP_LocalTransport_init_CT("EPTF_HTTP_Transport"); |
| |
| // init testcase |
| vl_local := { tsp_EPTF_HTTP_Test_Application1_host, tsp_EPTF_HTTP_Test_Application1_port }; |
| vl_remote := { tsp_EPTF_HTTP_Test_Responder_host, tsp_EPTF_HTTP_Test_Responder_port + vl_tcIdx }; |
| |
| vl_group := f_EPTF_HTTP_LocalTransport_newPort( // connection set to open instantly |
| {"MyLittlePorty", vl_local, vl_remote, false, false, false, omit}); |
| |
| if (vl_pass and vl_group != 0) { |
| log("Wrong group id acquired! (", vl_group, ")"); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| |
| if (vl_pass and not f_EPTF_HTTP_Test_checkPortState(vl_group, 0, OPENED, 1, true, true, false)) { |
| vl_pass := false; |
| setverdict(fail); |
| } |
| |
| |
| if (vl_pass) { |
| log("Starting altstep!"); |
| |
| var integer vl_actionCnt := 0; |
| timer t_action := 1.0; |
| timer t_guard := 12.0; |
| t_action.start; |
| t_guard.start; |
| alt { |
| /* [] IPL4_PCO.receive(ASP_RecvFrom:?) -> value v_ASP_RecvFrom { |
| log("ASP receive from: ", v_ASP_RecvFrom); |
| repeat; |
| } |
| [] IPL4_PCO.receive(ASP_Event:?) -> value v_ASP_Event { |
| log("ASP event: ", v_ASP_Event); |
| repeat; |
| } |
| [] IPL4_PCO.receive { |
| log("Invalid message received!"); |
| repeat; |
| }*/ |
| [] t_action.timeout { |
| if (vl_actionCnt == 0) { // reopen connection |
| var integer vl_sessionId := 1; |
| vl_bNoW := f_EPTF_HTTP_LocalTransport_connectionOpen(vl_group, vl_sessionId); |
| |
| if (not f_EPTF_HTTP_Test_checkPortState(vl_group, 0, OPENED, 1, true, true, false)) { |
| vl_pass := false; |
| setverdict(fail); |
| } else { |
| t_action.start; |
| } |
| } |
| else |
| if (vl_actionCnt == 1) { // send message |
| |
| v_HTTP_oct := f_EPTF_HTTP_Test_DummyHTTPRequest("AABBCC"); |
| f_EPTF_HTTP_LocalTransport_sendMessage(vl_group, 0, v_HTTP_oct); |
| //var integer vl_dec := dec_HTTPMessage(v_HTTP_oct, v_HTTP_msg); |
| //log("Sending (", vl_dec, "): ", v_HTTP_msg); |
| |
| if (not f_EPTF_HTTP_Test_checkPortState(vl_group, 0, OPENED, 1, true, true, true)) { |
| vl_pass := false; |
| setverdict(fail); |
| } else { |
| t_action.start; |
| } |
| } |
| else |
| if (vl_actionCnt == 2) { // send message |
| |
| v_HTTP_oct := f_EPTF_HTTP_Test_DummyHTTPRequest("CCBBAA"); |
| f_EPTF_HTTP_LocalTransport_sendMessage(vl_group, 1, v_HTTP_oct); |
| //var integer vl_dec := dec_HTTPMessage(v_HTTP_oct, v_HTTP_msg); |
| //log("Sending (", vl_dec, "): ", v_HTTP_msg); |
| |
| if (not f_EPTF_HTTP_Test_checkPortState(vl_group, 0, OPENED, 1, true, true, true)) { |
| vl_pass := false; |
| setverdict(fail); |
| } else { |
| t_action.start; |
| } |
| } |
| else |
| if (vl_actionCnt == 3) { // half close connection |
| f_EPTF_HTTP_LocalTransport_connectionHalfClose(vl_group); |
| |
| if (not f_EPTF_HTTP_Test_checkPortState(vl_group, 0, HALFCLOSED, 1, true, true, true)) { |
| vl_pass := false; |
| setverdict(fail); |
| } else { |
| t_action.start; |
| } |
| } |
| else |
| if (vl_actionCnt == 4) { // rehalf close connection |
| f_EPTF_HTTP_LocalTransport_connectionHalfClose(vl_group); |
| |
| if (not f_EPTF_HTTP_Test_checkPortState(vl_group, 0, HALFCLOSED, 1, true, true, true)) { |
| vl_pass := false; |
| setverdict(fail); |
| } else { |
| t_action.start; |
| } |
| } |
| else |
| if (vl_actionCnt == 5) { // close connection |
| f_EPTF_HTTP_LocalTransport_connectionClose(vl_group); |
| |
| if (not f_EPTF_HTTP_Test_checkPortState(vl_group, 0, IDLE, -1, false, false, false)) { |
| vl_pass := false; |
| setverdict(fail); |
| } else { |
| t_action.start; |
| } |
| } |
| else |
| if (vl_actionCnt == 6) { // reclose connection |
| f_EPTF_HTTP_LocalTransport_connectionClose(vl_group); |
| |
| if (not f_EPTF_HTTP_Test_checkPortState(vl_group, 0, IDLE, -1, false, false, false)) { |
| vl_pass := false; |
| setverdict(fail); |
| } |
| |
| //t_action.start; |
| } |
| |
| vl_actionCnt := vl_actionCnt + 1; |
| |
| repeat; |
| } |
| [] t_guard.timeout { |
| log("Timer timed out!"); |
| } |
| } |
| |
| } |
| |
| if (vl_pass) { |
| f_EPTF_HTTP_LocalTransport_closeConnection_defaultGroup(vl_group); |
| f_EPTF_HTTP_LocalTransport_deletePort(vl_group); |
| |
| if (f_EPTF_FBQ_itemIsBusy(vl_group, v_EPTF_HTTP_Transport_groupQueue)) { |
| log("Group not deleted properly!"); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| } |
| |
| f_EPTF_Base_cleanup_CT(); |
| |
| if (vl_pass) { setverdict(pass); }; |
| } |
| |
| ////========================================================================= |
| // real connection test for port object |
| // instant open / close / open for single port |
| testcase tc_EPTF_HTTP_Test_test6() |
| runs on EPTF_HTTP_Test_LocalAPI_CT |
| { |
| log("=============================="); |
| log("<< Starting test case 6 ... >>"); |
| log("=============================="); |
| log(""); |
| |
| var EPTF_HTTP_HostInformation vl_local, vl_remote; |
| var integer i, vl_group, vl_dummy, vl_tcIdx := 6; |
| var boolean vl_bNoW, vl_pass := true; |
| |
| // create components |
| f_EPTF_HTTP_Test_createResponder(vl_tcIdx, 12.0); |
| |
| // init base component |
| v_noIntWarning := f_EPTF_HTTP_LocalTransport_init_CT("EPTF_HTTP_Transport"); |
| |
| // init testcase |
| vl_local := { tsp_EPTF_HTTP_Test_Application1_host, tsp_EPTF_HTTP_Test_Application1_port + 1 }; |
| vl_remote := { tsp_EPTF_HTTP_Test_Responder_host, tsp_EPTF_HTTP_Test_Responder_port + vl_tcIdx }; |
| |
| vl_group := f_EPTF_HTTP_LocalTransport_newPortGroup( // connection set to open instantly |
| {"MyLittleGroupy", vl_local, vl_remote, 3, 1, 0, false, false, false, omit}); |
| |
| if (vl_pass and vl_group != 0) { |
| log("Wrong group id acquired! (", vl_group, ")"); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| |
| for (i := 0; i < 3; i := i + 1) { |
| if (vl_pass and not f_EPTF_HTTP_Test_checkPortState(vl_group, i, OPENED, i + 1, true, true, false)) { |
| vl_pass := false; i := 3; |
| setverdict(fail); |
| } |
| } |
| |
| if (vl_pass) { |
| log("Starting altstep!"); |
| |
| var integer vl_actionCnt := 0; |
| timer t_action := 1.0; |
| timer t_guard := 12.0; |
| t_action.start; |
| t_guard.start; |
| alt { |
| /* [] IPL4_PCO.receive(ASP_RecvFrom:?) -> value v_ASP_RecvFrom { |
| log("ASP receive from: ", v_ASP_RecvFrom); |
| repeat; |
| } |
| [] IPL4_PCO.receive(ASP_Event:?) -> value v_ASP_Event { |
| log("ASP event: ", v_ASP_Event); |
| repeat; |
| } |
| [] IPL4_PCO.receive { |
| log("Invalid message received!"); |
| repeat; |
| }*/ |
| [] t_action.timeout { |
| if (vl_actionCnt == 0) { // reopen connection |
| log("Action: ", vl_actionCnt+1); |
| var integer vl_sessionId := 1; |
| vl_bNoW := f_EPTF_HTTP_LocalTransport_connectionOpen(vl_group, vl_sessionId); |
| |
| for (i := 0; i < 3; i := i + 1) { |
| if (not f_EPTF_HTTP_Test_checkPortState(vl_group, i, OPENED, i + 1, true, true, false)) { |
| vl_pass := false; i := 3; |
| setverdict(fail); |
| } |
| } |
| if (vl_pass) { t_action.start; } |
| } |
| else |
| if (vl_actionCnt == 1) { // reopen connection |
| log("Action: ", vl_actionCnt+1); |
| for (i := 0; i < 4; i := i + 1) { |
| v_HTTP_oct := f_EPTF_HTTP_Test_DummyHTTPRequest("AABBCC" & int2str(i)); |
| f_EPTF_HTTP_LocalTransport_sendMessage(vl_group, vl_actionCnt, v_HTTP_oct); |
| //var integer vl_dec := dec_HTTPMessage(v_HTTP_oct, v_HTTP_msg); |
| //log("Sending (", vl_dec, "): ", v_HTTP_msg); |
| |
| } |
| |
| for (i := 0; i < 3; i := i + 1) { |
| if (not f_EPTF_HTTP_Test_checkPortState(vl_group, i, OPENED, i + 1, true, true, true)) { |
| vl_pass := false; i := 3; |
| setverdict(fail); |
| } |
| } |
| if (vl_pass) { t_action.start; } |
| } |
| else |
| if (vl_actionCnt == 2) { // half close connection |
| log("Action: ", vl_actionCnt+1); |
| f_EPTF_HTTP_LocalTransport_connectionHalfClose(vl_group); |
| |
| for (i := 0; i < 3; i := i + 1) { |
| if (not f_EPTF_HTTP_Test_checkPortState(vl_group, i, HALFCLOSED, i + 1, true, true, true)) { |
| vl_pass := false; i := 3; |
| setverdict(fail); |
| } |
| } |
| if (vl_pass) { t_action.start; } |
| } |
| else |
| if (vl_actionCnt == 3) { // re half close connection |
| log("Action: ", vl_actionCnt+1); |
| f_EPTF_HTTP_LocalTransport_connectionHalfClose(vl_group); |
| |
| for (i := 0; i < 3; i := i + 1) { |
| if (not f_EPTF_HTTP_Test_checkPortState(vl_group, i, HALFCLOSED, i + 1, true, true, true)) { |
| vl_pass := false; i := 3; |
| setverdict(fail); |
| } |
| } |
| if (vl_pass) { t_action.start; } |
| } |
| else |
| if (vl_actionCnt == 4) { // close connection |
| log("Action: ", vl_actionCnt+1); |
| f_EPTF_HTTP_LocalTransport_closeConnection_defaultGroup(vl_group); |
| |
| for (i := 0; i < 3; i := i + 1) { |
| if (not f_EPTF_HTTP_Test_checkPortState(vl_group, i, IDLE, -1, false, false, false)) { |
| vl_pass := false; i := 3; |
| setverdict(fail); |
| } |
| } |
| if (vl_pass) { t_action.start; } |
| } |
| else |
| if (vl_actionCnt == 5) { // reclose connection |
| log("Action: ", vl_actionCnt+1); |
| f_EPTF_HTTP_LocalTransport_connectionClose(vl_group); |
| |
| for (i := 0; i < 3; i := i + 1) { |
| if (not f_EPTF_HTTP_Test_checkPortState(vl_group, i, IDLE, -1, false, false, false)) { |
| vl_pass := false; i := 3; |
| setverdict(fail); |
| } |
| } |
| |
| //t_action.start; |
| } |
| |
| vl_actionCnt := vl_actionCnt + 1; |
| |
| repeat; |
| } |
| [] t_guard.timeout { |
| log("Timer timed out!"); |
| } |
| } |
| |
| } |
| |
| if (vl_pass) { |
| f_EPTF_HTTP_LocalTransport_connectionClose(vl_group); |
| f_EPTF_HTTP_LocalTransport_deletePortGroup(vl_group); |
| |
| if (f_EPTF_FBQ_itemIsBusy(vl_group, v_EPTF_HTTP_Transport_groupQueue)) { |
| log("Group not deleted properly!"); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| } |
| |
| f_EPTF_Base_cleanup_CT(); |
| |
| if (vl_pass) { setverdict(pass); }; |
| } |
| |
| // Creates 20 entity and a single global port to send against HTTP responder |
| // Test case passes if sent messages bodies are received from HTTP responder |
| // and if state transitions are performed properly |
| // Instant connection open and close disabled |
| // LocalTransport mode |
| // Responder runs for 10.0 seconds -> will stop during test |
| // LoadGen(s) run for 13.0 secodns -> receive conn close events after 10.0 seconds |
| // mtc runs for 15.0 seconds |
| testcase tc_EPTF_HTTP_Test_test7() |
| runs on EPTF_HTTP_Test_CT |
| { |
| log("=============================="); |
| log("<< Starting test case 7 ... >>"); |
| log("=============================="); |
| log(""); |
| |
| // set config |
| v_numberOfLGens1 := 1; |
| v_numberOfLGens2 := 0; |
| |
| f_EPTF_Base_init_CT("MTC Base"); |
| |
| // check config |
| if (not f_EPTF_HTTP_Test_checkConfig()) { log("Wrong config!"); setverdict(fail); } |
| else |
| { |
| // create components |
| var float vl_rRunTime := 14.0; |
| f_EPTF_HTTP_Test_createResponder(7, vl_rRunTime); |
| f_EPTF_HTTP_Test_createApplConfig1(7, 20, 13.0, vl_rRunTime, true, true, -1, false, false); |
| //f_createApplConfig2(); |
| } |
| |
| timer t_guard := 20.0; |
| t_guard.start; |
| t_guard.timeout; |
| |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| // Creates 20 entity with single ports to send against HTTP responder |
| // Test case passes if sent messages bodies are received from HTTP responder |
| // and if state transitions are performed properly |
| // Instant connection open and close disabled |
| // LocalTransport mode |
| // Responder runs for 10.0 seconds -> will stop during test |
| // LoadGen(s) run for 13.0 secodns -> receive conn close events after 10.0 seconds |
| // mtc runs for 15.0 seconds |
| testcase tc_EPTF_HTTP_Test_test8() |
| runs on EPTF_HTTP_Test_CT |
| { |
| log("=============================="); |
| log("<< Starting test case 8 ... >>"); |
| log("=============================="); |
| log(""); |
| |
| // set config |
| v_numberOfLGens1 := 1; |
| v_numberOfLGens2 := 0; |
| |
| f_EPTF_Base_init_CT("MTC Base"); |
| |
| // check config |
| if (not f_EPTF_HTTP_Test_checkConfig()) { log("Wrong config!"); setverdict(fail); } |
| else |
| { |
| // create components |
| var float vl_rRunTime := 14.0; |
| f_EPTF_HTTP_Test_createResponder(8, vl_rRunTime); |
| f_EPTF_HTTP_Test_createApplConfig1(8, 20, 13.0, vl_rRunTime, true, false, -1, false, false); |
| //f_createApplConfig2(); |
| } |
| |
| timer t_guard := 15.0; |
| t_guard.start; |
| t_guard.timeout; |
| |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| // Creates 20 entity and a single global port group containing to ports |
| // to send against HTTP responder |
| // Test case passes if sent messages bodies are received from HTTP responder |
| // and if state transitions are performed properly |
| // Instant connection open and close disabled |
| // LocalTransport mode |
| // Responder runs for 10.0 seconds -> will stop during test |
| // LoadGen(s) run for 13.0 secodns -> receive conn close events after 10.0 seconds |
| // mtc runs for 15.0 seconds |
| testcase tc_EPTF_HTTP_Test_test9() |
| runs on EPTF_HTTP_Test_CT |
| { |
| log("=============================="); |
| log("<< Starting test case 9 ... >>"); |
| log("=============================="); |
| log(""); |
| |
| // set config |
| v_numberOfLGens1 := 1; |
| v_numberOfLGens2 := 0; |
| |
| f_EPTF_Base_init_CT("MTC Base"); |
| |
| // check config |
| if (not f_EPTF_HTTP_Test_checkConfig()) { log("Wrong config!"); setverdict(fail); } |
| else |
| { |
| // create components |
| var float vl_rRunTime := 14.0; |
| f_EPTF_HTTP_Test_createResponder(9, vl_rRunTime); |
| f_EPTF_HTTP_Test_createApplConfig1(9, 20, 13.0, vl_rRunTime, false, true, 2, false, false); |
| //f_createApplConfig2(); |
| } |
| |
| timer t_guard := 15.0; |
| t_guard.start; |
| t_guard.timeout; |
| |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| // Creates 20 entity with global port groups containing two port |
| // to send against HTTP responder |
| // Test case passes if sent messages bodies are received from HTTP responder |
| // and if state transitions are performed properly |
| // Instant connection open and close disabled |
| // LocalTransport mode |
| // Responder runs for 10.0 seconds -> will stop during test |
| // LoadGen(s) run for 13.0 secodns -> receive conn close events after 10.0 seconds |
| // mtc runs for 15.0 seconds |
| testcase tc_EPTF_HTTP_Test_test10() |
| runs on EPTF_HTTP_Test_CT |
| { |
| log("==============================="); |
| log("<< Starting test case 10 ... >>"); |
| log("==============================="); |
| log(""); |
| |
| // set config |
| v_numberOfLGens1 := 1; |
| v_numberOfLGens2 := 0; |
| |
| f_EPTF_Base_init_CT("MTC Base"); |
| |
| // check config |
| if (not f_EPTF_HTTP_Test_checkConfig()) { log("Wrong config!"); setverdict(fail); } |
| else |
| { |
| // create components |
| var float vl_rRunTime := 14.0; |
| f_EPTF_HTTP_Test_createResponder(10, vl_rRunTime); |
| f_EPTF_HTTP_Test_createApplConfig1(10, 20, 13.0, vl_rRunTime, false, false, 2, false, false); |
| //f_createApplConfig2(); |
| } |
| |
| timer t_guard := 15.0; |
| t_guard.start; |
| t_guard.timeout; |
| |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| // Creates 20 entity with single ports to send against HTTP responder |
| // Test case passes if sent messages bodies are received from HTTP responder |
| // and if state transitions are performed properly |
| // Instant connection open and close enabled |
| // LocalTransport mode |
| // Responder runs for 10.0 seconds -> will stop during test |
| // LoadGen(s) run for 13.0 secodns -> receive conn close events after 10.0 seconds |
| // mtc runs for 15.0 seconds |
| testcase tc_EPTF_HTTP_Test_test11() |
| runs on EPTF_HTTP_Test_CT |
| { |
| log("==============================="); |
| log("<< Starting test case 11 ... >>"); |
| log("==============================="); |
| log(""); |
| |
| // set config |
| v_numberOfLGens1 := 1; |
| v_numberOfLGens2 := 0; |
| |
| f_EPTF_Base_init_CT("MTC Base"); |
| |
| // check config |
| if (not f_EPTF_HTTP_Test_checkConfig()) { log("Wrong config!"); setverdict(fail); } |
| else |
| { |
| // create components |
| var float vl_rRunTime := 11.0; |
| f_EPTF_HTTP_Test_createResponder(11, vl_rRunTime); |
| f_EPTF_HTTP_Test_createApplConfig1(11, 20, 10.0, vl_rRunTime, true, false, -1, true, true); |
| //f_createApplConfig2(); |
| } |
| |
| timer t_guard := 15.0; |
| t_guard.start; |
| t_guard.timeout; |
| |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| // Creates 20 entity and a single global port group containing to ports |
| // to send against HTTP responder |
| // Test case passes if sent messages bodies are received from HTTP responder |
| // and if state transitions are performed properly |
| // Instant connection open and close enabled |
| // LocalTransport mode |
| // Responder runs for 11.0 seconds -> will not stop during test |
| // LoadGen(s) run for 10.0 secodns -> doesn't receive conn close events after 10.0 seconds |
| // mtc runs for 15.0 seconds |
| testcase tc_EPTF_HTTP_Test_test12() |
| runs on EPTF_HTTP_Test_CT |
| { |
| log("==============================="); |
| log("<< Starting test case 12 ... >>"); |
| log("==============================="); |
| log(""); |
| |
| // set config |
| v_numberOfLGens1 := 1; |
| v_numberOfLGens2 := 0; |
| |
| f_EPTF_Base_init_CT("MTC Base"); |
| |
| // check config |
| if (not f_EPTF_HTTP_Test_checkConfig()) { log("Wrong config!"); setverdict(fail); } |
| else |
| { |
| // create components |
| var float vl_rRunTime := 11.0; |
| f_EPTF_HTTP_Test_createResponder(12, vl_rRunTime); |
| f_EPTF_HTTP_Test_createApplConfig1(12, 20, 10.0, vl_rRunTime, false, true, 20, true, true); |
| //f_createApplConfig2(); |
| } |
| |
| timer t_guard := 15.0; |
| t_guard.start; |
| t_guard.timeout; |
| |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| // Creates 20 entity with global port groups containing two port |
| // to send against HTTP responder |
| // Test case passes if sent messages bodies are received from HTTP responder |
| // and if state transitions are performed properly |
| // Instant connection open and close disabled |
| // LocalTransport mode |
| // Responder runs for 11.0 seconds -> will not stop during test |
| // LoadGen(s) run for 10.0 secodns -> doesn't receive conn close events after 10.0 seconds |
| // mtc runs for 15.0 seconds |
| testcase tc_EPTF_HTTP_Test_test13() |
| runs on EPTF_HTTP_Test_CT |
| { |
| log("==============================="); |
| log("<< Starting test case 13 ... >>"); |
| log("==============================="); |
| log(""); |
| |
| // set config |
| v_numberOfLGens1 := 1; |
| v_numberOfLGens2 := 0; |
| |
| f_EPTF_Base_init_CT("MTC Base"); |
| |
| // check config |
| if (not f_EPTF_HTTP_Test_checkConfig()) { log("Wrong config!"); setverdict(fail); } |
| else |
| { |
| // create components |
| var float vl_rRunTime := 11.0; |
| f_EPTF_HTTP_Test_createResponder(13, vl_rRunTime); |
| f_EPTF_HTTP_Test_createApplConfig1(13, 20, 10.0, vl_rRunTime, false, false, 2, true, true); |
| //f_createApplConfig2(); |
| } |
| |
| timer t_guard := 15.0; |
| t_guard.start; |
| t_guard.timeout; |
| |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| // Creates 20 entity with global port groups containing two port |
| // to send against HTTP responder |
| // Test case passes if sent messages bodies are received from HTTP responder |
| // and if state transitions are performed properly |
| // Instant connection open and close disabled |
| // RemoteTransport mode |
| // Responder runs for 10.0 seconds -> will stop during test |
| // LoadGen(s) run for 13.0 secodns -> receive conn close events after 10.0 seconds |
| // mtc runs for 15.0 seconds |
| testcase tc_EPTF_HTTP_Test_test14() |
| runs on EPTF_HTTP_Test_CT |
| { |
| log("=============================="); |
| log("<< Starting test case 14 ... >>"); |
| log("=============================="); |
| log(""); |
| |
| // set config |
| v_numberOfLGens1 := 2; |
| v_numberOfLGens2 := 0; |
| |
| f_EPTF_Base_init_CT("MTC Base"); |
| |
| // check config |
| if (not f_EPTF_HTTP_Test_checkConfig()) { log("Wrong config!"); setverdict(fail); } |
| else |
| { |
| // create components |
| var float vl_rRunTime := 5.0; |
| f_EPTF_HTTP_Test_createResponder(14, vl_rRunTime + 0.5); |
| f_EPTF_HTTP_Test_createApplConfig1(14, 5, vl_rRunTime, vl_rRunTime + 0.5, false, false, 2, false, false); |
| } |
| |
| timer t_guard := 15.0; |
| t_guard.start; |
| t_guard.timeout; |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| template EPTF_HTTP_Transport_PortInfoList t_expectedPorts1 := { |
| { |
| groupIndex := 0, |
| portIndex := 0, |
| connectionId := 1, |
| sessionId := 100, |
| portId := -1, |
| localhostInfoIdx := 0, |
| remotehostInfoIdx := 0, |
| state := OPENED, |
| 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_PortInfoList t_expectedPorts2 := { |
| { |
| 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_PortInfoList t_expectedPorts3 := { |
| { |
| 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 := 2, |
| sessionId := 200, |
| portId := -1, |
| localhostInfoIdx := 1, |
| remotehostInfoIdx := 0, |
| state := OPENED, |
| 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_PortInfoList t_expectedPorts4 := { |
| { |
| 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 := 2, |
| sessionId := -1, |
| portId := -1, |
| localhostInfoIdx := 1, |
| remotehostInfoIdx := 0, |
| state := OPENED, |
| 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 |
| } |
| } |
| |
| ////========================================================================= |
| // test new close and free port of user API |
| // local API |
| testcase tc_EPTF_HTTP_Test_test15() |
| runs on EPTF_HTTP_Test_LocalAPI_CT |
| { |
| log("=============================="); |
| log("<< Starting test case 15 ... >>"); |
| log("=============================="); |
| log(""); |
| |
| var EPTF_HTTP_HostInformation vl_local, vl_remote; |
| var integer i, vl_group, vl_dummy, vl_tcIdx := 15; |
| var boolean vl_pass := true; |
| |
| // create components |
| f_EPTF_HTTP_Test_createResponder(vl_tcIdx, 12.0); |
| |
| // init base component |
| v_noIntWarning := f_EPTF_HTTP_LocalTransport_init_CT("EPTF_HTTP_Transport"); |
| |
| // init testcase |
| vl_local := { tsp_EPTF_HTTP_Test_Application1_host, tsp_EPTF_HTTP_Test_Application1_port + 3*10 + 100 * vl_tcIdx }; |
| vl_remote := { tsp_EPTF_HTTP_Test_Responder_host, tsp_EPTF_HTTP_Test_Responder_port + vl_tcIdx }; |
| |
| vl_group := f_EPTF_HTTP_LocalTransport_newPortGroup( // connection set to open instantly |
| {"MyLittleGroupy", vl_local, vl_remote, 3, 1, 0, true, false, false, omit}); |
| |
| v_HTTP_oct := f_EPTF_HTTP_Test_DummyHTTPRequest("AABBCC"); |
| f_EPTF_HTTP_LocalTransport_sendMessage(vl_group, 100, v_HTTP_oct); |
| log("Port DB #1", v_EPTF_HTTP_Transport_portDB); |
| |
| if (not match(v_EPTF_HTTP_Transport_portDB[vl_group].portDatabase, t_expectedPorts1)) { |
| log("Database inconsistency after sending on port group!"); |
| log(match(v_EPTF_HTTP_Transport_portDB[vl_group].portDatabase, t_expectedPorts1)); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| |
| if (vl_pass) |
| { |
| f_EPTF_HTTP_LocalTransport_closePortOfUser(vl_group, 100); |
| log("Port DB #2", v_EPTF_HTTP_Transport_portDB); |
| |
| if (not match(v_EPTF_HTTP_Transport_portDB[vl_group].portDatabase, t_expectedPorts2)) { |
| log("Database inconsistency after closing port of user!"); |
| log(match(v_EPTF_HTTP_Transport_portDB[vl_group].portDatabase, t_expectedPorts2)); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| } |
| |
| if (vl_pass) |
| { |
| v_HTTP_oct := f_EPTF_HTTP_Test_DummyHTTPRequest("CCBBAA"); |
| f_EPTF_HTTP_LocalTransport_sendMessage(vl_group, 200, v_HTTP_oct); |
| log("Port DB #3", v_EPTF_HTTP_Transport_portDB); |
| |
| if (not match(v_EPTF_HTTP_Transport_portDB[vl_group].portDatabase, t_expectedPorts3)) { |
| log("Database inconsistency after sending on port group!"); |
| log(match(v_EPTF_HTTP_Transport_portDB[vl_group].portDatabase, t_expectedPorts3)); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| } |
| |
| if (vl_pass) |
| { |
| f_EPTF_HTTP_LocalTransport_freePortOfUser(vl_group, 200); |
| log("Port DB #4", v_EPTF_HTTP_Transport_portDB); |
| |
| if (not match(v_EPTF_HTTP_Transport_portDB[vl_group].portDatabase, t_expectedPorts4)) { |
| log("Database inconsistency after freeing port of user!"); |
| log(match(v_EPTF_HTTP_Transport_portDB[vl_group].portDatabase, t_expectedPorts4)); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| } |
| |
| f_EPTF_HTTP_LocalTransport_deletePort(vl_group); |
| |
| f_EPTF_Base_cleanup_CT(); |
| |
| if (vl_pass) { setverdict(pass); }; |
| } |
| |
| // Creates 20 entity and a single global port group containing to ports |
| // to send against HTTP responder |
| // Test case passes if reconnection to the Responder is successful |
| // after the Responder is explicitly shut and restarted |
| // Instant connection open enabled and instant connection close enabled |
| // LocalTransport mode |
| testcase tc_EPTF_HTTP_Test_test16() |
| runs on EPTF_HTTP_Test_CT |
| { |
| log("=============================="); |
| log("<< Starting test case 16 ... >>"); |
| log("=============================="); |
| log(""); |
| |
| var boolean vl_pass := true; |
| |
| // set config |
| v_numberOfLGens1 := 1; |
| v_numberOfLGens2 := 0; |
| |
| f_EPTF_Base_init_CT("MTC Base"); |
| f_EPTF_Var_init_CT("MTC Var"); |
| |
| var float vl_rRunTime := 5.5; |
| var float vl_serverDownTime := 2.1; |
| |
| // check config |
| if (not f_EPTF_HTTP_Test_checkConfig()) { log("Wrong config!"); setverdict(fail); } |
| else |
| { |
| // create components |
| f_EPTF_HTTP_Test_createResponder(16, vl_rRunTime); |
| f_EPTF_HTTP_Test_createApplConfig1(16, 20, |
| 2.0 * vl_rRunTime + vl_serverDownTime - 0.5, // application running time - 0.5 to surely die before responder dies for the 2nd time |
| 2.0 * vl_rRunTime + 1.0, |
| false, true, 20, true, true); |
| |
| // 20 is the number of ports in the created group, on Rhea it must be greater then the number of sends as in instant connection |
| // opend and close mode, the ports are reused but they cannot be reopened again within a given (OS defined) time limit |
| } |
| |
| timer t_guard := vl_rRunTime + 0.5; |
| t_guard.start; |
| t_guard.timeout; |
| |
| // responder should die now |
| log("*** Responder must be dead now! ***"); |
| |
| f_EPTF_Var_subscribeRemote( // subscribe to the number of received answers EPTF variable |
| v_HTTP_Local1_comps[0], "NumberOfReceivedAnswers", |
| realtime, |
| v_nofAnswers, "MYNumberOfReceivedAnswers"); |
| |
| var integer vl_nofAnswers_current := f_EPTF_Var_getIntValue(v_nofAnswers); |
| log("Number of messages arrived to local lgen from responder (after first deth of responder): ", vl_nofAnswers_current); |
| |
| if (vl_pass) |
| { |
| if (vl_nofAnswers_current != float2int(vl_rRunTime) + 1) { // first message at zero time + float2int(vl_rRunTime) messages (at 1 CPS) |
| log("Number of incoming messages from HTTP responder (", vl_nofAnswers_current, |
| ") are inconsistent with test case settings (Before Responder restart)!"); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| else |
| if (v_HTTP_Responder_comp.running) { |
| log("Responder is still alive! Test case error"); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| } |
| |
| if (vl_pass) |
| { |
| t_guard.start(vl_serverDownTime); // wait X sec before restarting responder |
| t_guard.timeout; |
| |
| // recreate responder |
| log("*** Responder is being restarted now! ***"); |
| |
| f_EPTF_HTTP_Test_createResponder(16, vl_rRunTime); |
| |
| t_guard.start(vl_rRunTime + 1.0); |
| t_guard.timeout; |
| |
| // responder should be dead now |
| log("*** Responder must be dead now again! ***"); |
| |
| vl_nofAnswers_current := f_EPTF_Var_getIntValue(v_nofAnswers); |
| log("Number of messages arrived to local lgen from responder (Second responder die)!: ", vl_nofAnswers_current); |
| |
| if (vl_pass) |
| { |
| if (vl_nofAnswers_current != 2 * (float2int(vl_rRunTime) + 1) - 2) { // second part misses first and last message according to time configurations |
| log("Number of incoming messages from HTTP responder (", vl_nofAnswers_current, |
| ") are inconsistent with test case settings (After Responder restart)!"); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| } |
| } |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| ////========================================================================= |
| // errornous connection test for port object |
| // instant open / close / open for single port |
| // connection is bad tsp_EPTF_HTTP_Test_NonExistent_host should be a non existent host |
| // testcase will pass if connection is failed |
| testcase tc_EPTF_HTTP_Test_test17() |
| runs on EPTF_HTTP_Test_LocalAPI_CT |
| { |
| log("=============================="); |
| log("<< Starting test case 17 ... >>"); |
| log("=============================="); |
| log(""); |
| |
| var EPTF_HTTP_HostInformation vl_local, vl_remote; |
| var integer i, vl_group, vl_dummy, vl_tcIdx := 6; |
| var boolean vl_bNoW, vl_pass := true; |
| |
| // create components |
| f_EPTF_HTTP_Test_createResponder(vl_tcIdx, 12.0); |
| |
| // init base component |
| f_EPTF_HTTP_init( |
| "APPL1_LGEN", |
| 1, |
| "HTTP1_", |
| 0); //, pl_bind, pl_reset, pl_unbind); |
| |
| v_noIntWarning := f_EPTF_HTTP_LocalTransport_init_CT( |
| "EPTF_HTTP_Transport", |
| refers(f_EPTF_HTTP_messageReceived), |
| refers(f_EPTF_HTTP_eventReceived), |
| refers(f_EPTF_HTTP_socketErrorReceived)); |
| |
| // init testcase |
| vl_local := { tsp_EPTF_HTTP_Test_NonExistent_host, tsp_EPTF_HTTP_Test_Application1_port + 1 }; |
| vl_remote := { tsp_EPTF_HTTP_Test_NonExistent_host, tsp_EPTF_HTTP_Test_Responder_port + vl_tcIdx }; |
| |
| vl_group := f_EPTF_HTTP_LocalTransport_newPortGroup( // connection set to open instantly |
| {"MyLittleGroupy", vl_local, vl_remote, 3, 1, 0, true, true, false, omit}); |
| |
| if (vl_pass and vl_group != 0) { |
| log("Wrong group id acquired! (", vl_group, ")"); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| |
| for (i := 0; i < 3; i := i + 1) { |
| if (vl_pass and not f_EPTF_HTTP_Test_checkPortState(vl_group, i, IDLE, -1, false, false, false)) { |
| vl_pass := false; i := 3; |
| setverdict(fail); |
| } |
| } |
| |
| if (vl_pass) { |
| log("Starting altstep!"); |
| |
| var integer vl_actionCnt := 0; |
| timer t_action := 1.0; |
| timer t_guard := 12.0; |
| t_action.start; |
| t_guard.start; |
| alt { |
| /* [] IPL4_PCO.receive(ASP_RecvFrom:?) -> value v_ASP_RecvFrom { |
| log("ASP receive from: ", v_ASP_RecvFrom); |
| repeat; |
| } |
| [] IPL4_PCO.receive(ASP_Event:?) -> value v_ASP_Event { |
| log("ASP event: ", v_ASP_Event); |
| repeat; |
| } |
| [] IPL4_PCO.receive { |
| log("Invalid message received!"); |
| repeat; |
| }*/ |
| [] t_action.timeout { |
| if (vl_actionCnt == 0) { // reopen connection |
| log("Action: ", vl_actionCnt+1); |
| var integer vl_sessionId := 1; |
| vl_bNoW := f_EPTF_HTTP_LocalTransport_connectionOpen(vl_group,vl_sessionId); |
| |
| for (i := 0; i < 3; i := i + 1) { |
| if (not f_EPTF_HTTP_Test_checkPortState(vl_group, i, IDLE, -1, false, false, false)) { |
| vl_pass := false; i := 3; |
| setverdict(fail); |
| } |
| } |
| if (vl_pass) { t_action.start; } |
| } |
| else |
| if (vl_actionCnt == 1) { // reopen connection |
| log("Action: ", vl_actionCnt+1); |
| for (i := 0; i < 4; i := i + 1) { |
| v_HTTP_oct := f_EPTF_HTTP_Test_DummyHTTPRequest("AABBCC" & int2str(i)); |
| f_EPTF_HTTP_LocalTransport_sendMessage(vl_group, vl_actionCnt, v_HTTP_oct); |
| //var integer vl_dec := dec_HTTPMessage(v_HTTP_oct, v_HTTP_msg); |
| //log("Sending (", vl_dec, "): ", v_HTTP_msg); |
| |
| } |
| |
| for (i := 0; i < 3; i := i + 1) { |
| if (not f_EPTF_HTTP_Test_checkPortState(vl_group, i, IDLE, -1, false, false, false)) { |
| vl_pass := false; i := 3; |
| setverdict(fail); |
| } |
| } |
| if (vl_pass) { t_action.start; } |
| } |
| else |
| if (vl_actionCnt == 2) { // half close connection |
| log("Action: ", vl_actionCnt+1); |
| f_EPTF_HTTP_LocalTransport_connectionHalfClose(vl_group); |
| |
| for (i := 0; i < 3; i := i + 1) { |
| if (not f_EPTF_HTTP_Test_checkPortState(vl_group, i, IDLE, -1, false, false, false)) { |
| vl_pass := false; i := 3; |
| setverdict(fail); |
| } |
| } |
| if (vl_pass) { t_action.start; } |
| } |
| else |
| if (vl_actionCnt == 3) { // re half close connection |
| log("Action: ", vl_actionCnt+1); |
| f_EPTF_HTTP_LocalTransport_connectionHalfClose(vl_group); |
| |
| for (i := 0; i < 3; i := i + 1) { |
| if (not f_EPTF_HTTP_Test_checkPortState(vl_group, i, IDLE, -1, false, false, false)) { |
| vl_pass := false; i := 3; |
| setverdict(fail); |
| } |
| } |
| if (vl_pass) { t_action.start; } |
| } |
| else |
| if (vl_actionCnt == 4) { // close connection |
| log("Action: ", vl_actionCnt+1); |
| f_EPTF_HTTP_LocalTransport_closeConnection_defaultGroup(vl_group); |
| |
| for (i := 0; i < 3; i := i + 1) { |
| if (not f_EPTF_HTTP_Test_checkPortState(vl_group, i, IDLE, -1, false, false, false)) { |
| vl_pass := false; i := 3; |
| setverdict(fail); |
| } |
| } |
| if (vl_pass) { t_action.start; } |
| } |
| else |
| if (vl_actionCnt == 5) { // reclose connection |
| log("Action: ", vl_actionCnt+1); |
| f_EPTF_HTTP_LocalTransport_connectionClose(vl_group); |
| |
| for (i := 0; i < 3; i := i + 1) { |
| if (not f_EPTF_HTTP_Test_checkPortState(vl_group, i, IDLE, -1, false, false, false)) { |
| vl_pass := false; i := 3; |
| setverdict(fail); |
| } |
| } |
| |
| //t_action.start; |
| } |
| |
| vl_actionCnt := vl_actionCnt + 1; |
| |
| repeat; |
| } |
| [] t_guard.timeout { |
| log("Timer timed out!"); |
| } |
| } |
| |
| } |
| |
| if (vl_pass) { |
| f_EPTF_HTTP_LocalTransport_connectionClose(vl_group); |
| f_EPTF_HTTP_LocalTransport_deletePortGroup(vl_group); |
| |
| if (f_EPTF_FBQ_itemIsBusy(vl_group, v_EPTF_HTTP_Transport_groupQueue)) { |
| log("Group not deleted properly!"); |
| vl_pass := false; |
| setverdict(fail); |
| } |
| } |
| |
| f_EPTF_Base_cleanup_CT(); |
| |
| if (vl_pass) { setverdict(pass); }; |
| } |
| |
| testcase tc_EPTF_HTTP_Test_test18() |
| runs on EPTF_HTTP_Test_LocalAPI_CT |
| { |
| log("=============================="); |
| log("<< Starting test case 18 ... >>"); |
| log("=============================="); |
| log(""); |
| |
| f_EPTF_int2int_HashMap_Init(); |
| f_EPTF_Logging_init_CT("TEST_"); |
| v_EPTF_HTTP_Transport_loggingMaskId := |
| f_EPTF_Logging_registerComponentMasks( |
| tsp_EPTF_HTTP_Transport_loggingComponentMask, |
| c_EPTF_HTTP_Transport_loggingEventClasses, |
| EPTF_Logging_CLL); |
| |
| setverdict(pass); |
| f_EPTF_HTTP_Test_bufferTest(5, 0); |
| f_EPTF_HTTP_Test_bufferTest(5, 3); |
| f_EPTF_HTTP_Test_bufferTest(5, 4); |
| } |
| |
| testcase tc_EPTF_HTTP_Test_test19() |
| runs on EPTF_HTTP_Test_LocalAPI_CT |
| { |
| log("=============================="); |
| log("<< Starting test case 19 ... >>"); |
| log("=============================="); |
| log(""); |
| |
| var EPTF_HTTP_setAuthData vl_EPTF_HTTP_setAuthData:={ |
| method:="", |
| algorithm:="", |
| realm:="", |
| domain:=omit, |
| qopOptions:="", |
| password:="password" |
| }; |
| |
| f_EPTF_HTTP_setAuthData(vl_EPTF_HTTP_setAuthData); |
| |
| setverdict(pass); |
| |
| var charstring vl_authData := "Digest algorithm=MD5, cnonce=\"0a4f113b\", nc=00000001, nonce=\"NGExMTY0MDiDrxJA7/5a8Ya0lZvlaNXuEw==\", opaque=\"\", qop=auth-int, realm=\"access.telekom.de\", response=\"ef57ea40d83403357c16306cd6b811a2\", uri=\"/\", username=\"TASP-SOAP1\""; |
| |
| var EPTF_HTTP_AuthDetails vl_authDetails := c_EPTF_HTTP_initAuthDetails; |
| |
| var EPTF_HTTP_AuthDetails vl_authDetailsExpected := { |
| realm := "access.telekom.de", |
| qop := "auth-int", |
| nonce := "NGExMTY0MDiDrxJA7/5a8Ya0lZvlaNXuEw==", |
| cnonce := "0a4f113b", |
| opaque := c_EPTF_HTTP_initAuthDetails.opaque, |
| nonceCount := "00000001", |
| algorithm := "MD5", |
| response := "ef57ea40d83403357c16306cd6b811a2", |
| uri := "/", |
| username := "TASP-SOAP1", |
| password := c_EPTF_HTTP_initAuthDetails.password |
| } |
| |
| |
| f_EPTF_HTTP_getAuthParams(vl_authData, vl_authDetails); |
| |
| if (vl_authDetails != vl_authDetailsExpected) |
| { |
| log("Error: retrieved: ", vl_authDetails, " expected: ", vl_authDetailsExpected); |
| setverdict(fail); |
| } |
| |
| /* var charstring vl_body := "<?xml version='1.0' ?>\n<env:Envelope xmlns:env=\"http://www.w3.org/2003/05/soap-envelope\"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.w3.org/2003/05/soap-envelope soap-envelope.xml http://dummydomain.telekom.de/LISA/VoIPNotruf_1_00 VoIPNotruf_1_00.xsd\" >\n<env:Header><lisa:emergencyInformationRequest xmlns:lisa=\"http://dummydomain.telekom.de/LISA/VoIPNotruf_1_00\" env:role=\"next\" env:mustUnderstand=\"true\">\n<lisa:interfaceVersion>1</lisa:interfaceVersion>\n</lisa:emergencyInformationRequest>\n</env:Header>\n<env:Body><lisa:emergencyInformationRequestData xmlns:lisa=\"http://dummydomain.telekom.de/LISA/VoIPNotruf_1_00\">\n<lisa:emergencyNumber>110</lisa:emergencyNumber>\n<lisa:clientIPAddress>217.89.24.10</lisa:clientIPAddress>\n</lisa:emergencyInformationRequestData>\n</env:Body>\n</env:Envelope>" |
| |
| if (not f_EPTF_HTTP_checkAuthData("POST", vl_authData, vl_body)) |
| { |
| log("Error: auth data checking."); |
| setverdict(fail); |
| }*/ |
| } |
| |
| /* |
| testcase tc_random() runs on EPTF_HTTP_Test_CT |
| { |
| var EPTF_IntegerList vl_intList := {}; |
| var EPTF_FloatList vl_floatList := {}; |
| var integer vl_randval, i, j, vl_maxOccurance, vl_different, vl_curMax, vl_curOccurance; |
| var integer vl_allvalues := tsp_runningTime*tsp_QPS; |
| var float vl_maxNumber, vl_prev; |
| var integer vl_time; |
| |
| v_randState := 0.0; |
| |
| vl_time := f_time(); |
| |
| // generate random value |
| for (i := 0; i < vl_allvalues; i := i + 1) |
| { |
| vl_randval := float2int((int2float(tsp_rangeHi) - 0.001) * f_myRandom()); |
| //log("Random value: ", vl_randval); |
| |
| vl_intList[sizeof(vl_intList)] := vl_randval; |
| } |
| |
| log("Generated list: ", vl_intList); |
| |
| |
| // convert to float because of bubble sort |
| for (i := 0; i < sizeof(vl_intList); i := i + 1) { vl_floatList[i] := int2float(vl_intList[i]); }; |
| f_EPTF_StatMeasure_bubblesort(vl_floatList); |
| |
| log("Generated list (BUBBLE): ", vl_floatList); |
| |
| // sarch max occurance and its number and value of different numbers |
| vl_prev := vl_floatList[0]; |
| vl_maxNumber := -1.0; |
| vl_maxOccurance := 0; |
| vl_different := 0; |
| vl_curMax := -1; |
| vl_curOccurance := 0; |
| for (j := 1; j < sizeof(vl_floatList); j := j + 1) |
| { |
| vl_curOccurance := vl_curOccurance + 1; |
| |
| if (vl_floatList[j] != vl_prev) { |
| vl_different := vl_different + 1; |
| |
| if (vl_curOccurance > vl_maxOccurance) { |
| vl_maxOccurance := vl_curOccurance; |
| vl_maxNumber := vl_prev; |
| } |
| |
| vl_curOccurance := 0; |
| } |
| |
| vl_prev := vl_floatList[j]; |
| } |
| |
| vl_time := f_time() - vl_time; |
| |
| log("Running time: ", vl_time); |
| log("Max number and max occurance: ", float2int(vl_maxNumber), " / ", vl_maxOccurance, |
| " (ALL: " , vl_allvalues, " / DIFFERENT: ", vl_different, ")"); |
| } |
| */ |
| |
| control { |
| execute(tc_EPTF_HTTP_Test_test1()); |
| execute(tc_EPTF_HTTP_Test_test2()); |
| execute(tc_EPTF_HTTP_Test_test3()); |
| execute(tc_EPTF_HTTP_Test_test4()); |
| execute(tc_EPTF_HTTP_Test_test5()); |
| execute(tc_EPTF_HTTP_Test_test6()); |
| execute(tc_EPTF_HTTP_Test_test7()); |
| execute(tc_EPTF_HTTP_Test_test8()); |
| execute(tc_EPTF_HTTP_Test_test9()); |
| execute(tc_EPTF_HTTP_Test_test10()); |
| execute(tc_EPTF_HTTP_Test_test11()); |
| execute(tc_EPTF_HTTP_Test_test12()); |
| execute(tc_EPTF_HTTP_Test_test13()); |
| execute(tc_EPTF_HTTP_Test_test14()); |
| execute(tc_EPTF_HTTP_Test_test15()); |
| execute(tc_EPTF_HTTP_Test_test16()); |
| execute(tc_EPTF_HTTP_Test_test17()); |
| execute(tc_EPTF_HTTP_Test_test18()); |
| execute(tc_EPTF_HTTP_Test_test19()); |
| } |
| |
| } |