Monday, January 16, 2012

Extend Btrace

If you would like to build you own methods in Btrace, you would prefer to checking out Btrace source code with Netbeans6.9plus and Mercurial, for detail steps, please refer to:
http://netbeans.org/kb/docs/ide/mercurial.html
the Repository URL: https://hg.kenai.com/hg/btrace~hg

Basically, I have added several methods to help monitoring the JVM Performance, for example:
  • currentProcessCpuTime
  • currentProcessCpuUsage
  • getTotalCollectionCount
  • getGCThroughput
  • getMinorGCDetailInfo
  • getFullGCDetailInfo
  • jstackAllFile(dump all thread stack trace to local file)

You can take a look at the source code i extend from my github, and extend yours if you like:
https://github.com/joychester/btrace_Ext

Tuesday, January 10, 2012

Question about benefits of Web automation

One of my friend asked a question about Automation recently :"is UI test automation actually providing anything useful?"
I Want to share some of thoughts and bias from my own experience and perspective:

The UI automation is a kind of faith. Once you believe it, you need to advocate a lot at first(need dedicate resource and patient from management team), then you get your pay back after a period of time gradually.

We should not exaggerate its effect/scope(So do expectation management to the managers are really important and critical). But it really helps in following situations i can think of:

1. Prevent the UI regression bugs (Yes, Prevent Regression not Find bugs, due to you need to write workable automation code based on the workable scenario, so once the automation test failed, then you have got a regression bug)
2. Reduce the execution time, so as the human resources.(You can run test anywhere, anytime without anyone, and then collect test result and analyze it afterwards) Also it can be scaled easily if you have tons of tests to be run. So the execution time is critical to the projects.
3. It is reliable and consistence(Not like Human, Computer always tell the truth :) )
4. QA can help with that.It is black box testing, so no need to know the detail implementation of "complex" technique stuff. (seems most of QA person would like to learn and write UI automation tests from my observation)
5.Easy to track the history data for Automation test.Automation test result can be kept easily, in which history data can reveal something about quality and people, who always break the build, who always write the bad code and who always write the bad test code, etc.
6. Help to do the application health check for QA. Health check is time consuming and always repeatable but not avoidable in some situation, so it is really helpful to do automation in this situation.
7.... many more can get from the web i am sure,so i will not mention that to waste of your time, lol

For Practical Way of doing Web UI Automation test, I have done some research about that in my previous days in 2010 although i am not an automation guy... So hope my thoughts can give you some clues to this tough question :)
It is deserved to take a look at the WebDriver project which has been merged to Selenium 2.0 project: http://code.google.com/p/selenium/ 
In this project, apart from the multiple drivers implementation and clean APIs, the most Important and Essential idea of how to do the Web Automation is introducing the Page Objects Pattern:http://code.google.com/p/selenium/wiki/PageObjects, which implement the Automation test as a OOD/OOP way. It is much easier to maintain the code and tests than traditional way (which is a record/playback, and step by step describe way to write the automation code).
Anyway, The manual test can be never replaced by Automation test, however, Web UI Automation is also great complement to improve your quality and deserve to put great effort to invest the future. Everything is from the initial purpose, so if Web Automation's strong points can be matched with the project real needs, so just do it with patient and no doubt. If they just want to produce instant results and cut down the bug number on production badly(as i said, Auto test is just preventing bugs not help to find new bugs), then it might loose them confidence i am afraid...

Monday, January 09, 2012

Apache Memory keep increasing due to Rotate logs (with so many Vitural hosts)

We have a lot of Private labels for our application. We managed their access log and Error log in each Virtual host with Apache Http server.
If CustomLog or ErrorLog directives are placed inside a section, all requests or errors for that virtual host will be logged only to the specified file.This technique is very useful for a small number of virtual hosts, but if the number of hosts is very large, it can be complicated to manage. In addition, it can often create problems with insufficient file descriptors.
We 'luckily' got its limitation recently by adding 2 more private labels recently. So the Apache memory is keeping increasing gradually even if there is no any requests coming in.
When using a large number of Virtual Hosts, Apache may run out of available file descriptors (sometimes called file handles)if each Virtual Host specifies different log files.The limit is typically 64, and may usually be increased up to a large hard-limit.
Solution to our case:
1. We can combine all the Error logs into one Common Error log instead of creating their own within each Virtual host. So it will reduce a lot of file handles at once.
Note: If it does not work for you , then you need have to reduce your number of Virtual Hosts with single box...
2. Or you can try to adjust file handles limit before starting Apache, for example 100:
    #!/bin/sh
    ulimit -S -n 100
    exec httpd
Apache official Reference:
It is worthy to take look at the official doc carefully before using its cool features, although it is hard :)