public async Task ServiceIsDeployedInLowerCase(ConsulMethod consulMethod) { AddServiceEndPoint(serviceName: _serviceName.ToLower()); var result = await Start(consulMethod); AssertOneDefaultEndpoint(result); }
public async Task ServiceMissingOnStart(ConsulMethod consulMethod) { var result = await Start(consulMethod); result.IsQueryDefined.ShouldBeFalse(); result.Error.ShouldBeNull(); }
public async Task EndpointExists(ConsulMethod consulMethod) { AddServiceEndPoint(); var result = await Start(consulMethod); AssertOneDefaultEndpoint(result); }
public async Task StartWithError(ConsulMethod consulMethod) { AddServiceEndPoint(); SetConsulIsDown(); var result = await Start(consulMethod); result.Error.ShouldNotBeNull(); }
public async Task ServiceIsBackAfterBeingMissing(ConsulMethod consulMethod) { var result = await Start(consulMethod); result.IsQueryDefined.ShouldBeFalse(); result = await GetResultAfter(() => AddServiceEndPoint()); AssertOneDefaultEndpoint(result); }
public async Task ServiceIsDeployedWithNoNodes(ConsulMethod consulMethod) { SetServiceVersion("1.0.0"); var result = await Start(consulMethod); result.IsQueryDefined.ShouldBeTrue(); result.EndPoints.Length.ShouldBe(0); var delays = _dateTimeFake.DelaysRequested.ToArray(); delays.Length.ShouldBeLessThan(4); // shouldn't take too many loops to get the result }
public async Task ServiceBecomesMissing(ConsulMethod consulMethod) { AddServiceEndPoint(); var result = await Start(consulMethod); result.IsQueryDefined.ShouldBeTrue(); result = await GetResultAfter(() => RemoveService()); result.IsQueryDefined.ShouldBeFalse(); result.Error.ShouldBeNull(); }
public async Task EndpointRemoved(ConsulMethod consulMethod) { AddServiceEndPoint(); AddServiceEndPoint("endpointToRemove"); var result = await Start(consulMethod); result.EndPoints.Length.ShouldBe(2); result = await GetResultAfter(() => RemoveServiceEndPoint("endpointToRemove")); AssertOneDefaultEndpoint(result); }
private Task <EndPointsResult> Start(ConsulMethod consulMethod) { var waitForStart = new TaskCompletionSource <bool>(); _getConfigMethod = () => { // When ConsulClient is started, it tries to get config. // We make it wait (for config) on start in order to make sure we get the first result right after the ConsulClient is up waitForStart.Task.GetAwaiter().GetResult(); _getConfigMethod = () => _consulConfig; return(_consulConfig); }; _consulConfig.UseLongPolling = (consulMethod == ConsulMethod.LongPolling); _consulClient = _testingKernel.Get <Func <string, IConsulClient> >()(_serviceName); return(GetResultAfter(() => waitForStart.SetResult(true))); }
public async Task ErrorAfterStart_UseLastKnownEndpoints(ConsulMethod consulMethod) { AddServiceEndPoint(); var resultBeforeError = await Start(ConsulMethod.LongPolling); SetConsulIsDown(); AddServiceEndPoint("another host"); await Task.Delay(1000); var resultAfterError = _consulClient.Result; resultAfterError.EndPoints.ShouldBe(resultBeforeError.EndPoints); var result = await GetResultAfter(SetConsulIsUpAgain); result.Error.ShouldBeNull(); result.EndPoints.Length.ShouldBe(2); }
private Task <EndPointsResult> Start(ConsulMethod consulMethod) { _consulConfig.LongPolling = (consulMethod == ConsulMethod.LongPolling); _consulClient = _testingKernel.Get <Func <string, IConsulClient> >()(_serviceName); return(GetResultAfter(() => _consulClient.Init())); }
private void Start(ConsulMethod consulMethod) { _consulConfig.UseLongPolling = (consulMethod == ConsulMethod.LongPolling); _consulClient = _testingKernel.Get <Func <string, IConsulClient> >()(_serviceName); }