title: Check MongoDB database instance is a replica set
body: <p>I'm writing tests for functions that use transactions.</p>
  <p><a href="https://stackoverflow.com/q/51238986/4653485">Transactions only work on replica sets or mongos</a>:</p>
  <pre><code>pymongo.errors.OperationFailure: Transaction numbers are only allowed on a replica set member or mongos, full error: {'ok': 0.0, 'errmsg': 'Transaction numbers are only allowed on a replica set member or mongos', 'code': 20, 'codeName': 'IllegalOperation'}
  </code></pre>
  <p>I would like those tests to be skipped if the database is a standalone mongod instance.</p>
  <p>How can I check from Python code (e.g. with a pymongo function) that I'm using an adequate environment?</p>
  <p>I can configure the CI Pipeline to use a replica set. I can, and did, configure that on my machine. But I don't want those few tests to be a hassle for potential contributors, so I'd rather skip them.</p>
  <p>Alternatively, I could catch the <code>OperationFailure</code> and try to ensure it is exactly the error above, not another <code>OperationFailure</code>, by matching the string, but this would be a sorry workaround.</p>
  <hr />
  <p>Perhaps I could use something like</p>
  <pre><code>MongoClient('localhost', 27017).admin.command(&quot;replSetGetStatus&quot;)
  </code></pre>
  <p>Before going through a tough trial and error session, I'd be happy to get an informed advice.</p>