Skip to content
Permalink
Browse files

PRESIDECMS-1562 disable query caching (by default) during running of …

…ad-hoc tasks
  • Loading branch information...
DominicWatson committed May 13, 2019
1 parent 6398de9 commit bb1f97d10315f7e14060886587bba52a3652d1c4
@@ -138,6 +138,29 @@ component extends="testbox.system.BaseSpec" {
expect( log[1].error.type ?: "" ).toBe( "AdHoTaskManagerService.task.already.running" );
expect( log[1].error.message ?: "" ).toBe( "Task not run. The task with ID, [#taskId#], is already running." );
} );

it( "should set useQueryCache to false for the request to ensure query caching is not used throughout the process (by default)", function(){
var service = _getService();
var taskId = CreateUUId();
var event = "some.handler.action";
var args = { test=CreateUUId(), fubar=123 };
var taskDef = QueryNew( 'event,event_args,status', 'varchar,varchar,varchar', [ [ event, SerializeJson( args ), "pending" ] ] );

_mockGetTask( taskId, taskDef );
mockColdbox.$( "runEvent" );
var mockProgress = _mockProgress( service, taskId );
var mockLogger = _mockLogger( service, taskId );

service.$( "completeTask" );
service.$( "failTask" );
service.$( "markTaskAsRunning" );

service.runTask( taskId );

log = mockRequestContext.$callLog().setUseQueryCache;
expect( log.len() ).toBe( 1 );
expect( log[1] ).toBe( [ false ] );
} );
} );

describe( "createTask()", function(){
@@ -725,6 +748,8 @@ component extends="testbox.system.BaseSpec" {
, threadUtil = mockThreadUtil
) );

mockRequestContext.$( "setUseQueryCache" );

service.$( "$getPresideObject" ).$args( "taskmanager_adhoc_task" ).$results( mockTaskDao );
service.$( "$getColdbox", mockColdbox );
service.$( "$getRequestContext", mockRequestContext );
@@ -94,6 +94,8 @@ component displayName="Ad-hoc Task Manager Service" {
*/
public boolean function runTask( required string taskId ) {
lock timeout="1" name="adhocRunTask#arguments.taskId#" {
$getRequestContext().setUseQueryCache( false );

var task = getTask( arguments.taskId );
var event = task.event ?: "";
var args = IsJson( task.event_args ?: "" ) ? DeserializeJson( task.event_args ) : {};

0 comments on commit bb1f97d

Please sign in to comment.
You can’t perform that action at this time.