public async Task PurgeByCompletedTimeTest() { var orchestrations = Utils.InfiniteOrchestrationTestData().Take(3).ToArray(); var histories = orchestrations .SelectMany(r => Utils.InfiniteWorkItemTestData(r.State.OrchestrationInstance.InstanceId, r.State.OrchestrationInstance.ExecutionId).Take(5)) .ToArray(); int secondsToAdd = 0; foreach (var item in orchestrations) { item.State.CompletedTime = DateTime.UtcNow.AddSeconds(secondsToAdd++); item.State.CreatedTime = item.State.LastUpdatedTime = DateTime.MaxValue; } await InstanceStore.WriteEntitiesAsync(orchestrations.Cast <InstanceEntityBase>().Concat(histories)); var historyEntriesDeleted = await InstanceStore.PurgeOrchestrationHistoryEventsAsync(orchestrations.ElementAt(1).State.CompletedTime, OrchestrationStateTimeRangeFilterType.OrchestrationCompletedTimeFilter); Assert.AreEqual(10, historyEntriesDeleted); var instance = orchestrations.Last().State.OrchestrationInstance; var count = (await InstanceStore.GetOrchestrationHistoryEventsAsync(instance.InstanceId, instance.ExecutionId)).Count(); Assert.AreEqual(5, count); foreach (var item in orchestrations.Take(2)) { instance = item.State.OrchestrationInstance; count = (await InstanceStore.GetOrchestrationHistoryEventsAsync(instance.InstanceId, instance.ExecutionId)).Count(); Assert.AreEqual(0, count); } }
public async Task VerifyWorkItemQueryTest() { var expectedInstanceId = Guid.NewGuid().ToString("N"); var expectedExecutionId = Guid.NewGuid().ToString("N"); var expectedWorkItemState = Utils.InfiniteWorkItemTestData(expectedInstanceId, expectedExecutionId).First(); //additional data to ensure query doesn't return back more data than it should var extraWorkItemState = Utils.InfiniteWorkItemTestData(Guid.NewGuid().ToString("N"), Guid.NewGuid().ToString("N")).First(); await InstanceStore.WriteEntitiesAsync(new InstanceEntityBase[] { expectedWorkItemState, extraWorkItemState }); var actual = (await InstanceStore.GetOrchestrationHistoryEventsAsync(expectedInstanceId, expectedExecutionId)).ToList(); Assert.AreEqual(1, actual.Count); var actualWorkItem = actual.First(); Assert.AreEqual(expectedInstanceId, actualWorkItem.InstanceId); Assert.AreEqual(expectedExecutionId, actualWorkItem.ExecutionId); }