コード例 #1
0
        public async Task WhenTheStorageHasNotBeenPreparedWeWantToInitBatches(bool useIndex)
        {
            nrOfTimeouts = RavenConstants.DefaultPagingSize + 5;
            await testSuite.InitTimeouts(nrOfTimeouts);

            await testSuite.CreateLegacyTimeoutManagerIndex(useIndex);

            var timeoutStorage =
                new RavenDbTimeoutsSource(testSuite.Logger, testSuite.ServerName, testSuite.DatabaseName, "TimeoutDatas", testSuite.RavenVersion, useIndex);
            var startTime = DateTime.UtcNow;
            var toolState = await timeoutStorage.Prepare(DateTime.Now.AddDays(-1), testSuite.EndpointName, new Dictionary <string, string>());

            Assert.That(toolState.NumberOfBatches, Is.EqualTo(2));
            var storedToolState = await testSuite.RavenAdapter.GetDocument <RavenToolStateDto>(RavenConstants.ToolStateId);

            Assert.That(storedToolState.NumberOfTimeouts, Is.EqualTo(nrOfTimeouts));
            Assert.That(storedToolState.NumberOfBatches, Is.EqualTo(2));
            Assert.That(storedToolState.Status, Is.EqualTo(MigrationStatus.StoragePrepared));
            Assert.That(storedToolState.StartedAt, Is.GreaterThan(startTime));

            var firstBatch = await toolState.TryGetNextBatch();

            var batchData = await timeoutStorage.ReadBatch(firstBatch.Number);

            Assert.That(batchData.Count(), Is.EqualTo(RavenConstants.DefaultPagingSize));

            firstBatch.State = BatchState.Completed;
            await timeoutStorage.MarkBatchAsCompleted(firstBatch.Number);

            var nextBatch = await toolState.TryGetNextBatch();

            var nextBatchData = await timeoutStorage.ReadBatch(nextBatch.Number);

            Assert.That(nextBatchData.Count(), Is.EqualTo(nrOfTimeouts - RavenConstants.DefaultPagingSize));
        }
コード例 #2
0
        public async Task Setup()
        {
            testSuite = CreateTestSuite();
            await testSuite.SetupDatabase();

            await testSuite.CreateLegacyTimeoutManagerIndex(true);
        }
コード例 #3
0
        public async Task CanReadDocumentsByIndexWhenIndexExist()
        {
            var nrOfTimeouts = 500;
            await testSuite.InitTimeouts(nrOfTimeouts);

            await testSuite.CreateLegacyTimeoutManagerIndex(true);

            var result = await testSuite.RavenAdapter.GetDocumentsByIndex <TimeoutData>(0, TimeSpan.Zero, (doc, id) => doc.Id = id);

            Assert.That(result.Documents.Count, Is.EqualTo(500));
        }