Esempio n. 1
0
        public async Task can_use_conventions_with_create_side_by_side_indexes_async_container()
        {
            using (var store = NewDocumentStore())
            {
                var container = new CompositionContainer(new TypeCatalog(typeof(CustomIdInIndexCreationTask)));
                await IndexCreation.SideBySideCreateIndexesAsync(container, store.AsyncDatabaseCommands, conventions);

                Assert.True(testFailed == false);
            }
        }
Esempio n. 2
0
        public async Task should_not_reset_lock_mode_on_multiple_async_side_by_side_index_creation()
        {
            using (var documentStore = NewDocumentStore())
            {
                var container = new CompositionContainer(new TypeCatalog(typeof(Entity_ById_V1)));
                await IndexCreation
                .SideBySideCreateIndexesAsync(container, documentStore.AsyncDatabaseCommands, documentStore.Conventions)
                .ConfigureAwait(false);

                WaitForIndexing(documentStore);

                documentStore.DatabaseCommands.SetIndexLock("Entity/ById", IndexLockMode.SideBySide);

                var databaseStatisticsBefore = documentStore.DatabaseCommands.GetStatistics();
                var indexStatsBefore         = databaseStatisticsBefore.Indexes.Single(i => i.Name == "Entity/ById");

                Assert.Equal(2, databaseStatisticsBefore.Indexes.Length);
                Assert.Equal(IndexLockMode.SideBySide, indexStatsBefore.LockMode);

                while (true)
                {
                    var index = documentStore.DatabaseCommands.GetStatistics().Indexes.FirstOrDefault(x => x.Name == "Entity/ById");
                    if (index != null)
                    {
                        break;
                    }
                    Thread.Sleep(100);
                }

                container = new CompositionContainer(new TypeCatalog(typeof(Entity_ById_V2)));
                await IndexCreation
                .SideBySideCreateIndexesAsync(container, documentStore.AsyncDatabaseCommands, documentStore.Conventions)
                .ConfigureAwait(false);

                WaitForIndexing(documentStore);

                while (documentStore.DatabaseCommands.GetStatistics().Indexes.Length != 2)
                {
                    Thread.Sleep(100);
                }

                var databaseStatisticsAfter = documentStore.DatabaseCommands.GetStatistics();
                var indexStatsAfter         = databaseStatisticsAfter.Indexes.Single(i => i.Name == "Entity/ById");

                Assert.Equal(2, databaseStatisticsAfter.Indexes.Length);
                Assert.Equal(IndexLockMode.SideBySide, indexStatsAfter.LockMode);
            }
        }