diff --git a/extensions/lifecycle/conductor/LifecycleConductor.js b/extensions/lifecycle/conductor/LifecycleConductor.js index 6456d032f..4bd211eb8 100644 --- a/extensions/lifecycle/conductor/LifecycleConductor.js +++ b/extensions/lifecycle/conductor/LifecycleConductor.js @@ -226,10 +226,14 @@ class LifecycleConductor { } _indexesGetOrCreate(task, log, cb) { - if (this._bucketSource !== 'mongodb' || !task.isLifecycled) { + if (!task.isLifecycled) { return process.nextTick(cb, null, lifecycleTaskVersions.v1); } + if (this._bucketSource !== 'mongodb') { + return process.nextTick(cb, null, lifecycleTaskVersions.v2); + } + const backbeatMetadataProxy = this.clientManager.getBackbeatMetadataProxy( this._accountIdCache.get(task.canonicalId)); if (!backbeatMetadataProxy) { diff --git a/tests/unit/lifecycle/LifecycleConductor.spec.js b/tests/unit/lifecycle/LifecycleConductor.spec.js index 1b82032f7..5bebfe27b 100644 --- a/tests/unit/lifecycle/LifecycleConductor.spec.js +++ b/tests/unit/lifecycle/LifecycleConductor.spec.js @@ -283,6 +283,7 @@ describe('Lifecycle Conductor', () => { indexesForFeature.lifecycle.v2, // getIndex response null, // metadata proxy error true, // flag for status ofin progress job retrieval + 'mongodb', ], [ [], // updated job state @@ -290,6 +291,21 @@ describe('Lifecycle Conductor', () => { lifecycleTaskVersions.v2, // expected version ], ], + [ + 'should return v2 if backend is not MongoDB', + [ + [], + null, + null, + true, + 'bucketd', + ], + [ + [], + null, + lifecycleTaskVersions.v2, + ], + ], [ 'should return v1: missing indexes + put indexes', [ @@ -297,6 +313,7 @@ describe('Lifecycle Conductor', () => { [], null, true, + 'mongodb', ], [ [ @@ -315,6 +332,7 @@ describe('Lifecycle Conductor', () => { [], null, true, + 'mongodb', ], [ [ @@ -334,6 +352,7 @@ describe('Lifecycle Conductor', () => { [], null, true, + 'mongodb', ], [ [ @@ -351,6 +370,7 @@ describe('Lifecycle Conductor', () => { [], null, false, + 'mongodb', ], [ [], @@ -365,6 +385,7 @@ describe('Lifecycle Conductor', () => { [], new Error('test error'), true, + 'mongodb', ], [ [], @@ -376,13 +397,14 @@ describe('Lifecycle Conductor', () => { tests.forEach(([msg, input, expected]) => it(msg, done => { - const [inJobs, getIndexes, mockError, getInProgressSucceeded] = input; + const [inJobs, getIndexes, mockError, getInProgressSucceeded, bucektSource] = input; const [expectedJobs, putIndexes, expectedVersion] = expected; const client = new BackbeatMetadataProxyMock(); conductor.clientManager.getBackbeatMetadataProxy = () => client; conductor.activeIndexingJobsRetrieved = getInProgressSucceeded; conductor.activeIndexingJobs = inJobs; + conductor._bucketSource = bucektSource; client.indexesObj = getIndexes; client.error = mockError;