Exemplo n.º 1
0
        public async Task GivenLegacyActivity_WhenReindexing_ThenShouldReindexEachInstance()
        {
            var batch = new ReindexBatch
            {
                QueryTags = new List <ExtendedQueryTagStoreEntry>
                {
                    new ExtendedQueryTagStoreEntry(1, "01", "DT", "foo", QueryTagLevel.Instance, ExtendedQueryTagStatus.Adding, QueryStatus.Enabled, 0),
                    new ExtendedQueryTagStoreEntry(2, "02", "DT", null, QueryTagLevel.Series, ExtendedQueryTagStatus.Adding, QueryStatus.Enabled, 0),
                    new ExtendedQueryTagStoreEntry(3, "03", "AS", "bar", QueryTagLevel.Study, ExtendedQueryTagStatus.Adding, QueryStatus.Enabled, 0),
                },
                WatermarkRange = new WatermarkRange(3, 10),
            };

            var expected = new List <VersionedInstanceIdentifier>
            {
                new VersionedInstanceIdentifier(TestUidGenerator.Generate(), TestUidGenerator.Generate(), TestUidGenerator.Generate(), 3),
                new VersionedInstanceIdentifier(TestUidGenerator.Generate(), TestUidGenerator.Generate(), TestUidGenerator.Generate(), 4),
                new VersionedInstanceIdentifier(TestUidGenerator.Generate(), TestUidGenerator.Generate(), TestUidGenerator.Generate(), 5),
                new VersionedInstanceIdentifier(TestUidGenerator.Generate(), TestUidGenerator.Generate(), TestUidGenerator.Generate(), 6),
                new VersionedInstanceIdentifier(TestUidGenerator.Generate(), TestUidGenerator.Generate(), TestUidGenerator.Generate(), 7),
                new VersionedInstanceIdentifier(TestUidGenerator.Generate(), TestUidGenerator.Generate(), TestUidGenerator.Generate(), 8),
                new VersionedInstanceIdentifier(TestUidGenerator.Generate(), TestUidGenerator.Generate(), TestUidGenerator.Generate(), 9),
            };

            // Arrange input
            _instanceStore
            .GetInstanceIdentifiersByWatermarkRangeAsync(batch.WatermarkRange, IndexStatus.Created, CancellationToken.None)
            .Returns(expected);

            foreach (VersionedInstanceIdentifier identifier in expected)
            {
                _instanceReindexer.ReindexInstanceAsync(batch.QueryTags, identifier).Returns(true);
            }

            // Call the activity
            await _reindexDurableFunction.ReindexBatchAsync(batch, NullLogger.Instance);

            // Assert behavior
            await _instanceStore
            .Received(1)
            .GetInstanceIdentifiersByWatermarkRangeAsync(batch.WatermarkRange, IndexStatus.Created, CancellationToken.None);

            foreach (VersionedInstanceIdentifier identifier in expected)
            {
                await _instanceReindexer.Received(1).ReindexInstanceAsync(batch.QueryTags, identifier);
            }
        }
 public Task ReindexBatchAsync([ActivityTrigger] ReindexBatch batch, ILogger logger)
 => ReindexBatchV2Async(batch?.ToArguments(_options.BatchThreadCount), logger);