class
ActiveStorage::Blob::PurgeableTest
- ActiveStorage::Blob::PurgeableTest
- Minitest::Test
- Minitest::Runnable
- Reference
- Object
Overview
A leak is a count, so the counts are what these assert: the rows of the three tables and the objects under the service root, before and after a purge. :nodoc:
Defined in:
active_storage/blob/purgeable_test.crConstant Summary
-
AVATAR_PATH =
(Path["/woodpecker/src/codeberg.org/miry/marten-rails-bridge/src/active_storage/blob"].join("../../../examples/demo/src/assets/images/avatar.jpg")).normalize.to_s -
The 1600x1200 image the demo serves, committed next to it.
-
BLOB_KEY =
"gz0zdzhk0yn6zjhxfzl6qt1ys5rj" -
CONTENT =
"0123456789abcdef"
Instance Method Summary
- #setup
- #teardown
- #test_delete_files_removes_the_objects_and_leaves_the_row
-
#test_purge_asks_for_no_prefix_when_the_blob_is_not_an_image
Rails guards the prefix removal with
image?, so a service is never asked to list a prefix no variant can be stored under. -
#test_purge_clears_the_prefix_of_this_blob_only
A wrong prefix would take the objects of every other key sharded next to it, because
variants/reads asva/rifor all of them. -
#test_purge_leaves_no_row_and_no_object_behind
The leak this exists for, in the shape it was measured: a blob with two tracked variants and the derived-key object of a third, where only the original used to go.
-
#test_purge_refuses_a_blob_that_is_still_attached
Rails refuses too, through a
before_destroyguard, but swallows the error so the caller is told nothing. - #test_purge_refuses_before_it_removes_any_variant
-
#test_purge_removes_a_variant_image_although_it_is_attached
The variant image blobs are attached, to their variant record.
-
#test_purge_removes_every_image_attached_to_a_variant_record
A request that loses the race in
ActiveStorage::VariantWithRecord#processattaches a second image to the same record, whichVariantRecord#imagenever reads. - #test_purge_removes_nothing_for_a_blob_that_was_never_saved
- #test_purge_removes_the_derived_key_object
- #test_purge_removes_the_row_and_the_object_of_a_blob_with_no_variant
- #test_purge_removes_the_variant_image_blob_with_the_row_holding_it
- #test_purge_twice_does_not_raise
Instance Method Detail
Rails guards the prefix removal with image?, so a service is never asked to list a prefix no
variant can be stored under. On S3 that guard is one request.
A wrong prefix would take the objects of every other key sharded next to it, because
variants/ reads as va/ri for all of them.
The leak this exists for, in the shape it was measured: a blob with two tracked variants and the derived-key object of a third, where only the original used to go.
Rails refuses too, through a before_destroy guard, but swallows the error so the caller is
told nothing. Here the refusal is the return value.
The variant image blobs are attached, to their variant record. The guard must not see them, or a purge would stop at the first variant it reached.
A request that loses the race in ActiveStorage::VariantWithRecord#process attaches a second
image to the same record, which VariantRecord#image never reads. It still has to go.