comparison tests/test_processing_base.py @ 411:e7b865f8f335

bake: Enable multiprocess baking. Baking is now done by running a worker per CPU, and sending jobs to them. This changes several things across the codebase: * Ability to not cache things related to pages other than the 'main' page (i.e. the page at the bottom of the execution stack). * Decouple the baking process from the bake records, so only the main process keeps track (and modifies) the bake record. * Remove the need for 'batch page getters' and loading a page directly from the page factories. There are various smaller changes too included here, including support for scope performance timers that are saved with the bake record and can be printed out to the console. Yes I got carried away. For testing, the in-memory 'mock' file-system doesn't work anymore, since we're spawning processes, so this is replaced by a 'tmpfs' file-system which is saved in temporary files on disk and deleted after tests have run.
author Ludovic Chabant <ludovic@chabant.com>
date Fri, 12 Jun 2015 17:09:19 -0700
parents e725af1d48fb
children c4b3a7fd2f87
comparison
equal deleted inserted replaced
410:d1a472464e57 411:e7b865f8f335
75 expected = {'blah.foo': 'A test file.'} 75 expected = {'blah.foo': 'A test file.'}
76 assert expected == fs.getStructure('counter') 76 assert expected == fs.getStructure('counter')
77 mtime = os.path.getmtime(fs.path('/counter/blah.foo')) 77 mtime = os.path.getmtime(fs.path('/counter/blah.foo'))
78 assert abs(time.time() - mtime) <= 2 78 assert abs(time.time() - mtime) <= 2
79 79
80 time.sleep(1)
80 pp.run() 81 pp.run()
81 assert expected == fs.getStructure('counter') 82 assert expected == fs.getStructure('counter')
82 assert mtime == os.path.getmtime(fs.path('/counter/blah.foo')) 83 assert mtime == os.path.getmtime(fs.path('/counter/blah.foo'))
83 84
85 time.sleep(1)
84 fs.withFile('kitchen/assets/blah.foo', 'A new test file.') 86 fs.withFile('kitchen/assets/blah.foo', 'A new test file.')
85 pp.run() 87 pp.run()
86 expected = {'blah.foo': 'A new test file.'} 88 expected = {'blah.foo': 'A new test file.'}
87 assert expected == fs.getStructure('counter') 89 assert expected == fs.getStructure('counter')
88 assert mtime < os.path.getmtime(fs.path('/counter/blah.foo')) 90 assert mtime < os.path.getmtime(fs.path('/counter/blah.foo'))
99 expected = {'blah.bar': 'FOO: A test file.'} 101 expected = {'blah.bar': 'FOO: A test file.'}
100 assert expected == fs.getStructure('counter') 102 assert expected == fs.getStructure('counter')
101 mtime = os.path.getmtime(fs.path('/counter/blah.bar')) 103 mtime = os.path.getmtime(fs.path('/counter/blah.bar'))
102 assert abs(time.time() - mtime) <= 2 104 assert abs(time.time() - mtime) <= 2
103 105
106 time.sleep(1)
104 pp.run() 107 pp.run()
105 assert expected == fs.getStructure('counter') 108 assert expected == fs.getStructure('counter')
106 assert mtime == os.path.getmtime(fs.path('/counter/blah.bar')) 109 assert mtime == os.path.getmtime(fs.path('/counter/blah.bar'))
107 110
111 time.sleep(1)
108 fs.withFile('kitchen/assets/blah.foo', 'A new test file.') 112 fs.withFile('kitchen/assets/blah.foo', 'A new test file.')
109 pp.run() 113 pp.run()
110 expected = {'blah.bar': 'FOO: A new test file.'} 114 expected = {'blah.bar': 'FOO: A new test file.'}
111 assert expected == fs.getStructure('counter') 115 assert expected == fs.getStructure('counter')
112 assert mtime < os.path.getmtime(fs.path('/counter/blah.bar')) 116 assert mtime < os.path.getmtime(fs.path('/counter/blah.bar'))
124 pp = _get_pipeline(fs) 128 pp = _get_pipeline(fs)
125 pp.filterProcessors(['copy']) 129 pp.filterProcessors(['copy'])
126 pp.run() 130 pp.run()
127 assert expected == fs.getStructure('counter') 131 assert expected == fs.getStructure('counter')
128 132
133 time.sleep(1)
129 os.remove(fs.path('/kitchen/assets/blah2.foo')) 134 os.remove(fs.path('/kitchen/assets/blah2.foo'))
130 expected = { 135 expected = {
131 'blah1.foo': 'A test file.'} 136 'blah1.foo': 'A test file.'}
132 assert expected == fs.getStructure('kitchen/assets') 137 assert expected == fs.getStructure('kitchen/assets')
133 pp.run() 138 pp.run()