Esempio n. 1
0
        public void CanGetGoodErrorForBadTopologies()
        {
            UseNewLocalServer(new Dictionary <string, string>
            {
                ["PublicServerUrl"] = "http://invalid.example.com" // intentionally broken!
            });

            var url     = Server.WebUrl;
            var reqExec = RequestExecutor.CreateForSingleNodeWithoutConfigurationUpdates(url, "Foo", null, DocumentConventions.Default);
            var op      = new CreateDatabaseOperation(new Raven.Client.ServerWide.DatabaseRecord("Foo"));

            using (reqExec.ContextPool.AllocateOperationContext(out var ctx))
            {
                Assert.Throws <RavenException>(() => reqExec.Execute(op.GetCommand(DocumentConventions.Default, ctx), ctx));
            }

            using (var store = new DocumentStore
            {
                Urls = new[] { url },
                Database = "Foo",
            })
            {
                store.Initialize();

                using (var session = store.OpenSession())
                {
                    var e = Assert.Throws <RavenException>(() => session.Load <object>("users/1-a"));
                    Assert.Contains("invalid.example.com", e.Message);
                }
            }
        }
        public void Should_throw_when_there_is_timeout()
        {
            UseNewLocalServer();
            Server.Configuration.Server.MaxTimeForTaskToWaitForDatabaseToLoad = new TimeSetting(0, TimeUnit.Milliseconds);
            Server.ServerStore.DatabasesLandlord.OnDatabaseLoaded            += s => Thread.Sleep(100); // force timeout

            var url  = Server.WebUrl;
            var name = Guid.NewGuid().ToString();
            var doc  = GenerateDatabaseDoc(name);

            try
            {
                Assert.Throws <DatabaseLoadTimeoutException>(() =>
                {
                    using (var ctx = JsonOperationContext.ShortTermSingleUse())
                        using (var requestExecutor = RequestExecutor.CreateForSingleNodeWithoutConfigurationUpdates(url, name, null, DocumentConventions.Default))
                        {
                            requestExecutor.Execute(
                                new CreateDatabaseOperation(doc).GetCommand(new DocumentConventions(), ctx), ctx);
                            requestExecutor.Execute(new GetDocumentsCommand("Raven/HiloPrefix", includes: null, metadataOnly: false), ctx);
                        }
                });
            }
            catch (TaskCanceledException e)
            {
                Console.WriteLine(e.InnerException);
                throw;
            }
        }
Esempio n. 3
0
        public Importer(
            string serverUrl,
            string sourceDatabaseName,
            SmugglerResult result,
            Action <IOperationProgress> onProgress,
            DocumentDatabase database,
            string migrationStateKey,
            OperationCancelToken cancelToken)
            : base(serverUrl, sourceDatabaseName, result, onProgress, database, cancelToken)
        {
            _migrationStateKey = migrationStateKey;

            _requestExecutor = RequestExecutor.CreateForSingleNodeWithoutConfigurationUpdates(ServerUrl, DatabaseName, Database.ServerStore.Server.ClusterCertificateHolder.Certificate, DocumentConventions.Default);

            _client = _requestExecutor.HttpClient;
        }
Esempio n. 4
0
        private static async Task SendKeyToNodeAsync(string name, string base64, JsonOperationContext ctx, ServerStore server, string node, string url)
        {
            using (var shortLived = RequestExecutor.CreateForSingleNodeWithoutConfigurationUpdates(url, name, server.Server.Certificate.Certificate, DocumentConventions.DefaultForServer))
            {
                var command = new PutSecretKeyCommand(name, base64);
                try
                {
                    await shortLived.ExecuteAsync(command, ctx);
                }
                catch (Exception e)
                {
                    throw new InvalidOperationException($"Failed to store secret key for {name} in Node {node}, url={url}", e);
                }

                if (command.StatusCode != HttpStatusCode.Created)
                {
                    throw new InvalidOperationException($"Failed to store secret key for {name} in Node {node}, url={url}. StatusCode = {command.StatusCode}");
                }
            }
        }
Esempio n. 5
0
 public RavenEtl(Transformation transformation, RavenEtlConfiguration configuration, DocumentDatabase database, ServerStore serverStore) : base(transformation, configuration, database, serverStore, RavenEtlTag)
 {
     Metrics          = new EtlMetricsCountersManager();
     _requestExecutor = RequestExecutor.CreateForSingleNodeWithoutConfigurationUpdates(configuration.Connection.Url, configuration.Connection.Database, serverStore.Server.ClusterCertificateHolder.Certificate, DocumentConventions.Default);
     _script          = new RavenEtlDocumentTransformer.ScriptInput(transformation);
 }