예제 #1
0
        public void WhenIndexDefinitionDidNotChangeThenWeShouldNotThrowErrorIfIndexIsInLockedErrorState()
        {
            using (var store = GetDocumentStore())
            {
                var index = new People_ByName();
                index.Execute(store);

                store.Maintenance.Send(new SetIndexesLockOperation(index.IndexName, IndexLockMode.LockedError));

                index.Execute(store);

                store.Maintenance.Send(new SetIndexesLockOperation(index.IndexName, IndexLockMode.Unlock));

                var definition = index.CreateIndexDefinition();
                definition.LockMode       = IndexLockMode.LockedError;
                definition.Fields["Name"] = new IndexFieldOptions
                {
                    Storage = FieldStorage.Yes
                };

                store.Maintenance.Send(new PutIndexesOperation(definition));

                WaitForIndexing(store);

                Assert.Throws <IndexAlreadyExistException>(() => index.Execute(store));
            }
        }
예제 #2
0
        public async Task WhenIndexDefinitionDidNotChangeThenWeShouldNotThrowErrorIfIndexIsInLockedErrorStateAsync()
        {
            using (var store = GetDocumentStore())
            {
                var index = new People_ByName();
                await index.ExecuteAsync(store).ConfigureAwait(false);

                store.Maintenance.Send(new SetIndexesLockOperation(index.IndexName, IndexLockMode.LockedError));

                await index.ExecuteAsync(store).ConfigureAwait(false);

                store.Maintenance.Send(new SetIndexesLockOperation(index.IndexName, IndexLockMode.Unlock));

                var definition = index.CreateIndexDefinition();
                definition.LockMode       = IndexLockMode.LockedError;
                definition.Fields["Name"] = new IndexFieldOptions
                {
                    Storage = FieldStorage.Yes
                };
                store.Maintenance.Send(new PutIndexesOperation(definition));

                WaitForIndexing(store);

                var c = await Assert.ThrowsAsync <RavenException>(() => index.ExecuteAsync(store));

                Assert.Contains("IndexAlreadyExistException", c.Message);
            }
        }
예제 #3
0
        public async Task WhenIndexDefinitionDidNotChangeThenWeShouldNotThrowErrorIfIndexIsInLockedErrorStateAsync()
        {
            using (var store = NewDocumentStore())
            {
                var index = new People_ByName();
                await index.ExecuteAsync(store).ConfigureAwait(false);

                store.DatabaseCommands.SetIndexLock(index.IndexName, IndexLockMode.LockedError);

                await index.ExecuteAsync(store).ConfigureAwait(false);

                await index.SideBySideExecuteAsync(store).ConfigureAwait(false);

                store.DatabaseCommands.SetIndexLock(index.IndexName, IndexLockMode.Unlock);

                var definition = index.CreateIndexDefinition();
                definition.SortOptions["Name"] = SortOptions.Int;
                store.DatabaseCommands.PutIndex(index.IndexName, definition, true);

                store.DatabaseCommands.SetIndexLock(index.IndexName, IndexLockMode.LockedError);

                await AssertAsync.Throws <IndexCompilationException>(() => index.ExecuteAsync(store));

                await AssertAsync.Throws <InvalidOperationException>(() => index.SideBySideExecuteAsync(store));
            }
        }