def setUp(self): self.dh = DirectoryHelper() (self.build_dir, self.cache_dir, self.temp_dir) = self.dh.create_bp_env(self.app_name) self.bp = BuildPack( { 'BUILD_DIR': self.build_dir, 'CACHE_DIR': self.cache_dir, 'TMPDIR': self.temp_dir }, '.') self.dh.copy_build_pack_to(self.bp.bp_dir) self.dh.register_to_delete(self.bp.bp_dir) self.opts = OptionsHelper( os.path.join(self.bp.bp_dir, 'defaults', 'options.json')) self.opts.set_download_url('http://localhost:5000/binaries/{STACK}')
def test_detect_with_asp_net_app(self): shutil.copytree('tests/data/app-asp-net', self.build_dir) bp = BuildPack({ 'BUILD_DIR': self.build_dir, 'CACHE_DIR': self.cache_dir, 'WEBDIR': 'htdocs' }, '.') # simulate clone, makes debugging easier os.rmdir(bp.bp_dir) shutil.copytree('.', bp.bp_dir, ignore=shutil.ignore_patterns("binaries", "env", "fixtures", "tests")) try: bp._detect().strip() except Exception, e: print e.output assert re.match('no', e.output)
def test_detect_static(self): shutil.copytree('tests/data/app-3', self.build_dir) bp = BuildPack({ 'BUILD_DIR': self.build_dir, 'CACHE_DIR': self.cache_dir, 'WEBDIR': 'htdocs' }, '.') # simulate clone, makes debugging easier os.rmdir(bp.bp_dir) shutil.copytree('.', bp.bp_dir, ignore=shutil.ignore_patterns("binaries", "env", "tests")) try: output = bp._detect().strip() eq_('STATIC', output) except Exception, e: print str(e) if hasattr(e, 'output'): print e.output raise
def test_detect_with_invalid_json(self): shutil.copytree('tests/data/app-invalid-json', self.build_dir) bp = BuildPack({ 'BUILD_DIR': self.build_dir, 'CACHE_DIR': self.cache_dir, 'WEBDIR': 'htdocs' }, '.') # simulate clone, makes debugging easier os.rmdir(bp.bp_dir) shutil.copytree('.', bp.bp_dir, ignore=shutil.ignore_patterns("binaries", "env", "fixtures", "tests")) try: output = bp._detect().strip() assert re.match('php*', output) except Exception, e: print str(e) if hasattr(e, 'output'): print e.output if output: print output
def test_compile_httpd_with_newrelic(self): os.environ['NEWRELIC_LICENSE'] = 'JUNK_LICENSE' os.environ['VCAP_APPLICATION'] = json.dumps({'name': 'app-name-1'}) bp = BuildPack( { 'BUILD_DIR': self.build_dir, 'CACHE_DIR': self.cache_dir, }, '.') self.copy_build_pack(bp.bp_dir) # set php & web server optsFile = os.path.join(bp.bp_dir, 'defaults', 'options.json') self._set_php(optsFile, 'hhvm') self._set_web_server(optsFile, 'httpd') try: output = '' output = bp._compile() outputLines = output.split('\n') eq_(16, len([l for l in outputLines if l.startswith('Downloaded')])) eq_(2, len([l for l in outputLines if l.startswith('Installing')])) eq_(True, outputLines[-1].startswith('Finished:')) # Test scripts and config self.assert_exists(self.build_dir, 'start.sh') with open(os.path.join(self.build_dir, 'start.sh')) as start: lines = [line.strip() for line in start.readlines()] eq_(5, len(lines)) eq_('export PYTHONPATH=$HOME/.bp/lib', lines[0]) eq_('$HOME/.bp/bin/rewrite "$HOME/httpd/conf"', lines[1]) eq_('$HOME/.bp/bin/rewrite "$HOME/.env"', lines[2]) eq_('$HOME/.bp/bin/rewrite "$HOME/hhvm/etc"', lines[3]) eq_('$HOME/.bp/bin/start', lines[4]) # Check scripts and bp are installed self.assert_exists(self.build_dir, '.bp', 'bin', 'rewrite') self.assert_exists(self.build_dir, '.bp', 'lib') bpu_path = os.path.join(self.build_dir, '.bp', 'lib', 'build_pack_utils') eq_(22, len(os.listdir(bpu_path))) self.assert_exists(bpu_path, 'utils.py') self.assert_exists(bpu_path, 'process.py') # Check env and procs files self.assert_exists(self.build_dir, '.env') self.assert_exists(self.build_dir, '.procs') with open(os.path.join(self.build_dir, '.env')) as env: lines = [line.strip() for line in env.readlines()] eq_(2, len(lines)) eq_('[email protected]', lines[0]) eq_('LD_LIBRARY_PATH=@LD_LIBRARY_PATH:@HOME/hhvm', lines[1]) with open(os.path.join(self.build_dir, '.procs')) as procs: lines = [line.strip() for line in procs.readlines()] eq_(2, len(lines)) eq_( 'httpd: $HOME/httpd/bin/apachectl -f ' '"$HOME/httpd/conf/httpd.conf" -k start -DFOREGROUND', lines[0]) eq_( 'hhvm: $HOME/hhvm/hhvm --mode server -c ' '$HOME/hhvm/etc/config.hdf', lines[1]) # Check htdocs and config self.assert_exists(self.build_dir, 'htdocs') self.assert_exists(self.build_dir, '.bp-config') self.assert_exists(self.build_dir, '.bp-config', 'options.json') # Test HTTPD self.assert_exists(self.build_dir) self.assert_exists(self.build_dir, 'httpd') self.assert_exists(self.build_dir, 'httpd', 'conf') self.assert_exists(self.build_dir, 'httpd', 'conf', 'httpd.conf') self.assert_exists(self.build_dir, 'httpd', 'conf', 'extra') self.assert_exists(self.build_dir, 'httpd', 'conf', 'extra', 'httpd-modules.conf') self.assert_exists(self.build_dir, 'httpd', 'conf', 'extra', 'httpd-remoteip.conf') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_authz_core.so') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_authz_host.so') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_dir.so') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_env.so') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_log_config.so') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_mime.so') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_mpm_event.so') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_proxy.so') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_proxy_fcgi.so') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_reqtimeout.so') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_unixd.so') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_remoteip.so') # Test PHP self.assert_exists(self.build_dir, 'hhvm') self.assert_exists(self.build_dir, 'hhvm', 'hhvm') self.assert_exists(self.build_dir, 'hhvm', 'etc', 'config.hdf') self.assert_exists(self.build_dir, 'hhvm', 'libmemcached.so.11') self.assert_exists(self.build_dir, 'hhvm', 'libevent-1.4.so.2.2.0') self.assert_exists(self.build_dir, 'hhvm', 'libevent-1.4.so.2') self.assert_exists(self.build_dir, 'hhvm', 'libboost_system.so.1.55.0') self.assert_exists(self.build_dir, 'hhvm', 'libc-client.so.2007e.0') self.assert_exists(self.build_dir, 'hhvm', 'libstdc++.so.6') self.assert_exists(self.build_dir, 'hhvm', 'libMagickWand.so.2') self.assert_exists(self.build_dir, 'hhvm', 'libicui18n.so.48') # Test NewRelic (should not be installed with HHVM) eq_(False, os.path.exists(os.path.join(self.build_dir, 'newrelic'))) except Exception, e: print str(e) if hasattr(e, 'output'): print e.output if output: print output raise
def test_compile_httpd_with_newrelic(self): os.environ['NEWRELIC_LICENSE'] = 'JUNK_LICENSE' os.environ['VCAP_APPLICATION'] = json.dumps({'name': 'app-name-1'}) bp = BuildPack( { 'BUILD_DIR': self.build_dir, 'CACHE_DIR': self.cache_dir, }, '.') self.copy_build_pack(bp.bp_dir) # set php & web server optsFile = os.path.join(bp.bp_dir, 'defaults', 'options.json') self._set_php(optsFile, 'php') self._set_web_server(optsFile, 'httpd') try: output = '' output = bp._compile() outputLines = output.split('\n') eq_(22, len([l for l in outputLines if l.startswith('Downloaded')])) eq_(2, len([l for l in outputLines if l.startswith('Installing')])) eq_(True, outputLines[-1].startswith('Finished:')) # Test scripts and config self.assert_exists(self.build_dir, 'start.sh') with open(os.path.join(self.build_dir, 'start.sh')) as start: lines = [line.strip() for line in start.readlines()] eq_(5, len(lines)) eq_('export PYTHONPATH=$HOME/.bp/lib', lines[0]) eq_('$HOME/.bp/bin/rewrite "$HOME/httpd/conf"', lines[1]) eq_('$HOME/.bp/bin/rewrite "$HOME/php/etc"', lines[2]) eq_('$HOME/.bp/bin/rewrite "$HOME/.env"', lines[3]) eq_('$HOME/.bp/bin/start', lines[4]) # Check scripts and bp are installed self.assert_exists(self.build_dir, '.bp', 'bin', 'rewrite') self.assert_exists(self.build_dir, '.bp', 'lib') bpu_path = os.path.join(self.build_dir, '.bp', 'lib', 'build_pack_utils') eq_(22, len(os.listdir(bpu_path))) self.assert_exists(bpu_path, 'utils.py') self.assert_exists(bpu_path, 'process.py') # Check env and procs files self.assert_exists(self.build_dir, '.env') self.assert_exists(self.build_dir, '.procs') with open(os.path.join(self.build_dir, '.env')) as env: lines = [line.strip() for line in env.readlines()] eq_(2, len(lines)) eq_('[email protected]', lines[0]) eq_('LD_LIBRARY_PATH=@LD_LIBRARY_PATH:@HOME/php/lib', lines[1]) with open(os.path.join(self.build_dir, '.procs')) as procs: lines = [line.strip() for line in procs.readlines()] eq_(3, len(lines)) eq_( 'httpd: $HOME/httpd/bin/apachectl -f ' '"$HOME/httpd/conf/httpd.conf" -k start -DFOREGROUND', lines[0]) eq_( 'php-fpm: $HOME/php/sbin/php-fpm -p "$HOME/php/etc" -y ' '"$HOME/php/etc/php-fpm.conf" -c "$HOME/php/etc"', lines[1]) eq_('php-fpm-logs: tail -F $HOME/logs/php-fpm.log', lines[2]) # Check htdocs and config self.assert_exists(self.build_dir, 'htdocs') self.assert_exists(self.build_dir, '.bp-config') self.assert_exists(self.build_dir, '.bp-config', 'options.json') # Test HTTPD self.assert_exists(self.build_dir) self.assert_exists(self.build_dir, 'httpd') self.assert_exists(self.build_dir, 'httpd', 'conf') self.assert_exists(self.build_dir, 'httpd', 'conf', 'httpd.conf') self.assert_exists(self.build_dir, 'httpd', 'conf', 'extra') self.assert_exists(self.build_dir, 'httpd', 'conf', 'extra', 'httpd-modules.conf') self.assert_exists(self.build_dir, 'httpd', 'conf', 'extra', 'httpd-remoteip.conf') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_authz_core.so') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_authz_host.so') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_dir.so') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_env.so') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_log_config.so') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_mime.so') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_mpm_event.so') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_proxy.so') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_proxy_fcgi.so') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_reqtimeout.so') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_unixd.so') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_remoteip.so') # Test PHP self.assert_exists(self.build_dir, 'php') self.assert_exists(self.build_dir, 'php', 'etc') self.assert_exists(self.build_dir, 'php', 'etc', 'php-fpm.conf') self.assert_exists(self.build_dir, 'php', 'etc', 'php.ini') self.assert_exists(self.build_dir, 'php', 'sbin', 'php-fpm') self.assert_exists(self.build_dir, 'php', 'bin') self.assert_exists(self.build_dir, 'php', 'lib', 'php', 'extensions', 'no-debug-non-zts-20100525', 'bz2.so') self.assert_exists(self.build_dir, 'php', 'lib', 'php', 'extensions', 'no-debug-non-zts-20100525', 'zlib.so') self.assert_exists(self.build_dir, 'php', 'lib', 'php', 'extensions', 'no-debug-non-zts-20100525', 'curl.so') self.assert_exists(self.build_dir, 'php', 'lib', 'php', 'extensions', 'no-debug-non-zts-20100525', 'mcrypt.so') # Test NewRelic self.assert_exists(self.build_dir, 'newrelic') self.assert_exists(self.build_dir, 'newrelic', 'daemon', 'newrelic-daemon.x64') self.assert_exists(self.build_dir, 'newrelic', 'agent', 'x64', 'newrelic-20100525.so') with open(os.path.join(self.build_dir, 'php', 'etc', 'php.ini'), 'rt') as php_ini: lines = php_ini.readlines() extn_path = '@{HOME}/newrelic/agent/x64/newrelic-20100525.so' eq_(True, lines.index('extension=%s\n' % extn_path) >= 0) eq_(True, lines.index('[newrelic]\n') >= 0) eq_(True, lines.index('newrelic.license=JUNK_LICENSE\n') >= 0) eq_(True, lines.index('newrelic.appname=app-name-1\n') >= 0) except Exception, e: print str(e) if hasattr(e, 'output'): print e.output if output: print output raise
def test_compile_httpd(self): bp = BuildPack( { 'BUILD_DIR': self.build_dir, 'CACHE_DIR': self.cache_dir }, '.') # simulate clone, makes debugging easier os.rmdir(bp.bp_dir) shutil.copytree('.', bp.bp_dir, ignore=shutil.ignore_patterns("binaries", "env", "tests")) # set web server self.set_web_server( os.path.join(bp.bp_dir, 'defaults', 'options.json'), 'httpd') try: output = '' output = bp._compile() outputLines = output.split('\n') eq_(21, len([l for l in outputLines if l.startswith('Downloaded')])) eq_(2, len([l for l in outputLines if l.startswith('Installing')])) eq_(True, outputLines[-1].startswith('Finished:')) # Test scripts and config self.assert_exists(self.build_dir, 'start.sh') with open(os.path.join(self.build_dir, 'start.sh')) as start: lines = [line.strip() for line in start.readlines()] eq_(5, len(lines)) eq_('export PYTHONPATH=$HOME/.bp/lib', lines[0]) eq_('$HOME/.bp/bin/rewrite "$HOME/httpd/conf"', lines[1]) eq_('$HOME/.bp/bin/rewrite "$HOME/php/etc"', lines[2]) eq_('$HOME/.bp/bin/rewrite "$HOME/.env"', lines[3]) eq_('$HOME/.bp/bin/start', lines[4]) # Check scripts and bp are installed self.assert_exists(self.build_dir, '.bp', 'bin', 'rewrite') self.assert_exists(self.build_dir, '.bp', 'lib') bpu_path = os.path.join(self.build_dir, '.bp', 'lib', 'build_pack_utils') eq_(22, len(os.listdir(bpu_path))) self.assert_exists(bpu_path, 'utils.py') self.assert_exists(bpu_path, 'process.py') # Check env and procs files self.assert_exists(self.build_dir, '.env') self.assert_exists(self.build_dir, '.procs') with open(os.path.join(self.build_dir, '.env')) as env: lines = [line.strip() for line in env.readlines()] eq_(2, len(lines)) eq_('[email protected]', lines[0]) eq_('LD_LIBRARY_PATH=@LD_LIBRARY_PATH:@HOME/php/lib', lines[1]) with open(os.path.join(self.build_dir, '.procs')) as procs: lines = [line.strip() for line in procs.readlines()] eq_(3, len(lines)) eq_( 'httpd: $HOME/httpd/bin/apachectl -f ' '"$HOME/httpd/conf/httpd.conf" -k start -DFOREGROUND', lines[0]) eq_( 'php-fpm: $HOME/php/sbin/php-fpm -p "$HOME/php/etc" -y ' '"$HOME/php/etc/php-fpm.conf" -c "$HOME/php/etc"', lines[1]) eq_('php-fpm-logs: tail -F $HOME/../logs/php-fpm.log', lines[2]) # Check htdocs and config self.assert_exists(self.build_dir, 'htdocs') self.assert_exists(self.build_dir, '.bp-config') self.assert_exists(self.build_dir, '.bp-config', 'options.json') # Test HTTPD self.assert_exists(self.build_dir) self.assert_exists(self.build_dir, 'httpd') self.assert_exists(self.build_dir, 'httpd', 'conf') self.assert_exists(self.build_dir, 'httpd', 'conf', 'httpd.conf') self.assert_exists(self.build_dir, 'httpd', 'conf', 'extra') self.assert_exists(self.build_dir, 'httpd', 'conf', 'extra', 'httpd-modules.conf') self.assert_exists(self.build_dir, 'httpd', 'conf', 'extra', 'httpd-remoteip.conf') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_authz_core.so') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_authz_host.so') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_dir.so') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_env.so') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_log_config.so') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_mime.so') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_mpm_event.so') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_proxy.so') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_proxy_fcgi.so') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_reqtimeout.so') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_unixd.so') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_remoteip.so') self.assert_exists(self.build_dir, 'httpd', 'modules', 'mod_rewrite.so') # Test PHP self.assert_exists(self.build_dir, 'php') self.assert_exists(self.build_dir, 'php', 'etc') self.assert_exists(self.build_dir, 'php', 'etc', 'php-fpm.conf') self.assert_exists(self.build_dir, 'php', 'etc', 'php.ini') self.assert_exists(self.build_dir, 'php', 'sbin', 'php-fpm') self.assert_exists(self.build_dir, 'php', 'bin') self.assert_exists(self.build_dir, 'php', 'lib', 'php', 'extensions', 'no-debug-non-zts-20100525', 'bz2.so') self.assert_exists(self.build_dir, 'php', 'lib', 'php', 'extensions', 'no-debug-non-zts-20100525', 'zlib.so') self.assert_exists(self.build_dir, 'php', 'lib', 'php', 'extensions', 'no-debug-non-zts-20100525', 'curl.so') self.assert_exists(self.build_dir, 'php', 'lib', 'php', 'extensions', 'no-debug-non-zts-20100525', 'mcrypt.so') except Exception, e: print str(e) if hasattr(e, 'output'): print e.output if output: print output raise
def test_compile_stand_alone(self): bp = BuildPack( { 'BUILD_DIR': self.build_dir, 'CACHE_DIR': self.cache_dir }, '.') # simulate clone, makes debugging easier os.rmdir(bp.bp_dir) shutil.copytree('.', bp.bp_dir, ignore=shutil.ignore_patterns("binaries", "env", "tests")) # set web server & php version optsFile = os.path.join(bp.bp_dir, 'defaults', 'options.json') self.set_web_server(optsFile, 'none') self.set_php_version(optsFile, '5.4.27') try: output = '' output = bp._compile() # Test Output outputLines = output.split('\n') eq_(6, len([l for l in outputLines if l.startswith('Downloaded')])) eq_(1, len([l for l in outputLines if l.startswith('No Web')])) eq_( 1, len([l for l in outputLines if l.startswith('Installing PHP')])) eq_(1, len([l for l in outputLines if l.find('php-cli') >= 0])) eq_(True, outputLines[-1].startswith('Finished:')) # Test scripts and config self.assert_exists(self.build_dir, 'start.sh') with open(os.path.join(self.build_dir, 'start.sh')) as start: lines = [line.strip() for line in start.readlines()] eq_(4, len(lines)) eq_('export PYTHONPATH=$HOME/.bp/lib', lines[0]) eq_('$HOME/.bp/bin/rewrite "$HOME/php/etc"', lines[1]) eq_('$HOME/.bp/bin/rewrite "$HOME/.env"', lines[2]) eq_('$HOME/.bp/bin/start', lines[3]) # Check scripts and bp are installed self.assert_exists(self.build_dir, '.bp', 'bin', 'rewrite') self.assert_exists(self.build_dir, '.bp', 'lib') bpu_path = os.path.join(self.build_dir, '.bp', 'lib', 'build_pack_utils') eq_(22, len(os.listdir(bpu_path))) self.assert_exists(bpu_path, 'utils.py') self.assert_exists(bpu_path, 'process.py') # Check env and procs files self.assert_exists(self.build_dir, '.env') self.assert_exists(self.build_dir, '.procs') with open(os.path.join(self.build_dir, '.env')) as env: lines = [line.strip() for line in env.readlines()] eq_(1, len(lines)) eq_('LD_LIBRARY_PATH=@LD_LIBRARY_PATH:@HOME/php/lib', lines[0]) with open(os.path.join(self.build_dir, '.procs')) as procs: lines = [line.strip() for line in procs.readlines()] eq_(1, len(lines)) eq_('php-app: $HOME/php/bin/php -c "$HOME/php/etc" ' 'app.php', lines[0]) # Test PHP self.assert_exists(self.build_dir, 'php') self.assert_exists(self.build_dir, 'php', 'etc') self.assert_exists(self.build_dir, 'php', 'etc', 'php.ini') self.assert_exists(self.build_dir, 'php', 'bin') self.assert_exists(self.build_dir, 'php', 'bin', 'php') self.assert_exists(self.build_dir, 'php', 'bin', 'phar.phar') self.assert_exists(self.build_dir, 'php', 'lib', 'php', 'extensions', 'no-debug-non-zts-20100525', 'bz2.so') self.assert_exists(self.build_dir, 'php', 'lib', 'php', 'extensions', 'no-debug-non-zts-20100525', 'zlib.so') self.assert_exists(self.build_dir, 'php', 'lib', 'php', 'extensions', 'no-debug-non-zts-20100525', 'curl.so') self.assert_exists(self.build_dir, 'php', 'lib', 'php', 'extensions', 'no-debug-non-zts-20100525', 'mcrypt.so') except Exception, e: print str(e) if hasattr(e, 'output'): print e.output if output: print output raise
def test_compile_nginx(self): bp = BuildPack( { 'BUILD_DIR': self.build_dir, 'CACHE_DIR': self.cache_dir }, '.') # simulate clone, makes debugging easier os.rmdir(bp.bp_dir) shutil.copytree('.', bp.bp_dir, ignore=shutil.ignore_patterns("binaries", "env", "tests")) # set web server self.set_web_server( os.path.join(bp.bp_dir, 'defaults', 'options.json'), 'nginx') try: output = '' output = bp._compile() # Test Output outputLines = output.split('\n') eq_(7, len([l for l in outputLines if l.startswith('Downloaded')])) eq_(2, len([l for l in outputLines if l.startswith('Installing')])) eq_(True, outputLines[-1].startswith('Finished:')) # Test scripts and config self.assert_exists(self.build_dir, 'start.sh') with open(os.path.join(self.build_dir, 'start.sh')) as start: lines = [line.strip() for line in start.readlines()] eq_(5, len(lines)) eq_('export PYTHONPATH=$HOME/.bp/lib', lines[0]) eq_('$HOME/.bp/bin/rewrite "$HOME/nginx/conf"', lines[1]) eq_('$HOME/.bp/bin/rewrite "$HOME/php/etc"', lines[2]) eq_('$HOME/.bp/bin/rewrite "$HOME/.env"', lines[3]) eq_('$HOME/.bp/bin/start', lines[4]) # Check scripts and bp are installed self.assert_exists(self.build_dir, '.bp', 'bin', 'rewrite') self.assert_exists(self.build_dir, '.bp', 'lib') bpu_path = os.path.join(self.build_dir, '.bp', 'lib', 'build_pack_utils') eq_(22, len(os.listdir(bpu_path))) self.assert_exists(bpu_path, 'utils.py') self.assert_exists(bpu_path, 'process.py') # Check env and procs files self.assert_exists(self.build_dir, '.env') self.assert_exists(self.build_dir, '.procs') with open(os.path.join(self.build_dir, '.env')) as env: lines = [line.strip() for line in env.readlines()] eq_(1, len(lines)) eq_('LD_LIBRARY_PATH=@LD_LIBRARY_PATH:@HOME/php/lib', lines[0]) with open(os.path.join(self.build_dir, '.procs')) as procs: lines = [line.strip() for line in procs.readlines()] eq_(3, len(lines)) eq_( 'nginx: $HOME/nginx/sbin/nginx -c ' '"$HOME/nginx/conf/nginx.conf"', lines[0]) eq_( 'php-fpm: $HOME/php/sbin/php-fpm -p "$HOME/php/etc" -y ' '"$HOME/php/etc/php-fpm.conf" -c "$HOME/php/etc"', lines[1]) eq_('php-fpm-logs: tail -F $HOME/../logs/php-fpm.log', lines[2]) # Test htdocs & config self.assert_exists(self.build_dir, 'htdocs') self.assert_exists(self.build_dir, '.bp-config') self.assert_exists(self.build_dir, '.bp-config', 'options.json') # Test NGINX self.assert_exists(self.build_dir) self.assert_exists(self.build_dir, 'nginx') self.assert_exists(self.build_dir, 'nginx', 'conf') self.assert_exists(self.build_dir, 'nginx', 'conf', 'fastcgi_params') self.assert_exists(self.build_dir, 'nginx', 'conf', 'http-logging.conf') self.assert_exists(self.build_dir, 'nginx', 'conf', 'http-defaults.conf') self.assert_exists(self.build_dir, 'nginx', 'conf', 'http-php.conf') self.assert_exists(self.build_dir, 'nginx', 'conf', 'mime.types') self.assert_exists(self.build_dir, 'nginx', 'conf', 'nginx-defaults.conf') self.assert_exists(self.build_dir, 'nginx', 'conf', 'nginx-workers.conf') self.assert_exists(self.build_dir, 'nginx', 'conf', 'nginx.conf') self.assert_exists(self.build_dir, 'nginx', 'conf', 'server-defaults.conf') self.assert_exists(self.build_dir, 'nginx', 'conf', 'server-locations.conf') self.assert_exists(self.build_dir, 'nginx', 'logs') self.assert_exists(self.build_dir, 'nginx', 'sbin') self.assert_exists(self.build_dir, 'nginx', 'sbin', 'nginx') with open( os.path.join(self.build_dir, 'nginx', 'conf', 'http-php.conf')) as fin: data = fin.read() eq_(-1, data.find('#{PHP_FPM_LISTEN}')) eq_(-1, data.find('{TMPDIR}')) # Test PHP self.assert_exists(self.build_dir, 'php') self.assert_exists(self.build_dir, 'php', 'etc') self.assert_exists(self.build_dir, 'php', 'etc', 'php-fpm.conf') self.assert_exists(self.build_dir, 'php', 'etc', 'php.ini') self.assert_exists(self.build_dir, 'php', 'sbin', 'php-fpm') self.assert_exists(self.build_dir, 'php', 'bin') self.assert_exists(self.build_dir, 'php', 'lib', 'php', 'extensions', 'no-debug-non-zts-20100525', 'bz2.so') self.assert_exists(self.build_dir, 'php', 'lib', 'php', 'extensions', 'no-debug-non-zts-20100525', 'zlib.so') self.assert_exists(self.build_dir, 'php', 'lib', 'php', 'extensions', 'no-debug-non-zts-20100525', 'curl.so') self.assert_exists(self.build_dir, 'php', 'lib', 'php', 'extensions', 'no-debug-non-zts-20100525', 'mcrypt.so') except Exception, e: print str(e) if hasattr(e, 'output'): print e.output if output: print output raise