当前位置:网站首页>Stress test WebService with JMeter
Stress test WebService with JMeter
2022-07-03 15:06:00 【Brother Xing plays with the clouds】
In real projects, we use JMeter Yes WebService Stress tests were carried out ,ApacheJMeter yes Apache Organization development based on Java Pressure testing tools for . For stress testing software .
One 、JMeter The role of
1. Can be right HTTP and FTP The server Perform pressure and performance tests , You can do the same for any database ( adopt JDBC).
2. Complete portability and 100% pure java.
3. Completely Swing And lightweight component support ( precompiled JAR Use javax.swing.*) package .
4. Full multithreading The framework allows concurrent sampling and Sampling different functions simultaneously through separate thread groups .
5. Elaborate GUI The design allows fast operation and more accurate timing .
6. Caching and offline analysis / Replay test results .
Two 、 About Jmeter The configuration of relevant environment variables of is similar to Java Configuration of , Refer to online materials
3、 ... and 、Jmeter in the light of Http Agreed webservice Test case .
1: First, create a new thread group in the test plan
among , The number of threads and the number of cycles in the thread attribute represent the actual number of runs when a test is executed , That is, access webservice The number of times .
2: Create a new thread group HTTP request ( About the configuration of related addresses and some parameters of the access interface service ) and HTTP Information manager ( send out webservice Public request header during service ), Aggregation report ( Test report ).
Four 、 After configuring everything , Click start to execute the test
=============we test webservice by http head start=========== name=clark =============we test webservice by http head end===========
remarks ==================================== The following is about webservice The configuration of services is integrated into spring in
applicationContext_webservice.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <context:annotation-config /> <import resource="classpath:META-INF/cxf/cxf.xml" />
<jaxrs:server id="restContainer" address="/"> <jaxrs:serviceBeans><!-- Here's your webservice bean Definition . Reference resources org.iboxpay.payment.merchant.ws.MerchantWebService --> <!-- <ref bean="orderWebService" /> <ref bean="merchantWebService" /> --> <ref bean="clearUserWebService" /> <ref bean="merchantWebService"/> <!-- <ref bean="balanceWebService" /> --> </jaxrs:serviceBeans> <jaxrs:extensionMappings> <entry key="json" value="application/json" /> <entry key="xml" value="application/xml" /> </jaxrs:extensionMappings> <jaxrs:providers> <!-- <ref bean="jsonExMapper" /> --> <ref bean="jaxbProvider" /> <ref bean="jsonProvider" /> </jaxrs:providers>
</jaxrs:server> <bean id="jaxbProvider" class="org.apache.cxf.jaxrs.provider.JAXBElementProvider" /> <!-- ******************** Use jackson As a serializer *********************** --> <bean id="jsonProvider" class="org.codehaus.jackson.jaxrs.JacksonJsonProvider" />
</beans>
web.xml In file CXF The plug-in configuration webservice <servlet> <servlet-name>CXFServlet</servlet-name> <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class> <load-on-startup>2</load-on-startup> </servlet> <servlet-mapping> <servlet-name>CXFServlet</servlet-name> <url-pattern>/services/*</url-pattern> </servlet-mapping>
Java in web service Configuration of services package com.iboxpay.clear.webservice;
import javax.annotation.Resource; import javax.ws.rs.Consumes; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType;
import org.springframework.stereotype.Service;
import com.iboxpay.clear.service.SysResourceService;
@Path("/clearPro") @Service("clearUserWebService") public class ClearWebService { @Resource private SysResourceService sysResourceService; @Path("/dispath") @POST @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public String dispath(String jsonStr) { System.out.println("=============we test webservice by http head start==========="); System.out.println(jsonStr); System.out.println("=============we test webservice by http head end==========="); return "can you"; }
}
If you need to check after executing the test Jmeter The returned results in , We need to create a new view result tree under the thread group ( Right click thread group > add to > Monitor > Look at the fruit tree ), In the response data column, you can see the result returned by the response
Be careful : stay Jmeter send out JSON When testing the format of string , We deliver JSON Parameter name cannot be given when parameter , Instead, you should give values directly . Otherwise, when it is transferred to the background, it will contain a series of non string styles -- Cause it to be garbled . It cannot be correctly resolved to the object we need . {"name":"zhangsan","description":"its"} You can , No need jsonStr = {"name":"zhangsan","description":"its"} It came from json We only need to resolve the parameter to the object corresponding to our background . /** * take JSON character string Convert to object * * @author weiyuanhua * @date 2010-11-18 Afternoon 02:52:13 * @param jsonStr * JSON character string * @param beanClass * Generic object * @param field * Properties that need to be ignored in the object * @return */ public static Object jsonToObject(String jsonStr, Class<?> beanClass,String... field) { JsonConfig jsonConfig = getJSONConfig(field); JSONObject jsonObject = JSONObject.fromObject(jsonStr, jsonConfig); return JSONObject.toBean(jsonObject, beanClass); }
private static JsonConfig getJSONConfig(String... field) { JsonConfig jsonConfig = new JsonConfig(); if (field != null) { jsonConfig = new JsonConfig(); String[] exclu = new String[field.length]; for (int i = 0; i < field.length; i++) { exclu[i] = field[i]; } jsonConfig.setExcludes(exclu); } return jsonConfig; }
边栏推荐
猜你喜欢

Yolov5系列(一)——網絡可視化工具netron

解决pushgateway数据多次推送会覆盖的问题
![Mysql报错:[ERROR] mysqld: File ‘./mysql-bin.010228‘ not found (Errcode: 2 “No such file or directory“)](/img/cd/2e4f5884d034ff704809f476bda288.png)
Mysql报错:[ERROR] mysqld: File ‘./mysql-bin.010228‘ not found (Errcode: 2 “No such file or directory“)

Influxdb2 sources add data sources

C language fcntl function

How can entrepreneurial teams implement agile testing to improve quality and efficiency? Voice network developer entrepreneurship lecture Vol.03

Open under vs2019 UI file QT designer flash back problem

Finally, someone explained the financial risk management clearly
![[wechat applet] wxss template style](/img/28/f9d12bf761e25f9564d92697cf049d.png)
[wechat applet] wxss template style

链表有环,快慢指针走3步可以吗
随机推荐
使用Tengine解决负载均衡的Session问题
Unity hierarchical bounding box AABB tree
零拷贝底层剖析
Neon global and Chinese markets 2022-2028: Research Report on technology, participants, trends, market size and share
[opengl] bone animation blending effect
[opengl] advanced chapter of texture - principle of flowmap
[ue4] material and shader permutation
Global and Chinese market of solder bars 2022-2028: Research Report on technology, participants, trends, market size and share
How can entrepreneurial teams implement agile testing to improve quality and efficiency? Voice network developer entrepreneurship lecture Vol.03
The latest M1 dedicated Au update Adobe audit CC 2021 Chinese direct installation version has solved the problems of M1 installation without flash back!
[transform] [NLP] first proposed transformer. The 2017 paper "attention is all you need" by Google brain team
在MapReduce中利用MultipleOutputs输出多个文件
Devaxpress: range selection control rangecontrol uses
C language dup2 function
Global and Chinese market of lighting control components 2022-2028: Research Report on technology, participants, trends, market size and share
C string format (decimal point retention / decimal conversion, etc.)
运维体系的构建
Remote server background hangs nohup
NOI OPENJUDGE 1.3(06)
[graphics] real shading in Unreal Engine 4