2014年3月9日星期日

A distributed concurrent test framework based on Zookeeper

    All developer who have developed back-end service should know that ensures these processes work properly just is first step,most important work still is the concurrent safe。
    For finding out the concurrent bug of program,we must prepare some of conditions while during the test:
  1. enough request stress,it ensures a data is requested by more than one thread save and update
  2. enough business processes is coverd,the read and the write、the save and the get should simultaneously happen,and the data involved must be extensive
    For increasing stress,we can start some of thread where they are distributed on other server mock user action,uninterruptedly proceed all kinds of action。this test method is called distributed test。many test tools can do this,such as Jmeter,apache AB,Loadrunner,and so on。
    But for distributed test,increasing stress just is one of difficult point,another difficult point is how to resolve test scheduler problem。
    Thinking back a typical automatic test process:


  1. built test logic
  2. execute test logic
  3. assert
    Mock stress with regard to top two step,for third step,it have changed "distributed assert",we must accurately control all test node for do this。
    The test tools which can implement distributed scheduler is complicated by using,we offen have to write many scrips and configuration,and there things needs very high stduty cost,some time after we have learned this,the time of working is very less。
Now with help of zookeeper,we can write a small program for do this,it is very simple and the codes is very short,general several lines。
    For zookeeper,I don't Introduce it,because it's information is very more on internet,just only a word,all the action of zookeeper is atomic,and can implement incrementing,we easily implement some of distributed and synchronous arithmetics by this feature。these arithmetics are base of implementing distributed scheduler。
    So I have writed a simple test framework:Dispatcher ,only if is userd for illustrating zookeeper's ability on distributed scheduler。
  architecture: