hce-node application  1.4.3
HCE Hierarchical Cluster Engine node application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
DRCEStressTest.cpp
Go to the documentation of this file.
1 #include <gtest/gtest.h>
2 #include <sstream>
3 #include <fstream>
4 #include <vector>
5 #include <limits>
6 #include <Poco/File.h>
7 
9 #include "DRCEStressTest.hpp"
10 #include "DRCEPrintStatus.hpp"
11 #include "DRCECleanupTest.hpp"
12 #include "DRCEFileStream.hpp"
13 #include "DRCECommonTask.hpp"
14 
15 namespace HCE
16 {
17 namespace drce
18 {
19 namespace tests
20 {
21 //-----------------------------------------------------------------------------
23 {
24  fObj.setMaxThreadCount(requestCount);
25  fObj.setResourceMonitorTimePeriod(10000);
26  fObj.setLogStream(std::cout);
27 
28  std::vector<unsigned int> tasks;
29  std::vector<std::string> jsons;
30 
31  unsigned int taskId(0), caseNumber(0);
32  for (;taskId<requestCount;)
33  {
34  jsons.push_back(std::forward<std::string>(DRCEStressTest::getJsonRequestSetExecuteAsyncLongTask(sessionType, ++taskId)));
35  tasks.push_back(taskId);
36 
37  jsons.push_back(std::forward<std::string>(DRCEStressTest::getJsonRequestSetExecuteAsyncExpitedTask(sessionType, ++taskId)));
38  jsons.push_back(std::forward<std::string>(DRCEStressTest::getJsonRequestSetExecuteAsyncShortTask(sessionType, ++taskId)));
39  jsons.push_back(std::forward<std::string>(DRCEStressTest::getJsonRequestSetExecuteSyncShortTask(sessionType, ++taskId)));
40 
41  jsons.push_back(std::forward<std::string>(DRCEStressTest::generateJsonRequest(caseNumber++, tasks.back())));
42  if (caseNumber > 7)
43  caseNumber = 0;
44  }
45 
46  for (size_t i=0;i<tasks.size();++i)
47  {
48  jsons.push_back(std::forward<std::string>(DRCEStressTest::generateJsonRequest(caseNumber++, tasks.back())));
49  if (caseNumber > 7)
50  caseNumber = 0;
51  }
52 
53  for (size_t i=0;i<jsons.size();++i)
54  {
55  DRCEStressTest::executeRequest(fObj, jsons[i]);
56  }
57  while(fObj.getAsyncTasksCount())
58  {
59  Poco::Thread::sleep(1000);
60  }
62  printSuccess ("Test Multiple Requests");
63 }
64 //-----------------------------------------------------------------------------
65 void DRCEStressTest::executeRequest(DRCEFunctionalObject& fObj, const std::string& json)
66 {
67  std::string resultJson = fObj.Process(json);
68 
69  ASSERT_FALSE(fObj.isError()) << printError(fObj);
70  ASSERT_EQ(fObj.getErrorCode(), NO_ERROR);
71  ASSERT_TRUE(fObj.getErrorMsg().empty());
72 
73  DRCEOutputJsonMessage resultJsonMessage(resultJson);
74  ASSERT_FALSE(resultJsonMessage.isError()) << printError(resultJsonMessage);
75  ASSERT_EQ(resultJsonMessage.getErrorCode(), NO_ERROR);
76  ASSERT_TRUE(resultJsonMessage.getErrorMsg().empty());
77 }
78 //-----------------------------------------------------------------------------
79 std::string DRCEStressTest::generateJsonRequest(unsigned int caseNumber, unsigned int requestId)
80 {
81  std::string json;
82  switch(caseNumber)
83  {
84  case 0: json = DRCEStressTest::getJsonRequestCheckState(DRCETaskRequestCheckState::CheckType::ctUninitialized, requestId);
85  break;
86  case 1: json = DRCEStressTest::getJsonRequestCheckState(DRCETaskRequestCheckState::CheckType::ctSimple, requestId);
87  break;
88  case 2: json = DRCEStressTest::getJsonRequestCheckState(DRCETaskRequestCheckState::CheckType::ctExtended, requestId);
89  break;
90  case 3: json = DRCEStressTest::getJsonRequestGetData(DRCETaskRequestGetData::FetchType::ftUninitialized, requestId);
91  break;
92  case 4: json = DRCEStressTest::getJsonRequestGetData(DRCETaskRequestGetData::FetchType::ftDeleteDataAfterFetch, requestId);
93  break;
94  case 5: json = DRCEStressTest::getJsonRequestGetData(DRCETaskRequestGetData::FetchType::ftNotDeleteDataAfterFetch, requestId);
95  break;
96  case 6: json = DRCEStressTest::getJsonRequestTerminate(DRCETaskRequestTerminate::AlgorithmType::atDefault, requestId);
97  break;
98  case 7: json = DRCEStressTest::getJsonRequestTerminate(DRCETaskRequestTerminate::AlgorithmType::atCustom, requestId);
99  break;
100  default:;
101  }
102  return json;
103 }
104 //-----------------------------------------------------------------------------
105 //-----------------------------------------------------------------------------
106 std::string DRCEStressTest::getJsonRequestSetExecute(DRCETaskRequestSetExecute& requestSetExecute, unsigned int requestId)
107 {
108  std::stringstream sourceJson;
109  sourceJson << requestSetExecute;
110 
111 // std::cout << "\nIN JSON: " << sourceJson.str() << std::endl;
112 
113  DRCEInputJsonMessage inputJsonMessage;
114  inputJsonMessage.setRequestType(DRCETaskRequest::RequestType::rtSetTaskExecute);
115  inputJsonMessage.setRequestData(sourceJson.str());
116  inputJsonMessage.setRequestId(requestId);
117 
118  sourceJson.str("");
119  sourceJson << inputJsonMessage;
120 
121  return sourceJson.str();
122 }
123 //-----------------------------------------------------------------------------
124 std::string DRCEStressTest::getJsonRequestSetExecuteAsyncExpitedTask(SessionOptions::SessionType sessionType,unsigned int requestId)
125 {
126  const std::string command = "echo \"scale=4000; 4*a(1)\" | bc -l && sleep 60 && ps xau";
127 
128  DRCETaskRequestSetExecute requestSetExecute;
129 
130  SessionOptions sessionOptions;
131  sessionOptions.sessionType = sessionType;
132  sessionOptions.timeMax = 10000; // msec
133  sessionOptions.tmode = SessionOptions::ThreadMode::tmAsync;
134  requestSetExecute.setSessionOptions(std::forward<SessionOptions>(sessionOptions));
135  requestSetExecute.setCommandLine(command);
136 
137  return DRCEStressTest::getJsonRequestSetExecute(requestSetExecute, requestId);
138 }
139 //-----------------------------------------------------------------------------
140 std::string DRCEStressTest::getJsonRequestSetExecuteAsyncLongTask(SessionOptions::SessionType sessionType, unsigned int requestId)
141 {
142  const std::string command = "echo \"scale=4000; 4*a(1)\" | bc -l && ps xau";
143 
144  DRCETaskRequestSetExecute requestSetExecute;
145 
146  SessionOptions sessionOptions;
147  sessionOptions.sessionType = sessionType;
148  sessionOptions.timeMax = 100000; // msec
149  sessionOptions.tmode = SessionOptions::ThreadMode::tmAsync;
150  requestSetExecute.setSessionOptions(std::forward<SessionOptions>(sessionOptions));
151  requestSetExecute.setCommandLine(command);
152 
153  return DRCEStressTest::getJsonRequestSetExecute(requestSetExecute, requestId);
154 }
155 //-----------------------------------------------------------------------------
156 std::string DRCEStressTest::getJsonRequestSetExecuteAsyncShortTask(SessionOptions::SessionType sessionType, unsigned int requestId)
157 {
158  const std::string command = "sort";
159  const std::string inputStream = "def\nabc\n123\n";
160 
161  DRCETaskRequestSetExecute requestSetExecute;
162 
163  SessionOptions sessionOptions;
164  sessionOptions.sessionType = sessionType;
165  sessionOptions.timeMax = 100000; // msec
166  sessionOptions.tmode = SessionOptions::ThreadMode::tmAsync;
167  requestSetExecute.setSessionOptions(std::forward<SessionOptions>(sessionOptions));
168 
169  ResourceLimits resourceLimits;
170  resourceLimits.procMax = 500;
171  resourceLimits.rramFreeMin = 100000;
172  requestSetExecute.setResourceLimits(resourceLimits);
173 
174  requestSetExecute.setCommandLine(command);
175  requestSetExecute.setInputStream(inputStream);
176 
177  return DRCEStressTest::getJsonRequestSetExecute(requestSetExecute, requestId);
178 }
179 //-----------------------------------------------------------------------------
180 std::string DRCEStressTest::getJsonRequestSetExecuteSyncShortTask(SessionOptions::SessionType sessionType, unsigned int requestId)
181 {
182  const std::string command = "sort";
183  const std::string inputStream = "def\nabc\n123\n";
184 
185  DRCETaskRequestSetExecute requestSetExecute;
186 
187  SessionOptions sessionOptions;
188  sessionOptions.sessionType = sessionType;
189  sessionOptions.timeMax = 100000; // msec
190  sessionOptions.tmode = SessionOptions::ThreadMode::tmSync;
191  requestSetExecute.setSessionOptions(std::forward<SessionOptions>(sessionOptions));
192  requestSetExecute.setCommandLine(command);
193  requestSetExecute.setInputStream(inputStream);
194 
195  return DRCEStressTest::getJsonRequestSetExecute(requestSetExecute, requestId);
196 }
197 //-----------------------------------------------------------------------------
198 //-----------------------------------------------------------------------------
199 std::string DRCEStressTest::getJsonRequestCheckState(DRCETaskRequestCheckState::CheckType checkType, unsigned int requestId)
200 {
201  DRCETaskRequestCheckState requestCheckState;
202  requestCheckState.setCheckType(checkType);
203 
204  std::stringstream sourceJson;
205  sourceJson << requestCheckState;
206 
207  DRCEInputJsonMessage inputJsonMessage;
208  inputJsonMessage.setRequestType(DRCETaskRequest::RequestType::rtCheckTaskState);
209  inputJsonMessage.setRequestData(sourceJson.str());
210  inputJsonMessage.setRequestId(requestId);
211 
212  sourceJson.str("");
213  sourceJson << inputJsonMessage;
214 
215  return sourceJson.str();
216 }
217 //-----------------------------------------------------------------------------
218 std::string DRCEStressTest::getJsonRequestGetData(DRCETaskRequestGetData::FetchType fetchType, unsigned int requestId)
219 {
220  DRCETaskRequestGetData requestGetData;
221  requestGetData.setFetchType(fetchType);
222 
223  std::stringstream sourceJson;
224  sourceJson << requestGetData;
225 
226  DRCEInputJsonMessage inputJsonMessage;
227  inputJsonMessage.setRequestType(DRCETaskRequest::RequestType::rtGetTaskData);
228  inputJsonMessage.setRequestData(sourceJson.str());
229  inputJsonMessage.setRequestId(requestId);
230 
231  sourceJson.str("");
232  sourceJson << inputJsonMessage;
233 
234  return sourceJson.str();
235 }
236 //-----------------------------------------------------------------------------
237 std::string DRCEStressTest::getJsonRequestTerminate(DRCETaskRequestTerminate::AlgorithmType algorithmType, unsigned int requestId)
238 {
239  DRCETaskRequestTerminate requestTerminate;
240  requestTerminate.setTaskId(requestId);
241  requestTerminate.setAlgorithmType(algorithmType);
242  requestTerminate.setDelayValue(1000);
243  requestTerminate.setRepeatValue(3);
244  requestTerminate.setSignalValue(9);
245 
246  std::stringstream sourceJson;
247  sourceJson << requestTerminate;
248 
249  // set request for execute task
250  DRCEInputJsonMessage inputJsonMessage;
251  inputJsonMessage.setRequestType(DRCETaskRequest::RequestType::rtTerminateTask);
252  inputJsonMessage.setRequestData(sourceJson.str());
253  inputJsonMessage.setRequestId(requestId);
254 
255  sourceJson.str("");
256  sourceJson << inputJsonMessage;
257 
258  return sourceJson.str();
259 }
260 //-----------------------------------------------------------------------------
261 std::string DRCEStressTest::getJsonRequestResourceLimits(SessionOptions::SessionType sessionType,
262  SessionOptions::ThreadMode threadMode, unsigned int requestId, const ResourceLimits& resourceLimits, const std::string& commandLine)
263 {
264  const std::string command = (commandLine.empty())?("echo \"scale=2000; 4*a(1)\" | bc -l && ps xau"):commandLine;
265 
266  DRCETaskRequestSetExecute requestSetExecute;
267 
268  SessionOptions sessionOptions;
269  sessionOptions.sessionType = sessionType;
270  sessionOptions.timeMax = 1000000; // msec
271  sessionOptions.tmode = threadMode;
272  requestSetExecute.setSessionOptions(std::forward<SessionOptions>(sessionOptions));
273  requestSetExecute.setCommandLine(command);
274  requestSetExecute.setResourceLimits(resourceLimits);
275 
276  return DRCEStressTest::getJsonRequestSetExecute(requestSetExecute, requestId);
277 }
278 //-----------------------------------------------------------------------------
279 //-----------------------------------------------------------------------------
280 unsigned int DRCEStressTest::getRequestTime(DRCEFunctionalObject& fObj, unsigned int requestId)
281 {
282  unsigned int elapsedTime = 0;
283  std::string resultJson = fObj.Process(DRCEStressTest::getJsonRequestGetData(DRCETaskRequestGetData::FetchType::ftNotDeleteDataAfterFetch, requestId));
284 
285  DRCEOutputJsonMessage resultJsonMessage(resultJson);
286  if (resultJsonMessage.getResultData().getItemsCount()==1)
287  elapsedTime = resultJsonMessage.getResultData().getDataItem(0).getTime();
288 
289  return elapsedTime;
290 }
291 //-----------------------------------------------------------------------------
292 void DRCEStressTest::testRequestsTimeDelay(DRCEFunctionalObject& fObj, SessionOptions::SessionType sessionType, unsigned int requestCount, unsigned int& taskId,
293  std::map<unsigned int, unsigned int>& delayTimes, std::map<unsigned int, unsigned int>& times)
294 {
295  delayTimes.clear();
296  times.clear();
297  fObj.setMaxThreadCount(requestCount);
298  fObj.setResourceMonitorTimePeriod(10000);
299 // fObj.setLogStream(std::cout);
300 
301  for (;taskId<requestCount;)
302  {
303  Poco::Timestamp now;
304  std::string resultJson = fObj.Process(DRCEStressTest::getJsonRequestSetExecuteAsyncLongTask(sessionType, ++taskId));
305 
306  ASSERT_FALSE(fObj.isError()) << printError(fObj);
307  ASSERT_EQ(fObj.getErrorCode(), NO_ERROR);
308  ASSERT_TRUE(fObj.getErrorMsg().empty());
309 
310  DRCEOutputJsonMessage resultJsonMessage(resultJson);
311  ASSERT_FALSE(resultJsonMessage.isError()) << printError(resultJsonMessage);
312  ASSERT_EQ(resultJsonMessage.getErrorCode(), NO_ERROR);
313  ASSERT_TRUE(resultJsonMessage.getErrorMsg().empty());
314 
315  Poco::Timestamp::TimeDiff diff = now.elapsed();
316  delayTimes[taskId] = diff;
317 
318 // ASSERT_EQ(resultJsonMessage.getResultData().getItemsCount(), 1);
319 // delayTimes[taskId] = resultJsonMessage.getResultData().getDataItem(0).getTime();
320  }
321 
322  while(fObj.getAsyncTasksCount())
323  {
324  Poco::Thread::sleep(5000);
325  }
326 
327  for (size_t i=0;i<requestCount;++i)
328  {
329  times[i+1] = DRCEStressTest::getRequestTime(fObj, i+1);
330  }
332 }
333 //-----------------------------------------------------------------------------
334 void DRCEStressTest::testRequestsTimeDelay(DRCEFunctionalObject& fObj, SessionOptions::SessionType sessionType, unsigned int requestCount, unsigned int repeat)
335 {
336  const unsigned int SZ = repeat;
337  unsigned int requestCounts[SZ];
338  for (unsigned int i=0;i<SZ;++i)
339  {
340  requestCounts[i] = static_cast<double>(requestCount/(i+1));
341  }
342 // unsigned int requestCounts[SZ] = {requestCount, requestCount/2, requestCount/3, requestCount/4, requestCount/5};
343  std::map<unsigned int, unsigned int> delayTimes[SZ];
344  std::map<unsigned int, unsigned int> times[SZ];
345  unsigned int taskId(0);
346 
347  for (unsigned int i=0;i<SZ;++i)
348  {
349  DRCEStressTest::testRequestsTimeDelay(fObj, sessionType, requestCounts[i], taskId, delayTimes[i], times[i]);
350  }
351 
352  while(fObj.getAsyncTasksCount())
353  {
354  Poco::Thread::sleep(1000);
355  }
356 
357  std::ofstream ofs("timeDelay.log", std::fstream::trunc);
358  ofs << "time delay (in microseconds):\n";
359  for (unsigned int i=0;i<SZ;++i)
360  {
361  for (size_t k=0;k<requestCount;++k)
362  ofs << delayTimes[i][k+1] << "\t";
363  ofs << std::endl;
364  }
365  ofs << "\nfull time (in msec):\n";
366  for (unsigned int i=0;i<SZ;++i)
367  {
368  for (size_t k=0;k<requestCount;++k)
369  ofs << times[i][k+1] << "\t";
370  ofs << std::endl;
371  }
372  ofs.close();
373 
375  printSuccess ("Test Requests Time Delay");
376 }
377 //-----------------------------------------------------------------------------
378 //-----------------------------------------------------------------------------
380  SessionOptions::SessionType sessionType,
381  SessionOptions::ThreadMode threadMode,
382  const ResourceLimits& resourceLimits,
383  unsigned int& taskId,
384  bool exceededLimits,
385  const std::string& commandLine)
386 {
387  std::string resultJson = fObj.Process(DRCEStressTest::getJsonRequestResourceLimits(sessionType, threadMode, ++taskId, resourceLimits, commandLine));
388 
389 // std::cout << "resultJson: " << resultJson << std::endl;
390 
391  ASSERT_FALSE(fObj.isError()) << printError(fObj);
392  ASSERT_EQ(fObj.getErrorCode(), NO_ERROR);
393  ASSERT_TRUE(fObj.getErrorMsg().empty());
394 
395  DRCEOutputJsonMessage resultJsonMessage(resultJson);
396  ASSERT_FALSE(resultJsonMessage.isError()) << printError(resultJsonMessage);
397  ASSERT_EQ(resultJsonMessage.getErrorCode(), NO_ERROR) << printError(resultJsonMessage);
398  ASSERT_TRUE(resultJsonMessage.getErrorMsg().empty()) << printError(resultJsonMessage);
399  ASSERT_EQ(resultJsonMessage.getResultData().getItemsCount(), 1);
400 
401 
402 // std::cout << ">>>>> taskId: " << taskId << " code: " << resultJsonMessage.getResultData().getDataItem(0).getErrorCode()
403 // << " message: " << resultJsonMessage.getResultData().getDataItem(0).getErrorMessage()
404 // << std::endl;
405 
406  if (exceededLimits==true)
407  ASSERT_TRUE(resultJsonMessage.getResultData().getDataItem(0).getErrorCode()==ERROR_EXCEEDED_RESOURCE_LIMITS ||
408  resultJsonMessage.getResultData().getDataItem(0).getErrorCode()==NO_ERROR);
409  else
410  {
411  if (resultJsonMessage.getResultData().getDataItem(0).getErrorCode() != NO_ERROR)
412  {
413  std::cout << ">>>>> taskId: " << taskId << " code: " << resultJsonMessage.getResultData().getDataItem(0).getErrorCode()
414  << " message: " << resultJsonMessage.getResultData().getDataItem(0).getErrorMessage()
415  << std::endl;
416  }
417  }
418 
420 }
421 //-----------------------------------------------------------------------------
423 {
424  fObj.setResourceMonitorTimePeriod(1000);
425 
426  unsigned int taskId(0);
427 
429  CpuUsageExtractor cpuUsageExtractor;
430 
431  resourceLimits.cpuMax = cpuUsageExtractor.getCpuUsage() * 2;
432  DRCEStressTest::testResourceLimits(fObj, sessionType, threadMode, resourceLimits, taskId, false);
433  resourceLimits.cpuMax = cpuUsageExtractor.getCpuUsage() / 3;
434  DRCEStressTest::testResourceLimits(fObj, sessionType, threadMode, resourceLimits, taskId, true);
435  printSuccess("Test Cpu usage");
436 
437  resourceLimits.cpuMax = 0;
438  resourceLimits.iowaitMax = cpuUsageExtractor.getIOWait() * 2;
439  DRCEStressTest::testResourceLimits(fObj, sessionType, threadMode, resourceLimits, taskId, false);
440  resourceLimits.iowaitMax = cpuUsageExtractor.getIOWait() / 3;
441  DRCEStressTest::testResourceLimits(fObj, sessionType, threadMode, resourceLimits, taskId, true);
442  printSuccess("Test getting IOWAIT");
443 
444  resourceLimits.clear();
445  DiskSpaceExtractor diskSpaceExtractor;
446  resourceLimits.diskFreeMin = diskSpaceExtractor.getDiskFree()-1024*1024;
447  DRCEStressTest::testResourceLimits(fObj, sessionType, threadMode, resourceLimits, taskId, false);
448  resourceLimits.diskFreeMin = diskSpaceExtractor.getDiskFree()+1024*1024;
449  DRCEStressTest::testResourceLimits(fObj, sessionType, threadMode, resourceLimits, taskId, true);
450  printSuccess("Test Free Disk");
451 
452  resourceLimits.clear();
453  resourceLimits.diskFree = diskSpaceExtractor.getDiskFreePercent()-1;
454  DRCEStressTest::testResourceLimits(fObj, sessionType, threadMode, resourceLimits, taskId, false);
455  resourceLimits.diskFree = diskSpaceExtractor.getDiskFreePercent()+1;
456  DRCEStressTest::testResourceLimits(fObj, sessionType, threadMode, resourceLimits, taskId, true);
457  printSuccess("Test Free Disk Percent");
458 
459  resourceLimits.clear();
460  MemoryExtractor memoryExtractor;
461  resourceLimits.rramFreeMin = memoryExtractor.getRramFree()-10*1024*1024;
462  DRCEStressTest::testResourceLimits(fObj, sessionType, threadMode, resourceLimits, taskId, false);
463  resourceLimits.rramFreeMin = memoryExtractor.getRramFree()+10*1024*1024;
464  DRCEStressTest::testResourceLimits(fObj, sessionType, threadMode, resourceLimits, taskId, true);
465  printSuccess("Test RRAM Free Min");
466 
467  resourceLimits.clear();
468  resourceLimits.rramFree = memoryExtractor.getRramFreePercent()-30;
469  DRCEStressTest::testResourceLimits(fObj, sessionType, threadMode, resourceLimits, taskId, false);
470  resourceLimits.rramFree = memoryExtractor.getRramFreePercent()+30;
471  DRCEStressTest::testResourceLimits(fObj, sessionType, threadMode, resourceLimits, taskId, true);
472  printSuccess("Test RRAM Free Percent");
473 
474  resourceLimits.clear();
475  resourceLimits.vramFreeMin = memoryExtractor.getVramFree()-10*1024*1024;
476  DRCEStressTest::testResourceLimits(fObj, sessionType, threadMode, resourceLimits, taskId, false);
477  resourceLimits.vramFreeMin = memoryExtractor.getVramFree()+10*1024*1024;
478  DRCEStressTest::testResourceLimits(fObj, sessionType, threadMode, resourceLimits, taskId, true);
479  printSuccess("Test VRAM Free Min");
480 
481  resourceLimits.clear();
482  resourceLimits.vramFree = memoryExtractor.getVramFreePercent()-30;
483  DRCEStressTest::testResourceLimits(fObj, sessionType, threadMode, resourceLimits, taskId, false);
484  resourceLimits.vramFree = memoryExtractor.getVramFreePercent()+30;
485  DRCEStressTest::testResourceLimits(fObj, sessionType, threadMode, resourceLimits, taskId, true);
486  printSuccess("Test VRAM Free Percent");
487 
488  resourceLimits.clear();
489  resourceLimits.procMax = 1000;
490  DRCEStressTest::testResourceLimits(fObj, sessionType, threadMode, resourceLimits, taskId, false);
491  resourceLimits.procMax = 10;
492  DRCEStressTest::testResourceLimits(fObj, sessionType, threadMode, resourceLimits, taskId, true);
493  printSuccess("Test Proc Max");
494 
495  resourceLimits.clear();
496  resourceLimits.threadsMax = 1000;
497  DRCEStressTest::testResourceLimits(fObj, sessionType, threadMode, resourceLimits, taskId, false);
498  resourceLimits.threadsMax = 10;
499  DRCEStressTest::testResourceLimits(fObj, sessionType, threadMode, resourceLimits, taskId, true);
500  printSuccess("Test Threads Max");
501 
502  while(fObj.getAsyncTasksCount())
503  {
504  Poco::Thread::sleep(10000);
505  }
506 
507  printSuccess ("Test Resource Limits");
508 }
509 //-----------------------------------------------------------------------------
511 {
512  const std::string command = "echo Hello && sleep 10 && ps auxf && sleep 10 && ls -l";
513  fObj.setResourceMonitorTimePeriod(10000);
514  unsigned int taskId(0);
515 
517  CpuUsageExtractor cpuUsageExtractor;
518  MemoryExtractor memoryExtractor;
519  DiskSpaceExtractor diskSpaceExtractor;
520 
521  resourceLimits.usageLimits.iowaitMax = 10;
522  DRCEStressTest::testResourceLimits(fObj, sessionType, threadMode, resourceLimits, taskId, false, command);
523  resourceLimits.usageLimits.iowaitMax = 0.001;
524  DRCEStressTest::testResourceLimits(fObj, sessionType, threadMode, resourceLimits, taskId, true, command);
525  printSuccess("Test usage IOWAIT limit");
526 
527  resourceLimits.clear();
528  resourceLimits.usageLimits.rramMax = memoryExtractor.getRramUsedPercent()-10;
529  DRCEStressTest::testResourceLimits(fObj, sessionType, threadMode, resourceLimits, taskId, false, command);
530  resourceLimits.usageLimits.rramMax = 0.0001;
531  DRCEStressTest::testResourceLimits(fObj, sessionType, threadMode, resourceLimits, taskId, true, command);
532  printSuccess("Test usage RRAM limit");
533 
534  resourceLimits.clear();
535  resourceLimits.usageLimits.vramMax = memoryExtractor.getVramUsedPercent()-10;
536  DRCEStressTest::testResourceLimits(fObj, sessionType, threadMode, resourceLimits, taskId, false, command);
537  resourceLimits.usageLimits.vramMax = 0.0001;
538  DRCEStressTest::testResourceLimits(fObj, sessionType, threadMode, resourceLimits, taskId, true, command);
539  printSuccess("Test usage VRAM limit");
540 
541  resourceLimits.clear();
542  resourceLimits.usageLimits.diskMax = diskSpaceExtractor.getDiskUsedPercent()-10;
543  DRCEStressTest::testResourceLimits(fObj, sessionType, threadMode, resourceLimits, taskId, false, command);
544  resourceLimits.usageLimits.diskMax = 0.0001;
545  DRCEStressTest::testResourceLimits(fObj, sessionType, threadMode, resourceLimits, taskId, true, command);
546  printSuccess("Test usage HDD limit percent");
547 
548  resourceLimits.clear();
549  resourceLimits.usageLimits.diskMaxBytes = diskSpaceExtractor.getDiskUsed()-1024*1024;
550  DRCEStressTest::testResourceLimits(fObj, sessionType, threadMode, resourceLimits, taskId, false, command);
551  resourceLimits.usageLimits.diskMaxBytes = 1;
552  DRCEStressTest::testResourceLimits(fObj, sessionType, threadMode, resourceLimits, taskId, true, command);
553  printSuccess("Test usage HDD limit bytes");
554 
555  while(fObj.getAsyncTasksCount())
556  {
557  Poco::Thread::sleep(10000);
558  }
559  printSuccess ("Test Resource Usage Limits");
560 }
561 //-----------------------------------------------------------------------------
562 //-----------------------------------------------------------------------------
563 } // end namespace tests
564 } // end namespace drce
565 } // end namespace HCE