当前位置:网站首页>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; }
边栏推荐
- [transform] [NLP] first proposed transformer. The 2017 paper "attention is all you need" by Google brain team
- Yolov5系列(一)——網絡可視化工具netron
- Open under vs2019 UI file QT designer flash back problem
- Apache ant extension tutorial
- 【可能是全中文网最全】pushgateway入门笔记
- Pytorch深度学习和目标检测实战笔记
- [opengl] geometry shader
- Yolov5进阶之七目标追踪最新环境搭建(二)
- Devaxpress: range selection control rangecontrol uses
- 4-33--4-35
猜你喜欢
Influxdb2 sources add data sources
[graphics] real shading in Unreal Engine 4
[ue4] cascading shadow CSM
解决pushgateway数据多次推送会覆盖的问题
[graphics] hair simulation in tressfx
【注意力机制】【首篇ViT】DETR,End-to-End Object Detection with Transformers网络的主要组成是CNN和Transformer
The picture quality has been improved! LR enhancement details_ Lightroom turns on AI photo detail enhancement: picture clarity increases by 30%
C language fcntl function
How can entrepreneurial teams implement agile testing to improve quality and efficiency? Voice network developer entrepreneurship lecture Vol.03
Besides lying flat, what else can a 27 year old do in life?
随机推荐
官网MapReduce实例代码详细批注
4-20-4-23 concurrent server, TCP state transition;
NOI OPENJUDGE 1.6(09)
Global and Chinese market of lighting control components 2022-2028: Research Report on technology, participants, trends, market size and share
Tensor ellipsis (three points) slice
[opengl] bone animation blending effect
【Transform】【实践】使用Pytorch的torch.nn.MultiheadAttention来实现self-attention
Piwigo 2.7.1 sqli learning
5-1 blocking / non blocking, synchronous / asynchronous
QT program font becomes larger on computers with different resolutions, overflowing controls
Besides lying flat, what else can a 27 year old do in life?
Apache ant extension tutorial
. Net six design principles personal vernacular understanding, please correct if there is any error
【pytorch学习笔记】Datasets and Dataloaders
.NET六大设计原则个人白话理解,有误请大神指正
[transformer] Introduction - the original author of Harvard NLP presented the annotated transformer in the form of line by line implementation in early 2018
Global and Chinese markets for ionization equipment 2022-2028: Research Report on technology, participants, trends, market size and share
Global and Chinese markets for transparent OLED displays 2022-2028: Research Report on technology, participants, trends, market size and share
Solve the problem that PR cannot be installed on win10 system. Pr2021 version -premiere Pro 2021 official Chinese version installation tutorial
Yolov5 advanced 8 format conversion between high and low versions