You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by St...@dlr.de on 2008/08/04 16:27:58 UTC

Testing modules using Python

Hi,
I want to unit test my module (catacomb.tigris.org) using Python. My
idea is to load the module with ctypes (a python module that allows to
load functions from shared libraries into python) and test it in this
environment. The main advantage is that it's much easier to create
mock-up objects in Python than in C. My problem is that ctypes fails if
the shared library contains any undefined symbols. Because the module is
used normally together with a httpd server,
there're a lot of undefined symbols. My solution is to link libapr,
libaprutil, libexpat and libmysql statically in my module and to add a
file with the definitions of the apache-internal functions (just copy
and paste from httpd source). With every function which I copy in this
file I get a few new undefined symbols. All in all it's a pain to search
all definitions and I probably have to do this again after adding new
features which uses other functionalities. 

Is there an easier way to do this? To build a module which includes all
needed links to apache functions without linking the needed libraries
statically and copy-and-paste functions from apache source? Or do you
know a better way to do this?

Steven 


------------------------------------------------
Steven Mohr
Bachelor student

DLR (German Aerospace Center), 
Simulation and Software Technology
Linder Hoehe, 51147 Cologne, Germany
voice: +49 2203 601 2956  fax: +49 2203 601 3070
eMail: steven.mohr at dlr.de      http://www.dlr.de/sc

AW: Testing modules using Python

Posted by St...@dlr.de.
Thanks for your advice. But I think that there's nothing comparable in Apache 2.x. I've wrote an email to dev@httpd.apache.org. Perhaps is there a possibility I don't know about and one of the guys there could help me. Do you have other ideas how I could solve my problem??

Steven


-----Ursprüngliche Nachricht-----
Von: Peter Poeml [mailto:poeml@suse.de] 
Gesendet: Montag, 4. August 2008 16:37
An: modules-dev@httpd.apache.org
Betreff: Re: Testing modules using Python

On Mon, Aug 04, 2008 at 04:27:58PM +0200, Steven.Mohr@dlr.de wrote:
> Hi,
> I want to unit test my module (catacomb.tigris.org) using Python. My
> idea is to load the module with ctypes (a python module that allows to
> load functions from shared libraries into python) and test it in this
> environment. The main advantage is that it's much easier to create
> mock-up objects in Python than in C. My problem is that ctypes fails if
> the shared library contains any undefined symbols. Because the module is
> used normally together with a httpd server,
> there're a lot of undefined symbols. My solution is to link libapr,
> libaprutil, libexpat and libmysql statically in my module and to add a
> file with the definitions of the apache-internal functions (just copy
> and paste from httpd source). With every function which I copy in this
> file I get a few new undefined symbols. All in all it's a pain to search
> all definitions and I probably have to do this again after adding new
> features which uses other functionalities. 
> 
> Is there an easier way to do this? To build a module which includes all
> needed links to apache functions without linking the needed libraries
> statically and copy-and-paste functions from apache source? Or do you
> know a better way to do this?
> 
> Steven 

With httpd 1.3, there used to be a way to build something what was
called "shared core", a shared object that contained the server in a
form you could link it into an application.

I don't know if this is still possible with httpd 2.x, but what used I
in an RPM package at the time was 

    --enable-rule=SHARED_CORE
    
    mkdir shared_core
    cp -p src/libhttpd.ep src/libhttpd.so src/httpd
    shared_core


   # install shared-core apache
   install -m 755 shared_core/libhttpd.ep $RPM_BUILD_ROOT/%{_libdir}/%{name}
   install -m 755 shared_core/libhttpd.so $RPM_BUILD_ROOT/%{_libdir}/%{name}
   ln -s %{_libdir}/%{name}/libhttpd.ep $RPM_BUILD_ROOT/%{_sbindir}/httpd-shared_core
   ln -s %{_libdir}/%{name}/libhttpd.so $RPM_BUILD_ROOT/%{_libdir}/libhttpd.so


At the time, that was reportedly working to build DSOs with Kylix 3.

Peter
-- 
Contact: admin@opensuse.org (a.k.a. ftpadmin@suse.com)
         #opensuse-mirrors on freenode.net
Info: http://en.opensuse.org/Mirror_Infrastructure
 
SUSE LINUX Products GmbH
Research & Development

Re: Testing modules using Python

Posted by Peter Poeml <po...@suse.de>.
On Mon, Aug 04, 2008 at 04:27:58PM +0200, Steven.Mohr@dlr.de wrote:
> Hi,
> I want to unit test my module (catacomb.tigris.org) using Python. My
> idea is to load the module with ctypes (a python module that allows to
> load functions from shared libraries into python) and test it in this
> environment. The main advantage is that it's much easier to create
> mock-up objects in Python than in C. My problem is that ctypes fails if
> the shared library contains any undefined symbols. Because the module is
> used normally together with a httpd server,
> there're a lot of undefined symbols. My solution is to link libapr,
> libaprutil, libexpat and libmysql statically in my module and to add a
> file with the definitions of the apache-internal functions (just copy
> and paste from httpd source). With every function which I copy in this
> file I get a few new undefined symbols. All in all it's a pain to search
> all definitions and I probably have to do this again after adding new
> features which uses other functionalities. 
> 
> Is there an easier way to do this? To build a module which includes all
> needed links to apache functions without linking the needed libraries
> statically and copy-and-paste functions from apache source? Or do you
> know a better way to do this?
> 
> Steven 

With httpd 1.3, there used to be a way to build something what was
called "shared core", a shared object that contained the server in a
form you could link it into an application.

I don't know if this is still possible with httpd 2.x, but what used I
in an RPM package at the time was 

    --enable-rule=SHARED_CORE
    
    mkdir shared_core
    cp -p src/libhttpd.ep src/libhttpd.so src/httpd
    shared_core


   # install shared-core apache
   install -m 755 shared_core/libhttpd.ep $RPM_BUILD_ROOT/%{_libdir}/%{name}
   install -m 755 shared_core/libhttpd.so $RPM_BUILD_ROOT/%{_libdir}/%{name}
   ln -s %{_libdir}/%{name}/libhttpd.ep $RPM_BUILD_ROOT/%{_sbindir}/httpd-shared_core
   ln -s %{_libdir}/%{name}/libhttpd.so $RPM_BUILD_ROOT/%{_libdir}/libhttpd.so


At the time, that was reportedly working to build DSOs with Kylix 3.

Peter
-- 
Contact: admin@opensuse.org (a.k.a. ftpadmin@suse.com)
         #opensuse-mirrors on freenode.net
Info: http://en.opensuse.org/Mirror_Infrastructure
 
SUSE LINUX Products GmbH
Research & Development

Can you set the request timeout dynamically within a module?

Posted by John Zhang <jo...@yahoo.com>.
Hi Everyone,
    We have an output filter.  Some requests take a "VERY" long time for the filter to process (I know many of you have questions here.  But the logic is in the page).  We would like to know if there is a way for the module (our output filter) to tell apache to not terminate "THIS" request.  We do not want to increase the default timeout.

   I looked at the server_rec struct, it has a timeout member (default = 300 secs, yes this is a very long time).  Is this the one that controls the request timeout? If yes, I guess it controls every request.  And is it a good idea for a request to change the server_rec struct?  Even if it is OK to change it, will it take affect for the current request?

  Or I am looking at a wrong place/parameter.

Thanks in advance!
John