@@ -24,44 +24,76 @@ protected override LazyResponses ClientUsage() => Calls(
2424 protected override bool ExpectIsValid => true ;
2525 protected override int ExpectStatusCode => 200 ;
2626 protected override HttpMethod HttpMethod => HttpMethod . POST ;
27- protected override string UrlPath => $ "/{ CallIsolatedValue } /_bulk";
27+ protected override string UrlPath => $ "/{ CallIsolatedValue } /_bulk?pipeline=default-pipeline ";
2828
2929 protected override bool SupportsDeserialization => false ;
3030
31+ protected override void IntegrationSetup ( IElasticClient client , CallUniqueValues values )
32+ {
33+ var pipelineResponse = client . PutPipeline ( "default-pipeline" , p => p
34+ . Processors ( pr => pr
35+ . Set < Project > ( t => t . Field ( f => f . Description ) . Value ( "Default" ) )
36+ )
37+ ) ;
38+
39+ if ( ! pipelineResponse . IsValid )
40+ throw new Exception ( "Failed to set up pipeline required for bulk" ) ;
41+
42+ pipelineResponse = client . PutPipeline ( "pipeline" , p => p
43+ . Processors ( pr => pr
44+ . Set < Project > ( t => t . Field ( f => f . Description ) . Value ( "Overridden" ) )
45+ )
46+ ) ;
47+
48+ if ( ! pipelineResponse . IsValid )
49+ throw new Exception ( "Failed to set up pipeline required for bulk" ) ;
50+
51+ base . IntegrationSetup ( client , values ) ;
52+ }
53+
3154 protected override object ExpectJson => new object [ ]
3255 {
33- new Dictionary < string , object > { { "index" , new { _type = "project" , _id = Project . Instance . Name } } } ,
56+ new Dictionary < string , object > { { "index" , new { _type = "project" , _id = Project . Instance . Name , pipeline = "pipeline" } } } ,
3457 Project . InstanceAnonymous ,
3558 new Dictionary < string , object > { { "update" , new { _type = "project" , _id = Project . Instance . Name } } } ,
3659 new { doc = new { leadDeveloper = new { firstName = "martijn" } } } ,
3760 new Dictionary < string , object > { { "create" , new { _type = "project" , _id = Project . Instance . Name + "1" } } } ,
3861 Project . InstanceAnonymous ,
3962 new Dictionary < string , object > { { "delete" , new { _type = "project" , _id = Project . Instance . Name + "1" } } } ,
63+ new Dictionary < string , object > { { "create" , new { _type = "project" , _id = Project . Instance . Name + "2" } } } ,
64+ Project . InstanceAnonymous ,
4065 } ;
4166
4267 protected override Func < BulkDescriptor , IBulkRequest > Fluent => d => d
4368 . Index ( CallIsolatedValue )
44- . Index < Project > ( b => b . Document ( Project . Instance ) )
69+ . Pipeline ( "default-pipeline" )
70+ . Index < Project > ( b => b . Document ( Project . Instance ) . Pipeline ( "pipeline" ) )
4571 . Update < Project , object > ( b => b . Doc ( new { leadDeveloper = new { firstName = "martijn" } } ) . Id ( Project . Instance . Name ) )
4672 . Create < Project > ( b => b . Document ( Project . Instance ) . Id ( Project . Instance . Name + "1" ) )
47- . Delete < Project > ( b=> b . Id ( Project . Instance . Name + "1" ) ) ;
48-
73+ . Delete < Project > ( b=> b . Id ( Project . Instance . Name + "1" ) )
74+ . Create < Project > ( b => b . Document ( Project . Instance ) . Id ( Project . Instance . Name + "2" ) ) ;
75+
4976
50- protected override BulkRequest Initializer =>
77+ protected override BulkRequest Initializer =>
5178 new BulkRequest ( CallIsolatedValue )
5279 {
80+ Pipeline = "default-pipeline" ,
5381 Operations = new List < IBulkOperation >
5482 {
55- new BulkIndexOperation < Project > ( Project . Instance ) ,
83+ new BulkIndexOperation < Project > ( Project . Instance ) { Pipeline = "pipeline" } ,
5684 new BulkUpdateOperation < Project , object > ( Project . Instance )
5785 {
5886 Doc = new { leadDeveloper = new { firstName = "martijn" } }
5987 } ,
6088 new BulkCreateOperation < Project > ( Project . Instance )
6189 {
62- Id = Project . Instance . Name + "1"
90+ Id = Project . Instance . Name + "1" ,
6391 } ,
6492 new BulkDeleteOperation < Project > ( Project . Instance . Name + "1" ) ,
93+ new BulkCreateOperation < Project > ( Project . Instance )
94+ {
95+ Id = Project . Instance . Name + "2" ,
96+ } ,
6597 }
6698 } ;
6799
@@ -84,9 +116,12 @@ protected override void ExpectResponse(IBulkResponse response)
84116 item . Shards . Successful . Should ( ) . BeGreaterThan ( 0 ) ;
85117 }
86118
87- var p1 = this . Client . Source < Project > ( Project . Instance . Name , p => p . Index ( CallIsolatedValue ) ) ;
88- p1 . LeadDeveloper . FirstName . Should ( ) . Be ( "martijn" ) ;
89- }
119+ var project1 = this . Client . Source < Project > ( Project . Instance . Name , p => p . Index ( CallIsolatedValue ) ) ;
120+ project1 . LeadDeveloper . FirstName . Should ( ) . Be ( "martijn" ) ;
121+ project1 . Description . Should ( ) . Be ( "Overridden" ) ;
90122
123+ var project2 = this . Client . Source < Project > ( Project . Instance . Name + "2" , p => p . Index ( CallIsolatedValue ) ) ;
124+ project2 . Description . Should ( ) . Be ( "Default" ) ;
125+ }
91126 }
92127}
0 commit comments