Each PSGI app (subroutine) gets its own cache, but the caches are
registered with the Ix::App object so that their caches can be cleared
as needed to prepare to shutdown the system. In production, this is
unlikely to be needed, but in testing we don't want lingering db
connections at global destruction. DBD::Pg gets grumpy and complains.
Calling $app->_shutdown in each test is inelegant, but the TestInstance
system (on another branch) ported from a downstream application can move
the shutdown into the TestInstance's demolish, making the cleanup happen
automatically in tests using a TestInstance.
Note: Rik isn't 100% sure why undefining the app sub isn't sufficient
to clear the cache (in a world where we don't register caches with the
Ix::App object). That may be worth looking into sometime.
With this change, the test suite drops nearly 200 connections in its
total run, as most tests run through a single app object created in the
test's prelude. With a TestInstance, this will happen behind the
scenes.
Each PSGI app (subroutine) gets its own cache, but the caches are registered with the Ix::App object so that their caches can be cleared as needed to prepare to shutdown the system. In production, this is unlikely to be needed, but in testing we don't want lingering db connections at global destruction. DBD::Pg gets grumpy and complains.
Calling $app->_shutdown in each test is inelegant, but the TestInstance system (on another branch) ported from a downstream application can move the shutdown into the TestInstance's demolish, making the cleanup happen automatically in tests using a TestInstance.
Note: Rik isn't 100% sure why undefining the app sub isn't sufficient to clear the cache (in a world where we don't register caches with the Ix::App object). That may be worth looking into sometime.
With this change, the test suite drops nearly 200 connections in its total run, as most tests run through a single app object created in the test's prelude. With a TestInstance, this will happen behind the scenes.