Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 2025

Show
Ignore:
Timestamp:
07/23/08 23:33:20
Author:
fumanchu
Message:

Got the --server=modfcgid option to test.py working.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/test/fcgi.conf

    r2018 r2025  
    22# Apache2 server conf file for testing CherryPy with mod_fcgid. 
    33 
    4 DocumentRoot "/
     4DocumentRoot "C:\Python25\Lib\site-packages\cherrypy\test
    55Listen 8080 
    66LoadModule fastcgi_module modules/mod_fastcgi.dll 
     
    1111RewriteEngine On 
    1212RewriteRule ^(.*)$ /fastcgi.pyc [L] 
    13 FastCgiServer "C:\\Python25\\Lib\\site-packages\\cherrypy\\test\\fastcgi.pyc" -port 4000 
     13FastCgiExternalServer "C:\\Python25\\Lib\\site-packages\\cherrypy\\test\\fastcgi.pyc" -host 127.0.0.1:4000 
  • trunk/cherrypy/test/helper.py

    r2004 r2025  
    148148        else: 
    149149            app = validate.validator(app) 
    150     cherrypy.server.httpserver.wsgi_app = app 
     150     
     151    h = cherrypy.server.httpserver 
     152    if hasattr(h, 'wsgi_app'): 
     153        # CherryPy's wsgiserver 
     154        h.wsgi_app = app 
     155    elif hasattr(h, 'fcgiserver'): 
     156        # flup's WSGIServer 
     157        h.fcgiserver.application = app 
     158    elif hasattr(h, 'scgiserver'): 
     159        # flup's WSGIServer 
     160        h.scgiserver.application = app 
    151161 
    152162def _run_test_suite_thread(moduleNames, conf): 
  • trunk/cherrypy/test/modfcgid.py

    r2018 r2025  
    4040import time 
    4141 
     42import cherrypy 
     43from cherrypy.process import plugins, servers 
    4244from cherrypy.test import test 
    4345 
     
    7173RewriteEngine On 
    7274RewriteRule ^(.*)$ /fastcgi.pyc [L] 
    73 FastCgiServer "%(server)s" -port 4000 
     75FastCgiExternalServer "%(server)s" -host 127.0.0.1:4000 
    7476""" 
    7577 
    76 def start(testmod, host, port, conf_template): 
     78def start_apache(host, port, conf_template): 
    7779    fcgiconf = CONF_PATH 
    7880    if not os.path.isabs(fcgiconf): 
     
    9092        f.close() 
    9193     
    92     # Write the .py file to import testmod and run setup_server 
    93     # Import it immediately so we get a .pyc file. 
    94     f = open(os.path.join(curdir, 'fastcgi.py'), 'wb') 
    95     try: 
    96         f.write("""import cherrypy 
    97 from cherrypy.process import plugins, servers 
    98 from cherrypy.test import %s 
    99  
    100 if hasattr(%s, 'setup_server'): 
    101     %s.setup_server() 
    102  
    103 def run(): 
    104     cherrypy.config.update(%r) 
    105      
    106     engine = cherrypy.engine 
    107     cherrypy.config.update({'environment': 'test_suite'}) 
    108      
    109     if hasattr(engine, "signal_handler"): 
    110         engine.signal_handler.subscribe() 
    111     if hasattr(engine, "console_control_handler"): 
    112         engine.console_control_handler.subscribe() 
    113      
    114     # Turn off autoreload when using fastcgi. 
    115     cherrypy.config.update({'engine.autoreload_on': False}) 
    116     cherrypy.server.unsubscribe() 
    117     bindAddress = ('127.0.0.1', 4000) 
    118     f = servers.FlupFCGIServer(application=cherrypy.tree, bindAddress=bindAddress) 
    119     s = servers.ServerAdapter(engine, httpserver=f, bind_addr=bindAddress) 
    120     s.subscribe() 
    121      
    122     # Always start the engine; this will start all other services 
    123     try: 
    124         engine.start() 
    125     except: 
    126         # Assume the error has been logged already via bus.log. 
    127         sys.exit(1) 
    128     else: 
    129         engine.block() 
    130  
    131 if __name__ == '__main__': 
    132     run() 
    133 """ % (testmod, testmod, testmod, os.path.join(curdir, 'test.conf'))) 
    134     finally: 
    135         f.close() 
    136     from cherrypy.test import fastcgi 
    137     reload(fastcgi) 
    138      
    13994    result = read_process(APACHE_PATH, "-k start -f %s" % fcgiconf) 
    14095    if result: 
     
    150105     
    151106    def _run(self, conf): 
    152         from cherrypy.test import webtest 
    153         webtest.WebCase.PORT = self.port 
    154         webtest.WebCase.harness = self 
    155         webtest.WebCase.scheme = "http" 
    156         webtest.WebCase.interactive = self.interactive 
    157         print 
    158         print "Running tests:", self.server 
    159          
    160         conf_template = conf_fcgid 
    161          
    162         # Since cherryd is run by the Apache process, Apache must be 
    163         # started separately for each test. 
    164         success = True 
    165         for testmod in self.tests: 
    166             try: 
    167                 start(testmod, self.host, self.port, conf_template) 
    168                 suite = webtest.ReloadingTestLoader().loadTestsFromName(testmod) 
    169                 result = webtest.TerseTestRunner(verbosity=2).run(suite) 
    170                 success &= result.wasSuccessful() 
    171             finally: 
    172                 stop() 
    173         if success: 
    174             return 0 
    175         else: 
    176             return 1 
     107        cherrypy.server.httpserver = servers.FlupFCGIServer( 
     108            application=cherrypy.tree, bindAddress=('127.0.0.1', 4000)) 
     109        cherrypy.server.httpserver.bind_addr = ('127.0.0.1', 4000) 
     110        try: 
     111            start_apache(self.host, self.port, conf_fcgid) 
     112            return test.TestHarness._run(self, conf) 
     113        finally: 
     114            stop() 
    177115 

Hosted by WebFaction

Log in as guest/cpguest to create tickets