CN-121984903-A - Internet of things equipment simulation online test method, system, equipment and storage medium
Abstract
The invention discloses an online simulation test method, system, equipment and medium for equipment of the Internet of things, wherein the method comprises the steps of collecting equipment information to be tested, importing the equipment information into a database through a data information publishing platform, pulling the written equipment information from the database, creating event loops based on asyncio, instantiating independent simulators for each piece of equipment of the Internet of things, creating exclusive asynchronous coroutines for each simulator, creating a message channel of an independent MQTT client for monitoring an instruction issued by the platform of the Internet of things through aiomqtt, analyzing and processing scheduling tasks, constructing equipment attributes and event data, and reporting the platform of the Internet of things. According to the invention, a simulator is adopted to replace real equipment for testing, through asyncio asynchronous programming architecture and aiomqtt asynchronous MQTT client side, multi-cooperative-process concurrent scheduling in a single thread is realized, the thread switching overhead of the traditional synchronous architecture is avoided, a single server can support more equipment for parallel simulation, and the online testing requirement of mass equipment can be met while the testing efficiency is improved.
Inventors
- LIU XIANGANG
Assignees
- 广西海桂云信息技术有限公司
Dates
- Publication Date
- 20260505
- Application Date
- 20260120
Claims (10)
- 1. The method for testing the Internet of things equipment on line in a simulation manner is characterized by comprising the following steps of, S1, collecting equipment information to be tested; S2, importing equipment information through a data information release platform, and writing the equipment information into a database; S3, starting an equipment simulation module, and pulling written equipment information from a database through a data access layer; s4, creating an event cycle based on asyncio, instantiating independent simulators for each Internet of things device according to the pulled device information, and creating exclusive asynchronous coroutines for each simulator; S5, each simulator creates an independent MQTT client through aiomqtt, configures an authentication mode matched with the platform of the Internet of things, initiates connection and completes equipment identity authentication; S6, the simulator monitors a message channel of an instruction issued by the Internet of things platform through the MQTT client, analyzes and processes the scheduling task, and returns a processing result to the Internet of things platform according to a preset Topic; s7, the simulator constructs attribute and event data corresponding to the type of the Internet of things equipment, and sends the attribute and event data to the Internet of things platform at regular time according to a preset reporting frequency to simulate the online state of the Internet of things equipment; s8, the equipment simulation module detects the cooperative programs of all simulators and the running working states of the MQTT client at regular time, and retries connection or restarting operation is carried out on the abnormally terminated client; and S9, registering the equipment simulation module as systemd hosting service, configuring abnormal automatic restarting of the program and a server starting self-starting rule, and ensuring continuous online operation of the simulation program.
- 2. The method of online simulation test of Internet of things equipment according to claim 1, wherein in step S1, the equipment information at least comprises a product Key, an equipment name, an equipment Key, an equipment model, an MQTT connection parameter and a preset reporting frequency.
- 3. The method for testing the Internet of things equipment on line in a simulation mode, which is characterized in that in the step S2, the data information release platform firstly performs uniqueness verification on imported equipment information, when the uniqueness verification is performed, the data information release platform reads all equipment unique identifiers which pass verification and are put in storage from a database to form a memory hash table, traverses each piece of new equipment information to be imported, extracts the unique identifier, inquires the hash table, refuses to write the equipment information into the database if repetition exists, records error information to form an error information list, and enters the next format verification if repetition data does not exist.
- 4. The method for simulating online testing of Internet of things equipment according to claim 3, wherein when format verification is performed, the data information release platform loads a corresponding regular rule pre-stored in a database according to the equipment model, performs standardized processing on the imported equipment information field values, then traverses the equipment information field to be verified to perform regular matching, if illegal fields exist, the verification fails, refuses to write the equipment information into the database, records error information, forms an error information list, and if all the fields are successfully matched, the verification passes, and allows the equipment information to be written into the database.
- 5. The method for simulating online testing of the Internet of things equipment according to claim 4, wherein in the process of writing equipment information into a database, the database synchronously executes final verification on the equipment information, a self-defined verification function built in the database is called, a built-in hash verification algorithm is called in the function to execute integrity verification, a rule matching algorithm is called to execute consistency verification, a regular matching algorithm is called to execute compliance verification, if the verification is passed, data writing is allowed, if the verification fails, batch writing is stopped and rolling back, and the database synchronizes verification and writing results to a data information release platform.
- 6. The method for simulating online testing of Internet of things equipment according to claim 5, wherein the database comprises a MySQL database and a Redis database, the MySQL database is used for storing total information of all the stored networking equipment and regular rules, the Redis database is used for caching unique identifiers of the stored Internet of things equipment and caching regular rules of various equipment models, and the unique identifiers of the Internet of things equipment and the regular rules are copies synchronized from the MySQL database.
- 7. The method for online simulation test of Internet of things equipment according to claim 6, wherein in step S7, the simulator adopts MOCK technology and a numerical generation algorithm to cooperatively construct attribute and event data corresponding to the model of the Internet of things equipment.
- 8. The system for testing the online simulation of the equipment of the Internet of things is characterized by comprising a data information release platform, an equipment simulation module, an Internet of things platform and a server which are connected in a communication mode, wherein the data information release platform is used for receiving equipment information to be tested, checking and then importing the equipment information to a database of the server, the equipment simulation module carries out simulator instantiation, asynchronous coroutine creation, MQTT client configuration and identity authentication based on the equipment information imported by the data information release platform, the Internet of things platform is used for receiving an online request, identity authentication information and data reporting information sent by the equipment simulation module, issuing an instruction to the equipment simulation module, analyzing a processing result returned by the equipment simulation module and outputting a test result, and the server is used for providing a database storage service, running the equipment simulation module and hosting the equipment simulation module.
- 9. A computer device comprising a memory and a processor, the memory having stored thereon a computer program executable on the processor, the processor implementing the method according to any of claims 1-7 when the computer program is executed.
- 10. A computer readable storage medium, characterized in that the computer readable storage medium stores a computer program for executing the method of any one of claims 1 to 7.
Description
Internet of things equipment simulation online test method, system, equipment and storage medium Technical Field The invention relates to the technical field of the Internet of things, in particular to an Internet of things equipment simulation online test method, system, equipment and storage medium. Background Along with the deep popularization of the internet of things technology, the internet of things platform needs to be connected with a large number of internet of things equipment of different models and different manufacturers, and compatibility verification, stability test, instruction interaction reliability verification and the like need to be performed before the equipment is on line. The current online test of the Internet of things equipment has two schemes of actual measurement or simple simulation test depending on real equipment, when the real equipment test is adopted, equipment of different types is needed to be purchased in batches, the hardware cost is high, equipment deployment and debugging periods are long, meanwhile, the real equipment test is difficult to realize multi-equipment parallel test, aiming at batch test scenes of hundreds or even thousands of equipment, the test efficiency is extremely low, the research and development rhythm of rapid iteration of an Internet of things platform cannot be matched, when the simulation test scheme is adopted, the traditional simulation module mainly adopts a synchronous programming architecture, each simulation equipment needs to occupy an independent thread, the thread context switching cost is high, a single server can only support the simulation operation of a small number of equipment, and when the test scale is expanded to the equipment above hundred stages, the problems of connection congestion, response delay and the like are easy to occur, and the concurrent online test requirement of the mass equipment cannot be met. Disclosure of Invention The invention aims to overcome the defects of the background technology and provides a method, a system, equipment and a storage medium for online simulation test of equipment of the Internet of things. In order to achieve the aim, the method for simulating the online test of the equipment of the Internet of things comprises the following steps of S1, collecting equipment information to be tested; S2, importing equipment information through a data information release platform, and writing the equipment information into a database; S3, starting an equipment simulation module, and pulling written equipment information from a database through a data access layer; s4, creating an event cycle based on asyncio, instantiating independent simulators for each Internet of things device according to the pulled device information, and creating exclusive asynchronous coroutines for each simulator; S5, each simulator creates an independent MQTT client through aiomqtt, configures an authentication mode matched with the platform of the Internet of things, initiates connection and completes equipment identity authentication; S6, the simulator monitors a message channel of an instruction issued by the Internet of things platform through the MQTT client, analyzes and processes the scheduling task, and returns a processing result to the Internet of things platform according to a preset Topic; s7, the simulator constructs attribute and event data corresponding to the type of the Internet of things equipment, and sends the attribute and event data to the Internet of things platform at regular time according to a preset reporting frequency to simulate the online state of the Internet of things equipment; s8, the equipment simulation module detects the cooperative programs of all simulators and the running working states of the MQTT client at regular time, and retries connection or restarting operation is carried out on the abnormally terminated client; and S9, registering the equipment simulation module as systemd hosting service, configuring abnormal automatic restarting of the program and a server starting self-starting rule, and ensuring continuous online operation of the simulation program. Further, in step S1, the device information at least includes a product Key, a device name, a device Key, a device model, an MQTT connection parameter, and a preset reporting frequency. Further, in step S2, the data information distribution platform performs a uniqueness check on the imported device information, when performing the uniqueness check, the data information distribution platform reads all the device unique identifiers that have passed the check and have been put in storage from the database to construct a memory hash table, traverses each new device information to be imported, extracts the unique identifier, queries the hash table, refuses to write the device information into the database if there is a repetition, records error information, and forms an error information list, and if there is no repeated data, ente