public async Task BenchmarkingPersistsResults()

in tests-integration/Elastic.CommonSchema.BenchmarkDotNetExporter.IntegrationTests/BdNetExporterTests.cs [53:109]


		public async Task BenchmarkingPersistsResults()
		{
			var url = Client.ElasticsearchClientSettings.NodePool.Nodes.First().Uri;
			IChannelDiagnosticsListener listener = null;
			var options = new ElasticsearchBenchmarkExporterOptions(url)
			{
				GitBranch = "externally-provided-branch",
				GitCommitMessage = "externally provided git commit message",
				GitRepositoryIdentifier = "repository",
				BootstrapMethod = BootstrapMethod.Silent,
				ChannelDiagnosticsCallback = (l) => listener = l
			};
			var exporter = new ElasticsearchBenchmarkExporter(options);
			var config = CreateDefaultConfig().AddExporter(exporter);
			var summary = BenchmarkRunner.Run(typeof(Md5VsSha256), config);

			// ensure publication was success
			listener.Should().NotBeNull();
			listener.PublishSuccess.Should().BeTrue("{0}", listener);

			if (summary.HasCriticalValidationErrors)
			{
				var errors = summary.ValidationErrors.Where(v => v.IsCritical).Select(v => v.Message);
				throw new Exception($"summary has critical validation errors: {string.Join(Environment.NewLine, errors)}");
			}

			// TODO: Temporarily disabled while we wait for ECS to be updated on different branch
			// var template = Client.Indices.GetTemplate(options.TemplateName);
			// if (!template.IsValid)
			//	throw new Exception(template.DebugInformation);

			var indexName = $"benchmarks-dotnet-{options.DataStreamNamespace}";
			var indexExists = await Client.Indices.ExistsAsync(indexName);
			if (!indexExists.IsValidResponse)
				throw new Exception(indexExists.DebugInformation);

			await Client.Indices.RefreshAsync(indexName);

			var searchResponse = await Client.SearchAsync<BenchmarkDocument>(s => s.Index(indexName).TrackTotalHits(new TrackHits(true)));
			if (!searchResponse.IsValidResponse || searchResponse.Total == 0)
				throw new Exception(searchResponse.DebugInformation);

			var doc = searchResponse.Documents.First();

			doc.Timestamp.Should().NotBeNull().And.BeCloseTo(DateTimeOffset.UtcNow, precision: 600000);

			doc.Benchmark.Should().NotBeNull();

			// Not asserting success until CI gets more stable
			if (doc.Benchmark.Success)
			{
				doc.Benchmark.Max.Should().BeGreaterThan(0);
				doc.Event.Duration.Should().BeGreaterThan(0);
				//searchResponse.Total.Should().Be(summary.BenchmarksCases.Length);
				searchResponse.Total.Should().BeGreaterThan(0);
			}
		}