Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit 9ff3a98

Browse files
author
Jay Logue
committed
Updated WDM functional tests
-- Updated the happy-based WDM functional tests to accommodate changes to the SubscriptionClient and SubscriptionHandler implementations introduced as a result of adding support for WDM over connection-oriented transports. -- Changed numerous python test scripts that have hard-coded dependencies on particular C++ method names appearing in log output. -- Fixed logic bugs in the MockWdmSubscriptionInitiator/Responder classes that depended on the existence of particular bugs in SubscriptionClient and SubscriptionHandler, which have now been fixed. -- Added additional logging as an aid to understanding the behavior of the MockWdmSubscriptionInitiator/Responder classes. -- Added option to TestWdmNext tool to enable use of WDM over a TCP connection. Note that, as of yet, there are no automated tests that exercise this feature.
1 parent 6a37b1c commit 9ff3a98

File tree

65 files changed

+127
-103
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+127
-103
lines changed

src/test-apps/MockWdmNodeOptions.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ MockWdmNodeOptions::MockWdmNodeOptions() :
3636
mWdmRoleInTest(0),
3737
mEnableMutualSubscription(false),
3838
mTestCaseId(NULL),
39+
mUseTCP(false),
3940
mEnableStopTest(false),
4041
mNumDataChangeBeforeCancellation(NULL),
4142
mFinalStatus(NULL),
@@ -61,6 +62,7 @@ MockWdmNodeOptions::MockWdmNodeOptions() :
6162
static OptionDef optionDefs[] =
6263
{
6364
{ "test-case", kArgumentRequired, kToolOpt_TestCaseId },
65+
{ "tcp", kNoArgument, kToolOpt_UseTCP },
6466
{ "enable-stop", kNoArgument, kToolOpt_EnableStopTest },
6567
{ "total-count", kArgumentRequired, kToolOpt_NumDataChangeBeforeCancellation },
6668
{ "final-status", kArgumentRequired, kToolOpt_FinalStatus },
@@ -138,6 +140,9 @@ MockWdmNodeOptions::MockWdmNodeOptions() :
138140
" --test-case <test case id>\n"
139141
" Further configure device behavior with this test case id\n"
140142
"\n"
143+
" --tcp\n"
144+
" Use tcp when initiating an interaction with a publisher\n"
145+
"\n"
141146
" --enable-stop\n"
142147
" Terminate WDM Next test in advance for Happy test\n"
143148
"\n"
@@ -418,6 +423,9 @@ bool MockWdmNodeOptions::HandleOption(const char *progName, OptionSet *optSet, i
418423
}
419424
mTestCaseId = strdup(arg);
420425
break;
426+
case kToolOpt_UseTCP:
427+
mUseTCP = true;
428+
break;
421429
case kToolOpt_EnableStopTest:
422430
mEnableStopTest = true;
423431
break;

src/test-apps/MockWdmNodeOptions.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ enum
4242
kToolOpt_WdmInitMutualSubscription,
4343
kToolOpt_WdmRespMutualSubscription,
4444
kToolOpt_TestCaseId,
45+
kToolOpt_UseTCP,
4546
kToolOpt_EnableStopTest,
4647
kToolOpt_NumDataChangeBeforeCancellation,
4748
kToolOpt_FinalStatus,
@@ -132,6 +133,7 @@ class MockWdmNodeOptions : public OptionSetBase
132133
int mWdmRoleInTest;
133134
bool mEnableMutualSubscription;
134135
const char * mTestCaseId;
136+
bool mUseTCP;
135137
bool mEnableStopTest;
136138
const char * mNumDataChangeBeforeCancellation;
137139
const char * mFinalStatus;

src/test-apps/MockWdmSubscriptionInitiator.cpp

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ class MockWdmSubscriptionInitiatorImpl: public MockWdmSubscriptionInitiator
134134
int mTestCaseId;
135135
int mTestSecurityMode;
136136
uint32_t mKeyId;
137+
bool mUseTCP;
137138

138139
TraitPath mTraitPaths[4];
139140
VersionedTraitPath mVersionedTraitPaths[4];
@@ -381,6 +382,8 @@ WEAVE_ERROR MockWdmSubscriptionInitiatorImpl::Init(
381382
mTestCaseId = kTestCase_TestTrait;
382383
}
383384

385+
mUseTCP = aConfig.mUseTCP;
386+
384387
mTestSecurityMode = aTestSecurityMode;
385388

386389
mKeyId = aKeyId;
@@ -705,12 +708,18 @@ WEAVE_ERROR MockWdmSubscriptionInitiatorImpl::PrepareBinding()
705708

706709
Binding::Configuration bindingConfig = mBinding->BeginConfiguration()
707710
.Target_NodeId(mPublisherNodeId) // TODO: aPublisherNodeId
708-
.Transport_UDP_WRM()
709-
.Transport_DefaultWRMPConfig(gWRMPConfig)
710-
711-
// (default) max num of msec between any outgoing message and next incoming message (could be a response to it)
712711
.Exchange_ResponseTimeoutMsec(kResponseTimeoutMsec);
713712

713+
if (mUseTCP)
714+
{
715+
bindingConfig.Transport_TCP();
716+
}
717+
else
718+
{
719+
bindingConfig.Transport_UDP_WRM()
720+
.Transport_DefaultWRMPConfig(gWRMPConfig);
721+
}
722+
714723
if (nl::Weave::kWeaveSubnetId_NotSpecified != mPublisherSubnetId)
715724
{
716725
bindingConfig.TargetAddress_WeaveFabric(mPublisherSubnetId);
@@ -777,13 +786,13 @@ void MockWdmSubscriptionInitiatorImpl::BindingEventCallback (void * const apAppS
777786
case nl::Weave::Binding::kEvent_PrepareFailed:
778787
// Don't fail; let the protocol retry.
779788
//err = aInParam.PrepareFailed.Reason;
780-
WeaveLogDetail(DataManagement, "kEvent_PrepareFailed: reason %d", err);
789+
WeaveLogDetail(DataManagement, "kEvent_PrepareFailed: reason %s", ::nl::ErrorStr(aInParam.PrepareFailed.Reason));
781790
break;
782791

783792
case nl::Weave::Binding::kEvent_BindingFailed:
784793
// Don't fail; let the protocol retry.
785794
//err = aInParam.BindingFailed.Reason;
786-
WeaveLogDetail(DataManagement, "kEvent_BindingFailed: reason %d", err);
795+
WeaveLogDetail(DataManagement, "kEvent_BindingFailed: reason %s", ::nl::ErrorStr(aInParam.PrepareFailed.Reason));
787796
break;
788797

789798
case nl::Weave::Binding::kEvent_BindingReady:
@@ -1090,11 +1099,15 @@ void MockWdmSubscriptionInitiatorImpl::ClientEventCallback (void * const aAppSta
10901099

10911100
break;
10921101
case SubscriptionClient::kEvent_OnSubscriptionTerminated:
1093-
WeaveLogDetail(DataManagement, "Client->kEvent_OnSubscriptionTerminated. Reason: %u, peer = 0x%" PRIX64 "\n",
1094-
aInParam.mSubscriptionTerminated.mReason,
1095-
aInParam.mSubscriptionTerminated.mClient->GetPeerNodeId());
1102+
WeaveLogDetail(DataManagement, "Client->kEvent_OnSubscriptionTerminated. peer = 0x%" PRIX64 ", %s: %s",
1103+
aInParam.mSubscriptionTerminated.mClient->GetPeerNodeId(),
1104+
(aInParam.mSubscriptionTerminated.mIsStatusCodeValid) ? "Status Report" : "Error",
1105+
(aInParam.mSubscriptionTerminated.mIsStatusCodeValid)
1106+
? ::nl::StatusReportStr(aInParam.mSubscriptionTerminated.mStatusProfileId, aInParam.mSubscriptionTerminated.mStatusCode)
1107+
: ::nl::ErrorStr(aInParam.mSubscriptionTerminated.mReason));
10961108

10971109
initiator->mWillRetry = aInParam.mSubscriptionTerminated.mWillRetry;
1110+
WeaveLogDetail(DataManagement, "mWillRetry is %s", aInParam.mSubscriptionTerminated.mWillRetry ? "true" : "false");
10981111

10991112
switch (gFinalStatus)
11001113
{
@@ -1263,8 +1276,9 @@ void MockWdmSubscriptionInitiatorImpl::PublisherEventCallback (void * const aApp
12631276
initiator->mExchangeMgr->MessageLayer->SystemLayer->CancelTimer(HandleDataFlipTimeout, initiator);
12641277
}
12651278

1266-
if (initiator->mEnableRetry == false || initiator->mWillRetry == false)
1279+
if (initiator->mEnableRetry == false)
12671280
{
1281+
WeaveLogDetail(DataManagement, "%s %d", __FUNCTION__, __LINE__);
12681282
HandlePublisherRelease();
12691283
if (gEvaluateSuccessIteration == true)
12701284
{
@@ -1290,8 +1304,11 @@ void MockWdmSubscriptionInitiatorImpl::HandleClientComplete(void *aAppState)
12901304
WEAVE_ERROR err;
12911305
MockWdmSubscriptionInitiatorImpl * const initiator = reinterpret_cast<MockWdmSubscriptionInitiatorImpl *>(aAppState);
12921306

1307+
WeaveLogDetail(DataManagement, "%s %d", __FUNCTION__, __LINE__);
1308+
12931309
if (gIsMutualSubscription == true)
12941310
{
1311+
WeaveLogDetail(DataManagement, "%s %d", __FUNCTION__, __LINE__);
12951312
gEvaluateSuccessIteration = true;
12961313
initiator->mWillRetry = false;
12971314
}
@@ -1317,9 +1334,11 @@ void MockWdmSubscriptionInitiatorImpl::HandleClientComplete(void *aAppState)
13171334

13181335
void MockWdmSubscriptionInitiatorImpl::HandlePublisherComplete()
13191336
{
1337+
WeaveLogDetail(DataManagement, "%s %d", __FUNCTION__, __LINE__);
13201338

13211339
if (gIsMutualSubscription == true)
13221340
{
1341+
WeaveLogDetail(DataManagement, "%s %d", __FUNCTION__, __LINE__);
13231342
gEvaluateSuccessIteration = true;
13241343
}
13251344

@@ -1573,7 +1592,7 @@ void MockWdmSubscriptionInitiatorImpl::MonitorClientCurrentState (nl::Weave::Sys
15731592
{
15741593
if (
15751594
#if WEAVE_CONFIG_ENABLE_WDM_UPDATE
1576-
false == initiator->mSubscriptionClient->IsUpdatePendingOrInProgress() && initiator->mUpdateTiming == MockWdmNodeOptions::kTiming_NoSub ||
1595+
(false == initiator->mSubscriptionClient->IsUpdatePendingOrInProgress() && initiator->mUpdateTiming == MockWdmNodeOptions::kTiming_NoSub) ||
15771596
#endif
15781597
(initiator->mSubscriptionClient->IsEstablishedIdle() && (gIsMutualSubscription == false || gSubscriptionHandler->IsEstablishedIdle())))
15791598
{

src/test-apps/MockWdmSubscriptionResponder.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -788,9 +788,12 @@ void MockWdmSubscriptionResponderImpl::PublisherEventCallback (void * const aApp
788788
break;
789789

790790
case SubscriptionHandler::kEvent_OnSubscriptionTerminated:
791-
WeaveLogDetail(DataManagement, "Publisher->kEvent_OnSubscriptionTerminated. Reason: %u, peer = 0x%" PRIX64 "\n",
792-
aInParam.mSubscriptionTerminated.mReason,
793-
aInParam.mSubscriptionTerminated.mHandler->GetPeerNodeId());
791+
WeaveLogDetail(DataManagement, "Publisher->kEvent_OnSubscriptionTerminated. peer = 0x%" PRIX64 ", %s: %s",
792+
aInParam.mSubscriptionTerminated.mHandler->GetPeerNodeId(),
793+
(aInParam.mSubscriptionTerminated.mIsStatusCodeValid) ? "Status Report" : "Error",
794+
(aInParam.mSubscriptionTerminated.mIsStatusCodeValid)
795+
? ::nl::StatusReportStr(aInParam.mSubscriptionTerminated.mStatusProfileId, aInParam.mSubscriptionTerminated.mStatusCode)
796+
: ::nl::ErrorStr(aInParam.mSubscriptionTerminated.mReason));
794797
switch (gFinalStatus)
795798
{
796799
case kPublisherCancel:
@@ -810,7 +813,6 @@ void MockWdmSubscriptionResponderImpl::PublisherEventCallback (void * const aApp
810813
{
811814
//responder->mExchangeMgr->MessageLayer->SystemLayer->CancelTimer(HandleDataFlipTimeout, aAppState);
812815
}
813-
HandleClientRelease(responder);
814816
HandlePublisherRelease();
815817
gResponderState.init();
816818
responder->onCompleteTest();
@@ -1025,7 +1027,9 @@ void MockWdmSubscriptionResponderImpl::HandleClientComplete(void *aAppState)
10251027
}
10261028
if (gFinalStatus == kClientAbort)
10271029
{
1028-
(void)responder->mSubscriptionClient->AbortSubscription();
1030+
responder->mSubscriptionClient->AbortSubscription();
1031+
responder->mSubscriptionClient->Free();
1032+
responder->mSubscriptionClient = NULL;
10291033
}
10301034
}
10311035
}

src/test-apps/TestEventLogging.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class TestSubscriptionHandler : public SubscriptionHandler
147147
GetVendedEvent(nl::Weave::Profiles::DataManagement::ImportanceType inImportance);
148148

149149
void SetActive(void) { mCurrentState = kState_Subscribing_Evaluating; }
150-
void SetAborted(void) { mCurrentState = kState_Aborted; }
150+
void SetTerminated(void) { mCurrentState = kState_Terminated; }
151151
void SetEstablishedIdle(void) { mCurrentState = kState_SubscriptionEstablished_Idle; }
152152
void SetExchangeContext(nl::Weave::ExchangeContext * aEC) { mEC = aEC; }
153153

src/test-apps/TestWdmNext.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ int main(int argc, char *argv[])
265265

266266
for (uint32_t iteration = 1; iteration <= gTestWdmNextOptions.mTestIterations; iteration++)
267267
{
268+
Done = false;
268269

269270
#ifdef ENABLE_WDMPERFDATA
270271

@@ -355,10 +356,13 @@ int main(int argc, char *argv[])
355356
MockEventGenerator::GetInstance()->Init(&ExchangeMgr, gEventGenerator, gMockWdmNodeOptions.mTimeBetweenEvents, true);
356357
}
357358

359+
printf("Start service network loop\n");
358360
while (!Done)
359361
{
360362
ServiceNetwork(sleepTime);
361363
}
364+
printf("End service network loop\n");
365+
362366
MockEventGenerator::GetInstance()->SetEventGeneratorStop();
363367

364368
if (gEventGenerator != NULL)
@@ -383,8 +387,6 @@ int main(int argc, char *argv[])
383387
}
384388

385389

386-
Done = false;
387-
388390
#ifdef ENABLE_WDMPERFDATA
389391

390392
TimeRef();
@@ -417,7 +419,6 @@ int main(int argc, char *argv[])
417419
}
418420

419421
printf("Current completed test iteration is %d\n", iteration);
420-
421422
}
422423

423424
MockWdmSubscriptionInitiator::GetInstance()->PrintVersionsLog();
@@ -454,11 +455,13 @@ static void HandleWdmCompleteTest()
454455
{
455456
if (gMockWdmNodeOptions.mEnableStopTest)
456457
{
458+
printf("HandleWdmCompleteTest: Done = true\n");
457459
Done = true;
458460
}
459461
}
460462

461463
static void HandleError()
462464
{
465+
printf("HandleError: Done = true\n");
463466
Done = true;
464467
}

src/test-apps/happy/tests/service/wdmNext/test_weave_wdm_next_service_mutual_subscribe_12.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_weave_wdm_next_service_mutual_subscribe_12(self):
3939
wdm_next_args['client_clear_state_between_iterations'] = True
4040
wdm_next_args['test_client_iterations'] = 10
4141
wdm_next_args['client_log_check'] = [('bound mutual subscription is going away', wdm_next_args['test_client_iterations']),
42-
('Client\[0\] \[(ALIVE|CONFM)\] AbortSubscription Ref\(\d+\)', wdm_next_args['test_client_iterations']),
42+
('Client\[0\] \[(ALIVE|CONFM)\] TerminateSubscription ', wdm_next_args['test_client_iterations']),
4343
('Client->kEvent_OnNotificationProcessed', wdm_next_args['test_client_iterations']),
4444
('Client\[0\] moving to \[ FREE\] Ref\(0\)', wdm_next_args['test_client_iterations']),
4545
('Handler\[0\] Moving to \[ FREE\] Ref\(0\)', wdm_next_args['test_client_iterations'] )]

src/test-apps/happy/tests/service/wdmNext/test_weave_wdm_next_service_mutual_subscribe_15.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def test_weave_wdm_next_service_mutual_subscribe_15(self):
4242
wdm_next_args['timeout'] = 60 * 15 * wdm_next_args['test_client_iterations']
4343

4444
wdm_next_args['client_log_check'] = [('bound mutual subscription is going away', wdm_next_args['test_client_iterations']),
45-
('Handler\[0\] \[(ALIVE|CONFM)\] AbortSubscription Ref\(\d+\)', wdm_next_args['test_client_iterations']),
45+
('Handler\[0\] \[(ALIVE|CONFM)\] TerminateSubscription ', wdm_next_args['test_client_iterations']),
4646
('Client->kEvent_OnNotificationProcessed', wdm_next_args['test_client_iterations']),
4747
('Client\[0\] moving to \[ FREE\] Ref\(0\)', wdm_next_args['test_client_iterations']),
4848
('Handler\[0\] Moving to \[ FREE\] Ref\(0\)', wdm_next_args['test_client_iterations'])]

src/test-apps/happy/tests/service/wdmNext/test_weave_wdm_next_service_mutual_subscribe_17.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ def test_weave_wdm_next_service_mutual_subscribe_17(self):
4444
wdm_next_args['client_log_check'] = [('bound mutual subscription is going away', wdm_next_args['test_client_iterations']),
4545
('Client\[0\] \[.+\] EndSubscription Ref\(\d+\)', wdm_next_args['test_client_iterations']),
4646
('Client->kEvent_OnNotificationProcessed', wdm_next_args['test_client_iterations']),
47-
('Client\[0\] moving to \[ FREE\] Ref\(0\)', wdm_next_args['test_client_iterations']),
4847
('Handler\[0\] Moving to \[ FREE\] Ref\(0\)', wdm_next_args['test_client_iterations'])]
4948

5049
wdm_next_args['test_tag'] = self.__class__.__name__

src/test-apps/happy/tests/service/wdmNext/test_weave_wdm_next_service_mutual_subscribe_18.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ def test_weave_wdm_next_service_mutual_subscribe_18(self):
4444
wdm_next_args['client_log_check'] = [('bound mutual subscription is going away', wdm_next_args['test_client_iterations']),
4545
('Handler\[0\] \[.+\] EndSubscription Ref\(\d+\)', wdm_next_args['test_client_iterations']),
4646
('Client->kEvent_OnNotificationProcessed', wdm_next_args['test_client_iterations']),
47-
('Client\[0\] moving to \[ FREE\] Ref\(0\)', wdm_next_args['test_client_iterations']),
4847
('Handler\[0\] Moving to \[ FREE\] Ref\(0\)', wdm_next_args['test_client_iterations'])]
4948

5049
wdm_next_args['test_tag'] = self.__class__.__name__

0 commit comments

Comments
 (0)