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)); } }
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); } }
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)); } }