Deactivate backendConnected().
This commit is contained in:
parent
6c4b02cb56
commit
edf1d105e7
291
worker.cpp
291
worker.cpp
@ -68,7 +68,7 @@ Worker::Worker(hwinf *hw,
|
|||||||
, m_ismasUpdateRequests(ISMAS_UPDATE_REQUESTS)
|
, m_ismasUpdateRequests(ISMAS_UPDATE_REQUESTS)
|
||||||
, m_waitForNewUpdates(this)
|
, m_waitForNewUpdates(this)
|
||||||
, m_filesToUpdate()
|
, m_filesToUpdate()
|
||||||
, m_updateProcessRunning(false)
|
, m_updateProcessRunning(true)
|
||||||
, m_returnCode(0)
|
, m_returnCode(0)
|
||||||
, m_progressValue(0)
|
, m_progressValue(0)
|
||||||
, m_withoutIsmasDirectPort(false) /* useful for testing */ {
|
, m_withoutIsmasDirectPort(false) /* useful for testing */ {
|
||||||
@ -206,77 +206,122 @@ void Worker::privateUpdate() {
|
|||||||
m_returnCode = -3;
|
m_returnCode = -3;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qInfo() << "CHECKOUT BRANCH...";
|
m_ismasClient.setProgressInPercent(10);
|
||||||
emit appendText("\nInitializing customer environment ...");
|
if (backendConnected()) {
|
||||||
startProgressLoop();
|
m_ismasClient.setProgressInPercent(20);
|
||||||
if (m_gc.gitCheckoutBranch()) {
|
if (updateTriggerSet()) {
|
||||||
stopProgressLoop();
|
m_ismasClient.setProgressInPercent(30);
|
||||||
emit replaceLast("Initializing customer environment ...", UPDATE_STEP_DONE);
|
if (customerEnvironment()) {
|
||||||
setProgress(100);
|
m_ismasClient.setProgressInPercent(40);
|
||||||
|
if (filesToUpdate()) {
|
||||||
|
// send message to ISMAS about files which have been
|
||||||
|
// checked in into git repository
|
||||||
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECK_FILES_TO_UPDATE_SUCCESS,
|
||||||
|
QString("Files to update: ") + m_filesToUpdate.join(','));
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.updateOfPSAContinues("CHECK-FILES-TO-UPDATE",
|
||||||
|
m_updateStatus.m_statusDescription));
|
||||||
|
m_ismasClient.setProgressInPercent(50);
|
||||||
|
if (updateFiles(50)) {
|
||||||
|
m_ismasClient.setProgressInPercent(60);
|
||||||
|
if (syncCustomerRepositoryAndFS()) {
|
||||||
|
m_ismasClient.setProgressInPercent(70);
|
||||||
|
if (sendIsmasLastVersionNotification()) {
|
||||||
|
m_ismasClient.setProgressInPercent(80);
|
||||||
|
sentIsmasLastVersionNotification = true;
|
||||||
|
if (saveLogFile()) {
|
||||||
|
m_ismasClient.setProgressInPercent(90);
|
||||||
|
|
||||||
m_ismasClient.setProgressInPercent(10);
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
//m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECKOUT_BRANCH,
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
// QString("CHECKED OUT BRANCH: ") + m_gc.branchName());
|
m_ismasClient.updateOfPSASucceeded(""));
|
||||||
//IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
||||||
// QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
||||||
// m_ismasClient.checkoutBranch(
|
|
||||||
// m_updateStatus.m_statusDescription, ""));
|
|
||||||
|
|
||||||
qInfo() << "CHECKED OUT BRANCH";
|
// mark update as activated -> this resets the WAIT button
|
||||||
if (backendConnected()) {
|
m_ismasClient.setProgressInPercent(95);
|
||||||
m_ismasClient.setProgressInPercent(20);
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
if (updateTriggerSet()) {
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
m_ismasClient.setProgressInPercent(30);
|
m_ismasClient.updateOfPSAActivated());
|
||||||
if (customerEnvironment()) {
|
|
||||||
m_ismasClient.setProgressInPercent(40);
|
|
||||||
if (filesToUpdate()) {
|
|
||||||
m_ismasClient.setProgressInPercent(50);
|
|
||||||
if (updateFiles(50)) {
|
|
||||||
m_ismasClient.setProgressInPercent(60);
|
|
||||||
if (syncCustomerRepositoryAndFS()) {
|
|
||||||
m_ismasClient.setProgressInPercent(70);
|
|
||||||
if (sendIsmasLastVersionNotification()) {
|
|
||||||
m_ismasClient.setProgressInPercent(80);
|
|
||||||
sentIsmasLastVersionNotification = true;
|
|
||||||
if (saveLogFile()) {
|
|
||||||
m_ismasClient.setProgressInPercent(90);
|
|
||||||
|
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
m_returnCode = 0;
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
||||||
m_ismasClient.updateOfPSASucceeded(""));
|
|
||||||
|
|
||||||
// mark update as activated -> this resets the WAIT button
|
|
||||||
m_ismasClient.setProgressInPercent(95);
|
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
||||||
m_ismasClient.updateOfPSAActivated());
|
|
||||||
|
|
||||||
m_returnCode = 0;
|
|
||||||
} else {
|
|
||||||
m_returnCode = -12;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::SAVE_LOG_FILES_FAILED,
|
||||||
|
QString("Saving log files failed"));
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
|
"SAVE-LOG-FILES",
|
||||||
|
m_updateStatus.m_statusDescription));
|
||||||
m_returnCode = -11;
|
m_returnCode = -11;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_SEND_LAST_VERSION_FAILED,
|
||||||
|
QString("Sending ISMAS last version failed"));
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
|
"ISMAS-SEND-LAST-VERSION",
|
||||||
|
m_updateStatus.m_statusDescription));
|
||||||
m_returnCode = -10;
|
m_returnCode = -10;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::RSYNC_UPDATES_FAILURE,
|
||||||
|
QString("Syncing files to update failed"));
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
|
"RSYNC-UPDATE-FILES",
|
||||||
|
m_updateStatus.m_statusDescription));
|
||||||
m_returnCode = -9;
|
m_returnCode = -9;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::PSA_UPDATE_FILES_FAILED,
|
||||||
|
QString("Updating files failed"));
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
|
"UPDATE-FILES",
|
||||||
|
m_updateStatus.m_statusDescription));
|
||||||
m_returnCode = -8;
|
m_returnCode = -8;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_FAILURE,
|
||||||
|
QString("No files to update"));
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
|
"FETCH-FILES-TO-UPDATE",
|
||||||
|
m_updateStatus.m_statusDescription));
|
||||||
m_returnCode = -7;
|
m_returnCode = -7;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECKOUT_BRANCH_REQUEST_FAILURE,
|
||||||
|
QString("Configuring customer environment failed"));
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
|
"GIT-CHECKOUT-BRANCH",
|
||||||
|
m_updateStatus.m_statusDescription));
|
||||||
m_returnCode = -6;
|
m_returnCode = -6;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_SET_FAILURE,
|
||||||
|
QString("ISMAS update trigger wrong"));
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
|
"CHECK-UPDATE-TRIGGER",
|
||||||
|
m_updateStatus.m_statusDescription));
|
||||||
m_returnCode = -5;
|
m_returnCode = -5;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_BACKEND_CHECK_FAILURE,
|
||||||
|
QString("ISMAS backend not available"));
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
|
"ISMAS-BACKEND-CHECK",
|
||||||
|
m_updateStatus.m_statusDescription));
|
||||||
m_returnCode = -4;
|
m_returnCode = -4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -302,45 +347,64 @@ void Worker::privateUpdate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Worker::backendConnected() {
|
bool Worker::backendConnected() {
|
||||||
if (m_withoutIsmasDirectPort) { // useful for testing
|
// deactivated: REQ_SELF does not really help. Observation was that even
|
||||||
return true;
|
// id ISMAS is reported as 'true', a following check of the update-trigger
|
||||||
}
|
// button has no access to ISMAS.
|
||||||
|
return true;
|
||||||
|
|
||||||
emit appendText("\nConnecting backend ...");
|
emit appendText("\nConnecting backend ...");
|
||||||
|
|
||||||
for (int repeat = 0; repeat < 50; ++repeat) {
|
if (false) { // so linker removes dead code
|
||||||
qInfo() << "REPEAT" << repeat << "In backendConnected() -> #M=APISM#C=REQ_SELF#J={}";
|
for (int repeat = 0; repeat < 50; ++repeat) {
|
||||||
startProgressLoop();
|
qInfo() << "REPEAT" << repeat << "In backendConnected() -> #M=APISM#C=REQ_SELF#J={}";
|
||||||
std::optional<QString> result
|
startProgressLoop();
|
||||||
= IsmasClient::sendRequestReceiveResponse(
|
std::optional<QString> result
|
||||||
IsmasClient::APISM::DIRECT_PORT, "#M=APISM#C=REQ_SELF#J={}");
|
= IsmasClient::sendRequestReceiveResponse(
|
||||||
if (result) {
|
IsmasClient::APISM::DIRECT_PORT, "#M=APISM#C=REQ_SELF#J={}");
|
||||||
stopProgressLoop();
|
if (result) {
|
||||||
int progress = (m_mainWindow->progressValue()/10) + 10;
|
stopProgressLoop();
|
||||||
setProgress(progress);
|
int progress = (m_mainWindow->progressValue()/10) + 10;
|
||||||
|
setProgress(progress);
|
||||||
|
|
||||||
QString msg = result.value();
|
QString msg = result.value();
|
||||||
qInfo() << "In backendConnected() -> APISM response" << msg;
|
qInfo() << "In backendConnected() -> APISM response" << msg;
|
||||||
QJsonParseError parseError;
|
QJsonParseError parseError;
|
||||||
QJsonDocument document(QJsonDocument::fromJson(msg.toUtf8(), &parseError));
|
QJsonDocument document(QJsonDocument::fromJson(msg.toUtf8(), &parseError));
|
||||||
if (parseError.error != QJsonParseError::NoError) {
|
if (parseError.error != QJsonParseError::NoError) {
|
||||||
qCritical() << "(2) INVALID JSON MSG: PARSING FAILED (msg=" << msg << "):"
|
qCritical() << "(1) INVALID JSON MSG: PARSING FAILED (msg=" << msg << "):"
|
||||||
<< parseError.error << parseError.errorString();
|
<< parseError.error << parseError.errorString();
|
||||||
emit replaceLast("Connecting backend ...", UPDATE_STEP_FAIL);
|
setProgress(100);
|
||||||
return false;
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::JSON_PARSE_FAILURE,
|
||||||
}
|
QString("(2) INVALID JSON %1 %2 %3")
|
||||||
if (!document.isObject()) {
|
.arg(msg)
|
||||||
qCritical() << "FILE IS NOT A JSON OBJECT!";
|
.arg(parseError.error)
|
||||||
emit replaceLast("Connecting backend ...", UPDATE_STEP_FAIL);
|
.arg(parseError.errorString()));
|
||||||
return false;
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
}
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.jsonParseFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
|
m_updateStatus.m_statusDescription));
|
||||||
|
emit replaceLast("Connecting backend ...", UPDATE_STEP_FAIL);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!document.isObject()) {
|
||||||
|
qCritical() << "FILE IS NOT A JSON OBJECT!";
|
||||||
|
setProgress(100);
|
||||||
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::JSON_PARSE_FAILURE,
|
||||||
|
QString("NOT A JSON-OBJECT %1").arg(msg));
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.jsonParseFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
|
m_updateStatus.m_statusDescription));
|
||||||
|
emit replaceLast("Connecting backend ...", UPDATE_STEP_FAIL);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
setProgress(progress + 1);
|
setProgress(progress + 1);
|
||||||
|
|
||||||
QJsonObject obj = document.object();
|
QJsonObject obj = document.object();
|
||||||
QStringList keys = obj.keys();
|
QStringList keys = obj.keys().filter("CMD_GET_APISMSTATUS_RESPONSE");
|
||||||
for (QString const& key : keys ) {
|
if (keys.size() == 1) {
|
||||||
if (key.contains("CMD_GET_APISMSTATUS_RESPONSE")) {
|
QString const key = keys.at(0);
|
||||||
QJsonValue v = obj.value(key);
|
QJsonValue v = obj.value(key);
|
||||||
if (v.isObject()) {
|
if (v.isObject()) {
|
||||||
obj = v.toObject();
|
obj = v.toObject();
|
||||||
@ -357,32 +421,61 @@ bool Worker::backendConnected() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emit showErrorMessage("Check backend connection",
|
|
||||||
QString ("REPEAT %1 Broker=<").arg(repeat)
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::BACKEND_CHECK,
|
||||||
+ status + ">, ISMAS=<" + (ismas ? "true>" : "false>"));
|
QString ("REPEAT %1 Broker=<").arg(repeat)
|
||||||
|
+ status + ">, ISMAS=<" + (ismas ? "true>" : "false>"));
|
||||||
|
//IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
// QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
// m_ismasClient.updateOfPSAContinues("BACKEND-CHECK", m_updateStatus.m_statusDescription));
|
||||||
|
|
||||||
|
qInfo() << "BACKEND-CHECK" << m_updateStatus.m_statusDescription;
|
||||||
|
emit showErrorMessage("Check backend connection", m_updateStatus.m_statusDescription);
|
||||||
QThread::sleep(6);
|
QThread::sleep(6);
|
||||||
continue;
|
continue;
|
||||||
|
} else {
|
||||||
|
setProgress(100);
|
||||||
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::BACKEND_CHECK_FAILURE,
|
||||||
|
"CMD_GET_APISM_STATUS_RESPONSE KEY NOT A JSON-OBJECT");
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.sanityCheckFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
|
m_updateStatus.m_statusDescription));
|
||||||
|
emit showErrorMessage("check backend connection", m_updateStatus.m_statusDescription);
|
||||||
|
emit replaceLast("Connecting backend ...", UPDATE_STEP_FAIL);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
setProgress(100);
|
||||||
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::BACKEND_CHECK_FAILURE,
|
||||||
|
"CMD_GET_APISMSTATUS_RESPONSE KEY NOT AVAILABLE");
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.sanityCheckFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
|
m_updateStatus.m_statusDescription));
|
||||||
|
emit showErrorMessage("check backend connection", m_updateStatus.m_statusDescription);
|
||||||
|
emit replaceLast("Connecting backend ...", UPDATE_STEP_FAIL);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
stopProgressLoop();
|
||||||
|
int progress = (m_mainWindow->progressValue()/10) + 10;
|
||||||
|
setProgress(progress);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
stopProgressLoop();
|
|
||||||
int progress = (m_mainWindow->progressValue()/10) + 10;
|
|
||||||
setProgress(progress);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setProgress(100);
|
||||||
|
|
||||||
|
emit replaceLast("Connecting backend", UPDATE_STEP_FAIL);
|
||||||
|
emit showErrorMessage("Error", "Backend not available");
|
||||||
|
|
||||||
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::BACKEND_NOT_CONNECTED,
|
||||||
|
QString("NO BACKEND CONNECTION"));
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.errorBackendNotConnected(m_updateStatus.m_statusDescription, ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
setProgress(100);
|
|
||||||
|
|
||||||
emit replaceLast("Connecting backend", UPDATE_STEP_FAIL);
|
|
||||||
emit showErrorMessage("Error", "Backend not available");
|
|
||||||
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::BACKEND_NOT_CONNECTED,
|
|
||||||
QString("NO BACKEND CONNECTION"));
|
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
||||||
m_ismasClient.errorBackendNotConnected(m_updateStatus.m_statusDescription, ""));
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user