Add some simple tests to sanity check the time machine gc.
This commit is contained in:
parent
b154e7acef
commit
d306e37e9d
1 changed files with 30 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
||||||
import unittest
|
import unittest
|
||||||
|
import time
|
||||||
|
|
||||||
from app import app, storage
|
from app import app, storage
|
||||||
from initdb import setup_database_for_testing, finished_database_for_testing
|
from initdb import setup_database_for_testing, finished_database_for_testing
|
||||||
|
@ -210,5 +211,34 @@ class TestGarbageColection(unittest.TestCase):
|
||||||
self.gcNow(repository)
|
self.gcNow(repository)
|
||||||
self.assertNotDeleted(repository, 'i1', 'i2', 'i3', 't1', 't2', 't3', 'f1', 'f2')
|
self.assertNotDeleted(repository, 'i1', 'i2', 'i3', 't1', 't2', 't3', 'f1', 'f2')
|
||||||
|
|
||||||
|
def test_time_machine_no_gc(self):
|
||||||
|
""" Repository has two tags with shared images. Deleting the tag should not remove any images
|
||||||
|
"""
|
||||||
|
repository = self.createRepository(latest=['i1', 'i2', 'i3'], other=['i1', 'f1'])
|
||||||
|
self._set_tag_expiration_policy(repository.namespace_user.username, 60*60*24)
|
||||||
|
|
||||||
|
self.deleteTag(repository, 'latest')
|
||||||
|
self.assertNotDeleted(repository, 'i2', 'i3')
|
||||||
|
self.assertNotDeleted(repository, 'i1', 'f1')
|
||||||
|
|
||||||
|
def test_time_machine_gc(self):
|
||||||
|
""" Repository has two tags with shared images. Deleting the second tag should cause the images
|
||||||
|
for the first deleted tag to gc.
|
||||||
|
"""
|
||||||
|
repository = self.createRepository(latest=['i1', 'i2', 'i3'], other=['i1', 'f1'])
|
||||||
|
|
||||||
|
self._set_tag_expiration_policy(repository.namespace_user.username, 1)
|
||||||
|
|
||||||
|
self.deleteTag(repository, 'latest')
|
||||||
|
self.assertNotDeleted(repository, 'i2', 'i3')
|
||||||
|
self.assertNotDeleted(repository, 'i1', 'f1')
|
||||||
|
|
||||||
|
time.sleep(2)
|
||||||
|
|
||||||
|
self.deleteTag(repository, 'other') # This will cause the images associated with latest to gc
|
||||||
|
self.assertDeleted(repository, 'i2', 'i3')
|
||||||
|
self.assertNotDeleted(repository, 'i1', 'f1')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Reference in a new issue