コード例 #1
0
        public async Task ServiceIsDeployedInLowerCase(ConsulMethod consulMethod)
        {
            AddServiceEndPoint(serviceName: _serviceName.ToLower());
            var result = await Start(consulMethod);

            AssertOneDefaultEndpoint(result);
        }
コード例 #2
0
        public async Task ServiceMissingOnStart(ConsulMethod consulMethod)
        {
            var result = await Start(consulMethod);

            result.IsQueryDefined.ShouldBeFalse();
            result.Error.ShouldBeNull();
        }
コード例 #3
0
        public async Task EndpointExists(ConsulMethod consulMethod)
        {
            AddServiceEndPoint();

            var result = await Start(consulMethod);

            AssertOneDefaultEndpoint(result);
        }
コード例 #4
0
        public async Task StartWithError(ConsulMethod consulMethod)
        {
            AddServiceEndPoint();
            SetConsulIsDown();

            var result = await Start(consulMethod);

            result.Error.ShouldNotBeNull();
        }
コード例 #5
0
        public async Task ServiceIsBackAfterBeingMissing(ConsulMethod consulMethod)
        {
            var result = await Start(consulMethod);

            result.IsQueryDefined.ShouldBeFalse();

            result = await GetResultAfter(() => AddServiceEndPoint());

            AssertOneDefaultEndpoint(result);
        }
コード例 #6
0
        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
        }
コード例 #7
0
        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();
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        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)));
        }
コード例 #10
0
        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);
        }
コード例 #11
0
 private Task <EndPointsResult> Start(ConsulMethod consulMethod)
 {
     _consulConfig.LongPolling = (consulMethod == ConsulMethod.LongPolling);
     _consulClient             = _testingKernel.Get <Func <string, IConsulClient> >()(_serviceName);
     return(GetResultAfter(() => _consulClient.Init()));
 }
コード例 #12
0
 private void Start(ConsulMethod consulMethod)
 {
     _consulConfig.UseLongPolling = (consulMethod == ConsulMethod.LongPolling);
     _consulClient = _testingKernel.Get <Func <string, IConsulClient> >()(_serviceName);
 }