protected DocumentStore GetDocumentStore( string serverVersion, InterversionTestOptions options = null, [CallerMemberName] string database = null) { return(AsyncHelpers.RunSync(() => GetDocumentStoreAsync(serverVersion, options, database))); }
protected async Task <ProcessNode> GetServerAsync( string serverVersion, InterversionTestOptions options = null, [CallerMemberName] string database = null, CancellationToken token = default) { var serverBuildInfo = ServerBuildDownloadInfo.Create(serverVersion); var serverPath = await _serverBuildRetriever.GetServerPath(serverBuildInfo, token); var testServerPath = NewDataPath(prefix: serverVersion); CopyFilesRecursively(new DirectoryInfo(serverPath), new DirectoryInfo(testServerPath)); var locator = new ConfigurableRavenServerLocator(Path.Combine(testServerPath, "Server"), serverVersion); var result = await RunServer(locator); return(new ProcessNode { Process = result.ServerProcess, Url = result.ServerUrl, Version = serverVersion, ServerPath = testServerPath, DataDir = locator.DataDir }); }
protected async Task <DocumentStore> GetDocumentStoreAsync( string serverVersion, InterversionTestOptions options = null, [CallerMemberName] string database = null, CancellationToken token = default) { var processNode = await GetServerAsync(serverVersion, options, database, token); options = options ?? InterversionTestOptions.Default; var name = GetDatabaseName(database); if (options.ModifyDatabaseName != null) { name = options.ModifyDatabaseName(name) ?? name; } var doc = new DatabaseRecord(name) { Settings = { [RavenConfiguration.GetKey(x => x.Replication.ReplicationMinimalHeartbeat)] = "1", [RavenConfiguration.GetKey(x => x.Replication.RetryReplicateAfter)] = "1", [RavenConfiguration.GetKey(x => x.Core.RunInMemory)] = "true", [RavenConfiguration.GetKey(x => x.Core.ThrowIfAnyIndexCannotBeOpened)] = "true", [RavenConfiguration.GetKey(x => x.Indexing.MinNumberOfMapAttemptsAfterWhichBatchWillBeCanceledIfRunningLowOnMemory)] = int.MaxValue.ToString() } }; options.ModifyDatabaseRecord?.Invoke(doc); var store = new DocumentStore { Urls = new[] { processNode.Url }, Database = name }; options.ModifyDocumentStore?.Invoke(store); store.Initialize(); if (options.CreateDatabase) { await store.Maintenance.Server.SendAsync(new CreateDatabaseOperation(doc, options.ReplicationFactor), token); } store.AfterDispose += (sender, e) => { KillSlavedServerProcess(processNode.Process); }; return(store); }
protected async Task <(Uri ServerUrl, Process ServerProcess)> GetServerAsync( string serverVersion, InterversionTestOptions options = null, [CallerMemberName] string database = null, CancellationToken token = default(CancellationToken)) { var serverBuildInfo = ServerBuildDownloadInfo.Create(serverVersion); var serverPath = await _serverBuildRetriever.GetServerPath(serverBuildInfo); var testServerPath = NewDataPath(prefix: serverVersion); CopyFilesRecursively(new DirectoryInfo(serverPath), new DirectoryInfo(testServerPath)); var locator = new ConfigurableRavenServerLocator(testServerPath); return(await RunServer(locator)); }
protected async Task <DocumentStore> GetDocumentStoreAsync( string serverVersion, InterversionTestOptions options = null, [CallerMemberName] string database = null, CancellationToken token = default) { var serverBuildInfo = ServerBuildDownloadInfo.Create(serverVersion); var serverPath = await _serverBuildRetriever.GetServerPath(serverBuildInfo, token); var testServerPath = NewDataPath(prefix: serverVersion); CopyFilesRecursively(new DirectoryInfo(serverPath), new DirectoryInfo(testServerPath)); var locator = new ConfigurableRavenServerLocator(testServerPath); var(serverUrl, serverProcess) = await RunServer(locator); options = options ?? InterversionTestOptions.Default; var name = GetDatabaseName(database); if (options.ModifyDatabaseName != null) { name = options.ModifyDatabaseName(name) ?? name; } var doc = new DatabaseRecord(name) { Settings = { [RavenConfiguration.GetKey(x => x.Replication.ReplicationMinimalHeartbeat)] = "1", [RavenConfiguration.GetKey(x => x.Replication.RetryReplicateAfter)] = "1", [RavenConfiguration.GetKey(x => x.Core.RunInMemory)] = "true", [RavenConfiguration.GetKey(x => x.Core.ThrowIfAnyIndexCannotBeOpened)] = "true", [RavenConfiguration.GetKey(x => x.Indexing.MinNumberOfMapAttemptsAfterWhichBatchWillBeCanceledIfRunningLowOnMemory)] = int.MaxValue.ToString() } }; options.ModifyDatabaseRecord?.Invoke(doc); var store = new DocumentStore { Urls = new[] { serverUrl.ToString() }, Database = name }; options.ModifyDocumentStore?.Invoke(store); store.Initialize(); if (options.CreateDatabase) { await store.Maintenance.Server.SendAsync(new CreateDatabaseOperation(doc, options.ReplicationFactor), token); } store.AfterDispose += (sender, e) => { KillSlavedServerProcess(serverProcess); }; return(store); }
private async Task <DocumentStore> GetStore(string serverUrl, Process serverProcess = null, [CallerMemberName] string database = null, InterversionTestOptions options = null) { options = options ?? InterversionTestOptions.Default; var name = database ?? GetDatabaseName(null); if (options.ModifyDatabaseName != null) { name = options.ModifyDatabaseName(name) ?? name; } var store = new DocumentStore { Urls = new[] { serverUrl }, Database = name }; options.ModifyDocumentStore?.Invoke(store); store.Initialize(); if (options.CreateDatabase) { var dbs = await store.Maintenance.Server.SendAsync(new GetDatabaseNamesOperation(0, 10)); foreach (var db in dbs) { if (db == name) { throw new InvalidOperationException($"Database '{name}' already exists."); } } var doc = new DatabaseRecord(name) { Settings = { [RavenConfiguration.GetKey(x => x.Replication.ReplicationMinimalHeartbeat)] = "1", [RavenConfiguration.GetKey(x => x.Replication.RetryReplicateAfter)] = "1", [RavenConfiguration.GetKey(x => x.Core.RunInMemory)] = true.ToString(), [RavenConfiguration.GetKey(x => x.Core.ThrowIfAnyIndexCannotBeOpened)] = true.ToString(), [RavenConfiguration.GetKey(x => x.Indexing.MinNumberOfMapAttemptsAfterWhichBatchWillBeCanceledIfRunningLowOnMemory)] = int.MaxValue.ToString() } }; options.ModifyDatabaseRecord?.Invoke(doc); DatabasePutResult result; result = await store.Maintenance.Server.SendAsync(new CreateDatabaseOperation(doc, options.ReplicationFactor)); } if (serverProcess != null) { store.AfterDispose += (sender, e) => { KillSlavedServerProcess(serverProcess); }; } return(store); }