Commit 816d3ef8 authored by Miguel Angel Reina Ortega's avatar Miguel Angel Reina Ortega
Browse files

Retargeting test cases implemented (see notes)



CRE permutations finalized
Other permutations to be finalized once a merge from Release1 branch is
done (some functions already defined there)
Signed-off-by: Miguel Angel Reina Ortega's avatarreinaortega <miguelangel.reinaortega@etsi.org>
parent b9bd8987
......@@ -413,6 +413,28 @@ module OneM2M_Functions {
return v_resourceIndex;
}
/**
* @desc Getting the address of the last local resource saved in the vc_localResourcesList
* @param p_tester Given component
*/
function f_getLatestLocalResourceAddress(in CseSimu p_component, AddressingMethod p_addressingMethod := PX_ADDRESSING_METHOD, PrimitiveScope p_primitiveScope := PX_PRIMITIVE_SCOPE) runs on Tester return XSD.ID {
var XSD.ID v_localResourceAddress;
f_connectInfoPort(p_component);
p_component.start(f_sendLatestLocalResourceAddress(p_addressingMethod, p_primitiveScope));
alt {
[]infoPort.receive(mw_resourceAddress) -> value v_localResourceAddress{
}
}
p_component.done;
f_disconnectInfoPort(p_component);
return v_localResourceAddress;
}
/**
* @desc Getting primitiveContent retrieved in an AeSimu component
......@@ -460,6 +482,31 @@ module OneM2M_Functions {
}
/**
* @desc Getting the latest resource from an AeSimu component
* @param p_tester AeSimu component
* @param p_resourceIndex Index of resource to be retrieved
*/
function f_getLatestResource(in Tester p_component) runs on Tester return integer {
var MyResource v_resource;
var integer v_resourceIndex := -1;
f_connectInfoPort(p_component);
p_component.start(f_sendLatestResource());
alt {
[]infoPort.receive(mw_resource) -> value v_resource {
v_resourceIndex := f_setResource(v_resource.resource, v_resource.resourceType, v_resource.parentIndex, false);
}
}
p_component.done;
f_disconnectInfoPort(p_component);
return v_resourceIndex;
}
/**
* @desc Getting a specific resource from an AeSimu component
* @param p_tester AeSimu component
......@@ -512,6 +559,15 @@ module OneM2M_Functions {
}
/**
* @desc Sending the address of the last resource saved in the vc_resourcesList
*/
function f_sendLatestLocalResourceAddress(AddressingMethod p_addressingMethod := PX_ADDRESSING_METHOD, PrimitiveScope p_primitiveScope := PX_PRIMITIVE_SCOPE) runs on CseSimu {
infoPort.send(f_getLocalResourceAddress(lengthof(vc_localResourcesList)-1, p_addressingMethod, p_primitiveScope));
}
/**
* @desc Sending of last local resourceIndex saved in the vc_localResourcesList
*/
......@@ -563,6 +619,14 @@ module OneM2M_Functions {
} else {
infoPort.send(vc_resourcesList[p_resourceIndex]);
}
}
/**
* @desc Sending of the latest resource through InfoPort
*/
function f_sendLatestResource() runs on Tester {
infoPort.send(vc_resourcesList[lengthof(vc_resourcesList)-1]);
}
......@@ -1324,6 +1388,36 @@ module OneM2M_Functions {
}// end f_cse_deleteResource
/**
* @desc Message exchange for any operation on a resource
* @param p_requestPrimitive Request primitive to be sent
* @return PrimitiveContent parameter of the operation response
* @verdict
*/
function f_cse_operationResource(template RequestPrimitive p_requestPrimitive) runs on AeSimu return PrimitiveContent{
mcaPort.send(f_getMsgOutPrimitive(m_request(valueof(p_requestPrimitive))));
tc_ac.start;
alt {
[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value vc_response {
tc_ac.stop;
setverdict(pass, __SCOPE__&":INFO: Success operation on resource");
}
[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) -> value vc_response {
tc_ac.stop;
setverdict(inconc, __SCOPE__&":INFO: Error on the operation on resource");
}
[] tc_ac.timeout {
setverdict(inconc, __SCOPE__&":INFO: No answer while operation on resource");
}
}
f_checkAeSimuStatus();
return vc_response.primitive.responsePrimitive.primitiveContent;
}// end f_cse_operationResource
/**
* @desc Check that a resource is present in the IUT (resourceId is known) by using RETRIEVE operation
* @param p_resourceIndex Resource index of the resource to be checked
......@@ -2428,6 +2522,26 @@ module OneM2M_Functions {
f_checkCseSimuStatus();
}
/**
* @desc Creation and save a local resource (Test System simulating a CSE)
* @param p_resource Resource to be created
* @param p_parentIndex Parent resource index of resource to be saved
* @param p_resourceType Type of the resource to be created
* @return Index of internal created resource
*/
function f_generateAndSetLocalResource(in template(omit) PrimitiveContent p_resource := omit, in integer p_parentIndex, in ResourceType p_resourceType) runs on CseSimu return Integer {
var PrimitiveContent v_localResource;
var integer v_localResourceIndex;
v_localResource := f_generateLocalResource(p_resource, p_parentIndex, p_resourceType);
v_localResourceIndex := f_setLocalResource(v_localResource, p_resourceType, p_parentIndex);
return v_localResourceIndex;
}//End of function
/**
* @desc Creation of a local resource (Test System simulating a CSE)
......@@ -3196,8 +3310,10 @@ module OneM2M_Functions {
}
}
}
p_request.to_ := f_getResourceAddress(p_parentIndex);
//Only set To parameter if it has not been set yet
if(valueof(p_request.to_) == "NotInitialized") {
p_request.to_ := f_getResourceAddress(p_parentIndex);
}
if (p_resourceType == int1) {//AccessControlPolicy
......@@ -3211,9 +3327,7 @@ module OneM2M_Functions {
p_request.primitiveContent.group_.memberIDs := {f_getResourceId(vc_resourcesList[p_parentIndex].resource)};
}
}
}
if(p_resourceType == int3){//container
} else if(p_resourceType == int3){//container
//when a container is created by hosting cse for storing location information, the container is seen as a location container
if(PX_IS_LOC_CONTAINER){
p_request.primitiveContent.container.locationID := f_getResourceId(vc_resourcesList[p_parentIndex].resource);//resourceID of the locationPolicy
......@@ -3223,18 +3337,12 @@ module OneM2M_Functions {
p_request.primitiveContent.container.accessControlPolicyIDs := {f_getResourceId(vc_resourcesList[vc_acpAuxIndex].resource)};
}
}
}
if (p_resourceType == int15) {//pollingChannel
} else if (p_resourceType == int15) {//pollingChannel
if(ischosen(vc_resourcesList[p_parentIndex].resource.aE)) {
p_request.from_ := vc_resourcesList[p_parentIndex].resource.aE.aE_ID;
}
}
if (p_resourceType == int18) {//schedule
}
if (p_resourceType == int23) {//subscription
} else if (p_resourceType == int18) {//schedule
} else if (p_resourceType == int23) {//subscription
//notificationURI
if(match(valueof(p_request.primitiveContent.subscription.notificationURI), v_defaultListOfURIs )){
p_request.primitiveContent.subscription.notificationURI := {f_getResourceAddress(p_parentIndex)};
......@@ -3251,8 +3359,7 @@ module OneM2M_Functions {
p_request.primitiveContent.subscription.accessControlPolicyIDs := {f_getResourceId(vc_resourcesList[vc_acpAuxIndex].resource)};
}
}
}
if (p_resourceType == int4) {//contentInstance
} else if (p_resourceType == int4) {//contentInstance
//creator attribute
if(ispresent(p_request.primitiveContent.contentInstance.creator)) {
p_request.primitiveContent.contentInstance.creator := f_getCreator(p_parentIndex);
......@@ -3320,7 +3427,10 @@ module OneM2M_Functions {
if(p_resourceType != int10002) {
p_request.from_ := f_getOriginator(p_resourceIndex);
p_request.to_ := f_getResourceAddress(p_resourceIndex);
//Only set To parameter if it has not been set yet
if(valueof(p_request.to_) == "NotInitialized") {
p_request.to_ := f_getResourceAddress(p_resourceIndex);
}
} else {
p_request.from_ := PX_CSE1_ID & "/" & f_getResourceId(vc_resourcesList[p_resourceIndex].resource);
......
......@@ -14,6 +14,7 @@
module OneM2M_Ports {
import from OneM2M_Types all;
import from XSD all;
/* ***************************************
* oneM2M Ports
* ***************************************
......@@ -47,9 +48,9 @@ module OneM2M_Ports {
*/
type port InfoPort message {
in
RequestPrimitive, ResponsePrimitive, PrimitiveContent, MyResource, integer;
RequestPrimitive, ResponsePrimitive, PrimitiveContent, MyResource, integer, XSD.ID;
out
RequestPrimitive, ResponsePrimitive, PrimitiveContent, MyResource, integer;
RequestPrimitive, ResponsePrimitive, PrimitiveContent, MyResource, integer, XSD.ID;
}
......
......@@ -5036,6 +5036,7 @@ module OneM2M_Templates {
template MyResource mw_resource := ?;
template integer mw_resourceIndex := ?;
template XSD.ID mw_resourceAddress := ?;
}//end group InfoPortTemplates
......
......@@ -1809,120 +1809,287 @@ module OneM2M_PermutationFunctions {
group Data_Management_and_Repository {
group Create {
function f_CSE_DMR_CRE_001(ResourceType p_resourceType, template RequestPrimitive p_requestPrimitive, in template (omit) RequestPrimitive p_parentRequestPrimitive := omit) runs on AeSimu return ResponsePrimitive {
function f_CSE_DMR_001(template RequestPrimitive p_requestPrimitive) runs on CseSimu {
// Local variables
var MsgIn v_response;
var RequestPrimitive v_request;
var integer v_parentIndex := -1;
var integer v_resourceIndex := -1;
var integer v_ae2Index := -1;
var integer v_acpAuxIndex := -1;
var PoaList v_poaList := {"http://" & PX_AE2_ADDRESS & "/"};
// Test control
// Test component configuration
f_cf01Up(true);
// Test adapter configuration
// Local variables
var integer v_aeIndex, v_remoteCseIndex, v_targetResourceIndex := -1;
var ResponseStatusCode v_responseStatusCode := int2000;
var XSD.ID v_targetResourceAddress;
// Test control
// Test component configuration
f_cf02UpCseSimuMaster();
// Test adapter configuration
// Preamble
v_remoteCseIndex := f_cse_registerRemoteCse(m_createRemoteCSE_poa(-, -, -, -, {f_getAnnouncementTargetPoA()}));
vc_ae1.start(f_cse_preamble_registerAe());
vc_ae1.done;
//Creating resource in Hosting CSE
v_targetResourceIndex := f_generateAndSetLocalResource(valueof(m_primitiveContentContainer(m_contentCreateContainer)), vc_cSEBaseIndex, int3);
// Test Body
v_aeIndex := f_getLatestResource(vc_ae1);
v_targetResourceAddress := f_getLocalResourceAddress(v_targetResourceIndex, PX_ADDRESSING_METHOD, e_spRelative);
p_requestPrimitive.from_ := f_getOriginator(v_aeIndex);
p_requestPrimitive.to_ := v_targetResourceAddress;
if(valueof(p_requestPrimitive.operation) == int1) {
v_responseStatusCode := int2001;
} else if(valueof(p_requestPrimitive.operation) == int2) {
v_responseStatusCode := int2000;
} else if(valueof(p_requestPrimitive.operation) == int3) {
v_responseStatusCode := int2004;
} else if(valueof(p_requestPrimitive.operation) == int4) {
v_responseStatusCode := int2002;
}
vc_ae1.start(f_cse_operationResource(p_requestPrimitive));
tc_ac.start;
alt {
[v_responseStatusCode == int2001] mccPortIn.receive(mw_request(mw_create(-, v_targetResourceAddress))) -> value vc_request {
tc_ac.stop;
setverdict(pass, __SCOPE__ & ": Request primitive retargeted successfully");
f_processCreateRequestPrimitive(vc_request.primitive.requestPrimitive);
mccPortIn.send(m_response(vc_response.primitive.responsePrimitive));
}
[v_responseStatusCode == int2000] mccPortIn.receive(mw_request(mw_retrieve(v_targetResourceAddress))) -> value vc_request {
tc_ac.stop;
setverdict(pass, __SCOPE__ & ": Request primitive retargeted successfully");
//f_processRetrieveRequestPrimitive(vc_request.primitive.requestPrimitive);
mccPortIn.send(m_response(vc_response.primitive.responsePrimitive));
}
[v_responseStatusCode == int2004] mccPortIn.receive(mw_request(mw_update(-, v_targetResourceAddress))) -> value vc_request {
tc_ac.stop;
setverdict(pass, __SCOPE__ & ": Request primitive retargeted successfully");
//f_processUpdateRequestPrimitive(vc_request.primitive.requestPrimitive);
mccPortIn.send(m_response(vc_response.primitive.responsePrimitive));
}
[v_responseStatusCode == int2002] mccPortIn.receive(mw_request(mw_delete(v_targetResourceAddress))) -> value vc_request {
tc_ac.stop;
setverdict(pass, __SCOPE__ & ": Request primitive retargeted successfully");
//f_processDeleteRequestPrimitive(vc_request.primitive.requestPrimitive);
mccPortIn.send(m_response(vc_response.primitive.responsePrimitive));
}
[] mccPortIn.receive(mw_request(?)) -> value vc_request {
tc_ac.stop;
setverdict(fail, __SCOPE__ & ": Wrong request received");
mccPortIn.send(m_response(m_responsePrimitive(int4000, vc_request.primitive.requestPrimitive.requestIdentifier)));
}
[] tc_ac.timeout {
setverdict(fail, __SCOPE__ & ": No answer while retargeting request");
}
}
f_cseSimu_checkComponentDoneAndGetVerdict(vc_ae1);
// Postamble
f_cse_postamble_deleteResourcesCSE();
// Tear down
f_cf02DownCseSimuMaster();
}//end f_CSE_DMR_001
function f_CSE_DMR_002(template RequestPrimitive p_requestPrimitive) runs on AeSimu {
// Preamble
if(ispresent(p_parentRequestPrimitive)) {
if(match(int23, p_parentRequestPrimitive.resourceType)){
vc_ae2.start(f_cse_preamble_createAcpAux("SubscriptionVerificationAcp", int63));
f_aeSimu_checkComponentDoneAndGetVerdict(vc_ae2);
vc_ae2.start(f_cse_createResource_withAcpAux(int2, m_createAe(PX_APP_ID, -, PX_AE2_ID_STEM, c_defaultAE2Name, v_poaList), -1)); // AE2 is registred
f_aeSimu_checkComponentDoneAndGetVerdict(vc_ae2);
v_ae2Index := f_getResource(vc_ae2);
p_parentRequestPrimitive.primitiveContent.subscription.notificationURI := {f_getResourceAddress(v_ae2Index)};
vc_ae2.start(f_cse_notifyProcedure_subscriptionVerificationHandler());
}
if(ischosen(p_parentRequestPrimitive.primitiveContent.group_)){
f_cse_preamble_registerAe();
}
v_parentIndex := f_cse_createResource(valueof(p_parentRequestPrimitive.resourceType), p_parentRequestPrimitive, v_parentIndex);
} else {//Resource under CSEBase
if(p_resourceType != int1) {
v_acpAuxIndex := f_cse_createAccessControlPolicyAux(-, -, -);
p_requestPrimitive := f_setAcpId(p_requestPrimitive, {vc_resourcesList[v_acpAuxIndex].resource.accessControlPolicy.resourceID});
}
if(ischosen(p_requestPrimitive.primitiveContent.group_)){
f_cse_preamble_registerAe();
}
}
// Test Body
if(match(int23, p_requestPrimitive.resourceType)){
// Local variables
var integer v_aeIndex, v_cseBaseIndex, v_targetResourceIndex := -1;
var ResponseStatusCode v_responseStatusCode := int2000;
var XSD.ID v_targetResourceAddress;
// Test control
// Test component configuration
f_cf02Up();
// Test adapter configuration
// Preamble
v_cseBaseIndex := f_getLatestLocalResourceIndex(vc_cse1);
vc_cse1.start(f_cse_registerRemoteCse(m_createRemoteCSE_poa(-, -, -, -, {f_getAnnouncementTargetPoA()})));
f_aeSimu_checkComponentDoneAndGetVerdict(vc_cse1);
v_aeIndex := f_cse_preamble_registerAe();
//Creating resource in Hosting CSE
vc_cse1.start(f_generateAndSetLocalResource(valueof(m_primitiveContentContainer(m_contentCreateContainer)), v_cseBaseIndex, int3));
vc_cse1.done;
// Test Body
v_targetResourceAddress := f_getLatestLocalResourceAddress(vc_cse1, PX_ADDRESSING_METHOD, e_spRelative);
p_requestPrimitive.to_ := v_targetResourceAddress;
p_requestPrimitive.from_ := f_getOriginator(v_aeIndex);
v_targetResourceIndex := f_getLatestLocalResourceIndex(vc_cse1);
if(valueof(p_requestPrimitive.operation) == int1) {
v_responseStatusCode := int2001;
vc_cse1.start(f_cse_createResourceHandler(mw_create(-, v_targetResourceAddress )));
} else if(valueof(p_requestPrimitive.operation) == int2) {
v_responseStatusCode := int2000;
//vc_cse1.start(f_cse_retrieveResourceHandler());
} else if(valueof(p_requestPrimitive.operation) == int3) {
v_responseStatusCode := int2004;
vc_cse1.start(f_cse_updateResourceHandler(v_targetResourceIndex ,mw_update()));
} else if(valueof(p_requestPrimitive.operation) == int4) {
v_responseStatusCode := int2002;
//vc_cse1.start(f_cse_deleteResourceHandler());
}
mcaPort.send(f_getMsgOutPrimitive(m_request(valueof(p_requestPrimitive))));
tc_ac.start;
alt {
[] mcaPort.receive(mw_response(mw_responsePrimitive(v_responseStatusCode))) -> value vc_response {
tc_ac.stop;
setverdict(pass, __SCOPE__ & ": Request primitieve retargeted successfully");
}
[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value vc_response {
tc_ac.stop;
setverdict(fail, __SCOPE__ & ": Wrong response status code");
}
[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) -> value vc_response {
tc_ac.stop;
setverdict(fail, __SCOPE__ & ": Error while retargeting request");
}
[] tc_ac.timeout {
setverdict(fail, __SCOPE__ & ": No answer while retargeting request");
}
}
f_aeSimu_checkComponentDoneAndGetVerdict(vc_cse1);
// Postamble
f_cse_postamble_deleteResources();
// Tear down
f_cf02Down();
}//end f_CSE_DMR_002
group Create {
function f_CSE_DMR_CRE_001(ResourceType p_resourceType, template RequestPrimitive p_requestPrimitive, in template (omit) RequestPrimitive p_parentRequestPrimitive := omit) runs on AeSimu return ResponsePrimitive {
// Local variables
var MsgIn v_response;
var RequestPrimitive v_request;
var integer v_parentIndex := -1;
var integer v_resourceIndex := -1;
var integer v_ae2Index := -1;
var integer v_acpAuxIndex := -1;
var PoaList v_poaList := {"http://" & PX_AE2_ADDRESS & "/"};
// Test control
// Test component configuration
f_cf01Up(true);
// Test adapter configuration
// Preamble
if(ispresent(p_parentRequestPrimitive)) {
if(match(int23, p_parentRequestPrimitive.resourceType)){
vc_ae2.start(f_cse_preamble_createAcpAux("SubscriptionVerificationAcp", int63));
f_aeSimu_checkComponentDoneAndGetVerdict(vc_ae2);
vc_ae2.start(f_cse_createResource_withAcpAux(int2, m_createAe(PX_APP_ID, -, PX_AE2_ID_STEM, c_defaultAE2Name, v_poaList), -1)); // AE2 is registred
f_aeSimu_checkComponentDoneAndGetVerdict(vc_ae2);
v_ae2Index := f_getResource(vc_ae2);
p_requestPrimitive.primitiveContent.subscription.notificationURI := {f_getResourceAddress(v_ae2Index)};
p_parentRequestPrimitive.primitiveContent.subscription.notificationURI := {f_getResourceAddress(v_ae2Index)};
vc_ae2.start(f_cse_notifyProcedure_subscriptionVerificationHandler());
}
v_request := f_getCreateRequestPrimitive(p_resourceType, p_requestPrimitive, v_parentIndex);
if(ischosen(p_parentRequestPrimitive.primitiveContent.group_)){
f_cse_preamble_registerAe();
mcaPort.send(f_getMsgOutPrimitive(m_request(v_request)));
tc_ac.start;
alt {
[] mcaPort.receive(mw_response(mw_responsePrimitive(int2001))) -> value vc_response {
tc_ac.stop;
setverdict(pass, __SCOPE__ & ": Resource type " & int2str(enum2int(p_resourceType)) & " created successfully");
f_checkAttributesToBeSaved(p_resourceType, v_request, vc_response.primitive.responsePrimitive);
v_resourceIndex := f_setResource(vc_response.primitive.responsePrimitive.primitiveContent, p_resourceType, v_parentIndex);
}
[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value vc_response {
tc_ac.stop;
setverdict(fail, __SCOPE__ & ": Wrong response status code");
}
[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) -> value vc_response {
tc_ac.stop;
setverdict(fail, __SCOPE__ & ": Error while creating resource type " & int2str(enum2int(p_resourceType)));
}
[] tc_ac.timeout {
setverdict(fail, __SCOPE__ & ": No answer while creating resource type " & int2str(enum2int(p_resourceType)));
}
}
f_checkAeSimuStatus();
//Check to see if the resource is present or not
if (f_isResourcePresent(v_resourceIndex)){
setverdict(pass, __SCOPE__ & ":INFO: Resource created");
} else {
setverdict(fail, __SCOPE__ & ":ERROR: Resource not created");
}
// Postamble
f_cse_postamble_deleteResources();
v_parentIndex := f_cse_createResource(valueof(p_parentRequestPrimitive.resourceType), p_parentRequestPrimitive, v_parentIndex);
// Tear down
f_cf01Down();
return vc_response.primitive.responsePrimitive;
}//end f_CSE_DMR_CRE_001
} else {//Resource under CSEBase
if(p_resourceType != int1) {
v_acpAuxIndex := f_cse_createAccessControlPolicyAux(-, -, -);
p_requestPrimitive := f_setAcpId(p_requestPrimitive, {vc_resourcesList[v_acpAuxIndex].resource.accessControlPolicy.resourceID});
}
if(ischosen(p_requestPrimitive.primitiveContent.group_)){
f_cse_preamble_registerAe();
}
}
// Test Body
if(match(int23, p_requestPrimitive.resourceType)){
vc_ae2.start(f_cse_preamble_createAcpAux("SubscriptionVerificationAcp", int63));
f_aeSimu_checkComponentDoneAndGetVerdict(vc_ae2);
vc_ae2.start(f_cse_createResource_withAcpAux(int2, m_createAe(PX_APP_ID, -, PX_AE2_ID_STEM, c_defaultAE2Name, v_poaList), -1)); // AE2 is registred
f_aeSimu_checkComponentDoneAndGetVerdict(vc_ae2);
v_ae2Index := f_getResource(vc_ae2);
p_requestPrimitive.primitiveContent.subscription.notificationURI := {f_getResourceAddress(v_ae2Index)};
vc_ae2.start(f_cse_notifyProcedure_subscriptionVerificationHandler());
}
v_request := f_getCreateRequestPrimitive(p_resourceType, p_requestPrimitive, v_parentIndex);
mcaPort.send(f_getMsgOutPrimitive(m_request(v_request)));
tc_ac.start;
alt {
[] mcaPort.receive(mw_response(mw_responsePrimitive(int2001))) -> value vc_response {
tc_ac.stop;
setverdict(pass, __SCOPE__ & ": Resource type " & int2str(enum2int(p_resourceType)) & " created successfully");
f_checkAttributesToBeSaved(p_resourceType, v_request, vc_response.primitive.responsePrimitive);
v_resourceIndex := f_setResource(vc_response.primitive.responsePrimitive.primitiveContent, p_resourceType, v_parentIndex);
}
[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value vc_response {
tc_ac.stop;