Skip to content

Commit a058d0f

Browse files
committed
fix tests.profiling behaviour on a clean checkout like it works on master and 6.x
1 parent f478044 commit a058d0f

File tree

7 files changed

+82
-9
lines changed

7 files changed

+82
-9
lines changed

src/Tests/Tests.Benchmarking/BulkDeserializationBenchmarkTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.IO;
22
using System.Linq;
3+
using System.Reflection;
34
using System.Text;
45
using BenchmarkDotNet.Attributes;
56
using Elasticsearch.Net;

src/Tests/Tests.Core/Tests.Core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</PropertyGroup>
66
<ItemGroup>
77
<ProjectReference Include="..\Tests.Domain\Tests.Domain.csproj" />
8-
<PackageReference Include="Elastic.Xunit" Version="0.1.0-ci20180902T153954" />
8+
<PackageReference Include="Elastic.Xunit" Version="0.1.0-ci20181120T172449" />
99
<PackageReference Include="xunit" Version="2.3.1" />
1010
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
1111
<PackageReference Include="FluentAssertions" Version="4.19.2" />

src/Tests/Tests.Domain/Tests.Domain.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</ItemGroup>
1313
<ItemGroup>
1414
<PackageReference Include="Bogus" Version="22.1.2" />
15-
<PackageReference Include="Elastic.Managed" Version="0.1.0-ci20180902T153954" />
15+
<PackageReference Include="Elastic.Managed" Version="0.1.0-ci20181120T172449" />
1616
<ProjectReference Include="..\Tests.Configuration\Tests.Configuration.csproj" />
1717
</ItemGroup>
1818
</Project>
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
using System;
2+
using System.Threading.Tasks;
3+
using Nest;
4+
using Tests.Domain;
5+
using Tests.Profiling.Framework;
6+
using Tests.Profiling.Framework.Performance;
7+
8+
namespace Tests.Profiling
9+
{
10+
public class BulkProfileTests
11+
{
12+
private static readonly string IndexName = "bulk-profile";
13+
private readonly IElasticClient _client;
14+
15+
public BulkProfileTests(ProfilingCluster cluster)
16+
{
17+
_client = cluster.Client;
18+
19+
if (_client.IndexExists(IndexName).Exists)
20+
_client.DeleteIndex(IndexName);
21+
22+
var createIndexResponse = _client.CreateIndex(IndexName);
23+
24+
if (!createIndexResponse.IsValid)
25+
Console.WriteLine($"invalid response creating index: {createIndexResponse.ServerError?.Error?.Reason}");
26+
}
27+
28+
[Performance(Iterations = 10)]
29+
public void Sync()
30+
{
31+
var bulkResponse = _client.Bulk(b => b
32+
.IndexMany(Developer.Generator.Generate(1000), (bd, d) => bd
33+
.Index(IndexName)
34+
.Document(d)
35+
));
36+
37+
if (!bulkResponse.IsValid)
38+
{
39+
if (bulkResponse.Errors)
40+
foreach (var error in bulkResponse.ItemsWithErrors)
41+
Console.WriteLine($"error with id {error.Id}. message: {error.Error.Reason}");
42+
}
43+
}
44+
45+
[Performance(Iterations = 10)]
46+
public async Task Async()
47+
{
48+
var bulkResponse = await _client.BulkAsync(b => b
49+
.IndexMany(Developer.Generator.Generate(1000), (bd, d) => bd
50+
.Index(IndexName)
51+
.Document(d)
52+
))
53+
.ConfigureAwait(false);
54+
55+
if (!bulkResponse.IsValid)
56+
{
57+
if (bulkResponse.Errors)
58+
foreach (var error in bulkResponse.ItemsWithErrors)
59+
Console.WriteLine($"error with id {error.Id}. message: {error.Error.Reason}");
60+
}
61+
}
62+
}
63+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
public static class Program
2+
{
3+
/// <summary>
4+
/// This file is only included because the Jetbrains profiling self hosting SDK has not yet been pulled down
5+
/// by the build.bat or build.sh root. You are probably seeing this file because you did a fresh checkout and
6+
/// are building this project in the IDE.
7+
/// </summary>
8+
public static void Main()
9+
{
10+
11+
}
12+
}

src/Tests/Tests.Profiling/Framework/ProfilingCluster.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ namespace Tests.Profiling.Framework
55
{
66
public class ProfilingCluster : ClientTestClusterBase
77
{
8-
protected override void SeedCluster()
9-
{
10-
var seeder = new DefaultSeeder(Client);
11-
seeder.DeleteIndicesAndTemplates();
12-
seeder.CreateIndices();
13-
}
8+
protected override void SeedCluster() => new DefaultSeeder(Client).SeedNode();
149
}
1510
}

src/Tests/Tests.Profiling/Tests.Profiling.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
<Reference Include="..\..\..\build\tools\dottrace-selfprofile\JetBrains.Profiler.Windows.dll" />
1414
<Reference Include="..\..\..\build\tools\dottrace-selfprofile\JetBrains.Profiler.Windows.Api.dll" />
1515
<Reference Include="..\..\..\build\tools\dottrace-selfprofile\JetBrains.Profiler.Windows.SelfApi.dll" />
16+
<Compile Remove="DummyProgram.cs" />
1617
</ItemGroup>
1718
<ItemGroup Condition="!Exists('..\..\..\build\tools\dottrace-selfprofile\JetBrains.Profiler.Windows.dll')">
18-
<Compile Remove="Framework\**" />
19+
<Compile Remove="**" />
20+
<Compile Include="DummyProgram.cs" />
1921
</ItemGroup>
2022
<ItemGroup>
2123
<ProjectReference Include="..\Tests.Core\Tests.Core.csproj" />

0 commit comments

Comments
 (0)