From 675884128ee61da36b910050153861278f42e8cb Mon Sep 17 00:00:00 2001 From: Shreyas Kalyan Date: Wed, 13 May 2020 11:24:50 -0700 Subject: SERVER-47964 Add OCSP Sharding tests --- jstests/ocsp/ocsp_sharding_basic.js | 86 +++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 jstests/ocsp/ocsp_sharding_basic.js diff --git a/jstests/ocsp/ocsp_sharding_basic.js b/jstests/ocsp/ocsp_sharding_basic.js new file mode 100644 index 00000000000..e7f6cb8f4e4 --- /dev/null +++ b/jstests/ocsp/ocsp_sharding_basic.js @@ -0,0 +1,86 @@ +// Check that OCSP verification works +// @tags: [requires_http_client] + +load("jstests/ocsp/lib/mock_ocsp.js"); + +(function() { +"use strict"; + +if (determineSSLProvider() === "apple") { + return; +} + +const ocsp_options = { + sslMode: "requireSSL", + sslPEMKeyFile: OCSP_SERVER_CERT, + sslCAFile: OCSP_CA_CERT, + sslAllowInvalidHostnames: "", +}; + +const sharding_config = { + shards: 1, + mongos: 1, + other: { + configOptions: ocsp_options, + mongosOptions: ocsp_options, + rsOptions: ocsp_options, + shardOptions: ocsp_options, + } +}; + +function test() { + assert.doesNotThrow(() => { + let st = new ShardingTest(sharding_config); + + st.getConnNames(); + st.stop(); + }); +} + +clearOCSPCache(); + +test(); + +let mock_ocsp = new MockOCSPServer("", 1000); +mock_ocsp.start(); + +clearOCSPCache(); + +test(); + +mock_ocsp.stop(); + +// We don't want to invoke the hang analyzer because we +// expect this test to fail by timing out +MongoRunner.runHangAnalyzer.disable(); + +clearOCSPCache(); + +var st = new ShardingTest(sharding_config); + +mock_ocsp = new MockOCSPServer(FAULT_REVOKED, 1); +mock_ocsp.start(); + +const err = assert.throws(() => { + st.restartMongos(0); +}); + +mock_ocsp.stop(); + +const errMsg = err.toString(); + +assert.gte(errMsg.search("assert.soon failed"), 0, "Test failed for wrong reason: " + err); + +sleep(2000); + +MongoRunner.runHangAnalyzer.enable(); + +mock_ocsp = new MockOCSPServer("", 1000); +mock_ocsp.start(); + +// Get the mongos back up again so that we can shutdown the ShardingTest. +st.restartMongos(0); + +mock_ocsp.stop(); +st.stop(); +}()); \ No newline at end of file -- cgit v1.2.1