public async Task when_initializing_all_expected_resources_are_created() { var collectionName = "AllExpectedResourcesAreCreated_" + Guid.NewGuid(); var storageEngine = await StorageEngineFactory.Create(DatabaseName, o => o.CollectionName = collectionName); await storageEngine.Initialise(); var database = (await client.ReadDatabaseAsync(databaseUri)).Resource; var collection = (await client.ReadDocumentCollectionAsync(UriFactory.CreateDocumentCollectionUri(DatabaseName, collectionName))).Resource; var storedProcedure = (await client.ReadStoredProcedureAsync(UriFactory.CreateStoredProcedureUri(DatabaseName, collectionName, TestConstants.AppendStoredProcedureName))).Resource; var offer = client.CreateOfferQuery() .Where(r => r.ResourceLink == collection.SelfLink) .AsEnumerable() .OfType <OfferV2>() .Single(); Assert.That(offer.Content.OfferThroughput, Is.EqualTo(TestConstants.RequestUnits)); Assert.That(collection.DefaultTimeToLive, Is.Null); Assert.That(collection.PartitionKey.Paths.Count, Is.EqualTo(1)); Assert.That(collection.PartitionKey.Paths.Single(), Is.EqualTo("/streamId")); Assert.That(collection.IndexingPolicy.IncludedPaths.Count, Is.EqualTo(1)); Assert.That(collection.IndexingPolicy.IncludedPaths[0].Path, Is.EqualTo("/*")); Assert.That(collection.IndexingPolicy.ExcludedPaths.Count, Is.EqualTo(3)); Assert.That(collection.IndexingPolicy.ExcludedPaths[0].Path, Is.EqualTo("/body/*")); Assert.That(collection.IndexingPolicy.ExcludedPaths[1].Path, Is.EqualTo("/metadata/*")); }
public async Task when_document_ttl_is_configured_then_documents_have_that_ttl_set() { const string DatabaseName = "AppendingTestsCosmosOnly"; var client = DocumentClientFactory.Create(DatabaseName); var collectionName = "TtlTests_" + Guid.NewGuid(); var storageEngine = await StorageEngineFactory.Create(DatabaseName, o => { o.CollectionName = collectionName; o.DefaultTimeToLiveSeconds = -1; o.DocumentTimeToLiveSeconds = 10; }); await storageEngine.Initialise(); var streamId = Guid.NewGuid().ToString(); var store = new EventStore(storageEngine); await store.AppendToStream(streamId, 0, new EventData(Guid.NewGuid(), new OrderCreated(streamId))); var commitsLink = UriFactory.CreateDocumentCollectionUri(DatabaseName, collectionName); var eventsQuery = client.CreateDocumentQuery <DocumentDbStorageEvent>(commitsLink) .Where(x => x.StreamId == streamId) .OrderBy(x => x.EventNumber) .AsDocumentQuery(); var response = await eventsQuery.ExecuteNextAsync <DocumentDbStorageEvent>(); Assert.That(response.First().TimeToLiveSeconds, Is.EqualTo(10)); }
protected override Task <IStorageEngine> CreateStorageEngine() { return(StorageEngineFactory.Create("JsonSerializationSettingsTests", new JsonSerializerSettings { Converters = new List <JsonConverter> { new VersionConverter() } })); }
private static async Task InitialiseStorageEngine(string collectionName, int collectionThroughput, int dbThroughput) { var storageEngine = await StorageEngineFactory.Create(DatabaseName, collectionOptions => { collectionOptions.CollectionName = collectionName; collectionOptions.CollectionRequestUnits = collectionThroughput; }, databaseOptions => { databaseOptions.DatabaseRequestUnits = dbThroughput; }); await storageEngine.Initialise(); }
public AzureDocumentDbStorageEngineHealthTests() { client = DocumentClientFactory.Create(DatabaseName); storageEngine = StorageEngineFactory.Create(DatabaseName, o => { o.CollectionName = CollectionName; o.DefaultTimeToLiveSeconds = -1; o.DocumentTimeToLiveSeconds = 10; }) .Result; storageEngine.Initialise().Wait(); }
public async Task when_using_shared_throughput_it_is_set_at_a_database_level() { const int throughput = 800; var collectionName = "SharedCollection_" + Guid.NewGuid(); var storageEngine = await StorageEngineFactory.Create(DatabaseName, collectionOptions => { collectionOptions.CollectionName = collectionName; collectionOptions.CollectionRequestUnits = null; }, databaseOptions => { databaseOptions.DatabaseRequestUnits = throughput; }); await storageEngine.Initialise(); Assert.AreEqual(throughput, await GetDatabaseThroughput()); }
public async Task when_initializing_with_a_time_to_live_it_is_set() { var ttl = 60; var collectionName = "TimeToLiveIsSet_" + Guid.NewGuid(); var client = DocumentClientFactory.Create(DatabaseName); var storageEngine = await StorageEngineFactory.Create(DatabaseName, o => { o.CollectionName = collectionName; o.DefaultTimeToLiveSeconds = ttl; }); await storageEngine.Initialise(); var collection = (await client.ReadDocumentCollectionAsync(UriFactory.CreateDocumentCollectionUri(DatabaseName, collectionName))).Resource; Assert.That(collection.DefaultTimeToLive, Is.EqualTo(ttl)); }
public async Task when_reading_a_stream_that_has_deleted_events_the_stream_can_still_be_read() { const string databaseName = "ReadingPartialStreamTests"; const string collectionName = "Commits"; var client = DocumentClientFactory.Create(databaseName); var storageEngine = await StorageEngineFactory.Create(databaseName, o => o.CollectionName = collectionName); var eventStore = new EventStore(storageEngine); var streamId = Guid.NewGuid().ToString(); await eventStore.AppendToStream(streamId, 0, new EventData(Guid.NewGuid(), new OrderCreated(streamId)), new EventData(Guid.NewGuid(), new OrderDispatched(streamId))); await SimulateTimeToLiveExpiration(databaseName, collectionName, client, streamId); var stream = await eventStore.ReadStreamForwards(streamId); Assert.That(stream.Count, Is.EqualTo(1)); Assert.That(stream.First().EventBody, Is.InstanceOf <OrderDispatched>()); Assert.That(stream.First().EventNumber, Is.EqualTo(2)); }
protected override Task <IStorageEngine> CreateStorageEngine() { return(StorageEngineFactory.Create("ReadingTests")); }
protected override Task <IStorageEngine> CreateStorageEngine() { return(StorageEngineFactory.Create("DeletingStreamTests")); }