Functional verification of docker-based distributed performance testing framework (2)

Functional verification of docker-based distributed performance testing framework (2)

This article is the practice of FunTester testing framework distributed performance testing function expansion, it is a relatively rough technical verification practice. The technical solution adopts the scenarios envisaged in the distributed performance testing framework use case scenario (2) , based on

jar
Function in the package, this solution needs to write the test case to update to
jar
In the package or
classpath
Under contents.

The rough implementation scheme is divided into three parts: master scheduling machine , slave test machine and server tested service .

  • master scheduling machine: handle use cases and assign tasks
  • Slave test machine: accept tasks and execute use cases
  • Server tested service: provide test interface

docker image

The content is the same as the article, Docker-based distributed performance testing framework function verification (1) , so I won't repeat it here.

master scheduling machine

Here I only implement a scheduling function: to provide an interface that returns a test case (the object has not been encapsulated). Provide the request to the slave tester and return it to the tester for the test task (test case). I'm still worth it

Fixed thread fixed number of requests
The pressure test model.

Here I chose two demos: 1. Write the use case and expose the number of executions

times
And the number of threads of execution
thread
And soft start time
runup
2. I put the request to be tested in the task in the form of parameterization, and the use case is only a compatibility extension for single-interface performance testing. I did not implement more complicated ones, because this requirement I will implement in the three scenarios, so stay tuned.

Still used here

FunTester moco server
Achieved, the single-node version of the distributed test framework is being tested internally. For more information, please pay attention to the recent public tweets.

master script

3.different return parameter methods are written here, mainly to match the execution method of the test case. When the test case is introduced later, the purpose will be explained in detail.

package com.mocofun.moco.main import com.alibaba.fastjson.JSON import com.alibaba.fastjson.JSONObject import com.funtester.base.bean.Result import com.funtester.httpclient.FunLibrary import com.funtester.httpclient.FunRequest import com.mocofun.moco.MocoServer class DcsServer2 extends MocoServer { public static void main (String[] args) { def server = getServer( 12345 ) def res = new JSONObject() res.path = "com.funtester.main.DcsCase.main" res.paramsType = [ "java.lang.Integer" , 10 , "java.lang.Integer" , 100 , "java.lang.Integer" , 2 ] def success = Result.success(res) output(success.toJson()) def res2 = new JSONObject() res2.path = "com.funtester.main.DcsCase.main" res2.paramsType = [ "java.lang.Integer" , 10 , "java.lang.Integer" , 100 , "java.lang.Integer" , 2 , "java.lang.String" , "http://192.168.80.169:12345/m" ] def success2 = Result.success(res2) def res3 = new JSONObject() res3.path = "com.funtester.main.DcsCase.main" res.paramsType = [ "java.lang.String" , "10,100,1" ] def success3 = Result.success(res3) server.get(urlStartsWith( "/m" )).response(obRes(success)) server.get(urlStartsWith( "/t" )).response(obRes(success2)) server.get(urlStartsWith( "/f" )).response(obRes(success3)) def run = run(server) waitForKey( "fun" ) run.stop() } } Copy code

among them

http://192.168.80.169:12345/m
It is the test interface exposed by the service under test, and it is also used
funtester moco server
If you do, the script content will be shared later.

Test case

among them

com.funtester.main.DcsCase.main
Yes
jar
A test case in the package, the class code is as follows:

import com.alibaba.fastjson.JSONObject import com.funtester.config.Constant import com.funtester.db.mysql.MySqlTest import com.funtester.frame.execute.Concurrent import com.funtester.frame.thread.RequestThreadTimes import com.funtester .httpclient.ClientManage import com.funtester.httpclient.FunLibrary import com.funtester.utils.ArgsUtil import org.apache.http.client.methods.HttpGet class DcsCase extends FunLibrary { public static void main (String[] args) { ClientManage.init( 60 , 60 , 0 , "" , 0 ); ArgsUtil util = new ArgsUtil(args); int thread = util.getIntOrdefault( 0 , 2 ); int times = util.getIntOrdefault( 1 , 10 ); Constant.RUNUP_TIME = util.getIntOrdefault( 2 , 10 ); String url = util.getStringOrdefault( 3 , "http://192.168.80.169:12345/m" ) MySqlTest.LOG_KEY = false ; JSONObject params = new JSONObject(); params.put( "name" , "FunTester" ); params.put( "password" , "123456798" ); HttpGet httpGet = getHttpGet(url, params); RequestThreadTimes requestThreadTimes = new RequestThreadTimes(httpGet, times); Concurrent funTester = new Concurrent(requestThreadTimes, thread, "FunTester test reflection execution" ); funTester.start(); } public static void main (String args) { main(args.split(COMMA)); } public static void main (Integer a, Integer b, Integer c) { main( new String[]{a + EMPTY, b + EMPTY, c + EMPTY}); } public static void main (Integer a, Integer b, Integer c, String url) { main( new String[]{a + EMPTY, b + EMPTY, c + EMPTY, url}); } } Copy code

Used here

public static void main(String[] args)
The method is to script the execution of the use case, but in the actual test, it is found that it cannot be solved
String[] args
Type of parameter passing, so I wrote a method for multiple loading
main(String args)
, And another method
main(Integer a, Integer b, Integer c)
Just to show how to write more different parameters, and the method
main(Integer a, Integer b, Integer c, String url)
It is to show the exposed parameters and custom functions of the method. Special attention: It is forbidden to use basic data type parameters .

slave test machine

This logic goes through simple polling

master scheduling machine
The provided interface obtains test tasks or test cases. Then parse and execute the test case.

package com.funtest.groovytest import com.alibaba.fastjson.JSONArray import com.funtester.frame.execute.ExecuteSource import com.funtester.httpclient.FunLibrary class Dcs2 extends FunLibrary { public static void main (String[] args) { while ( true ) { String url = "http://host.docker.internal:12345/m" //Requesting this interface will return a use case, currently there is no object encapsulation def get = getHttpGet(url) def response = getHttpResponse(get) if (response.getInteger("code") == 0) { def data = response.getJSONObject("data") def path = data.getString("path") JSONArray array = data.getJSONArray("paramsType") ExecuteSource.executeMethod(path, array.toArray()) } sleep(5.0) } } }

INFO-> oker/Users/oker/IdeaProjects/funtester/, :UTF-8, Mac OS X :10.16 INFO-> uri http://localhost:12345/t , 368 ms , HTTPcode: 200 INFO-> ========= , !========= INFO-> FunTester : 100% INFO-> 10 0.505 s, :973, :0, :0 INFO-> /Users/oker/IdeaProjects/funtester/long/data/FunTester 021904_10 INFO-> ~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~ JSON ~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~ { . "rt":4, . "failRate":0.0, . "threads":10, . "deviation":"22.93%", . "errorRate":0.0, . "executeTotal":973, . "qps2":1926.7326732673268, . "total":1637, . "qps":2500.0, . "startTime":"2021-06-02 19:04:24", . " EndTime " : "2021-06-02 19:04:25" , . "Mark" : "FunTester test reflection execution 021904" , .> "the Table" : "eJzj5VIgDNxK80JSi0tSi55t7X6xfurT/t6nG1qedS5/sbBHwdBAoSSjKDUxhQhzFHi5ePHbF5RaXJCfV5yqEJKZm2qlUKFbnFqUmZijkFeaq6NQqZubmpKZmEfIDmJckpuZpwAxzcpIIbdYJzexwsoSyKCKLygFj6Z1ABGRPhm1ZdSWwWnLo2ntQEQfm8BWDHmbHk1rAiJcFG1tRjYdHzVqMyk2tAIRORTtXUasDeRSQ9plj6Y1AhFJ1KBwNa0dMerqIeBq8ksdEgufAfDZIHDMqM9GvM8GhTNGfTjqw1EfDrwzRn046kO8PgQA59EyOA ==" } ~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~ JSON ~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~ Process finished with exit code 1 Copy code

server tested service

Content Communication Plan (1) is still not shared here.

The log is as follows:

Request received: GET/m HTTP/1.1 Host: 192.168 .80 .169 : 12345 Connection: Keep-Alive - Agent-the User: the Apache-HttpClient/4.5 of 5 .6 (the Java/1.8 .0_281 ) Accept-Encoding: gzip,deflate content-length: 0 Response return : HTTP/1.1 200 Content-Length: 18 Content-Type: text/plain; charset=utf- 8 hello funtester!!! Copy code

FunTester , Tencent Cloud author of the year , Boss direct hire contract author , GDevOps official cooperation media , non-famous test development, welcome to pay attention.