public void CreateGlobalWarmer() { using (var context = new ElasticsearchContext(ConnectionString, _elasticsearchMappingResolver)) { var warmer = new Warmer("mywarmerone") { Query = new Query(new MatchAllQuery()) }; context.TraceProvider = new ConsoleTraceProvider(); var found = context.WarmerCreate(warmer); Assert.IsTrue(found); } }
public void CreateIndexWithTypeWarmer() { using (var context = new ElasticsearchContext(ConnectionString, _elasticsearchMappingResolver)) { var warmer = new Warmer("mywarmerthree") { Query = new Query(new MatchAllQuery()) }; context.TraceProvider = new ConsoleTraceProvider(); var found = context.WarmerCreate(warmer, "existsdtofortestss", "wthree"); Assert.IsTrue(found); } }
public void DeleteIndexWarmer() { using (var context = new ElasticsearchContext(ConnectionString, _elasticsearchMappingResolver)) { const string warmerName = "mywarmerone"; var warmer = new Warmer(warmerName) { Query = new Query(new MatchAllQuery()) }; context.TraceProvider = new ConsoleTraceProvider(); var found = context.WarmerCreate(warmer); Assert.IsTrue(found); var ok = context.WarmerDelete(warmerName, "existsdtofortestss"); Assert.IsTrue(ok); } }
public void DeleteGlobalWarmer() { var ex = Assert.Throws <ElasticsearchCrudException>(() => { using (var context = new ElasticsearchContext(ConnectionString, _elasticsearchMappingResolver)) { const string warmerName = "mywarmerone"; var warmer = new Warmer(warmerName) { Query = new Query(new MatchAllQuery()) }; context.TraceProvider = new ConsoleTraceProvider(); var found = context.WarmerCreate(warmer); Assert.True(found); var ok = context.WarmerDelete(warmerName, ""); Assert.True(ok); } }); }
public async Task<ResultDetails<bool>> SendWarmerCommandAsync(Warmer warmer, string index, string type) { _traceProvider.Trace(TraceEventType.Verbose, string.Format("ElasticsearchContextWarmer: Creating Warmer {0}", warmer.Name)); var resultDetails = new ResultDetails<bool> { Status = HttpStatusCode.InternalServerError }; var elasticsearchUrl = CreateWarmerUriParameter(index, type, warmer.Name); var uri = new Uri(elasticsearchUrl); _traceProvider.Trace(TraceEventType.Verbose, "{1}: Request HTTP PUT uri: {0}", uri.AbsoluteUri, "ElasticsearchContextWarmer"); var content = new StringContent(warmer.ToString()); var response = await _client.PutAsync(uri, content, _cancellationTokenSource.Token).ConfigureAwait(false); if (response.StatusCode == HttpStatusCode.OK) { resultDetails.PayloadResult = true; return resultDetails; } _traceProvider.Trace(TraceEventType.Error, string.Format("ElasticsearchContextWarmer: Cound Not Execute Warmer Create {0}", warmer.Name)); throw new ElasticsearchCrudException(string.Format("ElasticsearchContextWarmer: Cound Not Execute Warmer Create {0}", warmer.Name)); }
public void Warm_ReceivesPopulatedConfig_CallsCorrectMethods() { var config = new Mock<IConfig>(); config.Setup(m => m.Checks).Returns( new List<Check> { new Check { Url = "http://www.yahoo.com/" }, new Check { Url = "http://www.google.com/" }, new Check { Url = "http://www.github.com/" }, new Check { Url = "http://www.bbc.co.uk/" } } ); var requester = new Mock<IRequester>(); requester.Setup(m => m.Check(It.IsAny<Check>())); var logger = new Mock<ILogger>(); logger.Setup(m => m.Log(It.IsAny<Check>())); var warmer = new Warmer(config.Object, requester.Object, logger.Object); warmer.Warm(); config.Verify(f => f.Checks, Times.Once()); requester.Verify(f => f.Check(It.IsAny<Check>()), Times.Exactly(4)); logger.Verify(f => f.Log(It.IsAny<Check>()), Times.Exactly(4)); logger.Verify(f => f.Close(), Times.Once()); }
public bool SendWarmerCommand(Warmer warmer, string index, string type) { var syncExecutor = new SyncExecute(_traceProvider); return syncExecutor.Execute(() => SendWarmerCommandAsync(warmer, index, type)); }