Page MenuHomePhabricator

Unit tests should fail when code writes to a DB connection obtained with the DB_REPLICA flag.
Closed, InvalidPublic

Description

Unit tests that interact with the database operate on a single database connection. Since the connection returned for the DB_REPLICA flag is the same as the one returned for the DB_MASTER flag, code that attempts to write to the connection obtained with the DB_REPLICA flag will not fail.

This should be changed so that in tests, asking the LoadBalancer for a DB connection with the DB_REPLICA flag will return a wrapper that prevents write operations.

Event Timeline

daniel triaged this task as Medium priority.Dec 19 2017, 1:48 PM
daniel created this task.
Catrope renamed this task from Unit tests should fail when code writes to a DB connection optianed with the DB_REPLICA flag. to Unit tests should fail when code writes to a DB connection obtained with the DB_REPLICA flag..Dec 19 2017, 2:17 PM

Why only in tests? It would be useful for the same thing to be done in development environments where there is only one DB. That would make it easier for mistakes to be caught in development.

daniel added a comment.EditedDec 19 2017, 3:39 PM

@Catrope yes, I see the point in that. But that should probably be a separate ticket. The mechanism may be the same, but the story is different. I'll file that.

Actually... no. This is all backwards. Hold on, I'll fix the tickets.

daniel closed this task as Invalid.Dec 19 2017, 3:45 PM

no separate ticket needed for this.