Distributed storage test method and device, computer equipment, readable storage medium and program product
By obtaining the configuration information of the distributed storage test object, determining and initializing the target storage object type to obtain the test interface, the inefficiency problem in traditional methods is solved and more efficient distributed storage testing is achieved.
Patent Information
- Application Number
- CN202411721748.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-28
- Publication Date
- 2025-03-18
AI Technical Summary
The traditional distributed storage testing method needs to query all version numbers every time the interface is called, resulting in increased data reading and logical judgment, which is poor in efficiency.
By obtaining the configuration information of the object to be tested, including the target version information, determining the target storage object type, and initializing it to obtain the target test interface, directly conducting tests to avoid querying the version number every time the interface is called.
It improves the execution efficiency of the target test interface, reduces unnecessary data reading and logical judgment, and improves the efficiency of distributed storage testing.
Smart Images

Figure CN119645857A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of testing technology, and in particular to a distributed storage testing method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Art
[0002] With the development of distributed system technology, the scale and complexity of distributed systems have increased dramatically, and the demand for automated testing of distributed storage has become increasingly urgent.
[0003] In traditional technology, the server pre-stores the test logic corresponding to the applications included in each system. Different versions of applications contain different test logics, and the test logic is encapsulated in the test interface. When it is necessary to test the system in the server, the server first initializes the object type in the test interface, and when calling the initialized test interface to run, it queries the version number corresponding to the test interface, and selects the test interface that matches the version of the object to be tested according to the version number for testing.
[0004] However, in traditional technology, each test interface queries all version numbers corresponding to the current test interface when it is running, which requires additional data reading and logical judgment, increases the overhead of each interface call, and results in poor efficiency in testing distributed storage. Summary of the invention
[0005] Based on this, it is necessary to provide a distributed storage testing method, apparatus, computer equipment, computer-readable storage medium and computer program product to address the above technical issues.
[0006] In a first aspect, the present application provides a distributed storage testing method, comprising:
[0007] Obtaining configuration information of the object to be tested; the configuration information includes target version information;
[0008] Determine the target storage object type corresponding to the target version information according to the target version information of the object to be tested and the storage object type of each version information;
[0009] Initializing the target storage object type to obtain each target test interface of the target version information corresponding to the object to be tested;
[0010] The object to be tested is tested according to each of the target test interfaces.
[0011] In one embodiment, determining the target storage object type corresponding to the target version information according to the target version information of the object to be tested and the storage object type of each version information includes:
[0012] Determine the name of the object to be tested according to the target version information;
[0013] Among the test object types corresponding to the version information, the target storage object type corresponding to the name of the object to be tested is determined.
[0014] In one embodiment, the configuration information further includes node information, node role and node attributes, and the method further includes:
[0015] Determine a target node corresponding to the object to be tested based on the node information, the node role and the node attribute;
[0016] The step of determining the target storage object type corresponding to the target version information according to the target version information of the object to be tested and the storage object type of each version information includes:
[0017] In the target node, an interface management configuration file is obtained; the interface management configuration file includes a storage object type of each version information;
[0018] The target version information is matched with the version information included in the interface management configuration file, and the storage object type corresponding to the target version information is determined as the target storage object type.
[0019] In one embodiment, the initializing the target storage object type to obtain each target test interface of the target version information corresponding to the object to be tested includes:
[0020] For each of the target storage object types, acquiring a target file corresponding to the target storage object type according to the path of the target storage object type;
[0021] According to the class object corresponding to the target storage object type in the target file, the instance object to which the target storage object type belongs is assigned to obtain a target instance object; the target instance object includes each target test interface of the target version information.
[0022] In one of the embodiments, after assigning a value to an instance object to which the target storage object type belongs according to the class object corresponding to the target storage object type in the target file to obtain the target instance object, the method further comprises:
[0023] Add the target instance object to the cluster to obtain an initialized cluster object; the cluster object has the same version information as the object to be tested;
[0024] The cluster object is determined as a unified entry of the test case, and the object to be tested is tested according to the unified entry to obtain a test result.
[0025] In one embodiment, if the target version information changes, the method further includes:
[0026] Obtaining update information of the object to be tested in the new version information; the update information includes a new storage object type;
[0027] In the new storage object type, if the target test interface to be updated exists, the rewritten target test interface is stored;
[0028] If there is a new function, a new test interface corresponding to the new function in the new storage object type will be stored.
[0029] In a second aspect, the present application also provides a distributed storage testing device, including:
[0030] A first acquisition module is used to acquire configuration information of the object to be tested; the configuration information includes target version information;
[0031] A first determination module, configured to determine a target storage object type corresponding to the target version information according to the target version information of the object to be tested and the storage object type of each version information;
[0032] An initialization module, used to initialize the target storage object type and obtain each target test interface of the target version information corresponding to the object to be tested;
[0033] The first testing module is used to test the object to be tested according to each of the target testing interfaces.
[0034] In one of the embodiments, the first determination module is specifically used to determine the name of the object to be tested according to the target version information;
[0035] Among the test object types corresponding to the version information, the target storage object type corresponding to the name of the object to be tested is determined.
[0036] In one embodiment, the configuration information further includes node information, node role and node attributes, and the device further includes:
[0037] A second determination module is used to determine a target node corresponding to the object to be tested based on the node information, the node role and the node attribute;
[0038] The first determination module is specifically used to obtain an interface management configuration file in the target node; the interface management configuration file contains a storage object type of each version information;
[0039] The target version information is matched with the version information included in the interface management configuration file, and the storage object type corresponding to the target version information is determined as the target storage object type.
[0040] In one of the embodiments, the initialization module is specifically used to obtain, for each of the target storage object types, a target file corresponding to the target storage object type according to a path of the target storage object type;
[0041] According to the class object corresponding to the target storage object type in the target file, the instance object to which the target storage object type belongs is assigned to obtain a target instance object; the target instance object includes each target test interface of the target version information.
[0042] In one embodiment, the device further comprises:
[0043] An adding module, used for adding the target instance object to the cluster to obtain an initialized cluster object; the cluster object has the same version information as the object to be tested;
[0044] The second testing module is used to determine the cluster object as a unified entry of the test case, and test the object to be tested according to the unified entry to obtain a test result.
[0045] In one embodiment, the device further comprises:
[0046] A second acquisition module is used to acquire update information of the object to be tested in the new version information; the update information includes a new storage object type;
[0047] A first storage module, configured to store the rewritten target test interface in the new storage object type if the target test interface to be updated exists;
[0048] The second storage module is used to store a new test interface corresponding to the new function in the new storage object type if there is a new function.
[0049] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0050] Obtaining configuration information of the object to be tested; the configuration information includes target version information;
[0051] Determine the target storage object type corresponding to the target version information according to the target version information of the object to be tested and the storage object type of each version information;
[0052] Initializing the target storage object type to obtain each target test interface of the target version information corresponding to the object to be tested;
[0053] The object to be tested is tested according to each of the target test interfaces.
[0054] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:
[0055] Obtaining configuration information of the object to be tested; the configuration information includes target version information;
[0056] Determine the target storage object type corresponding to the target version information according to the target version information of the object to be tested and the storage object type of each version information;
[0057] Initializing the target storage object type to obtain each target test interface of the target version information corresponding to the object to be tested;
[0058] The object to be tested is tested according to each of the target test interfaces.
[0059] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:
[0060] Obtaining configuration information of the object to be tested; the configuration information includes target version information;
[0061] Determine the target storage object type corresponding to the target version information according to the target version information of the object to be tested and the storage object type of each version information;
[0062] Initializing the target storage object type to obtain each target test interface of the target version information corresponding to the object to be tested;
[0063] The object to be tested is tested according to each of the target test interfaces.
[0064] The above-mentioned distributed storage testing method, apparatus, computer equipment, computer-readable storage medium and computer program product obtain configuration information of the object to be tested; the configuration information includes target version information; according to the target version information of the object to be tested and the storage object type of each version information, determine the target storage object type corresponding to the target version information; initialize the target storage object type to obtain each target test interface of the target version information corresponding to the object to be tested; test the object to be tested according to each target test interface. With this method, the target storage object type corresponding to the target version information of the object to be tested is selected during the initialization of the storage object type, and the target test interface corresponding to the object to be tested is obtained after the initialization is completed, so that when different target test interfaces are called, there is no need to select the test logic that matches the target test interface with the target version information in each target test interface, thereby improving the execution efficiency of the target test interface, and further improving the efficiency of fractional storage testing. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0066] Figure 1 An application environment diagram of a distributed storage testing method in one embodiment;
[0067] Figure 2 is a schematic diagram of configuration information included in a configuration file in an embodiment;
[0068] Figure 3 A schematic diagram of the organizational structure of a tree structure of an object to be tested in one embodiment;
[0069] Figure 4 A schematic diagram of a process for determining a target storage object type in one embodiment;
[0070] Figure 5 A schematic diagram of a process of initializing a target node and determining a target storage object type in another embodiment;
[0071] Figure 6 A schematic diagram of an interface management configuration file in one embodiment;
[0072] Figure 7 A schematic diagram of a process of initializing a target storage object type in one embodiment;
[0073] Figure 8A schematic diagram of a process of initializing a target storage object type to obtain a target test interface in another embodiment;
[0074] Fig. 9 A schematic diagram of a process of initializing a cluster object in one embodiment;
[0075] Fig.10 A schematic diagram of an example of testing a cluster object as a unified entry in an embodiment;
[0076] Fig.11 A schematic diagram of a process of updating an interface in one embodiment;
[0077] Fig.12 A schematic diagram of an example flow of a distributed storage testing method in an embodiment;
[0078] Fig.13 is a structural block diagram of a distributed storage testing device in one embodiment;
[0079] Fig.14 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0080] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0081] In one embodiment, Figure 1 As shown, a distributed storage test method is provided. This embodiment uses the method applied to a server as an example for illustration. It can be understood that the method can also be applied to a terminal, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. In this embodiment, the method includes the following steps:
[0082] Step 102: Obtain configuration information of the object to be tested.
[0083] The configuration information includes target version information.
[0084] In the embodiment of the present application, the object to be tested may be a storage service in a cloud computing service, for example, the storage service may be a Cloud Storage service. The server first reads a configuration file of the object to be tested, which may be a YAML file, and the configuration file is used to describe the configuration information of the object to be tested, such as Figure 2 As shown in , the configuration information includes the product version of the object to be tested, that is, the target version information, as well as the cluster attributes and node information of the object to be tested. Figure 2As shown in the figure, product represents the product name and target version information of the object to be tested, which is used for subsequent loading of the interface library; cluster_attrs represents some attributes or parameters of the cluster, for example, http_port represents the HTTP port provided by the cluster to the outside world; nodes represents all nodes of the cluster, and each node contains multiple fields, for example, IP (Internet Protocol) address (used for SSH (Secure Shell) connection), role (roles), attribute (attrs). Furthermore, the server can extract the target version information of the object to be tested from the configuration file of the object to be tested. Optionally, during the pre-construction of the configuration file, there is no need to manually specify the version in the configuration file. Instead, after completing the initialization of the Node node, a command is sent to the storage device to query the target version information corresponding to the object to be tested.
[0085] In addition, the correspondence between different versions of each object to be tested in the server and the storage object type can be stored in a tree structure, such as Figure 3 As shown in the figure, in the target version information of the object to be tested in the node Node-1, the server defines Pool, Lun and Snap in the Resource (storage) object. At the same time, each version corresponds to a configuration file, which is used to describe the version information of the object to be tested.
[0086] Step 104: Determine the target storage object type corresponding to the target version information according to the target version information of the object to be tested and the storage object type of each version information.
[0087] In the embodiments of the present application, storage object types refer to different types of data or resources managed and operated in the storage system. Storage objects can be physical (e.g., hard disk, flash memory) or logical (e.g., file system, database table). Each type of storage object has its specific attributes and operation methods. For example, storage object types can be Pool, LUN, Volume, Snapshot, etc.
[0088] Each version of the object to be tested is defined with its own storage object type. For example, the application APP1 has two different versions v1.0 and v2.0. v1.0 uses FileStorage as its storage object type, and v2.0 uses ObjectStorage as its storage object type. Therefore, since different versions of the object to be tested correspond to different storage object types, the server needs to determine the target storage object type corresponding to the current target version information of the object to be tested before testing, and obtain the target version information according to the configuration information of the object to be tested. Among them, the target version information and each version information can be recorded in the form of a version number, and the server stores the storage object type corresponding to the version number of each version information. Then, the server uses the target version number of the object to be tested as a matching basis, determines the target version number that matches the target version information among the version numbers of multiple version information, and obtains the target storage object type under the target version number. For example, if the target version information is v2.0, the server determines that the target storage object type is ObjectStorage.
[0089] Step 106, initializing the target storage object type, and obtaining each target test interface of the target version information corresponding to the object to be tested.
[0090] In the embodiment of the present application, before testing, the server needs to perform corresponding initialization and generate a test interface according to the storage object type of the target version. In the distributed storage, each node contains different types of collections, and the types of the collections can be storage object types, test tool types, and fault types. For example, storage object types include storage pools, storage volumes, LUNs, snapshots, etc. At the same time, each storage object type also includes all operations corresponding to the storage object type. For example, the operations of the storage pool include creating a storage pool, expanding the storage pool, and deleting the storage pool.
[0091] The server also predefines classes of various storage object types (data types in object-oriented programming), and each storage object type corresponding class also contains multiple methods, which are used to implement operations corresponding to the storage object type. After the storage object type of the target version information is instantiated, the server can generate a corresponding target test interface based on the methods contained in the class corresponding to the storage object type. After being called by the test case, the test interface can implement specific operations for the target storage object type.
[0092] Step 108: Testing the object to be tested according to each target test interface.
[0093] In an embodiment of the present application, after each node of the distributed storage starts running, the server determines the various test parameters and test data required for the test based on the pre-stored test cases. For example, the test parameters may include the size of the storage pool, the capacity of the storage volume, and the retention time of the snapshot. The test data is used for read and write operations on the target storage object type of the object to be tested during the test.
[0094] Then, the server calls each target test interface respectively, and calls the function or method corresponding to the target test interface to test the object to be tested. Each test interface corresponds to a specific operation, such as creating a storage pool, expanding storage volume, deleting snapshots, etc. After calling the test interface, the server needs to verify the test results to ensure that each operation is performed as expected and no errors or exceptions occur. Methods for verifying test results include checking operation logs, checking system status, and data integrity checks. Among them, checking operation logs is to check the operation logs of storage nodes to ensure that each operation is correctly recorded; checking system status is to check the system status of storage nodes to ensure that there are no abnormal states (for example, insufficient resources, network failures, etc.); data integrity checks are to check the integrity and consistency of data for operations involving data writing and reading.
[0095] In the above-mentioned distributed storage testing method, the target storage object type corresponding to the target version information of the object to be tested is selected during the initialization process of the storage object type, and the target test interface corresponding to the object to be tested is obtained after the initialization is completed. This ensures that when different target test interfaces are called, there is no need to select the test logic that matches the target test interface with the target version information in each target test interface, thereby improving the execution efficiency of the target test interface and further improving the efficiency of the fractional storage test.
[0096] In an exemplary embodiment, Figure 4 As shown, step 104 includes steps 402 to 404. Among them:
[0097] Step 402: determine the name of the object to be tested according to the target version information.
[0098] In the embodiment of the present application, the server first queries the target version information of the object to be tested. In step 102, the configuration file of the object to be tested has been obtained, and the product version described in the configuration file, that is, the target version information, can be read. Therefore, the server can directly obtain the name of the object to be tested corresponding to the object to be tested corresponding to the target version information. Alternatively, after completing the Node initialization, the server sends a command to the storage device to query the version information, and obtains the name of the object to be tested through dynamic query.
[0099] Step 404: Determine the target storage object type corresponding to the name of the object to be tested among the test object types corresponding to each version information.
[0100] In an embodiment of the present application, the configuration file of the object to be tested also includes the test object type corresponding to the object to be tested under each version information. The server searches for the target object name that matches the name of the object to be tested corresponding to the target version information among the object names corresponding to the version information of multiple versions according to the name of the object to be tested, and determines the module name and class name of each test object type recorded under the target object name in the configuration file, and then determines the target storage object type according to the module name and class name. For example, if the name of the object to be tested is storage-v3, the test object type corresponding to storage-v3 and its corresponding module name and class name can be extracted from the configuration file, including the test object type: pool, full module name: storage.pool.pool_v3, class name: Pool_v3; test object type: lun, full module name: storage.lun.lun_v3, class name: Lun_v3.
[0101] In this embodiment, during the testing process, it is only necessary to determine all target storage object types contained in the object to be tested under the target version information based on the name of the object to be tested in the target version information, and then obtain the target test interface corresponding to the target version information under the target storage object type. There is no need to select the test logic that matches the target test interface with the target version information in each target test interface, thereby improving the execution efficiency of the target test interface and thus improving the efficiency of the fractional storage test.
[0102] In an exemplary embodiment, the configuration information also includes node information, node roles and node attributes; Figure 5 As shown, the method also includes:
[0103] Step 502: determine the target node corresponding to the object to be tested based on the node information, node role and node attributes.
[0104] In an embodiment of the present application, the server extracts the node information, node role and node attributes of the deployment node of the object to be tested and each node from the configuration information of the object to be tested. Node information includes basic information such as network address, hardware configuration, operating system version, etc. The node role refers to the function or service that the node undertakes in the system. In this embodiment, a node can have multiple roles, for example, "osd" (storage node) and "gateway" (gateway node). In actual operation, the server can further subdivide each node into more roles or services according to demand. Attrs represents some attributes or parameters of the node. This field is also customized on demand. For example, the path of the test tool can be placed here.
[0105] After the server obtains the node information, node role and node attributes of each node, it determines the target node based on the node information. Then, the server initializes the target node based on the node information, node role and node attributes in the configuration information. Specifically, when initializing the node, the server traverses each node information under the nodes field in the configuration file, and initializes the SSH connector with the ip field (including the username and password). The SSH connector implements the server connection and command execution functions. Then, the role of the node is set according to the roles field (node role). In the subsequent test cases, different nodes can be filtered out according to the node role to perform operations on specific nodes. Finally, if the node attribute has an atrrs field, the server uses this field to set the node attribute, for example, to set the path of the test tool fio on the node.
[0106] Step 104 also includes:
[0107] Step 504: In the target node, obtain the interface management configuration file.
[0108] The interface management configuration file includes storage object types for each version information.
[0109] In the embodiment of the present application, the server uses an SSH connector to connect to the target node, finds the location of the interface management configuration file according to the known configuration file path or through the system management tool, downloads the configuration file to the local test environment or directly reads its content, and parses the content in the configuration file to extract the storage object type of each version information.
[0110] In an optional embodiment, the server manages multiple interfaces according to the interface management configuration file. Specifically, the multi-version interface management is mainly aimed at the target storage object type under the Resource type. Taking Pool as an example, if the first version class name is Pool_v1, it encapsulates all operations of Pool, the second version class name is Pool_v2, inherited from Pool_v1, and a small number of interfaces in Pool_v1 are redefined, and the third version class name is Pool_v3, inherited from Pool_v2, a small number of interfaces in Pool_v2 are redefined, and a small number of new interfaces are added.
[0111] The full names of the modules where the three classes are located are storage.pool.pool_v1, storage.pool.pool_v2, and storage.pool.pool_v3. Then, an interface management configuration file is used to manage all interface classes of all versions. The configuration file example is as follows: Figure 6As shown in the figure, all target storage object types of each version are placed under the keyword of the version. For example, pool and lun under storage-v1 represent the storage object types of the version, and under each storage object type, module_name represents the full name of the module that defines the object type, and class_name represents the class name of the object type. For example, the full module name of the storage-v1 version pool is storage.pool.pool_v1, and the class name is Pool_v1.
[0112] Step 506: Match the target version information with the version information included in the interface management configuration file, and determine the storage object type corresponding to the target version information as the target storage object type.
[0113] In an embodiment of the present application, the server searches for a version that matches the target version information in the interface management configuration file, extracts the storage object type corresponding to the matching version, and finally determines the extracted storage object type as the target storage object type for use during the test process.
[0114] In a specific embodiment, Figure 6 and Figure 7 As shown, Figure 6 For example, the interface management configuration file is Figure 7 This is an example of the initialization process for storage object types. The version information in the interface management configuration file includes storage-v1, storage-v2, and storage-v3. The storage object types included in storage-v1 are pool (storage.pool.pool_v1) and lun (storage.lun.lun_v1); the storage object types included in storage-v2 are pool (storage.pool.pool_v2) and lun (storage.lun.lun_v2); the storage object types included in storage-v3 are pool (storage.pool.pool_v3) and lun (storage.lun.lun_v3). And determine the target version information as storage-v3, the server searches for the version matching storage-v3 in the interface management configuration file, and then extracts the storage object types pool (storage.pool.pool_v3) and lun (storage.lun.lun_v3) under the storage-v3 version, and obtains the target storage object types Pool_v3 (corresponding module name: storage.pool.pool_v3) and Lun_v3 (corresponding module name: storage.lun.lun_v3).
[0115] After determining the target storage object type, the server finally imports and initializes the target storage object type. You can use Python's import_module to import the module, then use getattr to obtain the target storage object type, and then assign the target storage object type to the corresponding attribute of the Resource type. Taking pool as an example, first execute module_object=import_module('storage.pool.pool_v3') to import the pool type module, then execute resource.pool=getattr(module_object,'Pool_v3') to obtain the pool object type, and set the pool object type to resource.pool, thereby completing the initialization of the pool object type. The subsequent interfaces called through resource.pool in the test case will all call the storage-v3 version of the pool interface, and then there is no need to call the interface through resource.pool in the test case, and select the storage-v3 version of the pool interface in each interface in turn by judgment.
[0116] In this embodiment, by finely analyzing the node information, roles and attributes, and accurately matching the target version information with the version information in the interface management configuration file, it is ensured that when the interface is directly called in the test case, there is no need to judge and select the interface of the target version information one by one in each interface. The execution efficiency of the target test interface is significantly improved, making the test process more efficient.
[0117] In an exemplary embodiment, Figure 8 As shown, step 106 includes steps 802 to 804. Among them:
[0118] Step 802: for each target storage object type, find a target file corresponding to the target storage object type according to the path of the target storage object type.
[0119] In the embodiment of the present application, after determining the target storage object type, the server finds and loads the corresponding target file according to the path information of the target storage object type. The target file contains the relevant configuration or definition of the target storage object type, providing a basis for subsequent operations.
[0120] Step 804: assign a value to the instance object of the target storage object type according to the class object corresponding to the target storage object type in the target file to obtain a target instance object.
[0121] The target instance object includes target version information for each target test interface.
[0122] In the embodiment of the present application, after initializing the node, the server needs to initialize each collection object of the node. First, the server parses the class object in the target file, parses the class object definition corresponding to the target storage object type from the loaded target file, and creates an instance object of the target storage object type according to the class object definition. Then, the server assigns and configures the instance object according to the configuration information in the target file to ensure that it contains all the test interfaces of the target version information. The target instance object finally obtained contains each target test interface of the target version information, and the target test interface is used to call the test case in the subsequent test operation.
[0123] In a specific embodiment, taking the Resource collection object as an example, after extracting the class object corresponding to the target storage object type from the target file of the target node, it is only necessary to add a resource attribute to the target node during initialization and instantiate it as a Resource class object. When instantiating a Resource object, it is only necessary to set the relevant attributes to the class name of the class object corresponding to the target storage object type without instantiating a real object. For example, the pool attribute is set to the class name Pool. Since the storage pool has not been actually created at this time, there is no need to instantiate a real storage pool object. The Pool class provides a static method create for creating a real storage pool. This method returns a created Pool object. Other methods can be called on this pool object to perform storage pool operations. For example, the add_disk method can be called to expand the storage pool, and the delete method can be called to delete the storage pool.
[0124] In this embodiment, by finely loading and parsing the relevant files and class object definitions of the target storage object type, it is ensured that the instance object of the target storage object type can accurately contain all test interfaces of the target version information. When the test case calls the target test interface, it is unaware of the version of the interface. A set of test cases can be used for multiple versions, and the execution efficiency of the target test interface is improved, thereby improving the efficiency of fractional storage testing.
[0125] In an exemplary embodiment, Fig. 9 As shown, step 804 includes steps 902 to 904. Among them:
[0126] Step 902: Add the target instance object to the cluster to obtain an initialized cluster object.
[0127] The version information of the cluster object is the same as that of the object to be tested.
[0128] In the embodiment of the present application, the server finally initializes the cluster object. Specifically, the server adds the initialized node to the node list and adds the cluster_attrs field in the configuration file to the cluster attributes. The cluster object also provides methods for obtaining nodes, such as the get_nodes_by_roles method, which is used to filter nodes according to node roles.
[0129] like Figure 2 As shown in the figure, the cluster contains a group of Nodes, each of which corresponds to a server node. Different Nodes have different roles. A complete test cluster contains at least three nodes with different roles: storage nodes, computing nodes, and clients. In addition, Nodes can also assume multiple roles (integrated deployment scenarios). Nodes are the real objects of test operations. All test operations (commands) must be issued through Nodes, which is equivalent to the operations performed by logging in to the server in manual testing.
[0130] Node contains multiple different types of collections. For example, Resource is a collection of storage resource types, which includes all storage object types. For example, Pool encapsulates all operations on storage pools. Other storage object types include storage volume LUN, snapshot Snap, etc. Tool is a collection of all test tools. For example, Vdbench class encapsulates the operation of IO testing through Vdbench. Other tools include Fio, Cosbench, etc. Fault is a collection of all fault types, which is used to inject faults during reliability testing. For example, Disk class encapsulates the operation of fault injection and recovery on disks. Other common fault types include Network, File system, etc. Sys is a collection of commonly used basic operations, such as ps for querying processes, iostat for querying disk io, etc. Each collection type can be freely expanded, and new collection types can also be added.
[0131] Step 904: determine the cluster object as a unified entry of the test case, and test the object to be tested according to the unified entry to obtain a test result.
[0132] In the embodiment of the present application, in the test framework, the server uses the cluster object (cluster) as the unified entrance for all test cases, so that all test operations (such as node management, storage resource operations, tool calls, fault injection, etc.) can be called through the cluster object. In the execution process of each test case, the server is first initialized through the cluster object to ensure that all operations are based on the same cluster state and configuration. Then, according to the specific needs of the test case, the server operates and tests the object to be tested through various methods provided by the cluster object (for example, get_nodes_by_roles, Resource, Tool, Fault, Sys collection types, etc.), and obtains the distributed storage test results for the object to be tested.
[0133] The tree-structured management method for the objects to be tested has a clear and simple hierarchy and is easy to use. From the unified entrance of the cluster object as the root entrance, and then going down layer by layer to the leaf nodes, all the required target test interfaces can be found, which can significantly improve the efficiency of automated development. In addition, the tree-structured management method enables operations of the same type to be cohesive, and operations of different types are completely independent. New collection types can be added as needed, so it is easy to maintain and expand.
[0134] In addition, the entire initialization process can be called in a fixture of pytest (a Python testing framework). The scope of the fixture is session, that is, it is called before the entire test task is run. After the call, a cluster object will be returned as a unified entry for subsequent test cases. For example, Fig.10 As shown, if the name of the fixture is cluster, the fixture returns the initialized cluster object and calls the target test interface corresponding to the operation contained in the target storage object type under the target version information according to the cluster object.
[0135] In this embodiment, a tree-structured test object management method is adopted, which has the advantages of clear hierarchy, simple management and maintenance, and convenient expansion. At the same time, the cluster object is determined as the unified entrance of the test case, and all interfaces can be queried through the unified entrance, so that the type of each operation is clear, thereby further improving the efficiency of automated case development.
[0136] In an exemplary embodiment, Fig.11 As shown, if the target version information changes, the method further includes steps 1102 to 1106. Among them:
[0137] Step 1102: Obtain update information of the object to be tested in the new version information.
[0138] The update information includes a new storage object type.
[0139] In the embodiment of the present application, different versions of the test pair may contain different target storage object types, or changes to existing storage object types, including changes in parameters of the same target storage object type under different versions, or a target storage object under the new version has new operations. For example, the storage object type contained in the storage-v2 version is pool, and the storage object types contained in the storage-v3 version are pool and lun; or the operations contained in the pool storage object type in the storage-v2 version are only to create a storage pool and delete a storage pool, while the operations contained in the pool storage object type in the storage-v3 version are to create a storage pool, delete a storage pool, and expand the capacity of a storage pool.
[0140] Step 1104: If there is a target test interface to be updated in the new storage object type, the rewritten target test interface is stored.
[0141] In the embodiment of the present application, a new storage object type is defined in the new version, which is inherited from the storage object type of the old version, and the target test interface that needs to be updated is identified from the recorded update information. After the developer rewrites the target test interface, if there is a target test interface to be updated (the parameters in the target test interface have changed), the server stores the rewritten target test interface.
[0142] In a specific embodiment, various operations of the first version are encapsulated in the corresponding storage object type. For example, Pool encapsulates all operations of the storage pool. Starting from the second version, developers define a new storage object type that inherits the storage object type of the previous version. Then, for completely unchanged interfaces, the definition of the storage object type in the previous version will be directly used. For changed interfaces, it is only necessary to rewrite the interface in the new class corresponding to the new storage object type. At the same time, for newly added functions, it is only necessary to add a new interface in the new class corresponding to the new storage object type.
[0143] Step 1106: If there is a new function, a new test interface corresponding to the new function in the new storage object type is stored.
[0144] In an embodiment of the present application, after the storage object type is updated, the server identifies the updated content in the new storage object type according to the same principle as step 1004. If the object storage type has new functions, the server will store the new test interface corresponding to the new functions in the new storage object type.
[0145] In the embodiment of the present application, a multi-version interface management method is adopted, so that the interfaces of each version storage object type can reuse the interfaces and make the interfaces of each version storage object type relatively independent. Modifying the interface of the new version storage object type or adding a new interface will not affect the operation of the use case corresponding to the old version storage object type, thereby improving the stability, readability, maintainability and scalability of the application when the interface is called; at the same time, there is no need for each target test interface of each use case to query the corresponding version at runtime, thereby improving the execution efficiency of the use case.
[0146] In a specific embodiment, Fig.12 As shown, an example of a distributed storage testing method is provided, including:
[0147] Step 1201, obtaining configuration information of the object to be tested;
[0148] Step 1202, initializing the target node corresponding to the object to be tested;
[0149] Step 1203, initializing the target storage object type contained in each target node;
[0150] Step 1204 , initialize the cluster object, and based on the unified entry of the cluster object, call the target test interface to perform a distributed storage test on the object to be tested.
[0151] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0152] Based on the same inventive concept, the embodiment of the present application also provides a distributed storage test device for implementing the above-mentioned distributed storage test method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above-mentioned method, so the specific limitations in one or more distributed storage test device embodiments provided below can refer to the above-mentioned limitations on the distributed storage test method, and will not be repeated here.
[0153] In an exemplary embodiment, Fig.13As shown, a distributed storage test device 1300 is provided, including: a first acquisition module 1301, a first determination module 1302, an initialization module 1303 and a first test module 1304, wherein:
[0154] The first acquisition module 1301 is used to acquire configuration information of the object to be tested; the configuration information includes target version information;
[0155] A first determination module 1302 is used to determine a target storage object type corresponding to the target version information according to the target version information of the object to be tested and the storage object type of each version information;
[0156] Initialization module 1303, used to initialize the target storage object type and obtain each target test interface of the target version information corresponding to the object to be tested;
[0157] The first testing module 1304 is used to test the object to be tested according to each target testing interface.
[0158] In one embodiment, the first determination module 1302 is specifically used to determine the name of the object to be tested according to the target version information;
[0159] Among the test object types corresponding to the version information, determine the target storage object type corresponding to the name of the object to be tested.
[0160] In one embodiment, the configuration information further includes node information, node role and node attributes, and the apparatus 1300 further includes:
[0161] A second determination module is used to determine the target node corresponding to the object to be tested based on the node information, node role and node attributes;
[0162] The first determination module is specifically used to obtain an interface management configuration file in the target node; the interface management configuration file contains a storage object type of each version information;
[0163] The target version information is matched with the version information included in the interface management configuration file, and the storage object type corresponding to the target version information is determined as the target storage object type.
[0164] In one embodiment, the initialization module 1303 is specifically used to obtain, for each target storage object type, a target file corresponding to the target storage object type according to the path of the target storage object type;
[0165] According to the class object corresponding to the target storage object type in the target file, the instance object to which the target storage object type belongs is assigned to obtain the target instance object; the target instance object includes each target test interface of the target version information.
[0166] In one embodiment, the apparatus 1300 further includes:
[0167] The adding module is used to add the target instance object to the cluster to obtain the initialized cluster object; the cluster object has the same version information as the object to be tested;
[0168] The second test module is used to determine the cluster object as a unified entry of the test case, and test the object to be tested according to the unified entry to obtain a test result.
[0169] In one embodiment, the apparatus 1300 further includes:
[0170] The second acquisition module is used to obtain the update information of the object to be tested in the new version information; the update information includes a new storage object type;
[0171] A first storage module is used to store the rewritten target test interface in the new storage object type if there is a target test interface to be updated;
[0172] The second storage module is used to store the new test interface corresponding to the new function in the new storage object type if there is a new function.
[0173] Each module in the above-mentioned distributed storage test device can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0174] In an exemplary embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as shown in FIG. Fig.14As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, near field communication (NFC) or other technologies. When the computer program is executed by the processor, a distributed storage test method is implemented. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.
[0175] Those skilled in the art will understand that Fig.14 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0176] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0177] Get the configuration information of the object to be tested; the configuration information includes the target version information;
[0178] Determine the target storage object type corresponding to the target version information according to the target version information of the object to be tested and the storage object type of each version information;
[0179] Initialize the target storage object type and obtain the target test interface of the target version information corresponding to the object to be tested;
[0180] Test the object to be tested according to each target test interface.
[0181] In one embodiment, when the processor executes the computer program, the following steps are also implemented:
[0182] Determine the name of the object to be tested according to the target version information;
[0183] Among the test object types corresponding to the version information, determine the target storage object type corresponding to the name of the object to be tested.
[0184] In one embodiment, when the processor executes the computer program, the following steps are also implemented:
[0185] Determine the target node corresponding to the object to be tested based on the node information, node role and node attributes;
[0186] According to the target version information of the object to be tested and the storage object type of each version information, determining the target storage object type corresponding to the target version information includes:
[0187] In the target node, an interface management configuration file is obtained; the interface management configuration file includes a storage object type of each version information;
[0188] The target version information is matched with the version information included in the interface management configuration file, and the storage object type corresponding to the target version information is determined as the target storage object type.
[0189] In one embodiment, when the processor executes the computer program, the following steps are also implemented:
[0190] For each target storage object type, obtaining a target file corresponding to the target storage object type according to the path of the target storage object type;
[0191] According to the class object corresponding to the target storage object type in the target file, the instance object to which the target storage object type belongs is assigned to obtain the target instance object; the target instance object includes each target test interface of the target version information.
[0192] In one embodiment, when the processor executes the computer program, the following steps are also implemented:
[0193] Add the target instance object to the cluster to obtain the initialized cluster object; the cluster object has the same version information as the object to be tested;
[0194] The cluster object is determined as a unified entry of the test case, and the object to be tested is tested according to the unified entry to obtain the test result.
[0195] In one embodiment, when the processor executes the computer program, the following steps are also implemented:
[0196] Obtaining update information of the object to be tested in the new version information; the update information includes a new storage object type;
[0197] In the new storage object type, if there is a target test interface to be updated, the rewritten target test interface is stored;
[0198] If there are new functions, the new test interfaces corresponding to the new functions in the new storage object type will be stored.
[0199] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above method embodiments are implemented.
[0200] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0201] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0202] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0203] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0204] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A distributed storage testing method, characterized in that: The method comprises: Obtaining configuration information of the object to be tested; the configuration information includes target version information; Determine the target storage object type corresponding to the target version information according to the target version information of the object to be tested and the storage object type of each version information; Initializing the target storage object type to obtain each target test interface of the target version information corresponding to the object to be tested; The object to be tested is tested according to each of the target test interfaces.
2. The method according to claim 1, characterized in that The step of determining the target storage object type corresponding to the target version information according to the target version information of the object to be tested and the storage object type of each version information includes: Determine the name of the object to be tested according to the target version information; Among the test object types corresponding to the version information, the target storage object type corresponding to the name of the object to be tested is determined.
3. The method according to claim 1, characterized in that The configuration information also includes node information, node roles and node attributes, and the method further includes: Determine a target node corresponding to the object to be tested based on the node information, the node role and the node attribute; The step of determining the target storage object type corresponding to the target version information according to the target version information of the object to be tested and the storage object type of each version information includes: In the target node, an interface management configuration file is obtained; the interface management configuration file includes a storage object type of each version information; The target version information is matched with the version information included in the interface management configuration file, and the storage object type corresponding to the target version information is determined as the target storage object type.
4. The method according to claim 1, characterized in that The initializing the target storage object type to obtain each target test interface of the target version information corresponding to the object to be tested includes: For each of the target storage object types, acquiring a target file corresponding to the target storage object type according to the path of the target storage object type; According to the class object corresponding to the target storage object type in the target file, the instance object to which the target storage object type belongs is assigned to obtain a target instance object; the target instance object includes each target test interface of the target version information.
5. The method according to claim 4, characterized in that After assigning a value to an instance object to which the target storage object type belongs according to the class object corresponding to the target storage object type in the target file to obtain the target instance object, the method further includes: Add the target instance object to the cluster to obtain an initialized cluster object; the cluster object has the same version information as the object to be tested; The cluster object is determined as a unified entry of the test case, and the object to be tested is tested according to the unified entry to obtain a test result.
6. The method according to claim 1, characterized in that If the target version information changes, the method further includes: Obtaining update information of the object to be tested in the new version information; the update information includes a new storage object type; In the new storage object type, if the target test interface to be updated exists, the rewritten target test interface is stored; If there is a new function, a new test interface corresponding to the new function in the new storage object type will be stored.
7. A distributed storage test device, characterized in that: The device comprises: A first acquisition module is used to acquire configuration information of the object to be tested; the configuration information includes target version information; A first determination module, configured to determine a target storage object type corresponding to the target version information according to the target version information of the object to be tested and the storage object type of each version information; An initialization module, used to initialize the target storage object type and obtain each target test interface of the target version information corresponding to the object to be tested; The first testing module is used to test the object to be tested according to each of the target testing interfaces.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.