Commit 79064a17 authored by Łukasz Nowak's avatar Łukasz Nowak

Proof that bindings to nc are immutable.

parent b9795d85
...@@ -836,3 +836,155 @@ parse the original url and get the file name: ...@@ -836,3 +836,155 @@ parse the original url and get the file name:
... path=globals().get('tmp_dir') + '/tmp_file', ... path=globals().get('tmp_dir') + '/tmp_file',
... nc_server_path=sample_buildout) ... nc_server_path=sample_buildout)
'id=700c7d5382b01f94e7141' 'id=700c7d5382b01f94e7141'
Buildout bindings to networkcache are immune on slapos.libnetworkcache problems.
Lets prepare networkcache with errors:
>>> mkdir(sample_buildout, 'damagednc')
>>> mkdir(sample_buildout, 'damagednc', 'slapos')
>>> write(sample_buildout, 'damagednc', 'slapos', '__init__.py',
... """
... # See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
... try:
... __import__('pkg_resources').declare_namespace(__name__)
... except ImportError:
... from pkgutil import extend_path
... __path__ = extend_path(__path__, __name__)
... """)
>>> write(sample_buildout, 'damagednc', 'slapos', 'libnetworkcache.py',
... """
... += die during import
... """)
>>> write(sample_buildout, 'damagednc', 'setup.py',
... """
... from setuptools import setup, find_packages
...
... setup(
... name = "slapos.libnetworkcache",
... namespace_packages=['slapos'],
... packages=find_packages(),
... install_requires=['setuptools']
... )
... """)
>>> write(sample_buildout, 'damagednc', 'README.txt', " ")
And install it in buildout:
>>> write(sample_buildout, 'buildout.cfg',
... '''
... [buildout]
... parts = networkcache
... develop = damagednc
... # Do not register this buildout run
... installed =
...
... [networkcache]
... recipe = zc.recipe.egg
... eggs =
... slapos.libnetworkcache
... zc.buildout
... ''')
>>> print system(buildout)
Develop: '/sample-buildout/damagednc'
Installing networkcache.
Generated script '/sample-buildout/bin/buildout'.
So lets use such damaged networkcache:
>>> write(sample_buildout, 'buildout.cfg',
... '''
... [buildout]
...
... networkcache-section = networkcache
... develop = download damagednc
... parts = download
...
... [download]
... recipe = download
... url = %(remote_server_url)shello.txt
...
... [networkcache]
... download-cache-url = %(nc_url)sshacache
... download-dir-url = %(nc_url)sshadir
... ''' % globals())
>>> print system(buildout)
There was problem while trying to import slapos.libnetworkcache:
Traceback (most recent call last):
...
SyntaxError: invalid syntax
<BLANKLINE>
Networkcache forced to be disabled.
There was problem while trying to import slapos.libnetworkcache:
Traceback (most recent call last):
...
SyntaxError: invalid syntax
<BLANKLINE>
Networkcache forced to be disabled.
Develop: '/sample-buildout/download'
Develop: '/sample-buildout/damagednc'
Unused options for buildout: 'networkcache-section'.
Installing download.
Downloading http://localhost/hello.txt
download: Downloaded http://localhost/hello.txt
If networkcache internally has issues, or its API got changed, buildout will
still work:
>>> write(sample_buildout, 'damagednc', 'slapos', 'libnetworkcache.py',
... """
... class NetworkcacheClient(object):
... def parseUrl(*args, **kwargs):
... raise Die
... def __init__(*args, **kwargs):
... raise Die
... def upload(*args, **kwargs):
... raise Die
... def download(*args, **kwargs):
... raise Die
... def select(*args, **kwargs):
... raise Die
... class UploadError: pass
... class DirectoryNotFound: pass
... """)
>>> write(sample_buildout, 'buildout.cfg',
... '''
... [buildout]
...
... networkcache-section = networkcache
... develop = download damagednc
... parts = download
...
... [download]
... recipe = download
... url = %(remote_server_url)shello.txt
...
... [networkcache]
... download-cache-url = %(nc_url)sshacache
... download-dir-url = %(nc_url)sshadir
... upload-cache-url = %(nc_url)sshacache
... upload-dir-url = %(nc_url)sshadir
... ''' % globals())
>>> print system(buildout)
Networkcache enabled.
Networkcache download cache: 'http://localhost/shacache', directory 'http://localhost/shadir'
Networkcache upload cache: 'http://localhost/shacache', directory 'http://localhost/shadir'
Develop: '/sample-buildout/download'
Develop: '/sample-buildout/damagednc'
Updating download.
Downloading http://localhost/hello.txt
There was problem while calling method 'download_network_cached':
Traceback (most recent call last):
...
raise Die
NameError: global name 'Die' is not defined
<BLANKLINE>
Uploading http://localhost/hello.txt into network cache.
There was problem while calling method 'upload_network_cached':
Traceback (most recent call last):
...
raise Die
NameError: global name 'Die' is not defined
<BLANKLINE>
download: Downloaded http://localhost:20863/hello.txt
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment