added unit test and further hive optimizations

This commit is contained in:
vbawol 2017-03-27 17:44:55 -05:00
parent 1394dec6ba
commit d07593d038
17 changed files with 199 additions and 78 deletions

View File

@ -1 +1 @@
build=709;
build=736;

View File

@ -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

View File

@ -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];

View File

@ -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;

View File

@ -1 +1 @@
build=709;
build=736;

View File

@ -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;
_hiveResponse params [
["_status", 0],
["_data", ""]
];
_hiveStatus = _status;
if (_hiveStatus >= 1) then {
_hiveMessage = _hiveMessage + (_hiveResponse select 1);
};
};
_hiveMessage = _hiveMessage + _data;
};
};
};
if (_hiveStatus > 0 && _hiveMessage find "<null>" == -1) then {
_hiveMessage = call compile _hiveMessage;
if (isNil "_hiveMessage") then { _hiveMessage = [];}
}
else {
_hiveMessage = [];
};
// note: removed check for null in array _hiveMessage find "<null>" == -1
_hiveMessage = if (_hiveMessage isEqualTo "") then {[]} else {parseSimpleArray _hiveMessage};
[_hiveStatus, _hiveMessage]

View File

@ -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

View File

@ -17,50 +17,34 @@ params ["_prefix","_key"];
_hiveMessage = "";
_hiveStatus = 0;
_currentIndex = 0;
_hiveMakeCall = true;
_hiveCharCount = 10000; // get 10k chars
while {_hiveMakeCall} do {
_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 {
if !(_hiveResponse isEqualTo "") 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{
_hiveResponse params [
["_status", 0],
["_data", []]
];
if (_status isEqualTo 1 && !(_data isEqualTo [])) then{
// add data to string
_hiveStatus = _status;
_hiveMessage = _hiveMessage + _data;
// if data returned is exactly 10k chars then we likely need to make another call
if (count _data == 10000) then{
// 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]

View File

@ -50,12 +50,7 @@ while {_hiveStatus < 0 || _hiveStatus == 2} do {
_whileCount = _whileCount + 1;
};
if (_hiveStatus > 0 && _hiveMessage find "<null>" == -1) then {
_hiveMessage = call compile _hiveMessage;
if (isNil "_hiveMessage") then { _hiveMessage = [];}
}
else {
_hiveMessage = [];
};
// removed check for null in array _hiveMessage find "<null>" == -1
_hiveMessage = if (_hiveMessage isEqualTo "") then {[]} else {parseSimpleArray _hiveMessage};
[_hiveStatus, _hiveMessage, _hiveTTL]

View File

@ -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)];

View File

@ -41,6 +41,7 @@ class cfgFunctions
class server_hiveGETTTL {};
class server_hiveDEL {};
class server_hiveLog {};
class server_hiveUnitTest {};
};
};
};

View File

@ -1 +1 @@
build=709;
build=736;

View File

@ -1 +1 @@
709
736