示例#1
0
        public async Task WhenGettingTimeoutStateAndNoneIsFoundNullIsReturned()
        {
            await testSuite.InitTimeouts(nrOfTimeouts);

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

            Assert.That(toolState, Is.Null);
        }
示例#2
0
        public async Task CanReadDocumentsBySpecifiedIds()
        {
            var nrOfTimeouts = 5;
            await testSuite.InitTimeouts(nrOfTimeouts);

            var timeoutIds = new[] { "TimeoutDatas/1", "TimeoutDatas/2", "TimeoutDatas/3", "TimeoutDatas/4", "TimeoutDatas/0" };

            var timeouts = await testSuite.RavenAdapter.GetDocuments <TimeoutData>(timeoutIds, (doc, id) => doc.Id = id);

            Assert.That(timeouts.Count, Is.EqualTo(5));
            Assert.That(string.IsNullOrEmpty(timeouts.First().Id), Is.False);
        }
示例#3
0
        public async Task Setup()
        {
            testSuite = CreateTestSuite();
            await testSuite.SetupDatabase();

            await testSuite.InitTimeouts(nrOfTimeouts);
        }
示例#4
0
        public async Task WhenThereTimeoutsListEndpointsReturnsEndpointsList(bool useIndex)
        {
            var endpointATimes = await testSuite.InitTimeouts(nrOfTimeouts, "EndpointA", 0);

            var endpointBTimes = await testSuite.InitTimeouts(500, "EndpointB", nrOfTimeouts);

            var sut       = new RavenDbTimeoutsSource(testSuite.Logger, testSuite.ServerName, testSuite.DatabaseName, "TimeoutDatas", testSuite.RavenVersion, useIndex);
            var endpoints = await sut.ListEndpoints(DateTime.Now);

            Assert.IsNotNull(endpoints);
            Assert.That(endpoints.Count, Is.EqualTo(2));

            var endpointA = endpoints.FirstOrDefault(x => x.EndpointName == "EndpointA");

            Assert.IsNotNull(endpointA);
            Assert.That(endpointA.NrOfTimeouts, Is.EqualTo(nrOfTimeouts));
            Assert.That(endpointA.ShortestTimeout, Is.EqualTo(endpointATimes.ShortestTimeout));
            Assert.That(endpointA.LongestTimeout, Is.EqualTo(endpointATimes.LongestTimeout));

            var endpointB = endpoints.FirstOrDefault(x => x.EndpointName == "EndpointB");

            Assert.IsNotNull(endpointB);
            Assert.That(endpointB.NrOfTimeouts, Is.EqualTo(500));
            Assert.That(endpointB.ShortestTimeout, Is.EqualTo(endpointBTimes.ShortestTimeout));
            Assert.That(endpointB.LongestTimeout, Is.EqualTo(endpointBTimes.LongestTimeout));
        }
示例#5
0
        public async Task WhenAbortingWithAToolStateInPreparingToolWillStillCleanupBatches()
        {
            var cutOffTime = DateTime.Now.AddDays(-1);
            await testSuite.InitTimeouts(nrOfTimeouts);

            var storage = new RavenDbTimeoutsSource(testSuite.Logger, testSuite.ServerName, testSuite.DatabaseName, "TimeoutDatas", testSuite.RavenVersion, false);
            await storage.Prepare(cutOffTime, testSuite.EndpointName, new Dictionary <string, string>());

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

            toolState.Status = MigrationStatus.Preparing;
            await testSuite.RavenAdapter.UpdateDocument(RavenConstants.ToolStateId, toolState);

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

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

            var hiddenTimeouts = await testSuite.RavenAdapter.GetDocuments <TimeoutData>(timeout => timeout.OwningTimeoutManager.StartsWith(RavenConstants.MigrationOngoingPrefix), RavenConstants.DefaultTimeoutPrefix, (timeout, id) => { timeout.Id = id; });

            Assert.That(batchesInStore.Count, Is.EqualTo(0));
            Assert.That(hiddenTimeouts.Count, Is.EqualTo(0));
        }