Skip to content

Commit

Permalink
do not delete rabbitmq vhost after suite to prevent exceptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-etna committed Apr 20, 2022
1 parent 2af827e commit a0a2f36
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/RabbitMQ.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,21 @@ static public function createVhosts()
*/
static public function deleteVhosts()
{
$client = self::getRabbitMqClient();

foreach (self::$vhosts as $vhost) {
$vhost = str_replace('/', '%2f', $vhost);
$client->delete("/api/vhosts/{$vhost}");
}
// 2022-04: we do not want to delete the vhost(s) from inside the
// test-suite. It has unwanted side-effect: when a vhost is deleted,
// rabbitmq closes all client connections connected to that vhost.
// Then later when php garbage collects the rabbitmq clients and they
// try to properly close connections, we got exceptions that causes
// the test-suite to fail and exit(-1).
// The proper way would be to close all connections we delete the
// vhost, but their lifecycle is managed outside the test-suite,
// and it is way easier to just delete the vhosts outside the
// test-suite, once behat exits.

// $client = self::getRabbitMqClient();
// foreach (self::$vhosts as $vhost) {
// $vhost = str_replace('/', '%2f', $vhost);
// $client->delete("/api/vhosts/{$vhost}");
// }
}
}

0 comments on commit a0a2f36

Please sign in to comment.