Skip to content

Commit

Permalink
HPCC-32954 Add unit tests for the jobqueue
Browse files Browse the repository at this point in the history
Signed-off-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday committed Nov 19, 2024
1 parent 92149e3 commit d6dcd8c
Show file tree
Hide file tree
Showing 4 changed files with 402 additions and 0 deletions.
14 changes: 14 additions & 0 deletions common/workunit/wujobq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1264,6 +1264,20 @@ class CJobQueue: public CJobQueueBase, implements IJobQueue
}


IJobQueueItem *dequeue(int minPrio, unsigned timeout, unsigned prioritytransitiondelay) override
{
Owned<IJobQueueItem> item;
if (prioritytransitiondelay)
{
unsigned timeout = prioritytransitiondelay;
bool usePrevPrio = true;
item.setown(dodequeue(minPrio, timeout, usePrevPrio, nullptr));
}
if (!item)
item.setown(dodequeue(minPrio, timeout-prioritytransitiondelay, false, nullptr));
return item.getClear();
}

void placeonqueue(sQueueData &qd, IJobQueueItem *qitem,unsigned idx) // takes ownership of qitem
{
Owned<IJobQueueItem> qi = qitem;
Expand Down
1 change: 1 addition & 0 deletions common/workunit/wujobq.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ interface IJobQueue: extends IJobQueueConst
virtual void connect(bool validateitemsessions)=0; // must be called before dequeueing
// validateitemsessions ensures that all queue items have running session
virtual IJobQueueItem *dequeue(unsigned timeout=INFINITE)=0;
virtual IJobQueueItem *dequeue(int minPrio, unsigned timeout, unsigned prioritytransitiondelay)=0;
virtual void disconnect()=0; // signal no longer wil be dequeing (optional - done automatically on release)
virtual void getStats(unsigned &connected,unsigned &waiting, unsigned &enqueued)=0; // this not quick as validates clients still running
virtual bool waitStatsChange(unsigned timeout)=0;
Expand Down
2 changes: 2 additions & 0 deletions testing/unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ include_directories (
./../../dali/base
./../../system/security/shared
./../../common/deftype
./../../common/workunit
./../../system/security/cryptohelper
./../../configuration/configmgr/configmgrlib
${HPCC_SOURCE_DIR}/system/masking/include
Expand Down Expand Up @@ -118,6 +119,7 @@ target_link_libraries ( unittests
esphttp
esdllib
logginglib
workunit
${CppUnit_LIBRARIES}
)

Expand Down
Loading

0 comments on commit d6dcd8c

Please sign in to comment.