@@ -4211,6 +4211,22 @@ test_hint_pooled_command_primary (void)
4211
4211
_test_bulk_hint (true, true);
4212
4212
}
4213
4213
4214
+ // test_bulk_reply_w0_finished returns true when the last unacknowledged write
4215
+ // has applied in test_bulk_reply_w0.
4216
+ static bool
4217
+ test_bulk_reply_w0_finished (mongoc_collection_t * coll )
4218
+ {
4219
+ bson_error_t error ;
4220
+ int64_t count =
4221
+ mongoc_collection_count_documents (coll ,
4222
+ tmp_bson ("{'finished': true}" ),
4223
+ NULL /* opts */ ,
4224
+ NULL /* read_prefs */ ,
4225
+ NULL /* reply */ ,
4226
+ & error );
4227
+ ASSERT_OR_PRINT (-1 != count , error );
4228
+ return count == 1 ;
4229
+ }
4214
4230
4215
4231
static void
4216
4232
test_bulk_reply_w0 (void )
@@ -4233,12 +4249,18 @@ test_bulk_reply_w0 (void)
4233
4249
mongoc_bulk_operation_update (
4234
4250
bulk , tmp_bson ("{}" ), tmp_bson ("{'$set': {'x': 1}}" ), false);
4235
4251
mongoc_bulk_operation_remove (bulk , tmp_bson ("{}" ));
4252
+ mongoc_bulk_operation_insert (bulk , tmp_bson ("{'finished': true}" ));
4236
4253
4237
4254
ASSERT_OR_PRINT (mongoc_bulk_operation_execute (bulk , & reply , & error ),
4238
4255
error );
4239
4256
4240
4257
ASSERT (bson_empty (& reply ));
4241
4258
4259
+ // Wait for the last insert to finish applying before proceeding to the next
4260
+ // test. Otherwise, the commands may trigger failpoints of other tests (see
4261
+ // CDRIVER-4539).
4262
+ WAIT_UNTIL (test_bulk_reply_w0_finished (collection ));
4263
+
4242
4264
bson_destroy (& reply );
4243
4265
mongoc_bulk_operation_destroy (bulk );
4244
4266
bson_destroy (& opts );
@@ -4947,6 +4969,7 @@ test_bulk_write_multiple_errors (void *unused)
4947
4969
4948
4970
client = test_framework_new_default_client ();
4949
4971
BSON_ASSERT (client );
4972
+ mongoc_client_set_appname (client , "test_bulk_write_multiple_errors" );
4950
4973
4951
4974
collection = get_test_collection (client , "test_bulk_write_multiple_errors" );
4952
4975
BSON_ASSERT (collection );
@@ -4955,15 +4978,13 @@ test_bulk_write_multiple_errors (void *unused)
4955
4978
// the first error.
4956
4979
bson_append_bool (& opts , "ordered" , 7 , false);
4957
4980
bulk = mongoc_collection_create_bulk_operation_with_opts (collection , & opts );
4958
- // Insert three documents. This is sent as one "insert" command to the
4959
- // server.
4960
- // configure fail point
4981
+ // Use appName to isolate the failpoint to this test.
4961
4982
bool ret = mongoc_client_command_simple (
4962
4983
client ,
4963
4984
"admin" ,
4964
- tmp_bson (
4965
- "{'configureFailPoint ': 'failCommand ', 'mode': {'times': 2}, "
4966
- "'data': {'failCommands': ['insert', 'delete'] , 'errorCode ': 8 }}" ),
4985
+ tmp_bson ("{'configureFailPoint': 'failCommand', 'mode': {'times': 2}, "
4986
+ "'data': {'failCommands ': ['insert ', 'delete'], 'errorCode': "
4987
+ "8 , 'appName ': 'test_bulk_write_multiple_errors' }}" ),
4967
4988
NULL ,
4968
4989
NULL ,
4969
4990
& error );
@@ -5307,5 +5328,7 @@ test_bulk_install (TestSuite *suite)
5307
5328
test_bulk_write_multiple_errors ,
5308
5329
NULL ,
5309
5330
NULL ,
5310
- test_framework_skip_if_no_failpoint );
5331
+ test_framework_skip_if_no_failpoint ,
5332
+ /* Require server 4.2 for failCommand appName */
5333
+ test_framework_skip_if_max_wire_version_less_than_8 );
5311
5334
}
0 commit comments