From b35ae443dbbb960903b39bf4f5c6ae50792208f2 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Mon, 9 Sep 2019 17:28:19 -0400 Subject: [PATCH 1/3] Use errorContains: E11000 in all spec tests formerly referencing DuplicateKey --- spec/spec_tests/data/transactions/abort.yml | 6 +++--- spec/spec_tests/data/transactions/error-labels.yml | 6 +++--- spec/spec_tests/data/transactions_api/callback-retry.yml | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/spec/spec_tests/data/transactions/abort.yml b/spec/spec_tests/data/transactions/abort.yml index 9b3bc6e442..aa79043232 100644 --- a/spec/spec_tests/data/transactions/abort.yml +++ b/spec/spec_tests/data/transactions/abort.yml @@ -305,10 +305,10 @@ tests: document: _id: 1 result: - # Don't assert on errorCodeName because (after SERVER-38583) the - # DuplicateKey is reported in writeErrors, not as a top-level - # command error. errorLabelsOmit: ["TransientTransactionError", "UnknownTransactionCommitResult"] + # DuplicateKey error code included in the bulk write error message + # returned by the server + errorContains: E11000 # Make sure the server aborted the transaction. - name: insertOne object: collection diff --git a/spec/spec_tests/data/transactions/error-labels.yml b/spec/spec_tests/data/transactions/error-labels.yml index 8b90473ab5..722af4c3b5 100644 --- a/spec/spec_tests/data/transactions/error-labels.yml +++ b/spec/spec_tests/data/transactions/error-labels.yml @@ -25,10 +25,10 @@ tests: - _id: 1 - _id: 1 result: - # Don't assert on errorCodeName because (after SERVER-38583) the - # DuplicateKey is reported in writeErrors, not as a top-level - # command error. errorLabelsOmit: ["TransientTransactionError", "UnknownTransactionCommitResult"] + # DuplicateKey error code included in the bulk write error message + # returned by the server + errorContains: E11000 - name: abortTransaction object: session0 diff --git a/spec/spec_tests/data/transactions_api/callback-retry.yml b/spec/spec_tests/data/transactions_api/callback-retry.yml index ca0342a359..edff016bdb 100644 --- a/spec/spec_tests/data/transactions_api/callback-retry.yml +++ b/spec/spec_tests/data/transactions_api/callback-retry.yml @@ -160,10 +160,10 @@ tests: result: errorLabelsOmit: ["TransientTransactionError", "UnknownTransactionCommitResult"] result: - # Don't assert on errorCodeName because (after SERVER-38583) the - # DuplicateKey is reported in writeErrors, not as a top-level - # command error. errorLabelsOmit: ["TransientTransactionError", "UnknownTransactionCommitResult"] + # DuplicateKey error code included in the bulk write error message + # returned by the server + errorContains: E11000 expectations: - command_started_event: From 5d892e33d4599e13443733e998c80e68523e5e4d Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Mon, 9 Sep 2019 19:48:32 -0400 Subject: [PATCH 2/3] Guard against shards being empty --- spec/support/cluster_config.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec/support/cluster_config.rb b/spec/support/cluster_config.rb index 63837fb455..7770b6efe0 100644 --- a/spec/support/cluster_config.rb +++ b/spec/support/cluster_config.rb @@ -95,6 +95,9 @@ def storage_engine client = ClientRegistry.instance.global_client('root_authorized') if topology == :sharded shards = client.use(:admin).command(listShards: 1).first + if shards['shards'].empty? + raise 'Shards are empty' + end shard = shards['shards'].first address_str = shard['host'].sub(/^.*\//, '').sub(/,.*/, '') client = ClusterTools.instance.direct_client(address_str, From 9cf20c7361d10883940d679f2d568873dfa76024 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Fri, 13 Sep 2019 16:49:03 -0400 Subject: [PATCH 3/3] Fix multiple mongos requirement to only apply in sharded topologies --- spec/support/transactions.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/support/transactions.rb b/spec/support/transactions.rb index dce41c3c5f..f7c1cffc14 100644 --- a/spec/support/transactions.rb +++ b/spec/support/transactions.rb @@ -31,7 +31,7 @@ def define_transactions_spec_tests(test_paths) before do if test.multiple_mongoses? - unless SpecConfig.instance.addresses.length > 1 + if ClusterConfig.instance.topology == :sharded && SpecConfig.instance.addresses.length == 1 skip "Test requires multiple mongoses" end else