예제 #1
0
        public async Task <Auditor> TraceStartup(ClientCall callTrace = null)
        {
            this._cluster = _cluster ?? this.Cluster();
            if (!this.StartedUp)
            {
                this.AssertPoolBeforeStartup?.Invoke(this._cluster.ConnectionPool);
            }
            this.AssertPoolBeforeCall?.Invoke(this._cluster.ConnectionPool);
            this.Response   = this._cluster.ClientCall(callTrace?.RequestOverrides);
            this.AuditTrail = this.Response.ApiCall.AuditTrail;
            if (!this.StartedUp)
            {
                this.AssertPoolAfterStartup?.Invoke(this._cluster.ConnectionPool);
            }
            this.AssertPoolAfterCall?.Invoke(this._cluster.ConnectionPool);

            this._clusterAsync = _clusterAsync ?? this.Cluster();
            if (!this.StartedUp)
            {
                this.AssertPoolBeforeStartup?.Invoke(this._clusterAsync.ConnectionPool);
            }
            this.AssertPoolBeforeCall?.Invoke(this._clusterAsync.ConnectionPool);
            this.ResponseAsync = await this._clusterAsync.ClientCallAsync(callTrace?.RequestOverrides);

            this.AsyncAuditTrail = this.ResponseAsync.ApiCall.AuditTrail;
            if (!this.StartedUp)
            {
                this.AssertPoolAfterStartup?.Invoke(this._clusterAsync.ConnectionPool);
            }
            this.AssertPoolAfterCall?.Invoke(this._clusterAsync.ConnectionPool);
            return(new Auditor(_cluster, _clusterAsync));
        }
예제 #2
0
#pragma warning disable 1998
        public async Task <Auditor> TraceUnexpectedException(ClientCall callTrace, Action <UnexpectedElasticsearchClientException> assert)
#pragma warning restore 1998
        {
            this._cluster = _cluster ?? this.Cluster();
            this.AssertPoolBeforeCall?.Invoke(this._cluster.ConnectionPool);

            Action call      = () => this._cluster.ClientCall(callTrace?.RequestOverrides);
            var    exception = call.ShouldThrowExactly <UnexpectedElasticsearchClientException>()
                               .Subject.First();

            assert(exception);

            this.AuditTrail = exception.AuditTrail;
            this.AssertPoolAfterCall?.Invoke(this._cluster.ConnectionPool);

            this._clusterAsync = _clusterAsync ?? this.Cluster();
            Func <Task> callAsync = async() => await this._clusterAsync.ClientCallAsync(callTrace?.RequestOverrides);

            exception = callAsync.ShouldThrowExactly <UnexpectedElasticsearchClientException>()
                        .Subject.First();
            assert(exception);

            this.AsyncAuditTrail = exception.AuditTrail;
            this.AssertPoolAfterCall?.Invoke(this._clusterAsync.ConnectionPool);
            return(new Auditor(_cluster, _clusterAsync));
        }
예제 #3
0
        public async Task <Auditor> TraceElasticsearchException(ClientCall callTrace, Action <ElasticsearchClientException> assert)
        {
            this._cluster = _cluster ?? this.Cluster();
            this._cluster.ClientThrows(true);
            this.AssertPoolBeforeCall?.Invoke(this._cluster.ConnectionPool);

            Action call      = () => this._cluster.ClientCall(callTrace?.RequestOverrides);
            var    exception = call.ShouldThrowExactly <ElasticsearchClientException>()
                               .Subject.First();

            assert(exception);

            this.AuditTrail = exception.AuditTrail;
            this.AssertPoolAfterCall?.Invoke(this._cluster.ConnectionPool);

            this._clusterAsync = _clusterAsync ?? this.Cluster();
            this._clusterAsync.ClientThrows(true);
            Func <Task> callAsync = async() => await this._clusterAsync.ClientCallAsync(callTrace?.RequestOverrides);

            exception = callAsync.ShouldThrowExactly <ElasticsearchClientException>()
                        .Subject.First();
            assert(exception);

            this.AsyncAuditTrail = exception.AuditTrail;
            this.AssertPoolAfterCall?.Invoke(this._clusterAsync.ConnectionPool);
            var audit = new Auditor(_cluster, _clusterAsync);

            return(await audit.TraceElasticsearchExceptionOnResponse(callTrace, assert));
        }
예제 #4
0
        private async Task TraceException <TException>(ClientCall callTrace, Action <TException> assert)
            where TException : ElasticsearchClientException
        {
            this._cluster = _cluster ?? this.Cluster();
            this._cluster.ClientThrows(true);
            this.AssertPoolBeforeCall?.Invoke(this._cluster.ConnectionPool);

            Action call      = () => this._cluster.ClientCall(callTrace?.RequestOverrides);
            var    exception = call.ShouldThrowExactly <TException>()
                               .Subject.First();

            assert(exception);

            this.AuditTrail = exception.AuditTrail;
            this.AssertPoolAfterCall?.Invoke(this._cluster.ConnectionPool);

            this._clusterAsync = _clusterAsync ?? this.Cluster();
            this._clusterAsync.ClientThrows(true);
            Func <Task> callAsync = async() => await this._clusterAsync.ClientCallAsync(callTrace?.RequestOverrides);

            exception = callAsync.ShouldThrowExactly <TException>()
                        .Subject.First();
            assert(exception);

            this.AsyncAuditTrail = exception.AuditTrail;
            this.AssertPoolAfterCall?.Invoke(this._clusterAsync.ConnectionPool);
        }
예제 #5
0
		public async Task<Auditor> TraceElasticsearchException(ClientCall callTrace, Action<ElasticsearchClientException> assert)
		{
			this._cluster  = _cluster ?? this.Cluster();
			this._cluster.ClientThrows(true);
			this.AssertPoolBeforeCall?.Invoke(this._cluster.ConnectionPool);

			Action call = () => this._cluster.ClientCall(callTrace?.RequestOverrides);
			var exception = call.ShouldThrowExactly<ElasticsearchClientException>()
				.Subject.First();
			assert(exception);

			this.AuditTrail = exception.AuditTrail;
			this.AssertPoolAfterCall?.Invoke(this._cluster.ConnectionPool);

			this._clusterAsync = _clusterAsync ?? this.Cluster();
			this._clusterAsync.ClientThrows(true);
			Func<Task> callAsync = async () => await this._clusterAsync.ClientCallAsync(callTrace?.RequestOverrides);
			exception = callAsync.ShouldThrowExactly<ElasticsearchClientException>()
				.Subject.First();
			assert(exception);

			this.AsyncAuditTrail = exception.AuditTrail;
			this.AssertPoolAfterCall?.Invoke(this._clusterAsync.ConnectionPool);
			var audit  = new Auditor(_cluster, _clusterAsync);
			return await audit.TraceElasticsearchExceptionOnResponse(callTrace, assert);
		}
예제 #6
0
        public async Task <Auditor> TraceElasticsearchExceptionOnResponse(ClientCall callTrace, Action <ElasticsearchClientException> assert)
        {
            this._cluster = _cluster ?? this.Cluster();
            this._cluster.ClientThrows(false);
            this.AssertPoolBeforeCall?.Invoke(this._cluster.ConnectionPool);

            Action call = () => { this.Response = this._cluster.ClientCall(callTrace?.RequestOverrides); };

            call.ShouldNotThrow();
            this.Response.IsValid.Should().BeFalse();
            var exception = this.Response.ApiCall.OriginalException as ElasticsearchClientException;

            exception.Should().NotBeNull("OriginalException on response is not expected ElasticsearchClientException");
            assert(exception);

            this.AuditTrail = exception.AuditTrail;
            this.AssertPoolAfterCall?.Invoke(this._cluster.ConnectionPool);

            this._clusterAsync = _clusterAsync ?? this.Cluster();
            this._clusterAsync.ClientThrows(false);
            Func <Task> callAsync = async() => { this.ResponseAsync = await this._clusterAsync.ClientCallAsync(callTrace?.RequestOverrides); };

            callAsync.ShouldNotThrow();
            this.ResponseAsync.IsValid.Should().BeFalse();
            exception = this.ResponseAsync.ApiCall.OriginalException as ElasticsearchClientException;
            exception.Should().NotBeNull("OriginalException on response is not expected ElasticsearchClientException");
            assert(exception);

            this.AsyncAuditTrail = exception.AuditTrail;
            this.AssertPoolAfterCall?.Invoke(this._clusterAsync.ConnectionPool);
            var audit = new Auditor(_cluster, _clusterAsync);

            return(audit);
        }
예제 #7
0
        public void ChangeTime(Func <DateTime, DateTime> selector)
        {
            this._cluster      = _cluster ?? this.Cluster();
            this._clusterAsync = _clusterAsync ?? this.Cluster();

            this._cluster.ChangeTime(selector);
            this._clusterAsync.ChangeTime(selector);
        }
예제 #8
0
		public void ChangeTime(Func<DateTime, DateTime> selector)
		{
			this._cluster  = _cluster ?? this.Cluster();
			this._clusterAsync = _clusterAsync ?? this.Cluster();

			this._cluster.ChangeTime(selector);
			this._clusterAsync.ChangeTime(selector);
		}
예제 #9
0
        public async Task <Auditor> TraceStartup()
        {
            this._cluster = _cluster ?? this.Cluster();
            this.AssertPoolBeforeCall?.Invoke(this._cluster.ConnectionPool);
            this.Response = this._cluster.ClientCall();
            this.AssertPoolAfterCall?.Invoke(this._cluster.ConnectionPool);

            this._clusterAsync = _clusterAsync ?? this.Cluster();
            this.ResponseAsync = await this._clusterAsync.ClientCallAsync();

            this.AssertPoolAfterCall?.Invoke(this._clusterAsync.ConnectionPool);
            return(new Auditor(_cluster, _clusterAsync));
        }
예제 #10
0
		public async Task<Auditor> TraceStartup(ClientCall callTrace = null)
		{
			this._cluster  = _cluster ?? this.Cluster();
			this.AssertPoolBeforeCall?.Invoke(this._cluster.ConnectionPool);
			this.Response = this._cluster.ClientCall(callTrace?.RequestOverrides);
			this.AuditTrail = this.Response.ApiCall.AuditTrail;
			this.AssertPoolAfterCall?.Invoke(this._cluster.ConnectionPool);

			this._clusterAsync = _clusterAsync ?? this.Cluster();
			this.ResponseAsync = await this._clusterAsync.ClientCallAsync(callTrace?.RequestOverrides);
			this.AsyncAuditTrail = this.ResponseAsync.ApiCall.AuditTrail;
			this.AssertPoolAfterCall?.Invoke(this._clusterAsync.ConnectionPool);
			return new Auditor(_cluster, _clusterAsync);
		}
예제 #11
0
 private Auditor(VirtualizedCluster cluster, VirtualizedCluster clusterAsync)
 {
     _cluster      = cluster;
     _clusterAsync = clusterAsync;
 }
예제 #12
0
 private Auditor(VirtualizedCluster cluster, VirtualizedCluster clusterAsync)
 {
     _cluster       = cluster;
     _clusterAsync  = clusterAsync;
     this.StartedUp = true;
 }
예제 #13
0
#pragma warning disable 1998
		public async Task<Auditor> TraceElasticsearchExceptionOnResponse(ClientCall callTrace, Action<ElasticsearchClientException> assert)
#pragma warning restore 1998
		{
			this._cluster  = _cluster ?? this.Cluster();
			this._cluster.ClientThrows(false);
			this.AssertPoolBeforeCall?.Invoke(this._cluster.ConnectionPool);

			Action call = () => { this.Response = this._cluster.ClientCall(callTrace?.RequestOverrides); };
			call.ShouldNotThrow();

			this.Response.IsValid.Should().BeFalse();
			var exception = this.Response.ApiCall.OriginalException as ElasticsearchClientException;
			exception.Should().NotBeNull("OriginalException on response is not expected ElasticsearchClientException");
			assert(exception);

			this.AuditTrail = exception.AuditTrail;
			this.AssertPoolAfterCall?.Invoke(this._cluster.ConnectionPool);

			this._clusterAsync = _clusterAsync ?? this.Cluster();
			this._clusterAsync.ClientThrows(false);
			Func<Task> callAsync = async () => { this.ResponseAsync = await this._clusterAsync.ClientCallAsync(callTrace?.RequestOverrides); };
			callAsync.ShouldNotThrow();
			this.ResponseAsync.IsValid.Should().BeFalse();
			exception = this.ResponseAsync.ApiCall.OriginalException as ElasticsearchClientException;
			exception.Should().NotBeNull("OriginalException on response is not expected ElasticsearchClientException");
			assert(exception);

			this.AsyncAuditTrail = exception.AuditTrail;
			this.AssertPoolAfterCall?.Invoke(this._clusterAsync.ConnectionPool);
			var audit  = new Auditor(_cluster, _clusterAsync);

			return audit;
		}
예제 #14
0
		private Auditor(VirtualizedCluster cluster, VirtualizedCluster clusterAsync)
		{
			_cluster = cluster;
			_clusterAsync = clusterAsync;
		}
예제 #15
0
#pragma warning disable 1998
		public async Task<Auditor> TraceUnexpectedException(ClientCall callTrace, Action<UnexpectedElasticsearchClientException> assert)
#pragma warning restore 1998
		{
			this._cluster  = _cluster ?? this.Cluster();
			this.AssertPoolBeforeCall?.Invoke(this._cluster.ConnectionPool);

			Action call = () => this._cluster.ClientCall(callTrace?.RequestOverrides);
			var exception = call.ShouldThrowExactly<UnexpectedElasticsearchClientException>()
				.Subject.First();
			assert(exception);

			this.AuditTrail = exception.AuditTrail;
			this.AssertPoolAfterCall?.Invoke(this._cluster.ConnectionPool);

			this._clusterAsync = _clusterAsync ?? this.Cluster();
			Func<Task> callAsync = async () => await this._clusterAsync.ClientCallAsync(callTrace?.RequestOverrides);
			exception = callAsync.ShouldThrowExactly<UnexpectedElasticsearchClientException>()
				.Subject.First();
			assert(exception);

			this.AsyncAuditTrail = exception.AuditTrail;
			this.AssertPoolAfterCall?.Invoke(this._clusterAsync.ConnectionPool);
			return new Auditor(_cluster, _clusterAsync);
		}