mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
added full tests for different version upgrades, both backend and webUI
This commit is contained in:
@@ -112,41 +112,46 @@ let system_status = {
|
|||||||
status: 3
|
status: 3
|
||||||
};
|
};
|
||||||
|
|
||||||
let VERSION_IS_UPGRADEABLE: boolean;
|
// Testing Versioning
|
||||||
|
let DEV_VERSION_IS_UPGRADEABLE: boolean;
|
||||||
|
let STABLE_VERSION_IS_UPGRADEABLE: boolean;
|
||||||
|
let THIS_VERSION: string;
|
||||||
|
let version_test: number;
|
||||||
|
|
||||||
// Versions
|
|
||||||
// default - on latest stable, no stable upgrades
|
|
||||||
let THIS_VERSION = '3.7.2';
|
|
||||||
let LATEST_STABLE_VERSION = '3.7.2';
|
let LATEST_STABLE_VERSION = '3.7.2';
|
||||||
let LATEST_DEV_VERSION = '3.7.3-dev.3';
|
let LATEST_DEV_VERSION = '3.7.3-dev.3';
|
||||||
|
|
||||||
// scenarios for testing versioning
|
// scenarios for testing versioning
|
||||||
let version_test = 0;
|
version_test = 0; // on latest stable, can upgrade to dev only
|
||||||
version_test = 0; // on latest stable, no upgrades, but can switch
|
// version_test = 1; // on latest dev, no updates to either dev or stable
|
||||||
// version_test = 1; // on latest dev, no update
|
// version_test = 2; // upgrade an older stable to latest stable or the latest dev
|
||||||
// version_test = 2; // on stable, upgrade stable to latest stable
|
// version_test = 3; // upgrade an older dev to latest dev, no stable upgrades available
|
||||||
// version_test = 3; // on dev, upgrade dev to latest dev
|
|
||||||
|
|
||||||
switch (version_test as number) {
|
switch (version_test as number) {
|
||||||
case 0:
|
case 0:
|
||||||
default:
|
default:
|
||||||
// use default - on latest stable, no upgrades, but can switch
|
// on latest stable, can upgrade to dev only
|
||||||
VERSION_IS_UPGRADEABLE = false;
|
THIS_VERSION = LATEST_STABLE_VERSION;
|
||||||
|
STABLE_VERSION_IS_UPGRADEABLE = false;
|
||||||
|
DEV_VERSION_IS_UPGRADEABLE = true;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
// on latest dev, no update
|
// on latest dev, no updates to either dev or stable
|
||||||
THIS_VERSION = LATEST_DEV_VERSION;
|
THIS_VERSION = LATEST_DEV_VERSION;
|
||||||
VERSION_IS_UPGRADEABLE = false;
|
STABLE_VERSION_IS_UPGRADEABLE = false;
|
||||||
|
DEV_VERSION_IS_UPGRADEABLE = false;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
// upgrade stable to latest stable
|
// upgrade an older stable to latest stable or the latest dev
|
||||||
THIS_VERSION = '3.6.5';
|
THIS_VERSION = '3.6.5';
|
||||||
VERSION_IS_UPGRADEABLE = true;
|
STABLE_VERSION_IS_UPGRADEABLE = true;
|
||||||
|
DEV_VERSION_IS_UPGRADEABLE = true;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
// upgrade dev to latest dev
|
// upgrade an older dev to latest dev, no stable upgrades available
|
||||||
THIS_VERSION = '3.7.3-dev-1';
|
THIS_VERSION = '3.7.3-dev.2';
|
||||||
VERSION_IS_UPGRADEABLE = true;
|
STABLE_VERSION_IS_UPGRADEABLE = false;
|
||||||
|
DEV_VERSION_IS_UPGRADEABLE = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,21 +365,23 @@ function check_upgrade(version: string) {
|
|||||||
if (version) {
|
if (version) {
|
||||||
const dev_version = version.split(',')[0];
|
const dev_version = version.split(',')[0];
|
||||||
const stable_version = version.split(',')[1];
|
const stable_version = version.split(',')[1];
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
'latest dev version: ' +
|
'Version upgrade check from this version (' +
|
||||||
dev_version +
|
|
||||||
', latest stable version: ' +
|
|
||||||
stable_version
|
|
||||||
);
|
|
||||||
console.log(
|
|
||||||
'Version upgrade check from version ' +
|
|
||||||
THIS_VERSION +
|
THIS_VERSION +
|
||||||
', upgradable: ' +
|
') to dev (' +
|
||||||
VERSION_IS_UPGRADEABLE
|
dev_version +
|
||||||
|
') is ' +
|
||||||
|
(DEV_VERSION_IS_UPGRADEABLE ? 'YES' : 'NO') +
|
||||||
|
' and to stable (' +
|
||||||
|
stable_version +
|
||||||
|
') is ' +
|
||||||
|
(STABLE_VERSION_IS_UPGRADEABLE ? 'YES' : 'NO')
|
||||||
);
|
);
|
||||||
data = {
|
data = {
|
||||||
emsesp_version: THIS_VERSION,
|
emsesp_version: THIS_VERSION,
|
||||||
upgradeable: VERSION_IS_UPGRADEABLE
|
dev_upgradeable: DEV_VERSION_IS_UPGRADEABLE,
|
||||||
|
stable_upgradeable: STABLE_VERSION_IS_UPGRADEABLE
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
console.log('requesting ems-esp version (' + THIS_VERSION + ')');
|
console.log('requesting ems-esp version (' + THIS_VERSION + ')');
|
||||||
|
|||||||
@@ -1112,19 +1112,30 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
|||||||
// EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
// EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
||||||
|
|
||||||
// test version checks
|
// test version checks
|
||||||
// test with "current_version_s = "3.7.1-dev.8" in WebStatusService::checkUpgrade()
|
// use same data as in rest_server.ts
|
||||||
// request.url("/rest/action");
|
// log shows first if you can upgrade to dev, and then if you can upgrade to stable
|
||||||
// deserializeJson(doc, "{\"action\":\"checkUpgrade\", \"param\":\"3.7.1-dev.9,3.7.0\"}"); // is upgradable
|
request.url("/rest/action");
|
||||||
// EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
std::string LATEST_STABLE_VERSION = "3.7.2";
|
||||||
// deserializeJson(doc, "{\"action\":\"checkUpgrade\", \"param\":\"3.7.1-dev.7,3.7.0\"}"); // is not upgradable
|
std::string LATEST_DEV_VERSION = "3.7.3-dev.3";
|
||||||
// EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
std::string param = LATEST_DEV_VERSION + "," + LATEST_STABLE_VERSION;
|
||||||
|
std::string action = "{\"action\":\"checkUpgrade\", \"param\":\"" + param + "\"}";
|
||||||
|
deserializeJson(doc, action);
|
||||||
|
|
||||||
// test with "current_version_s = "3.6.5" in WebStatusService::checkUpgrade()
|
// case 0: on latest stable, can upgrade to dev only. So true, false
|
||||||
// request.url("/rest/action");
|
EMSESP::webStatusService.set_current_version(LATEST_STABLE_VERSION);
|
||||||
// deserializeJson(doc, "{\"action\":\"checkUpgrade\", \"param\":\"3.7.1-dev.9,3.6.5\"}"); // is noy upgradable
|
EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
||||||
// EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
|
||||||
// deserializeJson(doc, "{\"action\":\"checkUpgrade\", \"param\":\"3.7.1-dev.7,3.7.0\"}"); // is upgradable
|
// case 1: on latest dev, no updates to either dev or stable. So false, false
|
||||||
// EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
EMSESP::webStatusService.set_current_version(LATEST_DEV_VERSION);
|
||||||
|
EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
||||||
|
|
||||||
|
// case 2: upgrade an older stable to latest stable or the latest dev. So true, true
|
||||||
|
EMSESP::webStatusService.set_current_version("3.6.5");
|
||||||
|
EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
||||||
|
|
||||||
|
// case 3: upgrade an older dev to latest dev, no stable upgrades available. So true, false
|
||||||
|
EMSESP::webStatusService.set_current_version("3.7.3-dev.2");
|
||||||
|
EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
||||||
|
|
||||||
// char data6[] = "{\"device\":\"system\", \"cmd\":\"read\",\"value\":\"8 2 27 1\"}";
|
// char data6[] = "{\"device\":\"system\", \"cmd\":\"read\",\"value\":\"8 2 27 1\"}";
|
||||||
// deserializeJson(doc, data6);
|
// deserializeJson(doc, data6);
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace emsesp {
|
|||||||
// #define EMSESP_DEBUG_DEFAULT "310"
|
// #define EMSESP_DEBUG_DEFAULT "310"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "render"
|
// #define EMSESP_DEBUG_DEFAULT "render"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "api"
|
// #define EMSESP_DEBUG_DEFAULT "api"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "api3"
|
#define EMSESP_DEBUG_DEFAULT "api3"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "api4"
|
// #define EMSESP_DEBUG_DEFAULT "api4"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "crash"
|
// #define EMSESP_DEBUG_DEFAULT "crash"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "dv"
|
// #define EMSESP_DEBUG_DEFAULT "dv"
|
||||||
|
|||||||
Reference in New Issue
Block a user