Build Elasticsearch cluster Stress test cases for httptest4net

Source: Internet
Author: User

Httptest4net is a tool that can customize HTTP stress testing, and users can write test cases to load into httptest4net and run tests according to their own circumstances. Because of the recent need to test the Elasticsearch search cluster in a different situation, a simple test case was written for the test.

Code
1[Test ("ES Base")]2      Public classEs_searchurltester:iurltester3     {4      5          PublicEs_searchurltester ()6         {7           8 9         }Ten          Public stringURL One         { A             Get; -             Set; -         } the  -  -         Static string[] URLs =New string[] {  -             "Http://192.168.20.156:9200/gindex/gindex/_search", +             "Http://192.168.20.158:9200/gindex/gindex/_search", -             "Http://192.168.20.160:9200/gindex/gindex/_search" }; +  A         Private Static LongMindex =0; at  -         Private Staticlist<string>mwords; -  -         protected Staticilist<string>Words () -         { -  in             if(Mwords = =NULL) -             { to                 Lock(typeof(es_searchurltester)) +                 { -                     if(Mwords = =NULL) the                     { *Mwords =Newlist<string>(); $                         using(System.IO.StreamReader reader =NewStreamReader (@"D:\main.dic"))Panax Notoginseng                         { -                             stringLine ; the  +                              while(line = reader.) ReadLine ())! =NULL) A                             { the Mwords.add (line); +                             } -                         } $                     } $                 } -             } -             returnmwords; the         } -         /*Wuyi {"Query": the     { - "bool": { Wu "should": [{ - "field": { About " title": "#key" $       } -     }, { - "field": { - "kw": "#key" A       } +     } ] the   } -     }, $ from:0, the size:10 the } the          */ the         Private Static stringGetsearchurlword () -         { inilist<string> words=Words (); theSystem.Threading.Interlocked.Increment (refmindex); the             returnResource1.QueryString.Replace ("#key", words[(int) (Mindex%words. Count)]);  About         } the  the          PublicSystem.Net.HttpWebRequest createrequest () the         { +             varHttpWebRequest = (HttpWebRequest) webrequest.create (urls[mindex%URLs. Length]); -Httpwebrequest.contenttype ="Application/json"; theHttpwebrequest.keepalive =false;BayiHttpwebrequest.method ="POST"; the             stringJSON =Getsearchurlword (); the             using(varStreamWriter =NewStreamWriter (Httpwebrequest.getrequeststream ())) -             { -  the StreamWriter.Write (JSON); the StreamWriter.Flush (); the             } the             returnHttpWebRequest; -  the         } the  the          PublicTesttype Type94         { the             Get the             { the                 returnTesttype.post;98             } About         } -}

The use case is simple to build URLs and JSON packets of different requests based on nodes and keywords. This use case can be loaded and tested by compiling the above code behind the DLL and putting it into the httptest4net run directory.

Test situation

Download httptest4net

Build Elasticsearch cluster Stress test cases for httptest4net

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.