Disclosure of Invention
The invention aims to provide a method and a device for testing a plug-and-play function of a charging pile and a storage medium.
The purpose of the invention can be realized by the following technical scheme:
a plug and play function test method for a charging pile comprises the following steps:
establishing connection with background service;
acquiring a request data set, wherein the request data set comprises an authentication request, a charging request, charging process data and charging ending data;
sending an authentication request, receiving an authentication result signal responding to the authentication request, and analyzing the authentication result signal;
if the analysis result of the authentication result signal contains a first identifier, inquiring a response value corresponding to the value of the first identifier in a pre-configured first form based on the value of the first identifier, and otherwise, sending a charging request;
after receiving a charging response signal responding to the charging request, analyzing the charging response signal, and creating an order when an analysis result of the charging response signal contains a second identifier;
after the order is established, charging process data are sent;
sending a charging end request, receiving an end result signal responding to the charging end request, analyzing the end result signal, and inquiring a response value corresponding to a third identifier value in a pre-configured second form according to the value of the third identifier if the analysis result of the end result signal contains the third identifier.
The connection with the background service is a TCP connection.
The establishing of the connection with the background service comprises the following steps:
sending an IP address acquisition request to a registration center, and receiving a current IP of a background service returned by the registration center;
establishing a connection with the background service based on the returned current IP and the preconfigured port number.
The method further comprises the following steps: and after a response value corresponding to the value of the first identifier is inquired, inquiring in a third form based on the response value to obtain a corresponding execution instruction.
The authentication request at least contains charging pile station ID and vehicle ID.
The authentication request also contains a charging pile ID.
The type of the charging process data comprises electric quantity data and time data.
The method further comprises the following steps: and after a response value corresponding to the third identifier value is inquired, inquiring in a fourth form based on the response value to obtain a corresponding execution instruction.
A plug-and-play function testing device for a charging pile comprises a memory, a processor and a program stored in the memory, wherein the processor executes the program to realize the method.
A storage medium having stored thereon a program which, when executed, implements the method as described above.
Compared with the prior art, the invention has the following beneficial effects:
1. the pile and background service can be simulated for automatic testing, so that the field testing is not needed, and the manual execution cost and the material cost of the testing are greatly reduced.
2. The registration center can realize the inquiry of the dynamic IP, and the safety can be improved.
3. The inquiry of the solution of the authentication fault is realized according to the table look-up mode, and the test efficiency is improved.
4. Can realize testing to different stations and vehicles through changing charging pile station ID and vehicle ID, greatly reduce the manpower execution cost and the material object cost of test.
Detailed Description
The invention is described in detail below with reference to the figures and specific embodiments. The present embodiment is implemented on the premise of the technical solution of the present invention, and a detailed implementation manner and a specific operation process are given, but the scope of the present invention is not limited to the following embodiments.
Aiming at a new plug-and-play function, a new testing thought is designed, the old testing thought is skipped, the reasonable combination of a plurality of methods such as mock thought, a TCP protocol, Python, a database and the like is combined, the time after the request is sent is controlled, and different parameters are used for assembling a reasonable request message to be sent to the background service of the pile. And judging whether the response is successful or not according to the response, and then carrying out the next action.
A plug and play function test method for a charging pile is mainly shown in a figure 1, and concretely, the implementation of the method comprises the following aspects:
establishing a connection with a background service
Specifically, the process of establishing a connection with the background service includes: sending an IP address acquisition request to a registration center, and receiving a current IP of a background service returned by the registration center; based on the returned current IP and the pre-configured port number, the connection with the background service is established, and the query of the dynamic IP is realized through the registration center, so that the safety can be improved. Because the stub background service uses K8S and the IP dynamically changes, the present application introduces a method for dynamically obtaining the service IP from an NACOS (registry), first accessing the NACOS (registry) to obtain a dynamic IP (currently valid IP) of a corresponding service, then creating a TCP link using WebSocket (a protocol for performing full duplex communication on a single TCP connection), and establishing a thread. And establishing a message queue and putting the returned message into the queue.
Secondly, acquiring a request data set
Time data and data to be checked of each stage are prepared, namely, a request data set contains an authentication request, a charging request, charging process data and charging ending data. The types of the charging process data include power data and time data.
Third, authentication process
In the authentication process, an authentication request is sent after a pile is required to be simulated and a gun is inserted, and an authentication result is asserted, specifically, the authentication request is sent to background service first, an authentication result signal responding to the authentication request is received, and the authentication result signal is analyzed; if the analysis result of the authentication result signal contains a first identifier, inquiring a response value corresponding to the value of the first identifier in a pre-configured first form based on the value of the first identifier, and otherwise, sending a charging request;
in this embodiment, the method further includes: and after a response value corresponding to the first identifier value is inquired, inquiring in a third form based on the response value to obtain a corresponding execution instruction.
Wherein, the first identifier in the authentication request is used for representing an error code which fails in authentication, then the meaning of the error code is inquired in the first form and returned, for example, if an unfinished order exists, the order is automatically finished; if the account number does not open the plug-and-charge function, the function can be automatically opened; if the problem is a background service problem, the executor is prompted according to the error code of the error report, and the reason of the problem is located.
Third, start charging
After receiving a charging response signal responding to the charging request, analyzing the charging response signal, and creating an order when an analysis result of the charging response signal contains a second identifier;
specifically, when the code judges that the result of the authentication response is passed, a request for starting charging is sent, the response of the request for starting charging is judged, if the response is normal, the order is created, the client can check that the order is in charging, otherwise, the error reason is judged according to the error code of the response, and an executor knows the error condition and can solve the error condition.
Fourth, sending charging process data
In this embodiment, each test is performed, all the simulation piles need to transmit at least 2 pieces of data in the charging process, and the data conforms to background business logic, such as charging amount in unit time, reasonable charging duration (start and end time recorded by the system), start and end charging time conforming to current time, and the like.
Fifthly, the charging is finished
Sending a charging end request, receiving an end result signal responding to the charging end request, analyzing the end result signal, and querying a response value corresponding to a value of a third identifier in a preconfigured second form according to the value of the third identifier if an analysis result of the end result signal contains the third identifier, in this embodiment, the method further includes: and after a response value corresponding to the third identifier value is inquired, inquiring in a fourth form based on the response value to obtain a corresponding execution instruction.
Specifically, a request for finishing charging is sent through the simulation pile, the background service can judge whether the whole charging process is reasonable, the charging can be normally finished reasonably, and the user side displays that the order is paid; otherwise, the order cannot be finished, the operator needs to finish the order manually, the interface responds to the error reporting reason, and the executive tester can see the reason of the failure.
In this embodiment, after the test is finished, the automation may close the thread and give a test report.
In this embodiment, the authentication request at least includes the charging pile station ID and the vehicle ID. The testing method can be automatically executed and regularly executed, and only the charging pile site ID needs to be modified when different site piles are tested. If different vehicles are used, only the unique identification code of the corresponding vehicle, namely the vehicle ID, needs to be modified.
In addition, in some other embodiments, the authentication request may further include a charging pile ID, so as to improve flexibility.
The above functions, if implemented in the form of software functional units and sold or used as a separate product, may be stored in a computer-readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.