Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit test failure fix #389

Open
wants to merge 7 commits into
base: xmidt_send
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/upstream_rbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,20 @@ void eventReceiveHandler( rbusHandle_t rbus_Handle, rbusEvent_t const* event, rb
setWebpaInterface(interface);
}
if(newValue !=NULL && oldValue!=NULL && interface!=NULL) {
ParodusInfo("New Value: %s Old Value: %s New Interface Value: %s\n", rbusValue_GetString(newValue, NULL), rbusValue_GetString(oldValue, NULL), interface);
ParodusInfo("New Value: %s Old Value: %s New Interface Value: %s\n", rbusValue_GetString(newValue, NULL), rbusValue_GetString(oldValue, NULL), interface);

// If interface is already down then reset it and reconnect cloud conn as wan failover event is received
if(get_interface_down_event())
{
reset_interface_down_event();
ParodusInfo("Interface_down_event is reset\n");
resume_heartBeatTimer();
}
// Close cloud conn and reconnect with the new interface as wan failover event is received
set_global_reconnect_reason("WAN_FAILOVER");
set_global_reconnect_status(true);
set_close_retry();

}
}
#endif
21 changes: 10 additions & 11 deletions src/xmidtsend_rbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void addToXmidtUpstreamQ(wrp_msg_t * msg, rbusMethodAsyncHandle_t asyncHandle)
{
char * errorMsg = strdup("Max Queue Size Exceeded");
ParodusError("Queue Size Exceeded\n");
createOutParamsandSendAck(msg, asyncHandle, errorMsg , QUEUE_SIZE_EXCEEDED);
createOutParamsandSendAck(msg, asyncHandle, errorMsg , QUEUE_SIZE_EXCEEDED, RBUS_ERROR_INVALID_RESPONSE_FROM_DESTINATION);
wrp_free_struct(msg);
return;
}
Expand Down Expand Up @@ -105,7 +105,7 @@ void addToXmidtUpstreamQ(wrp_msg_t * msg, rbusMethodAsyncHandle_t asyncHandle)
{
char * errorMsg = strdup("Unable to enqueue");
ParodusError("failure in allocation for xmidt message\n");
createOutParamsandSendAck(msg, asyncHandle, errorMsg , ENQUEUE_FAILURE);
createOutParamsandSendAck(msg, asyncHandle, errorMsg , ENQUEUE_FAILURE, RBUS_ERROR_INVALID_RESPONSE_FROM_DESTINATION);
wrp_free_struct(msg);
}
return;
Expand Down Expand Up @@ -182,7 +182,7 @@ int processData(wrp_msg_t * msg, rbusMethodAsyncHandle_t asyncHandle)
{
ParodusError("xmidtMsg is NULL\n");
errorMsg = strdup("Unable to enqueue");
createOutParamsandSendAck(xmidtMsg, asyncHandle, errorMsg, ENQUEUE_FAILURE);
createOutParamsandSendAck(xmidtMsg, asyncHandle, errorMsg, ENQUEUE_FAILURE, RBUS_ERROR_INVALID_RESPONSE_FROM_DESTINATION);
xmidtQDequeue();
return rv;
}
Expand All @@ -198,7 +198,7 @@ int processData(wrp_msg_t * msg, rbusMethodAsyncHandle_t asyncHandle)
else
{
ParodusError("validation failed, send failure ack\n");
createOutParamsandSendAck(xmidtMsg, asyncHandle, errorMsg , statuscode);
createOutParamsandSendAck(xmidtMsg, asyncHandle, errorMsg , statuscode, RBUS_ERROR_INVALID_INPUT);
xmidtQDequeue();
}
return rv;
Expand Down Expand Up @@ -371,7 +371,7 @@ void sendXmidtEventToServer(wrp_msg_t * msg, rbusMethodAsyncHandle_t asyncHandle
{
ParodusError("wrp msg_len is zero\n");
errorMsg = strdup("Wrp message encoding failed");
createOutParamsandSendAck(msg, asyncHandle, errorMsg, WRP_ENCODE_FAILURE);
createOutParamsandSendAck(msg, asyncHandle, errorMsg, WRP_ENCODE_FAILURE, RBUS_ERROR_INVALID_RESPONSE_FROM_DESTINATION);
xmidtQDequeue();

ParodusPrint("wrp_free_struct\n");
Expand Down Expand Up @@ -405,7 +405,7 @@ void sendXmidtEventToServer(wrp_msg_t * msg, rbusMethodAsyncHandle_t asyncHandle
{
errorMsg = strdup("send failed due to client disconnect");
ParodusInfo("The event is having low qos proceed to dequeue\n");
createOutParamsandSendAck(msg, asyncHandle, errorMsg, CLIENT_DISCONNECT);
createOutParamsandSendAck(msg, asyncHandle, errorMsg, CLIENT_DISCONNECT, RBUS_ERROR_INVALID_RESPONSE_FROM_DESTINATION);
xmidtQDequeue();
break;
}
Expand All @@ -415,7 +415,7 @@ void sendXmidtEventToServer(wrp_msg_t * msg, rbusMethodAsyncHandle_t asyncHandle
if(sendRetStatus == 0)
{
errorMsg = strdup("send to server success");
createOutParamsandSendAck(msg, asyncHandle, errorMsg, DELIVERED_SUCCESS);
createOutParamsandSendAck(msg, asyncHandle, errorMsg, DELIVERED_SUCCESS, RBUS_ERROR_SUCCESS);
xmidtQDequeue();
}

Expand All @@ -436,7 +436,7 @@ void sendXmidtEventToServer(wrp_msg_t * msg, rbusMethodAsyncHandle_t asyncHandle
{
errorMsg = strdup("Memory allocation failed");
ParodusError("Memory allocation failed\n");
createOutParamsandSendAck(msg, asyncHandle, errorMsg, MSG_PROCESSING_FAILED);
createOutParamsandSendAck(msg, asyncHandle, errorMsg, MSG_PROCESSING_FAILED, RBUS_ERROR_INVALID_RESPONSE_FROM_DESTINATION);
xmidtQDequeue();
}

Expand All @@ -452,7 +452,7 @@ void sendXmidtEventToServer(wrp_msg_t * msg, rbusMethodAsyncHandle_t asyncHandle
}
}

void createOutParamsandSendAck(wrp_msg_t *msg, rbusMethodAsyncHandle_t asyncHandle, char *errorMsg, int statuscode)
void createOutParamsandSendAck(wrp_msg_t *msg, rbusMethodAsyncHandle_t asyncHandle, char *errorMsg, int statuscode, rbusError_t error)
{
rbusObject_t outParams;
rbusError_t err;
Expand Down Expand Up @@ -533,8 +533,7 @@ void createOutParamsandSendAck(wrp_msg_t *msg, rbusMethodAsyncHandle_t asyncHand
return;
}

err = rbusMethod_SendAsyncResponse(asyncHandle, RBUS_ERROR_SUCCESS, outParams);
//err = rbusMethod_SendAsyncResponse(asyncHandle, RBUS_ERROR_INVALID_RESPONSE_FROM_DESTINATION, outParams); //for negative case
err = rbusMethod_SendAsyncResponse(asyncHandle, error, outParams);

if(err != RBUS_ERROR_SUCCESS)
{
Expand Down
10 changes: 5 additions & 5 deletions src/xmidtsend_rbus.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ typedef enum
MISSING_CONTENT_TYPE,
MISSING_PAYLOAD,
MISSING_PAYLOADLEN,
QUEUE_SIZE_EXCEEDED,
WRP_ENCODE_FAILURE,
MSG_PROCESSING_FAILED,
ENQUEUE_FAILURE = 100,
CLIENT_DISCONNECT = 101
CLIENT_DISCONNECT = 101,
QUEUE_SIZE_EXCEEDED = 102,
WRP_ENCODE_FAILURE = 103,
MSG_PROCESSING_FAILED = 104
} XMIDT_STATUS;
/*----------------------------------------------------------------------------*/
/* Function Prototypes */
Expand All @@ -70,7 +70,7 @@ void sendXmidtEventToServer(wrp_msg_t * msg, rbusMethodAsyncHandle_t asyncHandle
int checkInputParameters(rbusObject_t inParams);
char* generate_transaction_uuid();
void parseRbusInparamsToWrp(rbusObject_t inParams, char *trans_id, wrp_msg_t **eventMsg);
void createOutParamsandSendAck(wrp_msg_t *msg, rbusMethodAsyncHandle_t asyncHandle, char *errorMsg, int statuscode);
void createOutParamsandSendAck(wrp_msg_t *msg, rbusMethodAsyncHandle_t asyncHandle, char *errorMsg, int statuscode, rbusError_t error);
int validateXmidtData(wrp_msg_t * eventMsg, char **errorMsg, int *statusCode);
void xmidtQDequeue();
bool highQosValueCheck(int qos);
Expand Down