Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/syncUS' into syncretry
Browse files Browse the repository at this point in the history
  • Loading branch information
nlrcomcast committed Aug 16, 2024
2 parents 8f465f1 + 1ae4503 commit 6653350
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ int createNopollConnection(noPollCtx *ctx, server_list_t *server_list)
#ifdef ENABLE_WEBCFGBIN
//Sending cloud connection online event only during reconnect
ParodusInfo("Sending cloud connection online event after reconnection\n");
SendRbusEventCloudConnOnline();
SendConnOnlineEvent();
#endif
int chk_ret = creat("/tmp/webpanotifyready",S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (chk_ret == -1)
Expand Down
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ int main( int argc, char **argv)
registerRbusLogger();
subscribeRBUSevent();
regXmidtSendDataMethod();
rbusRegCloudConnOnlineEvent();
regConnOnlineEvent();
#endif
setDefaultValuesToCfg(cfg);
if (0 != parseCommandLine(argc,argv,cfg)) {
Expand Down
4 changes: 2 additions & 2 deletions src/upstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ typedef struct UpStreamMsg__
/* Function Prototypes */
/*----------------------------------------------------------------------------*/
#ifdef ENABLE_WEBCFGBIN
int rbusRegCloudConnOnlineEvent();
rbusError_t SendRbusEventCloudConnOnline();
int regConnOnlineEvent();
rbusError_t SendConnOnlineEvent();
rbusError_t CloudConnSubscribeHandler(rbusHandle_t handle, rbusEventSubAction_t action, const char* eventName, rbusFilter_t filter, int32_t interval, bool* autoPublish);
#endif
void packMetaData();
Expand Down
21 changes: 11 additions & 10 deletions src/upstream_rbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ void eventReceiveHandler( rbusHandle_t rbus_Handle, rbusEvent_t const* event, rb
}
#endif

rbusError_t SendRbusEventCloudConnOnline()
rbusError_t SendConnOnlineEvent()
{
rbusError_t rc = RBUS_ERROR_BUS_ERROR;
if(cloud_online_subscribe)
Expand Down Expand Up @@ -285,12 +285,13 @@ rbusError_t CloudConnSubscribeHandler(rbusHandle_t handle, rbusEventSubAction_t
(void)autoPublish;
(void)interval;

ParodusInfo(
"CloudConnSubscribeHandler called:\n" \
"\taction=%s\n" \
"\teventName=%s\n",
action == RBUS_EVENT_ACTION_SUBSCRIBE ? "subscribe" : "unsubscribe",
eventName);
if(eventName == NULL)
{
ParodusError("CloudConnSubscribeHandler: event name is NULL\n");
return RBUS_ERROR_INVALID_INPUT;
}

ParodusInfo("CloudConnSubscribeHandler: action=%s eventName=%s\n", action == RBUS_EVENT_ACTION_SUBSCRIBE ? "subscribe" : "unsubscribe", eventName);

if(!strcmp(CLOUD_CONN_ONLINE, eventName))
{
Expand All @@ -305,15 +306,15 @@ rbusError_t CloudConnSubscribeHandler(rbusHandle_t handle, rbusEventSubAction_t
}


int rbusRegCloudConnOnlineEvent()
int regConnOnlineEvent()
{
rbusError_t ret = RBUS_ERROR_SUCCESS;
rbusDataElement_t SyncRetryElements[1] = {{CLOUD_CONN_ONLINE, RBUS_ELEMENT_TYPE_EVENT, {NULL, NULL, NULL, NULL, CloudConnSubscribeHandler, NULL}}};

ParodusInfo("Registering CloudConnectionOnlineEvent %s\n", CLOUD_CONN_ONLINE);
ParodusInfo("Registering rbus event %s\n", CLOUD_CONN_ONLINE);
if(!rbus_Handle)
{
ParodusError("rbusRegCloudConnOnlineEvent failed as rbus_handle is empty\n");
ParodusError("regConnOnlineEvent failed as rbus_handle is empty\n");
return -1;
}
ret = rbus_regDataElements(rbus_Handle, 1, SyncRetryElements);
Expand Down
2 changes: 1 addition & 1 deletion tests/test_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ void setMessageHandlers()
}

#ifdef ENABLE_WEBCFGBIN
rbusError_t SendRbusEventCloudConnOnline()
rbusError_t SendConnOnlineEvent()
{
return;
}
Expand Down
33 changes: 17 additions & 16 deletions tests/test_upstream_rbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,26 @@ int sendUpstreamMsgToServer(void **resp_bytes, size_t resp_size)
return;
}
//Test case for rbusRegCloudConnectionOnlineEventRbushandle failure
void test_rbusRegCloudConnectionOnlineEventRbushandle_failure()
void test_regConnOnlineEventRbushandle_failure()
{
int result = rbusRegCloudConnOnlineEvent();
int result = regConnOnlineEvent();
CU_ASSERT_EQUAL(result, -1);
}

//Test case for rbusRegCloudConnectionOnlineEvent success
void test_rbusRegCloudConnectionOnlineEvent_success()
void test_regConnOnlineEvent_success()
{
subscribeRBUSevent();
int result = rbusRegCloudConnOnlineEvent();
int result = regConnOnlineEvent();
CU_ASSERT_EQUAL(result, 0);
}

//Test case for rbusRegCloudConnectionOnlineEvent failure
void test_rbusRegCloudConnectionOnlineEvent_failure()
void test_regConnOnlineEvent_failure()
{
int result = rbusRegCloudConnOnlineEvent();
result = rbusRegCloudConnOnlineEvent();
//Register event two time and it will create error
int result = regConnOnlineEvent();
result = regConnOnlineEvent();
CU_ASSERT_NOT_EQUAL(result, 0);
}

Expand Down Expand Up @@ -110,31 +111,31 @@ void rbushandleclose(char * name)
}

//Test case for SendRbusEventCloudConnOnline Success
void test_SendRbusEventCloudConnOnline_success()
void test_SendConnOnlineEvent_success()
{
subscribe_to_event(CLOUD_CONN_ONLINE);
rbusError_t ret = SendRbusEventCloudConnOnline();
rbusError_t ret = SendConnOnlineEvent();
CU_ASSERT_EQUAL(ret, 0);
rbushandleclose(CLOUD_CONN_ONLINE);
sleep(1);
}

//Test case for SendRbusEventCloudConnOnline failure
void test_SendRbusEventCloudConnOnline_failure()
void test_SendConnOnlineEvent_failure()
{
rbusError_t ret = SendRbusEventCloudConnOnline();
rbusError_t ret = SendConnOnlineEvent();
CU_ASSERT_NOT_EQUAL(ret, 0);
}

void add_suites( CU_pSuite *suite )
{
*suite = CU_add_suite( "tests", NULL, NULL );
CU_add_test( *suite, "test rbusRegCloudConnOnlineEventRbushandle_failure", test_rbusRegCloudConnectionOnlineEventRbushandle_failure);
CU_add_test( *suite, "test rbusRegCloudConnOnlineEvent_success", test_rbusRegCloudConnectionOnlineEvent_success);
CU_add_test( *suite, "test rbusRegCloudConnOnlineEvent_failure", test_rbusRegCloudConnectionOnlineEvent_failure);
CU_add_test( *suite, "test regConnOnlineEventRbushandle_failure", test_regConnOnlineEventRbushandle_failure);
CU_add_test( *suite, "test regConnOnlineEvent_success", test_regConnOnlineEvent_success);
CU_add_test( *suite, "test regConnOnlineEvent_failure", test_regConnOnlineEvent_failure);
CU_add_test( *suite, "test CloudConnSubscribeHandler_success", test_CloudConnSubscribeHandler_success);
CU_add_test( *suite, "test SendRbusEventCloudConnOnlinesuccess", test_SendRbusEventCloudConnOnline_success);
CU_add_test( *suite, "test SendRbusEventCloudConnOnline_failure", test_SendRbusEventCloudConnOnline_failure);
CU_add_test( *suite, "test SendConnOnlineEvent_success", test_SendConnOnlineEvent_success);
CU_add_test( *suite, "test SendConnOnlineEvent_failure", test_SendConnOnlineEvent_failure);
}


Expand Down

0 comments on commit 6653350

Please sign in to comment.