in tests-integration/Elasticsearch.IntegrationDefaults/IngestionCluster.cs [19:59]
public static ElasticsearchClient CreateElasticsearchClient(
this IEphemeralCluster cluster,
ITestOutputHelper output,
Func<ElasticsearchClientSettings, ElasticsearchClientSettings> updateSettings,
Func<ICollection<Uri>, ICollection<Uri>>? alterNodes = null
)
{
var isCi = !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("CI"));
var nodes = cluster.NodesUris();
if (alterNodes != null) nodes = alterNodes(nodes);
var connectionPool = new StaticNodePool(nodes);
var settings = new ElasticsearchClientSettings(connectionPool)
.RequestTimeout(TimeSpan.FromSeconds(5))
.ServerCertificateValidationCallback(CertificateValidations.AllowAll)
.OnRequestCompleted(d =>
{
try
{
// ON CI only logged failed requests
// Locally we just log everything for ease of development
if (isCi)
{
if (!d.HasSuccessfulStatusCode)
output.WriteLine(d.DebugInformation);
}
else output.WriteLine(d.DebugInformation);
}
catch
{
// ignored
}
})
.EnableDebugMode();
if (cluster.DetectedProxy != None)
{
var proxyUrl = cluster.DetectedProxy == Fiddler ? "ipv4.fiddler" : "localhost";
settings = settings.Proxy(new Uri($"http://{proxyUrl}:8080"), null!, null!);
}
return new ElasticsearchClient(updateSettings(settings));
}