Skip to content

Commit

Permalink
Check an odd corner of Read Prefs spec: a PRIMARY read followed by SE…
Browse files Browse the repository at this point in the history
…CONDARY_PREFERRED goes to secondary and vice versa.
  • Loading branch information
ajdavis committed Oct 26, 2012
1 parent 97c6fe1 commit 1c69bb5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/test_replica_set_connection.py
Expand Up @@ -778,10 +778,18 @@ def test_pinned_member(self):
self.assertTrue(host in conn.secondaries)
assertReadFrom(self, conn, host, ReadPreference.SECONDARY)

# Oddly, we expect PRIMARY_PREFERRED to keep reading from secondary,
# since the secondary is pinned and "matches" the preference.
assertReadFrom(self, conn, host, ReadPreference.PRIMARY_PREFERRED)

# Repin
primary = read_from_which_host(conn, ReadPreference.PRIMARY)
self.assertEqual(conn.primary, primary)
assertReadFrom(self, conn, primary, ReadPreference.NEAREST)
assertReadFrom(self, conn, primary, ReadPreference.PRIMARY_PREFERRED)

# Since the we're pinned to primary we still use it
assertReadFrom(self, conn, primary, ReadPreference.SECONDARY_PREFERRED)

# Repin again
host = read_from_which_host(conn, ReadPreference.SECONDARY)
Expand Down

0 comments on commit 1c69bb5

Please sign in to comment.