Interface automated testing - protocol, request process

1. Structure

CRM customer relationship management system

SAAS Software As A Service Software As A Service

PAAS Platform AS A Service Platform as a Service

Fast delivery → fast: do it yourself, have results, respond to everything, and continue to improve

Monolithic Architecture——"Vertical Architecture—"Service Oriented Architecture——"Microservice Architecture (Distributed)

2. Interface test

Interface: a channel for data transmission and interaction between systems, between components and components.

(between systems: between multiple internal systems, between internal systems and external systems. between programs: between methods, between functions, between functions, between modules)

Interface test: It is to test the interface between systems or components, and verify the correctness of the transmitted data and the correctness of logical dependencies.

Principle: The main test target is the server. (Simulate the client sending a request to the server, and test whether the response data sent back by the server to the client request is consistent with the expected result)

Methodology: Analogy, finding common ground among different things.

Learning Dimensions:

协议:本质是什么?
​
主流工具:
​
代码框架:
​
MockServer

3. API automated testing

Interface testing is also known as API testing, which is a test mode of software testing. It includes two dimensions. In a narrow sense, it refers to testing the functions of application programming interfaces. Dimensionally refers to the completion, reliability, security and performance of the integration test by calling the API to test the overall function.

With the help of tools and codes, simulate the client sending requests to the server, and use assertions to automatically judge whether the expected results are consistent with the actual results.

Why is interface testing so popular in the past two years?

The SAAS architecture is fully implemented, and the stability of the server is particularly important

The change of development mode is mainly reflected in the mode of separation of front and back ends

Test Jobs: (Interview Questions!!)

Quality management + test efficiency improvement

Quality management refers to: the ability to actively seek to promote problem solving and continuous improvement of quality

Improving test efficiency can be said to be: to improve R&D efficiency through technical means to further improve test efficiency.

Morning meeting: What did you do yesterday? What are you going to do today?

现在我也找了很多测试的朋友,做了一个分享技术的交流群,共享了很多我们收集的技术文档和视频教程。
如果你不想再体验自学时找不到资源,没人解答问题,坚持几天便放弃的感受
可以加入我们一起交流。而且还有很多在自动化,性能,安全,测试开发等等方面有一定建树的技术大牛
分享他们的经验,还会分享很多直播讲座和技术沙龙
可以免费学习!划重点!开源的!!!
qq群号:110685036

 

Fourth, the pyramid model:

The lower ones should put a lot of energy into it, and the higher ones should put a little energy into it.

UI layer: can be understood as functional testing;

service: interface test (API);

Unit (unit test).

5. Tools:

There are many mainstream testing tools that can do interface testing, such as PostMan, JMeter, SoupUi, etc. In addition to tools, there are also many third-party libraries in the Python language that can be used for interface testing, such as : urllib, requests, aiohttp, etc.

6. Agreement (key points!!!)

1. Agreement: It is a set of standards and rules that require both parties in the communication to strictly abide by.

HTTP protocol, also known as " Hypertext Transfer Protocol ", is an application layer protocol based on request and response mode , and it is also the most widely used network protocol on the Internet.

2. The default port is 80. http:80; https:443.

3. The current version of HTTP is HTTP/1.1 and the latest version is HTTP/2.0

Steps to view network requests: (Developer Tools)

Open the website (using Google Chrome) → Check → Network, All → Refresh the web page

The HTTP/2.0 version uses:

In the distributed architecture and microservice architecture, the gRPC protocol is designed based on the new-generation architecture, which is designed based on the HTTP/2.0 version. (gRPC protocol: applied in Internet finance and other fields.)

Book: Diagramming TCP/IP

network layering

The TCP/IP protocol is mainly divided into layers: application layer, transport layer, network layer, and data link layer.

Application layer:

The application layer determines the communication activities when providing application services to users. The HTTP protocol and the gRPC protocol belong to the application layer protocol.

transport layer:

The lower layer of the application layer is the network transport layer, which provides data transmission between two computers in the network connection.

Network layer:

It is mainly used to process data packets flowing on the network. The so-called data packet is the smallest unit in network transmission. In this layer protocol, the path to reach the target computer is regulated, and the data packet is transmitted to the target computer. Square. Network layer: 1. Guarantee data transmission 2. Know the destination of data transmission

link layer:

It mainly deals with the hardware part connected to the network, such as the operating system, the driver of the hardware device, etc.

Three handshakes (interview must ask!!!)

The problem solved by the three-way handshake: ensuring the security and availability of data transmission

The three-way handshake is also called the TCP handshake protocol. In order to track and negotiate the amount of data sent each time, ensure the synchronization of sending and receiving data segments, confirm data sending according to the amount of data received, when to cancel contact after receiving, and establish a virtual connection. In order to ensure that the data can be sent to the target server, the TCP protocol internally uses a three-way handshake strategy mechanism, that is to say, in the TCP protocol, after TCP sends the data packet, TCP will confirm whether the other party has received it, or confirm Whether it is successfully delivered, the three-way handshake mainly uses the TCP flag, specifically: SYN and ACK. First, the client sends a connection request message (SYN), and the server replies with an ACK message after accepting the connection, and allocates resources for this connection (SYN+ACK). After receiving the ACK message, the client also sends an ACK message to the server segment and allocates resources, so that the TCP connection is established. (SYN=synchronous sequence number ACK=acknowledgment message)

The three-way handshake is summarized as follows:

  • The first handshake: both ends are in the CLOSED state at first, the Client sets the flag bit SYN to 1, randomly generates a value seq=x, and sends the data packet to the Server, and the Client enters the SYN-SENT state , waiting for Server confirmation;
  • The second handshake: After the server receives the data packet, the flag bit SYN=1 knows that the client requests to establish a connection, the server sets the flag bits SYN and ACK to 1, ack=x+1, and randomly generates a value seq=y, and send the data packet to the Client to confirm the connection request, the Server enters the SYN-RCVD state, and the operating system allocates TCP buffers and variables for the TCP connection at this time;
  • The third handshake: After receiving the confirmation, the Client checks whether the ack is x+1 and whether the ACK is 1. If it is correct, the flag bit ACK is set to 1, ack=y+1, and at this time the operating system is the TCP The connection allocates TCP cache and variables, and sends the data packet to the server. The server checks whether the ack is y+1 and whether the ACK is 1. If it is correct, the connection is established successfully. The client and server enter the ESTABLISHED state and complete the three-way handshake , then the Client and Server can start transferring data.

TCP is a connection-oriented protocol, so each request needs to be confirmed by the other party. The TCP client and the TCP server need to complete the three-way handshake before communicating to establish a connection.

The following is a detailed explanation of the three-way handshake process:

1st handshake

When the first handshake establishes a connection, the client sends a SYN message (SEQ=x, SYN=1) to the server, and enters the SYN_SENT state, waiting for the server to confirm, as shown in the figure.

2nd handshake

The second handshake is actually completed in two parts, namely SYN+ACK (request and confirmation) message.

  • The server receives the client's request and replies with an acknowledgment message (ACK=x+1) to the client.
  • The server then sends a SYN packet (SEQ=y) request to establish a connection to the client, at this time the server enters the SYN_RECV state, as shown in the figure.

3rd handshake

The third handshake is when the client receives the reply from the server (SYN+ACK message). At this time, the client also sends an acknowledgment packet (ACK) to the server. After the packet is sent, the client and server enter the ESTABLISHED state and complete the 3-way handshake, as shown in the figure.

Summarize:

1. The client sends a SYN request message to the server, enters the SYN_SENT state, and waits for the server to confirm.
2. The server receives the request, confirms it, and then sends a confirmation message and a connection establishment request to the client. At this time, the server enters the SYN_RECV state.
3. After receiving the request and confirmation message, the client sends a confirmation message to the server, and then the connection is successful. The client and server enter the ESTABLISHED state and complete the three-way handshake.

SYN and ACK are the handshake signals used by TCP/IP to establish a connection . When establishing a normal TCP network connection between the client and the server , the client first sends a SYN message, and the server uses SYN+ACK (request and confirmation message) The reply indicates that the message has been received, and finally the client responds with an ACK message. In this way, a reliable TCP connection can be established between the client computer and the server, and data can be transmitted between the client computer and the server.

Question: Why is it a three-way handshake instead of two:
Because the three-way handshake can allow both parties to confirm that their own and the other party's sending and receiving capabilities are normal.

URI sum URL

A URI can be called a Uniform Resource Identifier while a URL is a Uniform Resource Locator. URI can be understood as identifying a resource on the Internet , while URL represents the location of the resource . URI is used in the HTTP protocol to locate resources on the Internet, which is why we can obtain resources anywhere on the Internet. A URL is a special type of URI that contains enough information to find a resource.

HTTP protocol

In the architectural mode of microservices, a lightweight communication mode (REST API) is also used. In the architectural mode of microservices, it needs to be clear that its communication can be divided into synchronous communication mode and asynchronous communication mode, or More specifically, it is request/response and asynchronous request/response (publish/subscribe mode).

HTTP request process: (emphasis!!!)

1. Establish a TCP connection request between the client and the server

2. The client sends a Request request to the server

3. The server replies with Response to respond to the client's request

4. Close the TCP connection request between the client and the server

Persistent connection: connection:keep-alive

Persistent connection In the early version of HTTP, every time a request is sent, a TCP connection and disconnection (equivalent to steps 1 and 4 in the above figure) are required. Obviously, this will cause a very large performance loss on the server. , but also increases the communication overhead. Beginning with HTTP/1.0 and later versions, there is a persistent connection, that is, keep-alive. Its characteristic is that as long as the client or server does not explicitly disconnect, the TCP connection must always be maintained. Requests, persistent connections reduce the performance loss caused by repeated connections and disconnections of TCP connections, reduce the load on the server, and improve the performance of the overall response time.


The following are supporting learning materials. For friends who do [software testing], it should be the most comprehensive and complete preparation warehouse. This warehouse also accompanied me through the most difficult journey. I hope it can help you too!

Software testing interview applet

The software test question bank maxed out by millions of people! ! ! Who is who knows! ! ! The most comprehensive quiz mini program on the whole network, you can use your mobile phone to do the quizzes, on the subway or on the bus, roll it up!

The following interview question sections are covered:

1. Basic theory of software testing, 2. web, app, interface function testing, 3. network, 4. database, 5. linux

6. web, app, interface automation, 7. performance testing, 8. programming basics, 9. hr interview questions, 10. open test questions, 11. security testing, 12. computer basics

Information acquisition method:

Guess you like

Origin blog.csdn.net/jiangjunsss/article/details/132604962