Category Archives: Testing

Debugging mails being send from applications

Ever needed to test the e-mail functionality of your application, on windows, without having access to a SMTP server? Try SMTP server for developers, a brilliant piece of software, so far.

You need .Net for it. It’s really easy to setup and use. Another advantage of this SMTP server is that when you test your application, you don’t have to worry about test e-mails being send to customers. This because the SMTP server doesn’t really send the messages, but just places all of them on disk.

Update: one disadvantage. You can’t get it to run on any other port then 25, which is inconvenient if McAfee is blocking port 25. I contacted the author a while ago, but no response so far. Guess I’ll have to add this functionality myself, but then I need to get up to speed on .Net first. Ah well, I’ll wait a little longer.

Talking about McAfee… It’s kinda weird, it blocks e-mails on port 25 if I use for example Java to send the e-mail. But if I use telnet to connect to port 25, all is fine?

PHP Acceleration with eAccelerator

With high traffic sites, performance issue’s rise. Now one of the solutions is to use an opcode caching mechanism for PHP. There are two mainstream open source solutions for that, APC and eAccelerator. And there is Zend platform and Zend core.

Installing eAccelerator
I found a very straight forward howto about installing eAccelerator (and others) on Debian.

But, as always, there are some problems with that tutorial. First the -- is replaced by a special character on that tutorial (and in my blog if I don’t use the <code> tag) in the configure command, so that doesn’t work if you copy paste it. The working configure command is:


./configure --enable-eaccelerator=shared --with-php-config=/usr/bin/php-config

And you don’t need to do all the work as root, only the apt-get, the make install and the php.ini editing should be done as root (best practice, only use root privileges when needed).

Also the double quotes are changed into a special character in that tutorial, so if you get an error in your logs about unable to load \xe2\x80\x9deaccelerator.so\xe2\x80\x9d you copied them just like I did ;-)

This is what I put in the php.ini, without the special double quotes, and with one change


extension="eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/var/cache/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"

The tutorial writer creates the cache directory in /tmp. But he fails to make the remark that /tmp is cleared on server restart. So that’s not really a good option. So I’ve done the following in stead


sudo mkdir /var/cache/eaccelerator
sudo chown www-data /var/cache/eaccelerator
sudo chmod 0755 /var/cache/eaccelerator

Yes, the 0644 from the eAccelerator wiki is what you want for the files being created in there, but not for the directory itself.

The big disadvantage of this way of installing it, is that you probably need to recompile it (after a make clean) and reinstall it on every update of PHP. But reading up on APC vs eAccelerator made me choose for the latter.

But does it really help?
Now, the results. What better to test then my own PHP blog (and yes it’s not the fastest one, it’s running on a VPS).

Before installing eAccelerator:

Server Software:        Apache/2.2.8
Server Hostname:        blog.delgurth.com
Server Port:            80

Document Path: / Document Length: 44436 bytes
Concurrency Level: 10 Time taken for tests: 397.121299 seconds Complete requests: 1000 Failed requests: 0 Write errors: 0 Total transferred: 44796000 bytes HTML transferred: 44436000 bytes Requests per second: 2.52 [#/sec] (mean) Time per request: 3971.213 [ms] (mean) Time per request: 397.121 [ms] (mean, across all concurrent requests) Transfer rate: 110.16 [Kbytes/sec] received
Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.3 0 6 Processing: 712 3961 1674.7 3696 10696 Waiting: 368 2177 1013.3 2033 6943 Total: 712 3961 1674.7 3696 10696
Percentage of the requests served within a certain time (ms) 50% 3696 66% 4454 75% 4977 80% 5270 90% 6225 95% 7039 98% 8188 99% 8632 100% 10696 (longest request)

After installing eAccelerator

Server Software:        Apache/2.2.8
Server Hostname:        blog.delgurth.com
Server Port:            80

Document Path: / Document Length: 44436 bytes
Concurrency Level: 10 Time taken for tests: 242.584585 seconds Complete requests: 1000 Failed requests: 0 Write errors: 0 Total transferred: 44796000 bytes HTML transferred: 44436000 bytes Requests per second: 4.12 [#/sec] (mean) Time per request: 2425.846 [ms] (mean) Time per request: 242.585 [ms] (mean, across all concurrent requests) Transfer rate: 180.33 [Kbytes/sec] received
Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.2 0 4 Processing: 430 2419 983.2 2330 6409 Waiting: 100 648 448.6 578 3025 Total: 430 2419 983.2 2330 6409
Percentage of the requests served within a certain time (ms) 50% 2330 66% 2798 75% 3051 80% 3246 90% 3712 95% 4182 98% 4614 99% 4901 100% 6409 (longest request)

So it helps also quite a bit on my wordpress install, it’s about a 33% performance increase!

Some material I read

P.s. yet another wordpress rant, if you have empty lines between <code> tags, wordpress inserts <p> tags there for you. Not very nice to my liking, since it breaks the formatting of the <code> tag, which I used to format the apache bench results…

Using VMware player for testing Internet Explorer on Ubuntu

One disadvantage of developing websites/web applications on Unix (in my case Ubuntu) is that it’s hard to test things on Internet Explorer. Yes, you have IEs4Linux but that’s just not the same thing.

For real testing with the different versions of Internet Explorer Microsoft makes images available so you can test your websites/web applications in Microsoft Virtual PC. Unfortunately it’s not easy to use them when you develop on Unix.

So I wanted to see if I could convert these images into VMware images, since VMware player can run on Ubuntu. And it seems this is possible. Even though I’m not entirely sure I don’t break any EULA’s with this… To get it all working you need a Windows machine (with administrator rights) on which you need to unpack and convert the images. This conversion is not needed when you use VMware workstation. This conversion needs to be done every 6 months or so, since the windows version on the VPD has an expiry date.

Installing VMware player
Download VMware player tar.gz unpack it and run the installer as root.

When you are installing it you might get the following error (if you have a newer kernel):

include/asm/bitops_32.h:9:2: error: #error only <linux/bitops.h> can be included directly

But long live people who blog about their experiences, here is the solution for this problem. The writer forgot to put sudo before some of the commands and he assumes you came on his site after it failed and you didn’t try to remove the partially installed VMware player. Here are the steps with all the sudo’s:

  1. cd /usr/lib/vmware/modules/source
  2. sudo cp vmmon.tar vmmon.tar.orig (if you want to be able to undo your changes)
  3. sudo tar xvf vmmon.tar
  4. sudo vi vmmon-only/include/vcpuset.h
  5. change line 74 from: #include "asm/bitops.h" to: #include "linux/bitops.h"
  6. sudo rm vmmon.tar
  7. sudo tar cvf vmmon.tar vmmon-only/
  8. sudo rm -rf vmmon-only/
  9. sudo vmware-config.pl

Then you have a working VMware player.

Getting the Virtual PC Images
Microsoft makes VPC images available for IE6 and IE7, and now also the IE8 beta 1. Just download them and unpack them on a windows machine.

Converting the Virtual PC images
Get VMware converter to convert the free Virtual PC images to VMware images. Before you can convert them you first need to make a VPC image for the VHD. This can be done by running Virtual PC 2007. After that you can put the image in VMware converter and convert it into a VMware virtual machine. This is the part where I’m not sure if it’s legal or not. When converting the image, don’t forget to set the checkbox for the VMware tools.

Using the Virtual PC images
Because we use VMware player, we don’t have the VMware tools package. Lucky for us you can download the VMware workstation evaluation copy and unpack it. Then you need to copy the iso images in there to make sure that the VMware tools can get installed (you might get a message about inserting the windows xp sp2 cdrom, but if you just cancel those, the virtual machine still works good enough to test IE). You might wonder if this is legal, but according to this thread it should be ok. The following command I used to copy them, but you need to be in the directory below the one where you unpacked the workstation evaluation copy.

sudo cp -r vmware-distrib/lib/isoimages /usr/lib/vmware/

After that you are ready to use the Virtual PC images with VMware tools.

Other nice things to do

Using your existing windows partition
Other thing you can do is use your dual boot windows partition. For now no blog post about that, since I didn’t try that out myself. But here are some links about it:

When you use the same windows install from disk and from VMware, you will run into problems with the Windows hardware based activation. But also for that problem a a solution exists and is blogged about. It’s pretty simple, if you know it. It seems that windows activation creates two files that contain the activation information. If you just keep both versions of the activation information available and copy them into the right place at the right time, all should work well ;-)

Running things outside the VMware scope
If you want the Internet Explorer in a window outside your virtual machine, you can do that using rdesktop. Some information about that can be found on the following sites.

A side note
Unfortunately, while writing this post I encountered one problem with referring to other articles which contain the HOWTO for your problem. When you google for Run Existing Windows Installation on Ubuntu with Vmware Player you will find a lot of referrals to one specific article, which is no longer available. This is the main reason why I copy/pasted the steps to install VMWare player, in stead of only linking to them.