From 5fb7ba4d060e50a0fb17c86393978fcbce5b3d57 2018-01-15 17:16:41 From: mperrinel Date: 2018-01-15 17:16:41 Subject: [PATCH] Fix bug in acquisition !. Test fuzzing with 30 var in 8 group --- diff --git a/core/src/Variable/VariableAcquisitionWorker.cpp b/core/src/Variable/VariableAcquisitionWorker.cpp index 0b5132e..de9905b 100644 --- a/core/src/Variable/VariableAcquisitionWorker.cpp +++ b/core/src/Variable/VariableAcquisitionWorker.cpp @@ -140,9 +140,9 @@ void VariableAcquisitionWorker::abortProgressRequested(QUuid vIdentifier) void VariableAcquisitionWorker::onVariableRetrieveDataInProgress(QUuid acqIdentifier, double progress) { - qCInfo(LOG_VariableAcquisitionWorker()) << tr("TORM: onVariableRetrieveDataInProgress ") - << QThread::currentThread()->objectName() - << acqIdentifier << progress; + qCDebug(LOG_VariableAcquisitionWorker()) << tr("TORM: onVariableRetrieveDataInProgress ") + << QThread::currentThread()->objectName() + << acqIdentifier << progress; impl->lockRead(); auto aIdToARit = impl->m_AcqIdentifierToAcqRequestMap.find(acqIdentifier); if (aIdToARit != impl->m_AcqIdentifierToAcqRequestMap.cend()) { @@ -153,8 +153,6 @@ void VariableAcquisitionWorker::onVariableRetrieveDataInProgress(QUuid acqIdenti = std::isnan(progress) ? 0.0 : (progress * progressPartSize) / 100.0; // We can only give an approximation of the currentProgression since its upgrade is async. - qCInfo(LOG_VariableAcquisitionWorker()) - << tr("Progression: ") << aIdToARit->second.m_Progression << aIdToARit->second.m_Size; auto currentProgression = aIdToARit->second.m_Progression; if (currentProgression == aIdToARit->second.m_Size) { currentProgression = aIdToARit->second.m_Size - 1; @@ -165,15 +163,8 @@ void VariableAcquisitionWorker::onVariableRetrieveDataInProgress(QUuid acqIdenti auto finalProgression = currentAlreadyProgress + currentPartProgress; emit variableRequestInProgress(aIdToARit->second.m_vIdentifier, finalProgression); - qCInfo(LOG_VariableAcquisitionWorker()) - << tr("TORM: onVariableRetrieveDataInProgress ") - << QThread::currentThread()->objectName() << aIdToARit->second.m_vIdentifier - << progressPartSize << currentAlreadyProgress << currentPartProgress - << finalProgression; if (finalProgression == 100.0) { - qCInfo(LOG_VariableAcquisitionWorker()) - << tr("TORM: onVariableRetrieveDataInProgress : finished : 0.0 "); emit variableRequestInProgress(aIdToARit->second.m_vIdentifier, 0.0); } } @@ -189,14 +180,10 @@ void VariableAcquisitionWorker::onVariableAcquisitionFailed(QUuid acqIdentifier) if (it != impl->m_AcqIdentifierToAcqRequestMap.cend()) { auto request = it->second; impl->unlock(); - qCDebug(LOG_VariableAcquisitionWorker()) << tr("onVariableAcquisitionFailed") - << acqIdentifier << request.m_vIdentifier - << QThread::currentThread(); emit variableCanceledRequested(request.m_vIdentifier); } else { impl->unlock(); - // TODO log no acqIdentifier recognized } } @@ -228,8 +215,6 @@ void VariableAcquisitionWorker::onVariableDataAcquired(QUuid acqIdentifier, // Decrement the counter of the request auto &acqRequest = aIdToARit->second; - qCInfo(LOG_VariableAcquisitionWorker()) << tr("TORM: +1 update progresson ") - << acqIdentifier; acqRequest.m_Progression = acqRequest.m_Progression + 1; // if the counter is 0, we can return data then run the next request if it exists and @@ -318,7 +303,7 @@ void VariableAcquisitionWorker::VariableAcquisitionWorkerPrivate::cancelVarReque QUuid varRequestId) { qCDebug(LOG_VariableAcquisitionWorker()) - << "VariableAcquisitionWorkerPrivate::cancelVarRequest 0"; + << "VariableAcquisitionWorkerPrivate::cancelVarRequest start"; lockRead(); // get all AcqIdentifier in link with varRequestId QVector acqIdsToRm; @@ -374,9 +359,6 @@ void VariableAcquisitionWorker::VariableAcquisitionWorkerPrivate::removeAcqReque lockWrite(); - qCDebug(LOG_VariableAcquisitionWorker()) - << "VariableAcquisitionWorkerPrivate::updateToNextRequest removeAcqRequest: " - << acqRequestId; m_AcqIdentifierToAcqDataPacketVectorMap.erase(acqRequestId); m_AcqIdentifierToAcqRequestMap.erase(acqRequestId); diff --git a/core/src/Variable/VariableController.cpp b/core/src/Variable/VariableController.cpp index 9fcebef..e00039b 100644 --- a/core/src/Variable/VariableController.cpp +++ b/core/src/Variable/VariableController.cpp @@ -572,7 +572,7 @@ void VariableController::onRequestDataLoading(QVector } impl->m_VarGroupIdToVarIds.insert(std::make_pair(varRequestId, varIds)); for (const auto &var : variables) { - qCDebug(LOG_VariableController()) << "processRequest for" << var->name() << varRequestId + qCDebug(LOG_VariableController()) << "onRequestDataLoading: for" << varRequestId << varIds.size(); impl->processRequest(var, range, varRequestId); } @@ -591,6 +591,8 @@ void VariableController::onRequestDataLoading(QVector for (auto vId : vSyncIds) { varIds.push_back(vId); } + qCDebug(LOG_VariableController()) << "onRequestDataLoading sync: for" << varRequestId + << varIds.size(); impl->m_VarGroupIdToVarIds.insert(std::make_pair(varRequestId, varIds)); for (auto vId : vSyncIds) { @@ -832,8 +834,6 @@ void VariableController::VariableControllerPrivate::updateVariables(QUuid varReq auto &varIds = varGroupIdToVarIdsIt->second; auto varIdsEnd = varIds.end(); bool processVariableUpdate = true; - qCDebug(LOG_VariableController()) << "VariableControllerPrivate::updateVariables" - << varRequestId << varIds.size(); for (auto varIdsIt = varIds.begin(); (varIdsIt != varIdsEnd) && processVariableUpdate; ++varIdsIt) { auto itVarHandler = m_VarIdToVarRequestHandler.find(*varIdsIt); @@ -843,7 +843,6 @@ void VariableController::VariableControllerPrivate::updateVariables(QUuid varReq } if (processVariableUpdate) { - qCDebug(LOG_VariableController()) << "Final update OK for the var request" << varIds.size(); for (auto varIdsIt = varIds.begin(); varIdsIt != varIdsEnd; ++varIdsIt) { auto itVarHandler = m_VarIdToVarRequestHandler.find(*varIdsIt); if (itVarHandler != m_VarIdToVarRequestHandler.cend()) { @@ -862,7 +861,6 @@ void VariableController::VariableControllerPrivate::updateVariables(QUuid varReq << var->nbPoints(); emit var->updated(); - qCDebug(LOG_VariableController()) << tr("Update OK"); } else { qCCritical(LOG_VariableController()) @@ -894,13 +892,22 @@ void VariableController::VariableControllerPrivate::updateVariableRequest(QUuid auto &varIds = varGroupIdToVarIdsIt->second; auto varIdsEnd = varIds.end(); + + // First pass all canUpdate of handler to false for (auto varIdsIt = varIds.begin(); (varIdsIt != varIdsEnd); ++varIdsIt) { auto itVarHandler = m_VarIdToVarRequestHandler.find(*varIdsIt); if (itVarHandler != m_VarIdToVarRequestHandler.cend()) { auto varHandler = itVarHandler->second.get(); varHandler->m_CanUpdate = false; + } + } + // Second update requests of handler + for (auto varIdsIt = varIds.begin(); (varIdsIt != varIdsEnd); ++varIdsIt) { + auto itVarHandler = m_VarIdToVarRequestHandler.find(*varIdsIt); + if (itVarHandler != m_VarIdToVarRequestHandler.cend()) { + auto varHandler = itVarHandler->second.get(); switch (varHandler->m_State) { case VariableRequestHandlerState::OFF: { @@ -1016,8 +1023,6 @@ void VariableController::VariableControllerPrivate::cancelVariableRequest(QUuid void VariableController::VariableControllerPrivate::executeVarRequest(std::shared_ptr var, VariableRequest &varRequest) { - qCDebug(LOG_VariableController()) << tr("TORM: executeVarRequest"); - auto varIdIt = m_VariableToIdentifierMap.find(var); if (varIdIt == m_VariableToIdentifierMap.cend()) { qCWarning(LOG_VariableController()) << tr( @@ -1055,6 +1060,8 @@ void VariableController::VariableControllerPrivate::executeVarRequest(std::share } } else { + qCDebug(LOG_VariableController()) << "All already in the cache " + << varRequest.m_RangeRequested; acceptVariableRequest(varId, var->dataSeries()->subDataSeries(varRequest.m_CacheRangeRequested)); } diff --git a/gui/src/Visualization/VisualizationGraphWidget.cpp b/gui/src/Visualization/VisualizationGraphWidget.cpp index c77b9a6..f86e5ea 100644 --- a/gui/src/Visualization/VisualizationGraphWidget.cpp +++ b/gui/src/Visualization/VisualizationGraphWidget.cpp @@ -246,7 +246,7 @@ VisualizationGraphWidget::VisualizationGraphWidget(const QString &name, QWidget &VisualizationGraphWidget::onMouseDoubleClick); connect(ui->widget->xAxis, static_cast( &QCPAxis::rangeChanged), - this, &VisualizationGraphWidget::onRangeChanged, Qt::DirectConnection); + this, &VisualizationGraphWidget::onRangeChanged, Qt::DirectConnection); // Activates menu when right clicking on the graph ui->widget->setContextMenuPolicy(Qt::CustomContextMenu); diff --git a/plugins/amda/src/AmdaProvider.cpp b/plugins/amda/src/AmdaProvider.cpp index ff7d177..3395bd5 100644 --- a/plugins/amda/src/AmdaProvider.cpp +++ b/plugins/amda/src/AmdaProvider.cpp @@ -135,12 +135,16 @@ void AmdaProvider::onReplyDownloadProgress(QUuid acqIdentifier, finalProgress = finalProgress / fraq; } - qCDebug(LOG_AmdaProvider()) << tr("Current final progress: ") << fraq << finalProgress; + qCDebug(LOG_AmdaProvider()) << tr("final progress: ") + << QThread::currentThread()->objectName() << acqIdentifier + << fraq << finalProgress; emit dataProvidedProgress(acqIdentifier, finalProgress); } else { // This case can happened when a progression is send after the request has been finished. // Generaly the case when aborting a request + qCDebug(LOG_AmdaProvider()) << tr("Acquisition request not found: final progress: 100 : ") + << QThread::currentThread()->objectName() << acqIdentifier; emit dataProvidedProgress(acqIdentifier, 100.0); } } @@ -169,7 +173,6 @@ void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa QVariantHash urlProperties{{AMDA_SERVER_KEY, data.value(AMDA_SERVER_KEY)}}; auto url = QUrl{QString{AMDA_URL_FORMAT}.arg(AmdaServer::instance().url(urlProperties), startDate, endDate, productId)}; - qCInfo(LOG_AmdaProvider()) << tr("TORM AmdaProvider::retrieveData url:") << url; auto tempFile = std::make_shared(); // LAMBDA @@ -211,8 +214,8 @@ void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa if (reply->error() == QNetworkReply::NoError) { auto downloadFileUrl = QUrl{QString{reply->readAll()}.trimmed()}; - qCInfo(LOG_AmdaProvider()) - << tr("TORM AmdaProvider::retrieveData downloadFileUrl:") << downloadFileUrl; + qCDebug(LOG_AmdaProvider()) << tr("AmdaProvider::retrieveData downloadFileUrl:") + << downloadFileUrl; // Executes request for downloading file // // Creates destination file @@ -238,7 +241,6 @@ void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa // //////////////// // auto request = std::make_shared(url); - qCDebug(LOG_AmdaProvider()) << tr("First Request creation") << request.get(); updateRequestProgress(token, request, 0.0); emit requestConstructed(request, token, httpFinishedLambda); @@ -247,7 +249,6 @@ void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa void AmdaProvider::updateRequestProgress(QUuid acqIdentifier, std::shared_ptr request, double progress) { - qCDebug(LOG_AmdaProvider()) << tr("updateRequestProgress request") << request.get(); auto acqIdToRequestProgressMapIt = m_AcqIdToRequestProgressMap.find(acqIdentifier); if (acqIdToRequestProgressMapIt != m_AcqIdToRequestProgressMap.end()) { auto &requestProgressMap = acqIdToRequestProgressMapIt->second; diff --git a/plugins/amda/tests/FuzzingOperations.cpp b/plugins/amda/tests/FuzzingOperations.cpp index 059c233..7526b6e 100644 --- a/plugins/amda/tests/FuzzingOperations.cpp +++ b/plugins/amda/tests/FuzzingOperations.cpp @@ -178,7 +178,7 @@ struct SynchronizeOperation : public IFuzzingOperation { fuzzingState.synchronizeVariable(variableId, syncGroupId); variableController.onRequestDataLoading({variableState.m_Variable}, variableState.m_Range, - false); + true); } }; diff --git a/plugins/amda/tests/TestAmdaFuzzing.cpp b/plugins/amda/tests/TestAmdaFuzzing.cpp index eac10f4..9dec84e 100644 --- a/plugins/amda/tests/TestAmdaFuzzing.cpp +++ b/plugins/amda/tests/TestAmdaFuzzing.cpp @@ -73,30 +73,30 @@ using Validators = std::vector >; // ///////// // // Defaults values used when the associated properties have not been set for the test -const auto ACQUISITION_TIMEOUT_DEFAULT_VALUE = 30000; -const auto NB_MAX_OPERATIONS_DEFAULT_VALUE = 100; -const auto NB_MAX_SYNC_GROUPS_DEFAULT_VALUE = 1; -const auto NB_MAX_VARIABLES_DEFAULT_VALUE = 2; +const auto ACQUISITION_TIMEOUT_DEFAULT_VALUE = 100000; +const auto NB_MAX_OPERATIONS_DEFAULT_VALUE = 160; +const auto NB_MAX_SYNC_GROUPS_DEFAULT_VALUE = 8; +const auto NB_MAX_VARIABLES_DEFAULT_VALUE = 30; const auto AVAILABLE_OPERATIONS_DEFAULT_VALUE = QVariant::fromValue( - OperationsTypes{{FuzzingOperationType::CREATE, {400., true}}, + OperationsTypes{{FuzzingOperationType::CREATE, {40000., true}}, {FuzzingOperationType::DELETE, {0.0}}, // Delete operation is less frequent {FuzzingOperationType::PAN_LEFT, {1.}}, {FuzzingOperationType::PAN_RIGHT, {1.}}, - {FuzzingOperationType::ZOOM_IN, {0.}}, - {FuzzingOperationType::ZOOM_OUT, {0.}}, - {FuzzingOperationType::SYNCHRONIZE, {4000.0}}, - {FuzzingOperationType::DESYNCHRONIZE, {0.4}}}); + {FuzzingOperationType::ZOOM_IN, {1.}}, + {FuzzingOperationType::ZOOM_OUT, {1.}}, + {FuzzingOperationType::SYNCHRONIZE, {500.0}}, + {FuzzingOperationType::DESYNCHRONIZE, {0.0}}}); const auto CACHE_TOLERANCE_DEFAULT_VALUE = 0.2; /// Min/max delays between each operation (in ms) -const auto OPERATION_DELAY_BOUNDS_DEFAULT_VALUE = QVariant::fromValue(std::make_pair(20, 20)); +const auto OPERATION_DELAY_BOUNDS_DEFAULT_VALUE = QVariant::fromValue(std::make_pair(20, 3000)); /// Validators for the tests (executed in the order in which they're defined) const auto VALIDATORS_DEFAULT_VALUE = QVariant::fromValue( ValidatorsTypes{{FuzzingValidatorType::RANGE, FuzzingValidatorType::DATA}}); /// Min/max number of operations to execute before calling validation -const auto VALIDATION_FREQUENCY_BOUNDS_DEFAULT_VALUE = QVariant::fromValue(std::make_pair(2, 2)); +const auto VALIDATION_FREQUENCY_BOUNDS_DEFAULT_VALUE = QVariant::fromValue(std::make_pair(2, 10)); // /////// ////// @@ -374,6 +374,8 @@ public: auto waitAcquisition = nextValidationCounter == 0 || forceWait; + qCInfo(LOG_TestAmdaFuzzing()).noquote() << "Operation :" << i +1 << " on" + << nbOperations; fuzzingOperation->execute(variableId, m_FuzzingState, m_VariableController, m_Properties); @@ -464,7 +466,7 @@ void TestAmdaFuzzing::testFuzzing_data() // Test cases // // ////////// // - auto maxRange = SqpRange::fromDateTime({2017, 1, 3}, {0, 0}, {2017, 1, 5}, {0, 0}); + auto maxRange = SqpRange::fromDateTime({2017, 1, 5}, {8, 0}, {2017, 1, 5}, {16, 0}); MetadataPool metadataPool{{{"dataType", "vector"}, {"xml:id", "c1_b"}}}; // Note: we don't use auto here as we want to pass std::shared_ptr as is in the @@ -479,18 +481,18 @@ void TestAmdaFuzzing::testFuzzing_data() // {PROVIDER_PROPERTY, QVariant::fromValue(provider)}, // {CUSTOM_OPERATIONS_PROPERTY, CUSTOM_CASE_ONE}}; - QTest::newRow("fuzzingTestZoom") << Properties{ - {MAX_RANGE_PROPERTY, QVariant::fromValue(maxRange)}, - {METADATA_POOL_PROPERTY, QVariant::fromValue(metadataPool)}, - {PROVIDER_PROPERTY, QVariant::fromValue(provider)}, - {CUSTOM_OPERATIONS_PROPERTY, CUSTOM_CASE_TWO}}; +// QTest::newRow("fuzzingTestZoom") << Properties{ +// {MAX_RANGE_PROPERTY, QVariant::fromValue(maxRange)}, +// {METADATA_POOL_PROPERTY, QVariant::fromValue(metadataPool)}, +// {PROVIDER_PROPERTY, QVariant::fromValue(provider)}, +// {CUSTOM_OPERATIONS_PROPERTY, CUSTOM_CASE_TWO}}; //// Fuzzing -// QTest::newRow("fuzzingTest") << Properties{ -// {MAX_RANGE_PROPERTY, QVariant::fromValue(maxRange)}, -// {METADATA_POOL_PROPERTY, QVariant::fromValue(metadataPool)}, -// {PROVIDER_PROPERTY, QVariant::fromValue(provider)}}; + QTest::newRow("fuzzingTest") << Properties{ + {MAX_RANGE_PROPERTY, QVariant::fromValue(maxRange)}, + {METADATA_POOL_PROPERTY, QVariant::fromValue(metadataPool)}, + {PROVIDER_PROPERTY, QVariant::fromValue(provider)}}; }