Piotras' blog
Midgard unit and regression tests
Posted on 2008-08-25 22:43:44 EEST.
I must say, I do like GLib testing framework. I already started writing Midgard tests, but still wondering what, how and why should be changed. Even now, when few things seems to be too difficult to implement, I see many very nice features:
- Test can be automated (ok, not a big deal)
- Test program with routines might be run through
gtester - Once it's done, one may create xml report
- Once xml is created, one is able to make it much more user friendly
GTester Unit Test Report
| Program / Testcase | Duration (sec) | View | Result |
|---|---|---|---|
| midgard_test | 3.220978 | ER OK | 100.00% |
| /midgard_config | 0.000880 | - | success |
| /midgard_connection | 0.017047 | - | success |
| /midgard_database/create | 1.514101 | - | success |
| /midgard_database/update | 1.476490 | - | success |
| /midgard_object/basic | 0.011082 | - | success |
| /midgard_object/basic/create | 0.193323 | - | success |
| /midgard_object/basic/update | 0.000527 | - | success |
| /midgard_object/fetch | 0.001588 | - | success |
| Totals: 1 Binaries, 8 Tests, 0 Failed, 8 Succeeded | 3.220978 | - | 100.00% |
As test program is invoking typical API functions, I can easily run it via valgrind and catch memory leaks before they appear on production servers. And with some nice test separation, reported duration could be quite usefull to notice some obvious performance bottlenecks.
How to run Midgard 8.9.0
Posted on 2008-08-13 23:22:13 EEST.
Midgard 8.9.0 (1.9beta1) will be released soon. I have planned to make this today, but there are still small issues and bugs which must be fixed to have very nice beta version. If you feel impatient, follow me.
How to install it? It's quite simple. You can get fresh SVN checkout or install binary packages.
Build
SVN checkout
I assume you have svn client installed.
svn co https://svn.midgard-project.org/midgard/branches/branch-1-9 midgard
cd midgard
./makedist
Now you should have all tarballs. Untar all packages and build. In most cases simple build rules should be enough:
./configure
make
sudo make install
In case of any problems you can always get help:
./configure --help
Installing binary packages
The easiest way. Download packages from repository. We have debian, ubuntu and opensuse ones. Unfortunately, debian or ubuntu users have to download packages and install them via dpkg. I already reported apt-get way problems and let's hope guys from Opensuse will fix it soon.
Configure and install
Once Midgard package are installed. You can install new database or upgrade existing installation.
Installing new database
Just run datagard.
datagard
In this case, you will be asked few questions and datagard will:
- create new database
- install MidCOM from pear channel
- create new sitegroup ( Midgard Domain )
- create new Midgard host
- create new Apache virtual host
If you fell, you would like to enjoy your coffee, try this:
datagard -t q
'q' or 'quick' is quick and simple mode and 'w' or 'wizard' is the mode when you are need to answer the questions.
In this mode, datagard will try to be smart as much as possible and probably will not ask you any question.
In both cases, datagard will try to use default 'midgard' unified configuration. If you would like to use different configuration, specify it:
datagard -c myconfig
Upgrade exsiting installation
Create configuration which describes your setup best, and run datagard with 'upgrade' action.
datagard -c myconfig -a upgrade
This will remove MidCOM 2.8 ( if exists ) and install new MidCOM 2.9 from new pear channel. Also database will be updated.
Running simple action
Install pear packages.
datagard -a pear
Upgrade database only
datagard -a dbupdate
Install new sitegroup
datagard -a sitegroup
Install new Midgard host
datagard -a vhost
Iron Man
Posted on 2008-07-30 19:46:41 EEST.
Maybe quiz itself is old, but who cares ;)
Your results:
You are Iron Man
|
Inventor. Businessman. Genius.![]() |
More options for datagard
Posted on 2008-07-29 14:14:45 EEST.
New, rewritten datagard, which is responsible to correctly install Midgard has now more usable options. Basically it upports different setup types and different setup actions. Or combinations.
First you can start quick setup mode:
datagard -t q
It installs Midgard and doesn't ask you any questions, taking good default values for everything.
You can also set some key in configuration file:
datagard -t config -c midgard -a config-set loglevel message
Use 'config' setup type, take named 'midgard' as configuration and set 'message' as 'loglevel' key.
Create new sitegroup or new virtual host ( with default wizard setup type ) :
datagard -a sitegroup
datagard -a vhost
In latter case you are also asked for sitegroup, so if you want to create both, select this option. An interesting fact is that datagard, when creating new host will ask you if you want to create host for MidCOM3. When you say 'yes', your MidCOM3 has no page elements and empty content for page.
Create more, work less
Posted on 2008-07-18 14:06:29 EEST.
Providing easy to install binary packages for users and developers is not funny task, but also it's very important step in software development process.
Recently, I blogged about new binary packages for Midgard. And instead of waiting for feedback I decided to go few steps further. And just today we started to serve Midgard from three different repositories. One is for stable release, second for upcoming 1.9 which contains automatically built packages for developers, and third one is reserved for stable 1.9 release.
Packages are built at opensuse build system ( OBS ), and now we support debian, ubuntu and opensuse distros. Both 32bit and 64bit environments. Soon, we'll add support for CentOS and Fedora Core.
To test packages add to sources.list:
Debian:
http://download.opensuse.org/repositories/home:/midgardproject:/midgard19-dev/Debian_Etch ./
Ubuntu:
http://download.opensuse.org/repositories/home:/midgardproject:/midgard19-dev/xUbuntu_8.04 ./
You can also use OBS search functionality to find package and install it with one click. Just type 'midgard' and select distribution you use.
It's worth mentioning that new build process is fully automated. The script which is invoked periodically on machine acts like automated release manager and looks like this:
Get latest sources:
svn co https://svn.midgard-project.org/midgard/branches/branch-1-9/midgard obsmidgard
Go to sources directory
cd obsmidgard
Create tarballs and set default version to all packages.
./makedist
Login into OBS, remove old tarballs and upload new ones. Trigger rebuild.
php obs_upload.php
Clean all when it's done.
cd -
rm -rf obsmidgard
It's enough to commit changes to svn if anything must be changed. Script will use new functionalities when running next time.
Once we can find this usefull, we're going to create new repositories. For Midgard2.
Debug memory of PHP module
Posted on 2008-07-09 21:55:41 EEST.
The first question I ask to myself. What's the difference between PHP module and extension? Is it like, that PHP has modules while Zend extensions? If yes, why? If not, why there are both types? There are no comments allowed, so questions remain unanswered. Well... as usual, I would say. That's nature of Zend/PHP support.
Anyway, you wrote PHP module and want to debug or profile its memory. Or you just want to catch all memory leaks. The first action is to run php via valgrind, but in such case, the log file is far from being helpfull:
==17786== 4,096 bytes in 1 blocks are definitely lost in loss record 843 of 860
==17786== at 0x4C20FEB: malloc (vg_replace_malloc.c:207)
==17786== by 0x4C21134: realloc (vg_replace_malloc.c:429)
==17786== by 0xCFAD9C8: ???
==17786== by 0xCF93A59: ???
==17786== by 0xCD533D6: ???
==17786== by 0xCAFB918: ???
==17786== by 0xDEE3D40: ???
==17786== by 0xBA69642: ???
==17786== by 0xBA6E924: ???
==17786== by 0xBA67E89: ???
This is not what you expected. And to be honest, this is something which tells you nothing but nothing :)
PHP just unloads your module, so there's nothing which can be mentioned in log file. Luckilly, I found that module ( zend_module_entry ) has handle member which, if set to 0 tells zend, that your module should not be unloaded.
In practice, you should add similiar code to RSHUTDOWN:
zend_module_entry *module;
int rv = zend_hash_find(&module_registry, "module_name", strlen("module_name")+1, (void**)&module);
if(rv == SUCCESS)
module->handle = 0;
Once it's added, recompile module and run php via valgrind. Keep in mind, this code should be used for debug purposes only.
New binary packages for Midgard 1.8
Posted on 2008-07-09 11:22:49 EEST.
At last, Debian is not the only one platform, for which we provide Midgard binary packages. We started to build packages using quite nice and powerful opensuse build system. A bit difficult to build debian packages out of the box, but with few tricks used here and there, we have binary packages for debian stable and ubuntu. For both, 32bit and 64bit architectures. Debs are not the only ones we buil there. Included distributions are: CentOS ( RedHat ), Fedore Core and Opensuse. You can browse all of them.
Debian and Ubuntu users can try to install packages with apt-get, adding such line to /etc/apt/sources.list:
deb http://download.opensuse.org/repositories/home:/midgardproject:/midgard18/Debian_Etch ./
Kudos and big thanks to everaldo and potyl!. It couldn't be done, without you guys.
