blob: 7edad5fd9d0f93d187642251bd33a75a7ea21613 [file] [log] [blame]
///////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2000-2018 Ericsson Telecom AB
//
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// which accompanies this distribution, and is available at
// http://www.eclipse.org/legal/epl-v10.html
///////////////////////////////////////////////////////////////////////////////
//
// File: MBT_demo.ttcn
// Rev: <RnXnn>
// Prodnr: CNL 113 659
// Updated: 2009-10-01
// Contact: http://ttcn.ericsson.se
///////////////////////////////////////////////////////////////////////////////
module MBT_demo
{
import from EPTF_MBT_LGen_Definitions all;
import from EPTF_MBT_LGen_Functions all;
import from EPTF_CLL_Common_Definitions all;
import from EPTF_CLL_Base_Definitions all;
import from EPTF_CLL_Base_Functions all;
import from EPTF_CLL_RBTScheduler_Functions all;
import from EPTF_CLL_LGenBase_Definitions all;
import from EPTF_CLL_LGenBase_ConfigFunctions all;
import from EPTF_CLL_LGenBase_EventHandlingFunctions all;
import from EPTF_SIP_LGen_Definitions all;
import from EPTF_SIP_LGen_Functions all;
import from EPTF_SIP_Common_Functions all;
import from EPTF_SIP_UserDatabase_Functions all;
import from EPTF_SIP_Transport_Definitions all;
import from EPTF_SIP_Transport_Functions all;
import from EPTF_SIP_MessageHandler_Functions 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;
type component MBT_Demo_LGen_CT extends EPTF_MBT_LGen_CT, EPTF_SIP_LGen_CT, EPTF_SIP_LocalTransport_CT,
EPTF_HTTP_LGen_CT,EPTF_HTTP_LocalTransport_CT
{}
type component MBT_Demo_Tester_CT extends EPTF_MBT_Tester_CT {}
type component MBT_Demo_Main_CT extends EPTF_Base_CT {}
testcase tc_MBT_HTTP_Demo() runs on MBT_Demo_Main_CT
{
f_EPTF_Base_init_CT("mtc");
var MBT_Demo_LGen_CT vc_MBT_CT := MBT_Demo_LGen_CT.create;
var MBT_Demo_Tester_CT vc_Tester_CT := MBT_Demo_Tester_CT.create;
connect(vc_MBT_CT:EPTF_MBT_PCO, vc_Tester_CT:EPTF_MBT_TESTER_PCO);
vc_MBT_CT.start(f_MBT_Demo_LGen_HTTP_behavior());
vc_Tester_CT.start(f_MBT_Demo_Tester_HTTP_behavior());
//all component.done;
f_EPTF_Base_wait4Shutdown();
}
testcase tc_MBT_SIP_Demo() runs on MBT_Demo_Main_CT
{
f_EPTF_Base_init_CT("mtc");
var MBT_Demo_LGen_CT vc_MBT_CT := MBT_Demo_LGen_CT.create;
var MBT_Demo_Tester_CT vc_Tester_CT := MBT_Demo_Tester_CT.create;
connect(vc_MBT_CT:EPTF_MBT_PCO, vc_Tester_CT:EPTF_MBT_TESTER_PCO);
vc_MBT_CT.start(f_MBT_Demo_LGen_SIP_behavior());
vc_Tester_CT.start(f_MBT_Demo_Tester_SIP_behavior());
//all component.done;
f_EPTF_Base_wait4Shutdown();
}
function f_MBT_Demo_LGen_HTTP_behavior() runs on MBT_Demo_LGen_CT
{
//map(self:IPL4_PCO, system:IPL4_PCO);
f_EPTF_MBT_init("MBT_Demo_LGen",0, "MBT_")
f_EPTF_HTTP_init(
pl_selfName:="HTTP_LoadGen",
pl_selfId:=0,
pl_entityNamePrefix:="HTTP_AppLib_",
pl_numEntities:=0)
f_EPTF_HTTP_LocalTransport_init_CT(
pl_selfName:="EPTF_HTTP_LocalTransport",
pl_receiveFunction:=refers(f_EPTF_HTTP_messageReceived),
pl_eventReceiveFunction:=refers(f_EPTF_HTTP_eventReceived))
f_EPTF_HTTP_setSendRequestFunction(pl_sendRequest_fp:=refers(f_EPTF_HTTP_LocalTransport_sendMessage))
f_EPTF_HTTP_setConnectionOpenFunction(plf_connectionOpen:=refers(f_EPTF_HTTP_LocalTransport_connectionOpen))
f_EPTF_HTTP_setConnectionCloseFunction(plf_connectionClose:=refers(f_EPTF_HTTP_LocalTransport_connectionClose))
f_EPTF_HTTP_setConnectionHalfCloseFunction(plf_connectionHalfClose:=refers(f_EPTF_HTTP_LocalTransport_connectionHalfClose))
f_EPTF_HTTP_setFreePortOfUserFunction(plf_fpou:=refers(f_EPTF_HTTP_LocalTransport_freePortOfUser));
f_EPTF_HTTP_setClosePortOfUserFunction(plf_cpou:=refers(f_EPTF_HTTP_LocalTransport_closePortOfUser));
f_EPTF_MBT_initLGenFsm
(
refers(f_mbt_userfunction),
refers(f_EPTF_MBT_HTTP_Demo_fillInDB)
);
f_EPTF_Base_wait4Shutdown();
}
function f_MBT_Demo_Tester_HTTP_behavior() runs on MBT_Demo_Tester_CT
{
f_EPTF_Base_init_CT("MBT_Demo_Tester");
EPTF_MBT_TESTER_PCO.send(EPTF_MBT_ConfigRequest:
{
entityGroupName := "MBT_EntityType",
noEntities := 1,
behaviors := {"MBT_behavior", "HTTP Behavior"},
fsmName := "FSM_MBT"
}
);
// TODO: activate default altstep, with timeout handling
EPTF_MBT_TESTER_PCO.receive(EPTF_MBT_ConfigResponse:?);
EPTF_MBT_TESTER_PCO.send(EPTF_MBT_TestStepRequest: {"EPTF HTTP: Sends HTTP Request", {}, omit, omit});
EPTF_MBT_TESTER_PCO.receive(EPTF_MBT_TestStepResponse:{ bName := "HTTP Behavior", iName := "HTTP CHAR Response Message Received", addr := *});
EPTF_MBT_TESTER_PCO.send(EPTF_MBT_CommandRequest:{ quit := {}});
f_EPTF_Base_wait4Shutdown();
}
function f_MBT_Demo_LGen_SIP_behavior() runs on MBT_Demo_LGen_CT
{
f_EPTF_MBT_init("MBT_Demo_LGen",0, "MBT_")
f_SIP_applibInit("MBT_Demo_LGen");
f_EPTF_SIP_LocalTransport_init("udp");
vf_EPTF_SIP_LocalTransport_receive := refers(f_EPTF_SIP_Message_MsgHandler); //receive callback function on LocalTransport
vf_EPTF_SIP_LGen_msgSender := refers(f_EPTF_SIP_LocalTransport_sendSIPMessage); //send callback function on LGen
v_removeUAS := refers(fcb_EPTF_SIP_LocalTransport_removeUAS);
f_EPTF_MBT_initLGenFsm
(
null,
refers(f_EPTF_MBT_SIP_Demo_fillInDB)
);
f_EPTF_Base_wait4Shutdown();
}
function f_MBT_Demo_Tester_SIP_behavior() runs on MBT_Demo_Tester_CT
{
f_EPTF_Base_init_CT("MBT_Demo_Tester");
EPTF_MBT_TESTER_PCO.send(EPTF_MBT_ConfigRequest:
{
entityGroupName := "MBT_EntityType",
noEntities := 1,
behaviors := {"MBT_behavior", "HTTP Behavior"},
fsmName := "FSM_MBT"
}
);
// TODO: activate default altstep, with timeout handling
EPTF_MBT_TESTER_PCO.receive(EPTF_MBT_ConfigResponse:?);
EPTF_MBT_TESTER_PCO.send(EPTF_MBT_TestStepRequest: {"SIPAppLib: StepFunction_init", {}, omit, omit});
EPTF_MBT_TESTER_PCO.send(EPTF_MBT_TestStepRequest: {"SIPAppLib: StepFunction_createREGISTER", {}, omit, omit});
EPTF_MBT_TESTER_PCO.receive(EPTF_MBT_TestStepResponse:{ bName := "Behavior_SIP", iName := "401", addr := * });
EPTF_MBT_TESTER_PCO.send(EPTF_MBT_TestStepRequest: {"SIPAppLib: StepFunction_createREGISTER", {}, omit, omit});
EPTF_MBT_TESTER_PCO.receive(EPTF_MBT_TestStepResponse:{ bName := "Behavior_SIP", iName := "200", addr := * });
EPTF_MBT_TESTER_PCO.send(EPTF_MBT_TestStepRequest: {"SIPAppLib: StepFunction_createDEREGISTER", {}, omit, omit});
EPTF_MBT_TESTER_PCO.receive(EPTF_MBT_TestStepResponse:{ bName := "Behavior_SIP", iName := "401", addr := * });
EPTF_MBT_TESTER_PCO.send(EPTF_MBT_TestStepRequest: {"SIPAppLib: StepFunction_createDEREGISTER", {}, omit, omit});
EPTF_MBT_TESTER_PCO.receive(EPTF_MBT_TestStepResponse:{ bName := "Behavior_SIP", iName := "200", addr := * });
EPTF_MBT_TESTER_PCO.send(EPTF_MBT_TestStepRequest: {"SIPAppLib: StepFunction_cleanUp", {}, omit, omit});
EPTF_MBT_TESTER_PCO.send(EPTF_MBT_CommandRequest:{ quit := {}});
f_EPTF_Base_wait4Shutdown();
}
// CUSTOM PART
function f_mbt_userfunction(in EPTF_LGenBase_TestStepArgs pl_ptr)
runs on MBT_Demo_LGen_CT
return boolean
{
v_msgToProcess.response.messageBody:="Ferike";
return true;
}
function f_EPTF_MBT_SIP_Demo_fillInDB(in EPTF_MBT_ConfigRequest p_req) runs on MBT_Demo_LGen_CT
{
var integer vl_grpIdx := f_EPTF_LGenBase_entityGrpNameIndex(p_req.entityGroupName);
var integer vl_entityIdx := f_EPTF_LGenBase_getEGrpBaseOffset(vl_grpIdx);
for (var integer i:=0; i<p_req.noEntities; i:=i+1)
{
var EPTF_IntegerList vl_bCtx := f_EPTF_LGenBase_getBehaviorCtx(i + vl_entityIdx, v_SIP_myBIdx);
f_EPTF_SIP_IPL4asp_SetUserData
(
vl_bCtx[0],
"10.251.64.2", // local IP
{15000, 15001},
"udp",
"10.80.36.65", // proxy ip
5060 // proxy port
);
f_EPTF_SIP_User_SetUserData(
vl_bCtx[0],
{
{
addr := {
nameAddr := {
displayName := "titansim_user_7465000",
addrSpec := {
scheme := "sip",
userInfo := {
userOrTelephoneSubscriber := "titansim_user_7465000",
password := omit
},
hostPort := {
host := "tcj.ics.se",
portField := 5060
},
urlParameters := omit,
headers := omit
}
}
},
password := "pass2ICS"
}
},
"10.251.64.2",
{15000, 15001},
i + vl_entityIdx //entity index
);
f_EPTF_SIP_Session_AddData(vl_bCtx[0], f_EPTF_SIP_getTransport("UDP"),345600);
//f_EPTF_SIP_mapUser2TransportUser(vl_bCtx[0], 0);
f_EPTF_SIP_IPL4asp_startListening(vl_bCtx[0], true); // Both UDP and TCP
}
}
function f_EPTF_MBT_HTTP_Demo_fillInDB(in EPTF_MBT_ConfigRequest p_req) runs on MBT_Demo_LGen_CT
{
var integer vl_grpIdx := f_EPTF_LGenBase_entityGrpNameIndex(p_req.entityGroupName);
var integer vl_entityIdx := f_EPTF_LGenBase_getEGrpBaseOffset(vl_grpIdx);
for (var integer i:=0; i<p_req.noEntities; i:=i+1)
{
var EPTF_IntegerList vl_bCtx := f_EPTF_LGenBase_getBehaviorCtx(i + vl_entityIdx, v_EPTF_HTTP_myBIdx);
var integer vl_connHandle := f_EPTF_HTTP_LocalTransport_newPort(
{
name:="SingleHTTP_Port"& "_" & int2str(vl_bCtx[0]),
localHostInformation := { "192.168.163.130", 50000+vl_bCtx[0]},
remoteHostInformation := { "ttcn.ericsson.se", 80},
instantConnOpen := true,
instantConnClose := true,
useSSL := false,
userFunctions := omit
}
)
v_EPTF_HTTP_contexts[vl_bCtx[0]] := {
method := "GET",
uri:= "/",
version_major:=1,
version_minor:=1,
headerLinesIdx := f_EPTF_HTTP_addNewHeaderLines({
{header_name:="Host", header_value:="ttcn.ericsson.se" },
{header_name:="Connection", header_value:="close" } }),
authDetails := {"","","","","00000001","MD5","","","","",""},
//authDetails := {"","","","","00000001","MD5",""},
requestPending:=false,
connId := vl_connHandle,
bodyId :=f_EPTF_HTTP_setCharEntityBody("<HTML>Request.</HTML>"),
headerGetterFn:=refers(f_EPTF_HTTP_getHeaderContentForEntity),
rawHeaderGetterFn:= null,
contentGetterFn:=refers(f_EPTF_HTTP_getCharstringBodyContentForEntity),
charBodyHandlerFn:=refers(f_EPTF_HTTP_defaultCharstringBodyHandler) ,
binaryBodyHandlerFn:= refers(f_EPTF_HTTP_defaultBinaryBodyHandler)
}
}
}
}