From d07593d03861307f8ff667f913cb161a6cdcef79 Mon Sep 17 00:00:00 2001 From: vbawol Date: Mon, 27 Mar 2017 17:44:55 -0500 Subject: [PATCH] added unit test and further hive optimizations --- .../@epochhive/addons/epoch_server.pbo | Bin 454057 -> 454150 bytes .../@epochhive/addons/epoch_server_core.pbo | Bin 19236 -> 26585 bytes .../addons/epoch_server_settings.pbo | Bin 482246 -> 481834 bytes Sources/epoch_server/build.hpp | 2 +- .../epoch_player/EPOCH_server_makeSP.sqf | 2 +- .../epoch_vehicle/EPOCH_load_vehicles.sqf | 2 - Sources/epoch_server/init/server_init.sqf | 4 + Sources/epoch_server_core/build.hpp | 2 +- .../compile/epoch_hive/fn_server_hiveGET.sqf | 24 ++- .../epoch_hive/fn_server_hiveGETBIT.sqf | 21 ++- .../epoch_hive/fn_server_hiveGETRANGE.sqf | 60 +++---- .../epoch_hive/fn_server_hiveGETTTL.sqf | 9 +- .../epoch_hive/fn_server_hiveUnitTest.sqf | 146 ++++++++++++++++++ Sources/epoch_server_core/config.cpp | 1 + Sources/epoch_server_core/treeView.txt | Bin 1268 -> 1348 bytes Sources/epoch_server_settings/build.hpp | 2 +- build.txt | 2 +- 17 files changed, 199 insertions(+), 78 deletions(-) create mode 100644 Sources/epoch_server_core/compile/epoch_hive/fn_server_hiveUnitTest.sqf diff --git a/Server_Install_Pack/@epochhive/addons/epoch_server.pbo b/Server_Install_Pack/@epochhive/addons/epoch_server.pbo index 1530d89c5e1493020fc82b7b727d7eec4179642e..7cf15d91b2b06d02958ce7afaa1e00e5f6fb87b6 100644 GIT binary patch delta 583 zcmZ2^Te|Iz^aKy)BU5fp^p<7|o^msSpJC!&qmA?USXp~+U61IRypgqs4a8c)KRK6G zd9wB?fyq&w9SO>W@OnZB2Uk!unsFIb3I0w|<5eYFCk;ASt*HYTwC z41>uNxm70r;udGy2ec-E9n7`n`3IJLEf3;OpV!F9wK1Kq2@#OO&a+{Zn z7_)#}IQg!G8i!Q+%?JTy28QVdJDC+H>qzpl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4XVJ^ z0iF^y0^vUKw-zOZYT_1z{{1k{X4G zYDkp2!08g>y+pk?UG>8H;b$GVR~UPb>w2+vCE&aZoP6UoXh3*`t-3$cpp=ah%*YN? zepFc7!02dXj1-hj;505+2bkk8!Rs`~qftxYb_C2ur~EEBf%tYbj7Ww?r;~y*9-1py z#8;z^?IpP1hQuC0N=TOt1FyeCcS}V0Oj2W*|9JLK;`jgl=C6L5+5Y^OfAe35fBos7 F{x1*8LJj}` delta 1270 zcmd5*O-K}R6lWb>cSgs;)iw8{{?6v+66S6qD$7(B1QlyxUt8kGwEIs7r&*nuHA_UQ zdt^@}DDV;y9U>c|gP;fLY(XD%k1iT@@D@~WW_Q&UJ9TMbhWXF?z2AGk_kQzv+3|SB zaWBsN;y+BC@i9Nt_fzU?=gODfi>t*`BSGkN)Yzv7jCH!}sCAZ(yhzMCt<&3FEPL8n zv;rd2Qi4ng39d7jok*5gD~3-@+}qsT-rCY8#CUE3@9*=AS2D7a5?do}Q0GdRGsT({ zz#DS$9LuuuRRXu%HSp1U2Y&iQ=RXSYQu=Qc(t(icy&7_P}#@BTReuF&koolifYx zeBJyY8nSx3s6L!lv7$~DnlwlxOhl1H3(#A2|0NZZFja^OVM{;DT9eH_9jy6vM@La3 z&-EoUnnqRQgqosbs5*ie{Ax`;E)CIR)$Nrr?~?Jm0D-32#m z6Ip%%smfDt8(;&^HZ>6`l_GYUktVvK$?5>i`a*3sRV>#C_JT-UgALTEk8zdSTBFRBX)1kF`{{h6~W%(wV&Zq{-^@ZE8gl9K`U1VV_JgpAa=iaxSUmiID zQGaN1dz%-GW9yp#!QSIr-Cc_2C1`HTzUH!LuEb;MwEOihHC%- diff --git a/Server_Install_Pack/@epochhive/addons/epoch_server_settings.pbo b/Server_Install_Pack/@epochhive/addons/epoch_server_settings.pbo index 091d7c061734fb621c7206240acc60584875fece..b8f9a6e1a6c17f0a061124f93bd94b1a34a15e85 100644 GIT binary patch delta 625 zcmX@MU3S$L*$IITr>5MDaA9CzNGi?DNzuzFC;+k%APy+Y59B82=cQ$)>m{Q}12s>a z7|we2!S#sxiEp*o&H))xA2-V~MzXRUv$`2!BDlGREs>EKXw2jX>;Y0{#%3ml21?ev zT(v;_e)oQ`t+wXIrklMuTGvd@IV;K?8tOI_!CjJXQ*-CJG>(x)qhvwe{GwETSag$k^?fdhDLM aB2Nr+RJCgEG<%0_X=?7+Wl?S|9s>YVgW4GY delta 1009 zcmZ3rMfTWs*$IITOng@(To@P_l1ejkQuHzk3V>_`_?&kof*;6D&d*EBOxH_BlLl&@ zI5C`+bLrj)mx*t+*qDHf`yV#TGDfnp-88up;U>JfhAoki8EDMp2kZe-#>STBW=2ZZ zyj-Ii zY#+-QqqZx_vQJ}~zDto^R+N`Z0SNr^i*gfl6v9&zOEOZ6tfu>@vP%j?8|WAt>6jYC z0<8oon$DxdF2Qf0V`QphVhR^DP+}M5GdI;SG&F*X`75z2O*hbB7ZU=SVW4LS#0bgN zO6;=rP$T1u67y2>bKUaOof3;v6>JrN>J5Q5!0m)82ujS%3rox?g(@-71KJ0(4XVVy zEVU>(vABeQvhd8jl(5A5oCuI*x~4h?I&iN*4T7l1iNdQO2xtw&2%vL8Zbowr$Pkbk zh$%>FAVInPwj#SSQ$5rwut8vtgN?!B4y=-JH-G|62VE=Nc7!Z1m%hG2T7J5YLJ=@L zbrd-Bp<$*s-BE=-vYwXWNs_EG}>{=plJ9QLb%&6^Wb=W<1Mcy6%F81WQ!v@`e O_IJGTMHOjn9Pa@&mMi!G diff --git a/Sources/epoch_server/build.hpp b/Sources/epoch_server/build.hpp index cc789314..1edd4aff 100644 --- a/Sources/epoch_server/build.hpp +++ b/Sources/epoch_server/build.hpp @@ -1 +1 @@ -build=709; +build=736; diff --git a/Sources/epoch_server/compile/epoch_player/EPOCH_server_makeSP.sqf b/Sources/epoch_server/compile/epoch_player/EPOCH_server_makeSP.sqf index f810daf5..41d1cdeb 100644 --- a/Sources/epoch_server/compile/epoch_player/EPOCH_server_makeSP.sqf +++ b/Sources/epoch_server/compile/epoch_player/EPOCH_server_makeSP.sqf @@ -25,7 +25,7 @@ if (alive _jammer) then { _server_vars = _player getVariable["SERVER_VARS", []]; _currentPos = _server_vars param [0,[]]; // invalidate previous position - if (_jammer distance _currentPos > 20) then { _currentPos = [] }; + if (!(_currentPos isEqualTo []) && {_jammer distance _currentPos > 20}) then { _currentPos = [] }; if (_currentPos isEqualTo []) then { // set position of spawnpoint to players SERVER_VARS _server_vars set [0, getposATL _jammer]; // 0 = RESPAWN POS diff --git a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_load_vehicles.sqf b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_load_vehicles.sqf index bf7317c0..182fd4b1 100644 --- a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_load_vehicles.sqf +++ b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_load_vehicles.sqf @@ -300,8 +300,6 @@ for "_i" from 1 to _maxVehicleLimit do { } else { diag_log format["DEBUG: vehicle destroyed already (%2) or invalid vehicle class: %1",_class, _damage]; }; - } else { - diag_log format["DEBUG: invalid vehicle data count: %1 != %2",_arrNum,_dataFormatCount]; }; } else { diag_log format["DEBUG: invalid vehicle data: %1",_response]; diff --git a/Sources/epoch_server/init/server_init.sqf b/Sources/epoch_server/init/server_init.sqf index 42469024..4d7b362c 100644 --- a/Sources/epoch_server/init/server_init.sqf +++ b/Sources/epoch_server/init/server_init.sqf @@ -65,6 +65,7 @@ diag_log "Epoch: Init Variables"; call compile preprocessFileLineNumbers "\epoch_server\init\server_variables.sqf"; call compile preprocessFileLineNumbers "\epoch_server\init\server_securityfunctions.sqf"; + ["I", _instanceID, "86400", ["CONTINUE"]] call EPOCH_fnc_server_hiveSETEX; diag_log format["Epoch: Start Hive, Instance ID: '%1'", _instanceID]; @@ -225,3 +226,6 @@ _sapper setDamage 1; _sapper enableSimulationGlobal false; diag_log format ["Epoch: Server Start Complete: %1 seconds",diag_tickTime-_startTime]; + +// unit test start +// call EPOCH_fnc_server_hiveUnitTest; diff --git a/Sources/epoch_server_core/build.hpp b/Sources/epoch_server_core/build.hpp index cc789314..1edd4aff 100644 --- a/Sources/epoch_server_core/build.hpp +++ b/Sources/epoch_server_core/build.hpp @@ -1 +1 @@ -build=709; +build=736; diff --git a/Sources/epoch_server_core/compile/epoch_hive/fn_server_hiveGET.sqf b/Sources/epoch_server_core/compile/epoch_hive/fn_server_hiveGET.sqf index 029c25f7..71047188 100644 --- a/Sources/epoch_server_core/compile/epoch_hive/fn_server_hiveGET.sqf +++ b/Sources/epoch_server_core/compile/epoch_hive/fn_server_hiveGET.sqf @@ -24,24 +24,18 @@ while {_hiveStatus < 0 || _hiveStatus == 2} do { _hiveStatus = 0; if (_hiveResponse != "") then { _hiveResponse = call compile _hiveResponse; - if !(isNil "_hiveResponse") then { - - if (_hiveResponse isEqualType [] && !(_hiveResponse isEqualTo [])) then { - _hiveStatus = _hiveResponse select 0; - if (_hiveStatus >= 1) then { - _hiveMessage = _hiveMessage + (_hiveResponse select 1); - }; - }; + _hiveResponse params [ + ["_status", 0], + ["_data", ""] + ]; + _hiveStatus = _status; + if (_hiveStatus >= 1) then { + _hiveMessage = _hiveMessage + _data; }; }; }; -if (_hiveStatus > 0 && _hiveMessage find "" == -1) then { - _hiveMessage = call compile _hiveMessage; - if (isNil "_hiveMessage") then { _hiveMessage = [];} -} -else { - _hiveMessage = []; -}; +// note: removed check for null in array _hiveMessage find "" == -1 +_hiveMessage = if (_hiveMessage isEqualTo "") then {[]} else {parseSimpleArray _hiveMessage}; [_hiveStatus, _hiveMessage] diff --git a/Sources/epoch_server_core/compile/epoch_hive/fn_server_hiveGETBIT.sqf b/Sources/epoch_server_core/compile/epoch_hive/fn_server_hiveGETBIT.sqf index 81474b7f..a6673b22 100644 --- a/Sources/epoch_server_core/compile/epoch_hive/fn_server_hiveGETBIT.sqf +++ b/Sources/epoch_server_core/compile/epoch_hive/fn_server_hiveGETBIT.sqf @@ -13,19 +13,18 @@ https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server_core/compile/epoch_hive/fn_server_hiveGETBIT.sqf */ -private ["_hiveResponse","_hiveStatus","_hiveMessage"]; +private ["_hiveResponse","_hiveMessage"]; params ["_prefix","_key","_bit"]; - _hiveMessage = false; _hiveResponse = "epochserver" callExtension format["240|%1:%2|%3", _prefix, _key, _bit]; -if (_hiveResponse != "") then { - _hiveResponse = call compile _hiveResponse; - if !(isNil "_hiveResponse") then { - if (_hiveResponse isEqualType [] && !(_hiveResponse isEqualTo[])) then { - if ((_hiveResponse select 0) == 1) then { - _hiveMessage = ((_hiveResponse select 1) == "1"); - }; - }; - }; +if !(_hiveResponse isEqualTo "") then { + _hiveResponse = parseSimpleArray _hiveResponse; + _hiveResponse params [ + ["_status", 0], + ["_data", "0"] + ]; + if (_status == 1) then { + _hiveMessage = (_data isEqualTo "1"); + }; }; _hiveMessage diff --git a/Sources/epoch_server_core/compile/epoch_hive/fn_server_hiveGETRANGE.sqf b/Sources/epoch_server_core/compile/epoch_hive/fn_server_hiveGETRANGE.sqf index 685df095..102bdac7 100644 --- a/Sources/epoch_server_core/compile/epoch_hive/fn_server_hiveGETRANGE.sqf +++ b/Sources/epoch_server_core/compile/epoch_hive/fn_server_hiveGETRANGE.sqf @@ -17,50 +17,34 @@ params ["_prefix","_key"]; _hiveMessage = ""; _hiveStatus = 0; - _currentIndex = 0; - _hiveMakeCall = true; +_hiveCharCount = 10000; // get 10k chars while {_hiveMakeCall} do { - - _hiveMakeCall = false; - + _hiveMakeCall = false; // get 10k chars - _currentIndexMax = _currentIndex + 10000; + _currentIndexMax = _currentIndex + _hiveCharCount; _hiveResponse = "epochserver" callExtension format["220|%1:%2|%3|%4", _prefix, _key, _currentIndex, (_currentIndexMax-1)]; - - if (_hiveResponse != "") then { - - _hiveResponse = call compile _hiveResponse; - if !(isNil "_hiveResponse") then{ - - if (_hiveResponse isEqualType [] && !(_hiveResponse isEqualTo[])) then{ - - _hiveStatus = _hiveResponse select 0; - if (_hiveStatus == 1) then{ - - _data = _hiveResponse select 1; - - if !(_data isEqualTo []) then{ - - // add data to string - _hiveMessage = _hiveMessage + _data; - - // if data returned is exactly 10k chars then we likely need to make another call - if (count _data == 10000) then{ - _currentIndex = _currentIndexMax; - _hiveMakeCall = true; - }; - }; - }; - }; - }; - }; + if !(_hiveResponse isEqualTo "") then { + _hiveResponse = call compile _hiveResponse; + _hiveResponse params [ + ["_status", 0], + ["_data", []] + ]; + if (_status isEqualTo 1 && !(_data isEqualTo [])) then{ + // add data to string + _hiveStatus = _status; + _hiveMessage = _hiveMessage + _data; + // if data returned matches exactly _hiveCharCount then we likely need to make another call + if (count _data == _hiveCharCount) then{ + _currentIndex = _currentIndexMax; + _hiveMakeCall = true; + }; + }; + }; }; -if (_hiveStatus == 1) then{ - _hiveMessage = call compile _hiveMessage; - if (isNil "_hiveMessage") then{ _hiveMessage = []; } -}; +// avoid parse if data is blank and return empty array +_hiveMessage = if (_hiveMessage isEqualTo "") then {[]} else {parseSimpleArray _hiveMessage}; [_hiveStatus, _hiveMessage] diff --git a/Sources/epoch_server_core/compile/epoch_hive/fn_server_hiveGETTTL.sqf b/Sources/epoch_server_core/compile/epoch_hive/fn_server_hiveGETTTL.sqf index f47a8fe8..d1a73550 100644 --- a/Sources/epoch_server_core/compile/epoch_hive/fn_server_hiveGETTTL.sqf +++ b/Sources/epoch_server_core/compile/epoch_hive/fn_server_hiveGETTTL.sqf @@ -50,12 +50,7 @@ while {_hiveStatus < 0 || _hiveStatus == 2} do { _whileCount = _whileCount + 1; }; -if (_hiveStatus > 0 && _hiveMessage find "" == -1) then { - _hiveMessage = call compile _hiveMessage; - if (isNil "_hiveMessage") then { _hiveMessage = [];} -} -else { - _hiveMessage = []; -}; +// removed check for null in array _hiveMessage find "" == -1 +_hiveMessage = if (_hiveMessage isEqualTo "") then {[]} else {parseSimpleArray _hiveMessage}; [_hiveStatus, _hiveMessage, _hiveTTL] diff --git a/Sources/epoch_server_core/compile/epoch_hive/fn_server_hiveUnitTest.sqf b/Sources/epoch_server_core/compile/epoch_hive/fn_server_hiveUnitTest.sqf new file mode 100644 index 00000000..aebaf1f4 --- /dev/null +++ b/Sources/epoch_server_core/compile/epoch_hive/fn_server_hiveUnitTest.sqf @@ -0,0 +1,146 @@ +/* + Author: Aaron Clark - EpochMod.com + + Contributors: + + Description: + For testing callExtension and other DB related updates. + + Licence: + Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike + + Github: + https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server_core/compile/epoch_hive/fn_server_hiveUnitTest.sqf +*/ +_testID = "1234567890"; +_payload = "32D1ECB8511569B43A5CC39DF4261CACDA912C798B066EE1E1EE06E2F09D02073C1B3FC638F091D58E7691DA7D0F7E1F01371CB58346572A015F6F93429F3BDC"; +_expires = "600"; // 10 minutes +_payload_64k = ""; +_startTime = diag_tickTime; +for "_i" from 1 to 512 do +{ + _payload_64k = _payload_64k + _payload; +}; +_payload_64k_count = count _payload_64k; +diag_log format["DEBUG UNITTEST INIT: _payload count %1",count _payload, (diag_tickTime-_startTime)]; +diag_log format["DEBUG UNITTEST INIT: _payload_64k count %1",_payload_64k_count, (diag_tickTime-_startTime)]; + +_startTime = diag_tickTime; +_response = "epochserver" callExtension ""; +diag_log format ["Epoch UnitTest: version Time: %2 : %1 ", _response, (diag_tickTime-_startTime)]; + +// server config instanceID +_startTime = diag_tickTime; +_response = "epochserver" callExtension "000"; +diag_log format ["Epoch UnitTest: 000 Time: %2 : %1 ", _response, (diag_tickTime-_startTime)]; + +// time +_startTime = diag_tickTime; +_response = "epochserver" callExtension "510"; +diag_log format ["Epoch UnitTest: 510 Time: %2 : %1 ", _response, (diag_tickTime-_startTime)]; + + +// SET +_startTime = diag_tickTime; +_response = ["TEST_DATA", _testID, [_payload]] call EPOCH_fnc_server_hiveSET; +diag_log format ["Epoch UnitTest: EPOCH_fnc_server_hiveSET Time: %2 : %1 ", _response, (diag_tickTime-_startTime)]; +// SET 64k +_startTime = diag_tickTime; +_response = ["TEST_DATA_64", _testID, [_payload_64k]] call EPOCH_fnc_server_hiveSET; +diag_log format ["Epoch UnitTest: EPOCH_fnc_server_hiveSET 64k Time: %2 : %1 ", _response, (diag_tickTime-_startTime)]; + +// SETBIT true +_startTime = diag_tickTime; +_response = ["TEST_BIT_DATA", _testID, 0, 1] call EPOCH_fnc_server_hiveSETBIT; +diag_log format ["Epoch UnitTest: EPOCH_fnc_server_hiveSETBIT Time: %2 : %1 ", _response, (diag_tickTime-_startTime)]; +// SETBIT false +_startTime = diag_tickTime; +_response = ["TEST_BIT_DATA", _testID, 1, 0] call EPOCH_fnc_server_hiveSETBIT; +diag_log format ["Epoch UnitTest: EPOCH_fnc_server_hiveSETBIT Time: %2 : %1 ", _response, (diag_tickTime-_startTime)]; + +// GETBIT true +_startTime = diag_tickTime; +_response = ["TEST_BIT_DATA", _testID, 0] call EPOCH_fnc_server_hiveGETBIT; +_charCheck = true isEqualTo _response; +diag_log format ["Epoch UnitTest: EPOCH_fnc_server_hiveGETBIT Time: %2 : %1 ", ["isOK:",_charCheck], (diag_tickTime-_startTime)]; +// GETBIT false +_startTime = diag_tickTime; +_response = ["TEST_BIT_DATA", _testID, 1] call EPOCH_fnc_server_hiveGETBIT; +_charCheck = false isEqualTo _response; +diag_log format ["Epoch UnitTest: EPOCH_fnc_server_hiveGETBIT Time: %2 : %1 ", ["isOK:",_charCheck], (diag_tickTime-_startTime)]; + +// SETEX +_startTime = diag_tickTime; +_response = ["TEST_EXPIRES_DATA", _testID, _expires, [_payload]] call EPOCH_fnc_server_hiveSETEX; +diag_log format ["Epoch UnitTest: EPOCH_fnc_server_hiveSETEX Time: %2 : %1 ", _response, (diag_tickTime-_startTime)]; +// SETEX 64k +_startTime = diag_tickTime; +_response = ["TEST_EXPIRES_DATA_64", _testID, _expires, [_payload_64k]] call EPOCH_fnc_server_hiveSETEX; +diag_log format ["Epoch UnitTest: EPOCH_fnc_server_hiveSETEX 64k Time: %2 : %1 ", _response, (diag_tickTime-_startTime)]; + +// GET +_startTime = diag_tickTime; +_response = ["TEST_DATA", _testID] call EPOCH_fnc_server_hiveGET; +_response params ["_status","_data"]; +_charCheck = [_payload] isEqualTo _data; +diag_log format ["Epoch UnitTest: EPOCH_fnc_server_hiveGET Time: %2 : %1 ", ["isOK:",_charCheck], (diag_tickTime-_startTime)]; +// GET 64k +_startTime = diag_tickTime; +_response = ["TEST_DATA_64", _testID] call EPOCH_fnc_server_hiveGET; +_response params ["_status","_data"]; +_charCheck = [_payload_64k] isEqualTo _data; +diag_log format ["Epoch UnitTest: EPOCH_fnc_server_hiveGET 64k Time: %2 : %1 ", ["isOK:",_charCheck], (diag_tickTime-_startTime)]; + +// GETRANGE +_startTime = diag_tickTime; +_response = ["TEST_DATA", _testID] call EPOCH_fnc_server_hiveGETRANGE; +_response params ["_status","_data"]; +_charCheck = [_payload] isEqualTo _data; +diag_log format ["Epoch UnitTest: EPOCH_fnc_server_hiveGETRANGE Time: %2 : %1 ", ["isOK:",_charCheck], (diag_tickTime-_startTime)]; +// GETRANGE 64k +_startTime = diag_tickTime; +_response = ["TEST_DATA_64", _testID] call EPOCH_fnc_server_hiveGETRANGE; +_response params ["_status","_data"]; +_charCheck = [_payload_64k] isEqualTo _data; +diag_log format ["Epoch UnitTest: EPOCH_fnc_server_hiveGETRANGE 64k Time: %2 : %1 ", ["isOK:",_charCheck], (diag_tickTime-_startTime)]; + +// Expire +_startTime = diag_tickTime; +_response = ["TEST_DATA", _testID, _expires] call EPOCH_fnc_server_hiveEXPIRE; +diag_log format ["Epoch UnitTest: EPOCH_fnc_server_hiveEXPIRE Time: %2 : %1 ", _response, (diag_tickTime-_startTime)]; + +// GETTTL +_startTime = diag_tickTime; +_response = ["TEST_EXPIRES_DATA", _testID] call EPOCH_fnc_server_hiveGETTTL; +_response params ["_status","_data"]; +_charCheck = [_payload] isEqualTo _data; +diag_log format ["Epoch UnitTest: EPOCH_fnc_server_hiveGETTTL Time: %2 : %1 ", ["isOK:",_charCheck], (diag_tickTime-_startTime)]; + +// GETTTL 64k +_startTime = diag_tickTime; +_response = ["TEST_EXPIRES_DATA_64", _testID] call EPOCH_fnc_server_hiveGETTTL; +_response params ["_status","_data"]; +_charCheck = [_payload_64k] isEqualTo _data; +diag_log format ["Epoch UnitTest: EPOCH_fnc_server_hiveGETTTL 64k Time: %2 : %1 ", ["isOK:",_charCheck], (diag_tickTime-_startTime)]; + +// Del +_startTime = diag_tickTime; +_response = ["TEST_DATA", _testID] call EPOCH_fnc_server_hiveDEL; +diag_log format ["Epoch UnitTest: EPOCH_fnc_server_hiveDEL TEST_DATA Time: %2 : %1 ", _response, (diag_tickTime-_startTime)]; +_startTime = diag_tickTime; +_response = ["TEST_DATA_64", _testID] call EPOCH_fnc_server_hiveDEL; +diag_log format ["Epoch UnitTest: EPOCH_fnc_server_hiveDEL TEST_DATA_64 Time: %2 : %1 ", _response, (diag_tickTime-_startTime)]; +_startTime = diag_tickTime; +_response = ["TEST_EXPIRES_DATA", _testID] call EPOCH_fnc_server_hiveDEL; +diag_log format ["Epoch UnitTest: EPOCH_fnc_server_hiveDEL TEST_EXPIRES_DATA Time: %2 : %1 ", _response, (diag_tickTime-_startTime)]; +_startTime = diag_tickTime; +_response = ["TEST_EXPIRES_DATA_64", _testID] call EPOCH_fnc_server_hiveDEL; +diag_log format ["Epoch UnitTest: EPOCH_fnc_server_hiveDEL TEST_EXPIRES_DATA_64 Time: %2 : %1 ", _response, (diag_tickTime-_startTime)]; + +// HIVELOG +_startTime = diag_tickTime; +_response = ['TEST_LOG', _payload] call EPOCH_fnc_server_hiveLog; +diag_log format ["Epoch UnitTest: EPOCH_fnc_server_hiveLog Time: %2 : %1 ", _response, (diag_tickTime-_startTime)]; +_startTime = diag_tickTime; +_response = ['TEST_LOG', _payload_64k] call EPOCH_fnc_server_hiveLog; +diag_log format ["Epoch UnitTest: EPOCH_fnc_server_hiveLog 64k Time: %2 : %1 ", _response, (diag_tickTime-_startTime)]; diff --git a/Sources/epoch_server_core/config.cpp b/Sources/epoch_server_core/config.cpp index eaeb64f2..aab44f00 100644 --- a/Sources/epoch_server_core/config.cpp +++ b/Sources/epoch_server_core/config.cpp @@ -41,6 +41,7 @@ class cfgFunctions class server_hiveGETTTL {}; class server_hiveDEL {}; class server_hiveLog {}; + class server_hiveUnitTest {}; }; }; }; diff --git a/Sources/epoch_server_core/treeView.txt b/Sources/epoch_server_core/treeView.txt index 6055f48bd77b5477782ac2c518df63b003ad7913..9d6b2ea4e66e013be3565b8b46578161e5bb7bbc 100644 GIT binary patch delta 35 rcmeyud4y}jA(qJx7-jfF8S)r18A=#J7*ZLE8A>KIGO12J#9{;h(-8`1 delta 11 ScmX@Y^@Vf8A(qKPtVRGG