|
13 | 13 | using EventStore.Core.Authorization;
|
14 | 14 | using EventStore.Core.Bus;
|
15 | 15 | using EventStore.Core.Certificates;
|
16 |
| -using EventStore.Core.LogAbstraction; |
17 | 16 | using EventStore.Core.Messages;
|
18 | 17 | using EventStore.Core.Services.Monitoring;
|
19 | 18 | using EventStore.Core.Tests.Http;
|
|
24 | 23 | using Microsoft.AspNetCore.Hosting;
|
25 | 24 | using Microsoft.AspNetCore.Server.Kestrel.Core;
|
26 | 25 | using Microsoft.AspNetCore.Server.Kestrel.Https;
|
27 |
| -using Microsoft.AspNetCore.TestHost; |
28 | 26 | using ILogger = Serilog.ILogger;
|
29 | 27 | using EventStore.Core.Services.Storage.ReaderIndex;
|
30 | 28 |
|
@@ -56,8 +54,6 @@ public class MiniClusterNode<TLogFormat, TStreamId> {
|
56 | 54 | public VNodeState NodeState = VNodeState.Unknown;
|
57 | 55 | private readonly IWebHost _host;
|
58 | 56 |
|
59 |
| - private readonly TestServer _kestrelTestServer; |
60 |
| - |
61 | 57 | private static bool EnableHttps() {
|
62 | 58 | return !RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
|
63 | 59 | }
|
@@ -168,8 +164,7 @@ public MiniClusterNode(string pathname, int debugIndex, IPEndPoint internalTcp,
|
168 | 164 | GC.MaxGeneration == 0
|
169 | 165 | ? "NON-GENERATION (PROBABLY BOEHM)"
|
170 | 166 | : $"{GC.MaxGeneration + 1} GENERATIONS", "DBPATH:", _dbPath, "ExTCP ENDPOINT:",
|
171 |
| - ExternalTcpEndPoint, "ExHTTP ENDPOINT:", |
172 |
| - HttpEndPoint); |
| 167 | + ExternalTcpEndPoint, "ExHTTP ENDPOINT:", HttpEndPoint); |
173 | 168 |
|
174 | 169 | var logFormatFactory = LogFormatHelper<TLogFormat, TStreamId>.LogFormatFactory;
|
175 | 170 | Node = new ClusterVNode<TStreamId>(options, logFormatFactory, new AuthenticationProviderFactory(
|
@@ -210,10 +205,6 @@ public MiniClusterNode(string pathname, int debugIndex, IPEndPoint internalTcp,
|
210 | 205 | })
|
211 | 206 | .UseStartup(Node.Startup)
|
212 | 207 | .Build();
|
213 |
| - |
214 |
| - _kestrelTestServer = new TestServer(new WebHostBuilder() |
215 |
| - .UseKestrel() |
216 |
| - .UseStartup(Node.Startup)); |
217 | 208 | }
|
218 | 209 |
|
219 | 210 | public void Start() {
|
@@ -257,24 +248,31 @@ void WaitForAdminUser(StorageMessage.EventCommitted m) {
|
257 | 248 |
|
258 | 249 | _host.Start();
|
259 | 250 | Node.Start();
|
260 |
| - |
261 | 251 | }
|
262 |
| - |
| 252 | + |
263 | 253 | public HttpClient CreateHttpClient() {
|
264 |
| - return new HttpClient(_kestrelTestServer.CreateHandler()); |
| 254 | + var httpClient = new HttpClient(new SocketsHttpHandler { |
| 255 | + AllowAutoRedirect = false, |
| 256 | + SslOptions = { |
| 257 | + RemoteCertificateValidationCallback = delegate { return true; } |
| 258 | + } |
| 259 | + }, true); |
| 260 | + |
| 261 | + var scheme = Node.DisableHttps ? "http://" : "https://"; |
| 262 | + httpClient.BaseAddress = new Uri($"{scheme}{HttpEndPoint}"); |
| 263 | + return httpClient; |
265 | 264 | }
|
266 | 265 |
|
267 | 266 | public async Task Shutdown(bool keepDb = false) {
|
268 | 267 | StoppingTime.Start();
|
269 |
| - _kestrelTestServer?.Dispose(); |
270 |
| - await Node.StopAsync().WithTimeout(TimeSpan.FromSeconds(20)); |
| 268 | + _host?.Dispose(); |
| 269 | + await Node.StopAsync().WithTimeout(TimeSpan.FromSeconds(20)); |
271 | 270 |
|
272 | 271 | // the same message 'BecomeShutdown' triggers the disposal of the ReadIndex
|
273 | 272 | // and also the notification here that the node as stopped so there is a race.
|
274 | 273 | // For now let's wait for a moment before we try to delete the directory.
|
275 | 274 | await Task.Delay(500);
|
276 |
| - |
277 |
| - _host?.Dispose(); |
| 275 | + |
278 | 276 | if (!keepDb)
|
279 | 277 | TryDeleteDirectory(_dbPath);
|
280 | 278 |
|
|
0 commit comments