diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-11-25 12:49:54 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-11-25 12:49:54 +0100 |
commit | 50f6817ce99f3870e1e8dea92eaa35a0c40553ba (patch) | |
tree | af5dc3fbc1755312e2c8dbe28eab6b3a13d1693e /tests | |
parent | 60682e17047df19c9486bfc21a993e08bbfce5ce (diff) | |
parent | a95d4c2b22e2cf0deb4958bc3aa3b20ed9d0463c (diff) | |
download | nextcloud-server-50f6817ce99f3870e1e8dea92eaa35a0c40553ba.tar.gz nextcloud-server-50f6817ce99f3870e1e8dea92eaa35a0c40553ba.zip |
Merge pull request #20439 from owncloud/etag-propagate-in-storage
Take submount etag into account for folder etags
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/files/cache/changepropagator.php | 33 | ||||
-rw-r--r-- | tests/lib/files/cache/updaterlegacy.php | 47 | ||||
-rw-r--r-- | tests/lib/files/etagtest.php | 1 |
3 files changed, 43 insertions, 38 deletions
diff --git a/tests/lib/files/cache/changepropagator.php b/tests/lib/files/cache/changepropagator.php index 1b56da5e97c..9108330eb9b 100644 --- a/tests/lib/files/cache/changepropagator.php +++ b/tests/lib/files/cache/changepropagator.php @@ -94,4 +94,37 @@ class ChangePropagator extends \Test\TestCase { $this->assertEquals(100, $time - $cache->get('foo')['mtime']); $this->assertEquals(100, $time - $cache->get('foo/bar')['mtime']); } + + public function testPropagateCrossStorage() { + $storage = new Temporary(); + $this->view->mkdir('/foo'); + Filesystem::mount($storage, [], $this->view->getAbsolutePath('/foo/submount')); + $this->view->mkdir('/foo/submount/bar'); + $this->view->file_put_contents('/foo/submount/bar/sad.txt', 'qwerty'); + + $oldInfo1 = $this->view->getFileInfo('/'); + $oldInfo2 = $this->view->getFileInfo('/foo'); + $oldInfo3 = $this->view->getFileInfo('/foo/submount'); + $oldInfo4 = $this->view->getFileInfo('/foo/submount/bar'); + + $time = time() + 50; + + $this->propagator->addChange('/foo/submount/bar/sad.txt'); + $this->propagator->propagateChanges($time); + + $newInfo1 = $this->view->getFileInfo('/'); + $newInfo2 = $this->view->getFileInfo('/foo'); + $newInfo3 = $this->view->getFileInfo('/foo/submount'); + $newInfo4 = $this->view->getFileInfo('/foo/submount/bar'); + + $this->assertEquals($newInfo1->getMTime(), $time); + $this->assertEquals($newInfo2->getMTime(), $time); + $this->assertEquals($newInfo3->getMTime(), $time); + $this->assertEquals($newInfo4->getMTime(), $time); + + $this->assertNotSame($oldInfo1->getEtag(), $newInfo1->getEtag()); + $this->assertNotSame($oldInfo2->getEtag(), $newInfo2->getEtag()); + $this->assertNotSame($oldInfo3->getEtag(), $newInfo3->getEtag()); + $this->assertNotSame($oldInfo4->getEtag(), $newInfo3->getEtag()); + } } diff --git a/tests/lib/files/cache/updaterlegacy.php b/tests/lib/files/cache/updaterlegacy.php index f4d52e9a390..c1a0d3d8230 100644 --- a/tests/lib/files/cache/updaterlegacy.php +++ b/tests/lib/files/cache/updaterlegacy.php @@ -10,6 +10,7 @@ namespace Test\Files\Cache; use \OC\Files\Filesystem as Filesystem; use OC\Files\Storage\Temporary; +use OC\Files\View; class UpdaterLegacy extends \Test\TestCase { /** @@ -111,7 +112,8 @@ class UpdaterLegacy extends \Test\TestCase { $storage2->getScanner()->scan(''); //initialize etags $cache2 = $storage2->getCache(); Filesystem::mount($storage2, array(), '/' . self::$user . '/files/folder/substorage'); - $folderCachedData = $this->cache->get('folder'); + $view = new View('/' . self::$user . '/files'); + $folderCachedData = $view->getFileInfo('folder'); $substorageCachedData = $cache2->get(''); Filesystem::file_put_contents('folder/substorage/foo.txt', 'asd'); $this->assertTrue($cache2->inCache('foo.txt')); @@ -124,7 +126,7 @@ class UpdaterLegacy extends \Test\TestCase { $this->assertInternalType('string', $cachedData['etag']); $this->assertNotSame($substorageCachedData['etag'], $cachedData['etag']); - $cachedData = $this->cache->get('folder'); + $cachedData = $view->getFileInfo('folder'); $this->assertInternalType('string', $folderCachedData['etag']); $this->assertInternalType('string', $cachedData['etag']); $this->assertNotSame($folderCachedData['etag'], $cachedData['etag']); @@ -168,8 +170,9 @@ class UpdaterLegacy extends \Test\TestCase { $cache2 = $storage2->getCache(); Filesystem::mount($storage2, array(), '/' . self::$user . '/files/folder/substorage'); Filesystem::file_put_contents('folder/substorage/foo.txt', 'asd'); + $view = new View('/' . self::$user . '/files'); $this->assertTrue($cache2->inCache('foo.txt')); - $folderCachedData = $this->cache->get('folder'); + $folderCachedData = $view->getFileInfo('folder'); $substorageCachedData = $cache2->get(''); Filesystem::unlink('folder/substorage/foo.txt'); $this->assertFalse($cache2->inCache('foo.txt')); @@ -180,7 +183,7 @@ class UpdaterLegacy extends \Test\TestCase { $this->assertNotSame($substorageCachedData['etag'], $cachedData['etag']); $this->assertGreaterThanOrEqual($substorageCachedData['mtime'], $cachedData['mtime']); - $cachedData = $this->cache->get('folder'); + $cachedData = $view->getFileInfo('folder'); $this->assertInternalType('string', $folderCachedData['etag']); $this->assertInternalType('string', $cachedData['etag']); $this->assertNotSame($folderCachedData['etag'], $cachedData['etag']); @@ -222,8 +225,9 @@ class UpdaterLegacy extends \Test\TestCase { $cache2 = $storage2->getCache(); Filesystem::mount($storage2, array(), '/' . self::$user . '/files/folder/substorage'); Filesystem::file_put_contents('folder/substorage/foo.txt', 'asd'); + $view = new View('/' . self::$user . '/files'); $this->assertTrue($cache2->inCache('foo.txt')); - $folderCachedData = $this->cache->get('folder'); + $folderCachedData = $view->getFileInfo('folder'); $substorageCachedData = $cache2->get(''); $fooCachedData = $cache2->get('foo.txt'); Filesystem::rename('folder/substorage/foo.txt', 'folder/substorage/bar.txt'); @@ -240,7 +244,7 @@ class UpdaterLegacy extends \Test\TestCase { // rename can cause mtime change - invalid assert // $this->assertEquals($mtime, $cachedData['mtime']); - $cachedData = $this->cache->get('folder'); + $cachedData = $view->getFileInfo('folder'); $this->assertInternalType('string', $folderCachedData['etag']); $this->assertInternalType('string', $cachedData['etag']); $this->assertNotSame($folderCachedData['etag'], $cachedData['etag']); @@ -287,35 +291,4 @@ class UpdaterLegacy extends \Test\TestCase { $this->assertEquals($time, $cachedData['mtime']); } - public function testTouchWithMountPoints() { - $storage2 = new \OC\Files\Storage\Temporary(array()); - $cache2 = $storage2->getCache(); - Filesystem::mount($storage2, array(), '/' . self::$user . '/files/folder/substorage'); - Filesystem::file_put_contents('folder/substorage/foo.txt', 'asd'); - $this->assertTrue($cache2->inCache('foo.txt')); - $folderCachedData = $this->cache->get('folder'); - $substorageCachedData = $cache2->get(''); - $fooCachedData = $cache2->get('foo.txt'); - $cachedData = $cache2->get('foo.txt'); - $time = 1371006070; - $this->cache->put('folder', ['mtime' => $time - 100]); - Filesystem::touch('folder/substorage/foo.txt', $time); - $cachedData = $cache2->get('foo.txt'); - $this->assertInternalType('string', $fooCachedData['etag']); - $this->assertInternalType('string', $cachedData['etag']); - $this->assertNotSame($fooCachedData['etag'], $cachedData['etag']); - $this->assertEquals($time, $cachedData['mtime']); - - $cachedData = $cache2->get(''); - $this->assertInternalType('string', $substorageCachedData['etag']); - $this->assertInternalType('string', $cachedData['etag']); - $this->assertNotSame($substorageCachedData['etag'], $cachedData['etag']); - - $cachedData = $this->cache->get('folder'); - $this->assertInternalType('string', $folderCachedData['etag']); - $this->assertInternalType('string', $cachedData['etag']); - $this->assertNotSame($folderCachedData['etag'], $cachedData['etag']); - $this->assertEquals($time, $cachedData['mtime']); - } - } diff --git a/tests/lib/files/etagtest.php b/tests/lib/files/etagtest.php index 1a11b29cf00..192768d04af 100644 --- a/tests/lib/files/etagtest.php +++ b/tests/lib/files/etagtest.php @@ -27,7 +27,6 @@ class EtagTest extends \Test\TestCase { \OC_Hook::clear('OC_Filesystem', 'setup'); $application = new \OCA\Files_Sharing\AppInfo\Application(); $application->registerMountProviders(); - $application->setupPropagation(); \OCP\Share::registerBackend('file', 'OC_Share_Backend_File'); \OCP\Share::registerBackend('folder', 'OC_Share_Backend_Folder', 'file'); |