Method and system for simulating sending coordinates and computer equipment
By using local Web services to judge the behavior of coordinate point drop/reporting point and reporting on server side, the problem of the inability to freely control coordinate point reporting and discarding in the online ride-hailing industry test is solved, and an efficient and accurate testing process is achieved.
Patent Information
- Application Number
- CN202411635391.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-15
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2044-11-15
AI Technical Summary
The existing technology cannot freely control the reporting and discarding of coordinate points through the HTTP interface during the test of the online ride-hailing industry, resulting in high testing costs, low efficiency and inaccurate testing data.
By obtaining test data, using pre-built local web services to judge the behavior of drop/point reporting, depositing the lost point data set for coordinate points that need to be discarded, and calling the point reporting service for coordinate points that do not need to be discarded for server reporting.
It realizes the control of the sending and stopping behavior of coordinate points through the Web interface call, simulates the test of reporting coordinate points, reduces the cost and time of manual real scene testing, and improves the accuracy of the test.
Smart Images

Figure CN119512956A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software testing, and in particular to a method and system for simulating sending coordinates, and computer equipment. Background Art
[0002] The test scope of the online car-hailing industry includes the test of the driver's location and driving trajectory. The driver's location and driving trajectory are mainly obtained by collecting longitude and latitude from the app and sending them to the server. Due to the complexity of the real environment, there are often a small number of reporting failures in the reporting of coordinate points, that is, lost points. Lost coordinate points (lost points) refer to the behavior of a mobile device failing to successfully report coordinate points due to various reasons (such as device shutdown, passing through tunnels, network jitter, etc.) when reporting coordinate points. The loss of coordinate points directly affects the driver's mileage and driving time, and then affects the income calculation. Currently, there are usually two testing methods for driver lost points:
[0003] 1) Simulate real scenarios, that is, testers use mobile devices to test in real environments. This method requires testers to try to create a point loss scenario (such as turning off the network, shutting down the phone, weak network signal, etc.). However, the degree of limitation is high. If the tester only tests in the office area, most of the test coordinate points obtained are repeated and relatively close, and the reference value is not high; if the tester tests outdoors, the test coordinate points obtained are very real, but the entire test process is relatively time-consuming, the cost is too high, and the data cannot be accurately controlled.
[0004] 2) Simulation reporting tools are relatively flexible and do not require the use of mobile devices. They can also customize reporting strategies, such as reporting coordinates, number of coordinates, reporting time, reporting interval, driving speed, etc. Different reporting strategies can be used for different scenarios. However, the currently available simulation reporting tools can only simulate reporting behaviors based on the established order trajectory route, and cannot simulate the loss of points. Summary of the invention
[0005] To this end, the present invention provides a method and system for simulating the sending of coordinates, and a computer device, aiming to solve the technical problems in the prior art of online car-hailing, which is that when conducting simulated environment testing, the reporting and discarding of coordinate points cannot be freely controlled through the HTTP interface, resulting in high testing costs, low testing efficiency, and inaccurate test data.
[0006] To achieve the above objectives, the present invention adopts the following technical solutions:
[0007] According to a first aspect of the present invention, the present invention provides a method for simulating sending coordinates, the method comprising:
[0008] Acquire test data and use pre-built local Web services to determine the loss / reporting behavior of the test data;
[0009] For the first coordinate point that needs to be discarded, store the lost point data set;
[0010] For the second coordinate point that does not need to be discarded, the pre-built reporting service is called to report the first coordinate point to the server.
[0011] Furthermore, when reporting the first coordinate point, the method further includes:
[0012] Determine whether there is existing data of the first coordinate point in the lost point data set;
[0013] If there is no existing data of the first coordinate point in the lost point data set, continue to report the first coordinate point;
[0014] If there is existing data of the first coordinate point in the lost point data set, the first coordinate point is reported as a recovery reporting point, and historical points that have been lost except the recovery reporting point are counted to generate lost point interval data for test analysis.
[0015] Further, the test data includes a coordinate set;
[0016] The obtaining of test data comprises:
[0017] Freely construct a test scene and use a preset method to obtain a coordinate collection based on the test scene;
[0018] The preset method includes manually generating coordinates or automatically generating coordinates using a simulation point reporting tool.
[0019] Furthermore, the use of a pre-built local Web service to determine the loss / reporting behavior of the test data includes:
[0020] Traverse each coordinate element in the coordinate set, and obtain the point loss / reporting behavior corresponding to each coordinate element according to the " / status" interface provided by the local Web service;
[0021] If the interface return value corresponding to the coordinate element is "True", the coordinate element is used as the first coordinate point to be discarded;
[0022] If the interface return value corresponding to the coordinate element is "False", the coordinate element is used as the second coordinate point that does not need to be discarded.
[0023] Furthermore, the calling of the pre-built reporting service to report the first coordinate point to the server includes:
[0024] The reporting service calls the connect() method of the socket library to establish a long connection with the server;
[0025] Obtain each of the first coordinate points, encapsulate the first coordinate points, and call the send() method built into Python to report the encapsulated first coordinate point data to the server;
[0026] After all the packaged first coordinate point data are sent, the close() method is called to close the long link established with the server.
[0027] Further, the encapsulating the first coordinate point includes:
[0028] The first coordinate point is parsed to obtain byte types of different lengths, and the point reporting parameters are concatenated to obtain coordinate data in a standard format that meets the acceptance requirements of the server, as the encapsulated first coordinate point data.
[0029] Furthermore, before obtaining the test data, the method further includes:
[0030] Create the local web service through the Flask framework;
[0031] The local Web service is used to provide an interface call, and the interface call is used to operate event status change / multi-threaded Event method to obtain event status.
[0032] Furthermore, the method further comprises:
[0033] After completing the point loss / reporting operation for the test data, the point loss data set is cleared.
[0034] According to a second aspect of the present invention, the present invention provides a system for simulating sending coordinates, the system comprising a simulated point loss module, a point reporting service module and a Web service module;
[0035] The Web service module is used to provide interface calls and obtain / operate event status;
[0036] The reporting service module is used to establish a long link with the server and perform data analysis / reporting;
[0037] The simulated point loss module is used to obtain test data, and use the local Web service provided by the Web service module to determine the loss / point reporting behavior of the test data; for the first coordinate point that needs to be discarded, a point loss data set is stored; for the second coordinate point that does not need to be discarded, the point reporting service provided by the point reporting service module is called to report the first coordinate point to the server.
[0038] According to the third aspect of the present invention, the present invention provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method for simulating sending coordinates as described in any one of the first aspect of the present invention is implemented.
[0039] The present invention adopts the above technical solution and has at least the following beneficial effects:
[0040] Through the scheme of the present invention, the test data is obtained, and the loss / reporting behavior of the test data is judged by using the pre-built local Web service; for the first coordinate point that needs to be discarded, the loss point data set is stored; for the second coordinate point that does not need to be discarded, the pre-built reporting service is called to report the first coordinate point to the server. Thus, the sending and stopping behavior of the coordinate point is controlled by calling the web interface, and the test of simulating the reporting of coordinate points for the loss point scenario is realized, thereby solving the technical problems of high cost, low efficiency and low accuracy of artificial real scene testing in the test loss point scenario.
[0041] It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0043] Figure 1 A schematic diagram showing a flow chart of a method for simulating sending coordinates provided by an embodiment of the present invention;
[0044] Figure 2 A working principle diagram of a local Web service provided by an embodiment of the present invention is shown;
[0045] Figure 3 A specific operation flow chart of a method for simulating sending coordinates provided by an embodiment of the present invention is shown;
[0046] Figure 4 A working principle diagram of a point reporting service provided by an embodiment of the present invention is shown;
[0047] Figure 5 A schematic diagram of the physical structure of a computer device provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0048] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0049] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "include..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0050] The embodiment of the present invention provides a method for simulating sending coordinates, such as Figure 1 As shown, at least the following steps S101 to S102 may be included:
[0051] Step S101, obtaining test data, and using a pre-built local Web service to determine the loss / reporting behavior of the test data;
[0052] Step S102: for a first coordinate point that needs to be discarded, a lost point data set is stored; and for a second coordinate point that does not need to be discarded, a pre-built reporting service is called to report the first coordinate point to the server.
[0053] In an embodiment of the present invention, the test data includes a coordinate set. The test data can be obtained by freely constructing a test scenario and obtaining a coordinate set based on the test scenario in a preset manner. The preset manner includes manually generating coordinates or automatically generating coordinates using a simulation reporting tool. In other words, a test scenario can be freely constructed according to specific needs, and a coordinate set consisting of multiple coordinate elements can be generated manually or in other ways.
[0054] After obtaining the coordinate set, traverse each coordinate element in the coordinate set to determine the lost / reported point behavior. The embodiment of the present invention determines the event status based on the local Web service. The local Web service is a small Web service created locally, which is used to implement interface calls, query the current event status, and operate event status changes. Figure 2 The figure shows the working principle of Web service.
[0055] For the construction of local Web services, you can create it through the Flask framework, that is, you can create a small Web service after starting it locally. The service mainly includes two parts of functions: event operation and interface operation. Specifically, you can complete the operation of events by calling the interface provided by the service. Among them, the event status is completed by calling the multi-threaded Event method (thread.Event()), and there are two states (True, False). The event status will be initialized synchronously when the Web service is started, and the default state is False. The interface is mainly used to operate the change of event status or obtain the event status, with a total of three interfaces ( / stop, / status, / clear). The specific calling functions are as follows:
[0056] 1) Call the / stop interface, and the service will call the Event.set() method to set the event status to True;
[0057] 2) Call the / clear interface, and the service will call the Event.clear() method to set the event status to False;
[0058] 3) Call the / status interface, and the service will call the Event.is_set() method to obtain the current status of the event.
[0059] Therefore, when conducting simulation tests on point loss scenarios, you can customize the point loss timing, point loss quantity, point loss duration, and number of point loss times through local Web services. You can also query the current time status through the interface to determine the point loss / reporting behavior corresponding to each coordinate element.
[0060] like Figure 3 As shown, it is a specific operation flow chart of the method for simulating sending coordinates proposed in an embodiment of the present invention. For the judgment of the loss / reporting behavior of each coordinate element in the coordinate set, each coordinate element in the traversal coordinate set can be obtained, and the loss / reporting behavior corresponding to each coordinate element can be obtained according to the " / status" interface provided by the local Web service; if the interface return value corresponding to the coordinate element is "True", the coordinate element is used as the first coordinate point to be discarded; if the interface return value corresponding to the coordinate element is "False", the coordinate element is used as the second coordinate point that does not need to be discarded. In other words, if the obtained interface return value is "True", it is considered that the current coordinate point needs to be discarded, and the reporting method is not called at this time. At the same time, the discarded point is stored in the lost point data set for subsequent logical query. If the obtained interface return value is "False", it is considered that the current coordinate point does not need to be discarded, and the point is reported.
[0061] The embodiment of the present invention reports the first coordinate point to the server based on the reporting service. Figure 4 The figure shows the working principle of the point reporting service. The point reporting service is mainly responsible for parsing and sending points. All points will be parsed by the point reporting service before being sent, and then sent after being packaged.
[0062] Specifically, the reporting service is implemented by the built-in socket library of Python. You can call the connect() method of the socket library to establish a long connection with the server. It can be understood that all point transmissions are based on the establishment of a long connection, and the entire reporting / dropping process needs to maintain the connection until the program ends.
[0063] After the link is established, the reporting operation can be performed. Specifically, each first coordinate point can be obtained, the first coordinate point can be encapsulated, and the python built-in send() method can be called to report the encapsulated first coordinate point data to the server, that is, the sending of the coordinate point is completed once; after all the encapsulated first coordinate point data is sent, the close() method is called to close the long link established with the server.
[0064] In the embodiment of the present invention, the first coordinate point is encapsulated. Specifically, the first coordinate point can be parsed to obtain byte types of different lengths, and the point reporting parameters can be spliced to obtain standard format coordinate data that meets the acceptance requirements of the server as the encapsulated first coordinate point data.
[0065] It should also be noted that, in order to facilitate program calls, the embodiment of the present invention can also encapsulate the entire link from data acquisition to the final data transmission into a send_point() function to make the service more integrated. After all the first coordinate point data are sent, the close() method is called to close the long link established with the server.
[0066] Furthermore, when reporting the first coordinate point, the embodiment of the present invention also needs to determine whether there is existing data of the first coordinate point in the lost point data set; if there is no existing data of the first coordinate point in the lost point data set, continue to report the first coordinate point; if there is existing data of the first coordinate point in the lost point data set, report the first coordinate point as a recovery reporting point, and count the historical points that have been lost except for the recovery reporting point, and generate lost point interval data for test analysis.
[0067] The purpose of the above steps is to distinguish whether the current point report is a recovery point report after a point loss. It can be understood that if there is no existing data of the first coordinate point in the lost point data set, it is considered that the point loss has not been triggered yet, and no recovery is required, and the report can continue; if there is existing data of the first coordinate point in the lost point data set, it is considered that the point loss has been triggered, and the current reporting behavior belongs to the recovery point report, so it is necessary to count the lost historical points and print them for subsequent test analysis.
[0068] Furthermore, after completing the point loss / reporting operation on the test data, the point loss data set is cleared.
[0069] When all coordinate elements contained in the test data have been reported, the lost point data set can be cleared so that when the lost point operation is performed again, there will be no duplicate data and data pollution.
[0070] The embodiment of the present invention provides a method for simulating the sending of coordinates, including obtaining test data, using a pre-built local Web service to determine the loss / reporting behavior of the test data; for a first coordinate point that needs to be discarded, storing a loss point data set; for a second coordinate point that does not need to be discarded, calling a pre-built reporting service to report the first coordinate point to the server. Through the present invention, there is no need to manually construct a real loss point scene to perform a loss point test, but to control the reporting / loss point behavior through a custom point set + interface control method, which can greatly save labor costs, is simple to operate, and provides more accurate data, solving the problems of high cost, low efficiency, and low accuracy of artificial real scene testing.
[0071] Further, as Figure 1 In the specific implementation, an embodiment of the present invention provides a system for simulating sending coordinates, which may include: a simulated point loss module, a point reporting service module and a Web service module.
[0072] Among them, the Web service module can be used to provide interface calls and obtain / operate event status;
[0073] The reporting service module can be used to establish a long link with the server and perform data analysis / reporting;
[0074] The simulated point loss module can be used to obtain test data and use the local Web service provided by the Web service module to determine the loss / reporting behavior of the test data; for the first coordinate point that needs to be discarded, the point loss data set is stored; for the second coordinate point that does not need to be discarded, the point reporting service provided by the point reporting service module is called to report the first coordinate point to the server.
[0075] Furthermore, the point loss simulation module can also be used to determine whether there is existing data of the first coordinate point in the point loss data set;
[0076] If there is no existing data of the first coordinate point in the lost point data set, continue to report the first coordinate point;
[0077] If there is existing data of the first coordinate point in the lost point data set, the first coordinate point will be reported as the recovery report point, and the historical points that have been lost except the recovery report point will be counted to generate the lost point interval data for test analysis.
[0078] Furthermore, the simulated point loss module can also be used to freely construct test scenarios and obtain a coordinate collection based on the test scenario using a preset method;
[0079] Among them, the preset method includes manually generating coordinates or automatically generating coordinates using a simulation point reporting tool.
[0080] Furthermore, the point loss simulation module can also be used to traverse each coordinate element in the coordinate set, and obtain the point loss / reporting behavior corresponding to each coordinate element according to the " / status" interface provided by the Web service module;
[0081] If the interface return value corresponding to the coordinate element is "True", the coordinate element is used as the first coordinate point to be discarded;
[0082] If the interface return value corresponding to the coordinate element is "False", the coordinate element is used as the second coordinate point that does not need to be discarded.
[0083] Furthermore, the simulated point loss module can also be used to use the point reporting service module to call the connect() method of the socket library to establish a long connection with the server;
[0084] Get each first coordinate point, encapsulate the first coordinate point, and call the built-in send() method of Python to report the encapsulated first coordinate point data to the server;
[0085] After all the encapsulated first coordinate point data is sent, call the close() method to close the long connection established with the server.
[0086] Furthermore, the simulated point loss module can also be used to utilize the point reporting service module to perform data analysis on the first coordinate point, obtain byte types of different lengths, and concatenate the point reporting parameters to obtain standard format coordinate data that meets the server acceptance requirements as the encapsulated first coordinate point data.
[0087] Furthermore, the simulated point loss module can also be used to clear the point loss data set after completing the point loss / reporting operation on the test data.
[0088] It should be noted that for other corresponding descriptions of various functional modules involved in the system for simulating sending coordinates provided in an embodiment of the present invention, reference can be made to Figure 1 The corresponding description of the method shown will not be repeated here.
[0089] Based on the above Figure 1 The embodiment of the method shown in the figure, the embodiment of the present invention also provides a physical structure diagram of a computer device, such as Figure 5 As shown, the computer device may include a communication bus, a processor, a memory and a communication interface, and may also include an input and output interface and a display device, wherein each functional unit may communicate with each other through the bus. The memory stores a computer program, and the processor is used to execute the program stored in the memory and execute the steps of the method for simulating sending coordinates in the above embodiment.
[0090] Those skilled in the art can clearly understand that the specific working processes of the systems, devices, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, and for the sake of brevity, they are not further described here.
[0091] In addition, the functional units in various embodiments of the present invention may be physically independent of each other, or two or more functional units may be integrated together, or all functional units may be integrated into one processing unit. The above integrated functional units may be implemented in the form of hardware, or in the form of software or firmware.
[0092] Those skilled in the art can understand that if the integrated functional unit is implemented in the form of software and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention can essentially or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, which includes a number of instructions to enable a computing device (such as a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present invention when running the instructions. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk and other media that can store program codes.
[0093] Alternatively, all or part of the steps of implementing the aforementioned method embodiments may be accomplished by hardware associated with program instructions (such as a computing device such as a personal computer, a server, or a network device), and the program instructions may be stored in a computer-readable storage medium. When the program instructions are executed by a processor of a computing device, the computing device executes all or part of the steps of the methods described in the embodiments of the present invention.
[0094] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that within the spirit and principles of the present invention, the technical solutions described in the aforementioned embodiments can still be modified, or some or all of the technical features therein can be replaced by equivalents. However, these modifications or replacements do not deviate from the protection scope of the present invention.
Claims
1. A method for simulating sending coordinates, characterized in that: The method comprises: Acquire test data and use pre-built local Web services to determine the loss / reporting behavior of the test data; For the first coordinate point that needs to be discarded, store the lost point data set; For the second coordinate point that does not need to be discarded, the pre-built reporting service is called to report the first coordinate point to the server.
2. The method according to claim 1, characterized in that When the first coordinate point is reported, the method further includes: Determine whether there is existing data of the first coordinate point in the lost point data set; If there is no existing data of the first coordinate point in the lost point data set, continue to report the first coordinate point; If there is existing data of the first coordinate point in the lost point data set, the first coordinate point is reported as a recovery reporting point, and historical points that have been lost except the recovery reporting point are counted to generate lost point interval data for test analysis.
3. The method according to claim 1, characterized in that The test data includes a coordinate set; The obtaining of test data comprises: Freely construct a test scene and use a preset method to obtain a coordinate collection based on the test scene; The preset method includes manually generating coordinates or automatically generating coordinates using a simulation point reporting tool.
4. The method according to claim 3, characterized in that The use of the pre-built local Web service to determine the loss / reporting behavior of the test data includes: Traverse each coordinate element in the coordinate set, and obtain the loss / reporting behavior corresponding to each coordinate element according to the " / status" interface provided by the local Web service; If the interface return value corresponding to the coordinate element is "True", the coordinate element is used as the first coordinate point to be discarded; If the interface return value corresponding to the coordinate element is "False", the coordinate element is used as the second coordinate point that does not need to be discarded.
5. The method according to claim 1, characterized in that The calling of a pre-built reporting service to report the first coordinate point to the server includes: The reporting service calls the connect() method of the socket library to establish a long connection with the server; Obtain each of the first coordinate points, encapsulate the first coordinate points, and call the send() method built into Python to report the encapsulated first coordinate point data to the server; After all the packaged first coordinate point data are sent, the close() method is called to close the long link established with the server.
6. The method according to claim 5, characterized in that The encapsulating the first coordinate point includes: The first coordinate point is parsed to obtain byte types of different lengths, and the point reporting parameters are concatenated to obtain coordinate data in a standard format that meets the acceptance requirements of the server, as the encapsulated first coordinate point data.
7. The method according to claim 1, characterized in that Before obtaining the test data, the method further includes: Create the local web service through the Flask framework; The local Web service is used to provide an interface call, and the interface call is used to operate event status change / multi-threaded Event method to obtain event status.
8. The method according to any one of claims 1 to 7, characterized in that: The method further comprises: After completing the point loss / reporting operation for the test data, the point loss data set is cleared.
9. A system for simulating the transmission of coordinates, characterized in that: The system includes a simulated point loss module, a point reporting service module and a Web service module; The Web service module is used to provide interface calls and obtain / operate event status; The reporting service module is used to establish a long link with the server and perform data analysis / reporting; The simulated point loss module is used to obtain test data and use the local Web service provided by the Web service module to determine the point loss / reporting behavior of the test data; For the first coordinate point that needs to be discarded, a lost point data set is stored; for the second coordinate point that does not need to be discarded, the point reporting service provided by the point reporting service module is called to report the first coordinate point to the server.
10. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the method for simulating the transmission of coordinates according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Test data automatic generation device and test data automatic generation method
CN104063314A
Method for generating driving data in simulated manner, system, simulation terminal and test system
CN109857085A
Gas station user information processing method and device and server
CN112541551A
Load capacity test system and method for background service, storage medium and electronic equipment
CN112799950A
Simulation test method and device, electronic equipment and storage medium
CN113687600A