コード例 #1
0
        public async Task WhenLoadingAnOngoingMigrationAndWeFoundOneWeReturnIt()
        {
            await testSuite.InitTimeouts(nrOfTimeouts);

            await testSuite.SaveToolState(testSuite.SetupToolState(DateTime.Now.AddDays(-1)));

            var timeoutStorage     = new RavenDbTimeoutsSource(testSuite.Logger, testSuite.ServerName, testSuite.DatabaseName, "TimeoutDatas", testSuite.RavenVersion, false);
            var retrievedToolState = await timeoutStorage.TryLoadOngoingMigration();

            Assert.That(retrievedToolState, Is.Not.Null);
            Assert.That(retrievedToolState.NumberOfBatches, Is.GreaterThan(0));
        }
コード例 #2
0
        public async Task WhenThereIsStateAbortShouldDeleteState()
        {
            var toolState = testSuite.SetupToolState(DateTime.Now);
            await testSuite.SaveToolState(toolState);

            var sut = new RavenDbTimeoutsSource(testSuite.Logger, testSuite.ServerName, testSuite.DatabaseName, "TimeoutDatas", testSuite.RavenVersion, false);
            await sut.Abort();

            var storedSate = await testSuite.GetToolState();

            Assert.That(storedSate, Is.Null);
        }
コード例 #3
0
        public async Task WhenCompletingMigrationToolStateIsArchived()
        {
            var toolState = testSuite.SetupToolState(DateTime.Now);
            await testSuite.SaveToolState(toolState);

            var timeStarted = DateTime.UtcNow;

            var sut = new RavenDbTimeoutsSource(testSuite.Logger, testSuite.ServerName, testSuite.DatabaseName, "TimeoutDatas", testSuite.RavenVersion, false);
            await sut.Complete();

            var updatedToolState = await testSuite.RavenAdapter.GetDocument <RavenToolStateDto>(RavenConstants.ToolStateId);

            Assert.IsNull(updatedToolState);

            var batches = await testSuite.RavenAdapter.GetDocuments <RavenBatch>(info => true, RavenConstants.BatchPrefix);

            Assert.That(batches.Count, Is.EqualTo(0));

            var archivedToolStates = await testSuite.RavenAdapter.GetDocuments <RavenToolStateDto>(_ => true, RavenConstants.ArchivedToolStateIdPrefix);

            Assert.That(archivedToolStates.Count, Is.EqualTo(1));

            var archivedToolState = archivedToolStates.Single();

            Assert.That(archivedToolState.Status, Is.EqualTo(MigrationStatus.Completed));
            Assert.That(archivedToolState.CompletedAt, Is.GreaterThan(timeStarted));
        }