* This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. */ namespace Test\Files\Cache; use OC\Files\Storage\Temporary; use OCP\Files\Cache\ICacheEntry; use OCP\Files\Storage\IStorage; use Test\TestCase; /** * @group DB */ class PropagatorTest extends TestCase { /** @var IStorage */ private $storage; protected function setUp(): void { parent::setUp(); $this->storage = new Temporary(); $this->storage->mkdir('foo/bar'); $this->storage->file_put_contents('foo/bar/file.txt', 'bar'); $this->storage->getScanner()->scan(''); } /** * @param $paths * @return ICacheEntry[] */ private function getFileInfos($paths) { $values = array_map(function ($path) { return $this->storage->getCache()->get($path); }, $paths); return array_combine($paths, $values); } public function testEtagPropagation() { $paths = ['', 'foo', 'foo/bar']; $oldInfos = $this->getFileInfos($paths); $this->storage->getPropagator()->propagateChange('foo/bar/file.txt', time()); $newInfos = $this->getFileInfos($paths); foreach ($oldInfos as $i => $oldInfo) { $this->assertNotEquals($oldInfo->getEtag(), $newInfos[$i]->getEtag()); } } public function testTimePropagation() { $paths = ['', 'foo', 'foo/bar']; $oldTime = time() - 200; $targetTime = time() - 100; $now = time(); $cache = $this->storage->getCache(); $cache->put('', ['mtime' => $now]); $cache->put('foo', ['mtime' => $now]); $cache->put('foo/bar', ['mtime' => $oldTime]); $cache->put('foo/bar/file.txt', ['mtime' => $oldTime]); $this->storage->getPropagator()->propagateChange('foo/bar/file.txt', $targetTime); $newInfos = $this->getFileInfos($paths); $this->assertEquals($targetTime, $newInfos['foo/bar']->getMTime()); // dont lower mtimes $this->assertEquals($now, $newInfos['foo']->getMTime()); $this->assertEquals($now, $newInfos['']->getMTime()); } public function testSizePropagation() { $paths = ['', 'foo', 'foo/bar']; $oldInfos = $this->getFileInfos($paths); $this->storage->getPropagator()->propagateChange('foo/bar/file.txt', time(), 10); $newInfos = $this->getFileInfos($paths); foreach ($oldInfos as $i => $oldInfo) { $this->assertEquals($oldInfo->getSize() + 10, $newInfos[$i]->getSize()); } } public function testSizePropagationNoNegative() { $paths = ['', 'foo', 'foo/bar']; $oldInfos = $this->getFileInfos($paths); $this->storage->getPropagator()->propagateChange('foo/bar/file.txt', time(), -100); $newInfos = $this->getFileInfos($paths); foreach ($oldInfos as $i => $oldInfo) { $this->assertEquals(-1, $newInfos[$i]->getSize()); } } public function testBatchedPropagation() { $this->storage->mkdir('foo/baz'); $this->storage->mkdir('asd'); $this->storage->file_put_contents('asd/file.txt', 'bar'); $this->storage->file_put_contents('foo/baz/file.txt', 'bar'); $this->storage->getScanner()->scan(''); $paths = ['', 'foo', 'foo/bar', 'asd', 'foo/baz']; $oldInfos = $this->getFileInfos($paths); $propagator = $this->storage->getPropagator(); $propagator->beginBatch(); $propagator->propagateChange('asd/file.txt', time(), 10); $propagator->propagateChange('foo/bar/file.txt', time(), 2); $newInfos = $this->getFileInfos($paths); // no changes until we finish the batch foreach ($oldInfos as $i => $oldInfo) { $this->assertEquals($oldInfo->getSize(), $newInfos[$i]->getSize()); $this->assertEquals($oldInfo->getEtag(), $newInfos[$i]->getEtag()); $this->assertEquals($oldInfo->getMTime(), $newInfos[$i]->getMTime()); } $propagator->commitBatch(); $newInfos = $this->getFileInfos($paths); foreach ($oldInfos as $i => $oldInfo) { if ($oldInfo->getPath() !== 'foo/baz') { $this->assertNotEquals($oldInfo->getEtag(), $newInfos[$i]->getEtag()); } } $this->assertEquals($oldInfos['']->getSize() + 12, $newInfos['']->getSize()); $this->assertEquals($oldInfos['asd']->getSize() + 10, $newInfos['asd']->getSize()); $this->assertEquals($oldInfos['foo']->getSize() + 2, $newInfos['foo']->getSize()); $this->assertEquals($oldInfos['foo/bar']->getSize() + 2, $newInfos['foo/bar']->getSize()); $this->assertEquals($oldInfos['foo/baz']->getSize(), $newInfos['foo/baz']->getSize()); } } n value='author'>author
path: root/build/release-test.js
blob: be5227a43a7c2773e4b9a8223a337ccdec701b57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
var shell = require( "shelljs" );
var Release = {
	define: function( props ) {
		for ( var key in props ) {
			Release[ key ] = props[ key ];
		}
	},
	exec: function( _options, errorMessage ) {
		var result,
			command = _options.command || _options,
			options = {};

		if ( _options.silent ) {
			options.silent = true;
		}

		errorMessage = errorMessage || "Error executing command: " + command;

		result = shell.exec( command, options );
		if ( result.code !== 0 ) {
			Release.abort( errorMessage );
		}

		return result.output;
	},
	abort: function() {
		console.error.apply( console, arguments );
		process.exit( 1 );
	},
	newVersion: require( "../package" ).version
};

var script = require( "./release" );
script( Release );

// Ignores actual version installed, should be good enough for a test
if ( shell.exec( "npm ls --depth 0 | grep download.jqueryui.com" ).code === 1 ) {
	shell.exec( "npm install " + script.dependencies.join( " " ) );
}

// If AUTHORS.txt is outdated, this will update it
// Very annoying during an actual release
shell.exec( "grunt update-authors" );

Release.generateArtifacts( function() {
	console.log( "Done generating artifacts, verify output, should be in dist/cdn" );
} );