/** Run the test.
 */
TVerdict CT_LbsConflictStep_X3PPushMenu::doTestStepL()
	{
	INFO_PRINTF1(_L(">>CT_LbsConflictStep_X3PPushMenu::doTestStepL()"));

	if (TestStepResult() == EPass)
		{		
		// Setup the expected sequence events for the test.
		SetExpectedSeq();
				
		// Open and setup net sim.
		OpenNetSim(this);

		// Kick off the test abort and keep alive timers.
		TTimeIntervalMicroSeconds32 abortInterval(KLbsAbortPeriod);
		TTimeIntervalMicroSeconds32 keepAliveInterval(KLbsKeepAlivePeriod);

		iAbortTimer->SetTimer(abortInterval);
		iKeepAliveTimer->SetTimer(keepAliveInterval);

		// Kick off test.
		CActiveScheduler::Start();

		// Verify location data.
		VerifyPosInfos();

		// Clean up.
		CloseNetSim();
		}

	INFO_PRINTF1(_L("<<CT_LbsConflictStep_X3PPushMenu::doTestStepL()"));

	return TestStepResult();
	}
/** A standard TEF test case doTestStepL, this SHOULD only support a single test case.

	Typically the function will look much like this.
 */
TVerdict CT_LbsConflictStep_selflocatex3ppush::doTestStepL()
	{
	// Generic test step used to test the LBS Client Notify position update API.
	INFO_PRINTF1(_L(">>CT_LbsConflictStep_selflocatex3ppush::doTestStepL()"));

	if (TestStepResult() == EPass)
		{		
		// Setup the expected sequence events for the test.
		SetExpectedSeq();
				
		// Open and setup net sim.
		OpenNetSim(this);

		// Kick off the test abort and keep alive timers.
		TTimeIntervalMicroSeconds32 abortInterval(KLbsAbortPeriod);
		TTimeIntervalMicroSeconds32 keepAliveInterval(KLbsKeepAlivePeriod);

		iKeepAliveTimer->SetTimer(keepAliveInterval);

		// Set up test module so there's a delay in responding to request for fix:
		TModuleDataIn modDataInTimeout; // Used to send test information to the test module.
		const TInt KLbsTestModuleTimeOut = 3000000;	// 3 sec delay
		// The module request type - time out value.
		modDataInTimeout.iRequestType = TModuleDataIn::EModuleRequestTimeOut;
		// Micro seconds time value to delay the return position update from the module.
		modDataInTimeout.iTimeOut = KLbsTestModuleTimeOut;
		T_LbsUtils utils;
		utils.NotifyModuleOfConfigChangeL(modDataInTimeout);
		
		// Kick off test.
		CActiveScheduler::Start();

		// Verify location data.
		VerifyPosInfos();

		// Clean up.
		CloseNetSim();
		}

	INFO_PRINTF1(_L("<<CT_LbsConflictStep_selflocatex3ppush::doTestStepL()"));

	return TestStepResult();
	}
예제 #3
0
void SyncSourceFeedback::run(executor::TaskExecutor* executor, BackgroundSync* bgsync) {
    Client::initThread("SyncSourceFeedback");

    HostAndPort syncTarget;

    // keepAliveInterval indicates how frequently to forward progress in the absence of updates.
    Milliseconds keepAliveInterval(0);

    while (true) {  // breaks once _shutdownSignaled is true
        auto txn = cc().makeOperationContext();

        if (keepAliveInterval == Milliseconds(0)) {
            keepAliveInterval = calculateKeepAliveInterval(txn.get(), _mtx);
        }

        {
            // Take SyncSourceFeedback lock before calling into ReplicationCoordinator
            // to avoid deadlock because ReplicationCoordinator could conceivably calling back into
            // this class.
            stdx::unique_lock<stdx::mutex> lock(_mtx);
            while (!_positionChanged && !_shutdownSignaled) {
                if (_cond.wait_for(lock, keepAliveInterval.toSystemDuration()) ==
                    stdx::cv_status::timeout) {
                    MemberState state = ReplicationCoordinator::get(txn.get())->getMemberState();
                    if (!(state.primary() || state.startup())) {
                        break;
                    }
                }
            }

            if (_shutdownSignaled) {
                break;
            }

            _positionChanged = false;
        }

        {
            stdx::lock_guard<stdx::mutex> lock(_mtx);
            MemberState state = ReplicationCoordinator::get(txn.get())->getMemberState();
            if (state.primary() || state.startup()) {
                continue;
            }
        }

        const HostAndPort target = bgsync->getSyncTarget();
        // Log sync source changes.
        if (target.empty()) {
            if (syncTarget != target) {
                syncTarget = target;
            }
            // Loop back around again; the keepalive functionality will cause us to retry
            continue;
        }

        if (syncTarget != target) {
            LOG(1) << "setting syncSourceFeedback to " << target;
            syncTarget = target;

            // Update keepalive value from config.
            auto oldKeepAliveInterval = keepAliveInterval;
            keepAliveInterval = calculateKeepAliveInterval(txn.get(), _mtx);
            if (oldKeepAliveInterval != keepAliveInterval) {
                LOG(1) << "new syncSourceFeedback keep alive duration = " << keepAliveInterval
                       << " (previously " << oldKeepAliveInterval << ")";
            }
        }

        Reporter reporter(
            executor,
            makePrepareReplSetUpdatePositionCommandFn(txn.get(), _mtx, syncTarget, bgsync),
            syncTarget,
            keepAliveInterval);
        {
            stdx::lock_guard<stdx::mutex> lock(_mtx);
            _reporter = &reporter;
        }
        ON_BLOCK_EXIT([this]() {
            stdx::lock_guard<stdx::mutex> lock(_mtx);
            _reporter = nullptr;
        });

        auto status = _updateUpstream(txn.get(), bgsync);
        if (!status.isOK()) {
            LOG(1) << "The replication progress command (replSetUpdatePosition) failed and will be "
                      "retried: "
                   << status;
        }
    }
}
/**
 * @return - TVerdict code
 * Override of base class pure virtual
 * Our implementation only gets called if the base class doTestStepPreambleL() did
 * not leave. That being the case, the current test result value will be EPass.
 */
TVerdict CT_LbsClientStep_PartialUpdate::doTestStepL()
{
    // Generic test step used to test the LBS SetUpdateOptions API.
    INFO_PRINTF1(_L("&gt;&gt;CT_LbsClientStep_PartialUpdate::doTestStepL()"));

    if (TestStepResult()==EPass)
    {
        TInt err = KErrNone;
        iPosUpdateStatus = EPositionUpdateStart;

        //Configure partial Updates
        TPositionUpdateOptions optsA;
        optsA.SetAcceptPartialUpdates(ETrue);

        if(!optsA.AcceptPartialUpdates())
        {
            INFO_PRINTF1(_L("Partial Updates not set."));
            SetTestStepResult(EFail);
        }

        err = iDoPosUpdatePtr->SetOptions(optsA);
        User::LeaveIfError(err);

        CLbsAdmin* lbsAdminApi = CLbsAdmin::NewL();
        CleanupStack::PushL(lbsAdminApi);

        // Carryout unique test actions.
        if (GetIntFromConfig(ConfigSection(), KTestCaseId, iTestCaseId))
        {
            switch (iTestCaseId)
            {
            // Test case LBS-Partial-Update-Options-0001
            case 1:
            {
                CLbsAdmin::TGpsMode gpsMode = CLbsAdmin::EGpsAutonomous;
                lbsAdminApi->Set(KLbsSettingHomeGpsMode,gpsMode);

                //Configure Partial Update to EFalse
                TPositionUpdateOptions updOpts;
                updOpts.SetUpdateTimeOut(10*1000000);
                updOpts.SetAcceptPartialUpdates(EFalse);
                if(EFalse != updOpts.AcceptPartialUpdates())
                {
                    INFO_PRINTF1(_L("Partial Updates not set."));
                    SetTestStepResult(EFail);
                }

                err = iDoPosUpdatePtr->SetOptions(updOpts);
                User::LeaveIfError(err);

                break;
            }

            // Test case LBS-Partial-Update-Options-0002
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            {
                CLbsAdmin::TGpsMode gpsMode = CLbsAdmin::EGpsAutonomous;
                lbsAdminApi->Set(KLbsSettingHomeGpsMode,gpsMode);

                break;
            }

            case 21:
            case 22:
            case 24:
            case 25:
            case 26:
            {
                CLbsAdmin::TGpsMode gpsMode = CLbsAdmin::EGpsPreferTerminalBased;
                lbsAdminApi->Set(KLbsSettingHomeGpsMode,gpsMode);

                break;
            }

            case 23:
            {
                CLbsAdmin::TGpsMode gpsMode = CLbsAdmin::EGpsPreferTerminalBased;
                lbsAdminApi->Set(KLbsSettingHomeGpsMode,gpsMode);

                //Configure Partial Update to EFalse
                TPositionUpdateOptions updOpts;
                updOpts.SetAcceptPartialUpdates(EFalse);
                if(EFalse != updOpts.AcceptPartialUpdates())
                {
                    INFO_PRINTF1(_L("Partial Updates not set."));
                    SetTestStepResult(EFail);
                }

                err = iDoPosUpdatePtr->SetOptions(updOpts);
                User::LeaveIfError(err);

                break;
            }

            case 27:
            case 28:
            {
                //Tracking
                CLbsAdmin::TGpsMode gpsMode;
                if(iTestCaseId == 27)
                {
                    gpsMode = CLbsAdmin::EGpsAutonomous;
                }
                else
                {
                    gpsMode = CLbsAdmin::EGpsPreferTerminalBased;
                }

                lbsAdminApi->Set(KLbsSettingHomeGpsMode,gpsMode);

                TPositionUpdateOptions updOpts;
                updOpts.SetUpdateInterval(10*1000000); //Set Update Interval to 10 secs
                updOpts.SetAcceptPartialUpdates(ETrue);

                err = iDoPosUpdatePtr->SetOptions(updOpts);
                User::LeaveIfError(err);

                break;
            }

            default:
                User::Panic(KLbsClientStep_PartialUpdate, KErrUnknown);

            }
        }

        User::LeaveIfError(OpenNetSim());

        // Kick off the test abort and keep alive timers.
        TTimeIntervalMicroSeconds32 keepAliveInterval(KLbsKeepAlivePeriod);
        iKeepAliveTimer->SetTimer(keepAliveInterval);

        // Kick off test.
        CActiveScheduler::Start();

        // Verify location data.
        VerifyPosInfos();

        //Reset Test module timeout
        TModuleDataIn modDataIn;
        modDataIn.iRequestType = TModuleDataIn::EModuleRequestTimeOut;
        modDataIn.iTimeOut = 0;

        T_LbsUtils utils;
        utils.NotifyModuleOfConfigChangeL(modDataIn);

        // Clean up.
        CloseNetSim();

        CleanupStack::PopAndDestroy(lbsAdminApi);
    }

    INFO_PRINTF1(_L("&lt;&lt;CT_LbsClientStep_PartialUpdate::doTestStepL()"));

    return TestStepResult();
}