Configuration file detection method and device, electronic equipment and storage medium
By comparing Nacos configuration files and using target comparison templates to verify different configuration items, the problem of environmental differences in configuration file detection is solved, and an efficient and automated detection process is achieved.
Patent Information
- Application Number
- CN202411816925.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-10
- Publication Date
- 2025-04-11
AI Technical Summary
In large distributed systems, during the abnormal detection process of Nacos configuration files, it is impossible to intelligently distinguish allowable differences caused by environmental differences and real configuration file errors, resulting in a large amount of manual participation and inefficiency.
By comparing the target configuration file of the target environment with the baseline configuration file of the baseline environment, obtain the configuration items for the difference, and verify these configuration items based on the generated target comparison template to determine whether they are allowed to have differences.
The configuration files can be inspected without manual participation, which improves detection efficiency, reduces manual errors, and enhances the automation and accuracy of the detection process.
Smart Images

Figure CN119806998A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of computer technology, and in particular, relates to a configuration file detection method, device, electronic device and storage medium. Background Art
[0002] In large-scale distributed systems, the Nacos configuration file is the core part of the Nacos server configuration, which is used to customize various behaviors and features of Nacos. In general, the Nacos configuration file is checked for abnormalities by comparing the contents in the Nacos configuration file item by item.
[0003] However, there are certain differences in Nacos configuration files in different environments (such as development, test, and production environments). In the process of detecting whether there are anomalies in the Nacos configuration files, the method of comparing the contents of the Nacos configuration files item by item cannot intelligently determine whether the compared anomalies are merely allowable differences due to different environments or real configuration file error information. At this time, human participation is required to distinguish, which makes the Nacos configuration file anomaly detection process consume a lot of manpower and the detection process is inefficient. Summary of the invention
[0004] The present application aims to solve at least one of the technical problems existing in the prior art. To this end, the present application proposes a configuration file detection method, device, electronic device and storage medium to reduce manual participation in the configuration file anomaly detection process and improve detection efficiency.
[0005] In a first aspect, the present application provides a configuration file detection method, the method comprising:
[0006] Compare the target configuration file of the target environment with the benchmark configuration file of the benchmark environment to obtain the first target configuration item that differs between the target configuration file and the benchmark configuration file; both the target configuration file and the benchmark configuration file are configuration files of the target distributed system based on Nacos; the configuration items in the benchmark configuration file are all correct;
[0007] The first target configuration item is checked based on the target comparison template to obtain the detection result of the target configuration file; the target comparison template is generated based on the reference configuration file; the target comparison template is used to indicate the information of the second target configuration item that allows the target configuration file to differ from the reference configuration file.
[0008] According to the configuration file detection method of the present application, the target configuration file of the target environment is compared with the benchmark configuration file of the benchmark environment to obtain the first target configuration item that is different from the target configuration file and the benchmark configuration file, and the first target configuration item is checked based on the target comparison template for indicating the information of the second target configuration item that is allowed to be different from the target configuration file and the benchmark configuration file. The detection result of the target configuration file is obtained in a way to check whether the first target configuration item that is different from the target configuration file and the benchmark configuration file is a configuration item that is allowed to be different, so as to check the target configuration file, so that the process of checking the target configuration file does not require human participation, thereby improving the detection efficiency.
[0009] According to an embodiment of the present application, the first target configuration item is checked based on the target comparison template to obtain the detection result of the target configuration file, including:
[0010] Based on the target comparison template, checking whether each first target configuration item is a second target configuration item;
[0011] In the case where each first target configuration item is also a second target configuration item, the detection result is determined as the target configuration file meeting the requirement.
[0012] According to an embodiment of the present application, after verifying whether each first target configuration item is a second target configuration item based on the standard comparison template, the method further includes:
[0013] In a case where at least one first target configuration item is not the second target configuration item, the detection result is determined as the target configuration file not meeting the requirement.
[0014] According to an embodiment of the present application, before testing the first target configuration item based on the target comparison template and obtaining the test result of the target configuration file, the method further includes:
[0015] Get target input for a second target configuration item in the benchmark configuration file;
[0016] Based on the target input, a target comparison template is obtained.
[0017] According to one embodiment of the present application, before obtaining the target input for the second target configuration item in the benchmark configuration file, the method further includes:
[0018] In the case where a target comparison template already exists, based on the target comparison template, a benchmark configuration file is loaded and a second target configuration item in the benchmark configuration file is highlighted;
[0019] Based on the target input, obtain the target comparison template, including:
[0020] Based on the target input, update the target comparison template.
[0021] According to one embodiment of the present application, before obtaining the target input for the second target configuration item in the benchmark configuration file, the method further includes:
[0022] In the absence of a target alignment template, load the benchmark configuration file.
[0023] According to an embodiment of the present application, comparing a target configuration file of a target environment with a reference configuration file of a reference environment to obtain a first target configuration item having a difference between the target configuration and the reference configuration file includes:
[0024] For each first configuration item in the reference configuration file, based on the path and name of the configuration item, determining whether there is a second configuration item corresponding to the first configuration item in the target configuration file;
[0025] When there is no second configuration item corresponding to the first configuration item in the target configuration file, the first configuration item is determined as the first target configuration item.
[0026] According to an embodiment of the present application, after determining whether a second configuration item corresponding to the first configuration item exists in the target configuration file based on the path of the configuration item, the method further includes:
[0027] When there is a second configuration item corresponding to the first configuration item in the target configuration file, comparing whether the first configuration item is the same as the second configuration item;
[0028] When the first configuration item is different from the second configuration item, the first configuration item is determined as the first target configuration item.
[0029] According to an embodiment of the present application, for each second target configuration item, the information of the second target configuration item includes: a path, a name, and a type of the second target configuration item.
[0030] According to an embodiment of the present application, when the type of the second target configuration item is a value type, the information of the second target configuration item further includes: an allowed value of the second target configuration item.
[0031] According to an embodiment of the present application, based on the target comparison template, checking whether each first target configuration item is a second target configuration item includes:
[0032] For any first target configuration item whose value is determined by a variable expression, check whether the variable expression in the first target configuration item matches the allowed value of the first configuration item corresponding to the first second configuration item;
[0033] If the two match, the first target configuration item is the second target configuration item; if the two do not match, the first target configuration item is not the second target configuration item.
[0034] According to an embodiment of the present application, checking whether a variable expression in the first target configuration item matches an allowed value of the first configuration item corresponding to the second configuration item includes:
[0035] When the allowed value includes only the fixed part of the variable expression, and the fixed part of the variable expression in the first target configuration item is the same as the fixed part of the variable expression in the allowed value, it is determined that the variable expression in the first target configuration item matches the allowed value.
[0036] According to an embodiment of the present application, when at least one first target configuration item is not a second target configuration item, after determining the detection result as the target configuration file not meeting the requirement, the method further includes:
[0037] Based on the target configuration file, a third target configuration item is highlighted; the third target configuration item is the first target configuration item that is not the second target configuration item.
[0038] According to an embodiment of the present application, when each first target configuration item is a second target configuration item, after determining the detection result as the target configuration file meeting the requirement, the method further includes:
[0039] In the case where the target configuration file is manually modified after being detected as not meeting the requirements, the configuration of the target environment of the target distributed system is updated based on the target configuration file.
[0040] In a second aspect, the present application provides a configuration file detection device, the device comprising:
[0041] A comparison module is used to compare the target configuration file of the target environment with the benchmark configuration file of the benchmark environment to obtain the first target configuration item that is different between the target configuration file and the benchmark configuration file; both the target configuration file and the benchmark configuration file are configuration files of the target distributed system based on Nacos; and the configuration items in the benchmark configuration file are correct;
[0042] The inspection module is used to inspect the first target configuration item based on the target comparison template to obtain the detection result of the target configuration file; the target comparison template is generated based on the reference configuration file; the target comparison template is used to indicate the information of the second target configuration item that allows the target configuration file to differ from the reference configuration file.
[0043] According to the configuration file detection device of the present application, by comparing the target configuration file of the target environment with the benchmark configuration file of the benchmark environment, a first target configuration item that is different from the target configuration file and the benchmark configuration file is obtained, and based on a target comparison template for indicating information of a second target configuration item that is allowed to be different from the target configuration file and the benchmark configuration file, the first target configuration item is checked to obtain a detection result of the target configuration file, and whether the first target configuration item that is different from the target configuration file and the benchmark configuration file is a configuration item that is allowed to be different is checked, so as to check the target configuration file, so that the process of checking the target configuration file does not require human participation, thereby improving the detection efficiency.
[0044] In a third aspect, the present application provides an electronic 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 detecting a configuration file as described in the first aspect above is implemented.
[0045] In a fourth aspect, the present application provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the configuration file detection method as described in the first aspect above is implemented.
[0046] In a fifth aspect, the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the configuration file detection method as described in the first aspect above.
[0047] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:
[0049] Figure 1 This is one of the flow charts of the configuration file detection method provided in the embodiment of the present application;
[0050] Figure 2 This is the second flow chart of the configuration file detection method provided in the embodiment of the present application;
[0051] Figure 3 It is a schematic diagram of a process for obtaining a target comparison template provided in an embodiment of the present application;
[0052] Figure 4 is a schematic diagram of the structure of a configuration file detection device provided in an embodiment of the present application;
[0053] Figure 5 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0054] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.
[0055] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0056] The following describes in detail the configuration file detection method, configuration file detection device, electronic device and readable storage medium provided in the embodiments of the present application through specific embodiments and application scenarios in conjunction with the accompanying drawings.
[0057] The configuration file detection method may be applied to a terminal, and may be specifically executed by hardware or software in the terminal.
[0058] The terminal includes, but is not limited to, a portable communication device such as a mobile phone or tablet computer with a touch-sensitive surface (e.g., a touch screen display and / or a touch pad). It should also be understood that in some embodiments, the terminal may not be a portable communication device, but a desktop computer with a touch-sensitive surface (e.g., a touch screen display and / or a touch pad).
[0059] In the following various embodiments, a terminal including a display and a touch-sensitive surface is described. However, it should be understood that the terminal may include one or more other physical user interface devices such as a physical keyboard, a mouse and a joystick.
[0060] The configuration file detection method provided in the embodiment of the present application may be executed by an electronic device or a functional module or functional entity in the electronic device that can implement the configuration file detection method. The electronic devices mentioned in the embodiment of the present application include but are not limited to mobile phones, tablet computers, computers, cameras, and wearable devices. The configuration file detection method provided in the embodiment of the present application is described below by taking the electronic device as an example of the execution subject.
[0061] In the related art, there are certain differences in Nacos configuration files in different environments (such as development, testing, and production environments). Usually, in the process of detecting whether there is an anomaly in the Nacos configuration file, the content in the Nacos configuration file is compared item by item. It is impossible to intelligently determine whether the compared differences are allowable differences due to different environments or configuration file error information. At this time, human participation is required to distinguish the compared differences, which makes the Nacos configuration file anomaly detection process consume a lot of manpower and the detection process is inefficient.
[0062] like Figure 1 As shown, the configuration file detection method includes: step 110 and step 120.
[0063] Step 110: Compare the target configuration file of the target environment with the benchmark configuration file of the benchmark environment to obtain the first target configuration item that differs between the target configuration and the benchmark configuration file; both the target configuration file and the benchmark configuration file are configuration files of the target distributed system based on Nacos; and the configuration items in the benchmark configuration file are correct.
[0064] In actual execution, the target environment can be a development environment, a test environment, a production environment, or any other theoretically existing environment, and the target configuration file can be a configuration file running in the target environment. The benchmark environment can be a development environment, a test environment, a production environment, or any other theoretically existing environment, and the benchmark configuration file can be a configuration file running in the benchmark environment. The benchmark configuration file can be a configuration file of the same type as the target configuration file, for example, the benchmark configuration file and the target configuration file are both Nacos configuration files. The target configuration file and the benchmark configuration file can be files of the same format, for example, the target configuration file and the benchmark configuration file are both json format files. The target configuration file and the benchmark configuration file can be files with the same name. The configuration items in the benchmark configuration file are all configuration items that are detected without abnormalities, so that the configuration items in the target configuration file can be compared with the configuration items in the benchmark configuration file.
[0065] In some embodiments, based on each first configuration item in the baseline configuration file, it can be determined whether there is a configuration item in the target configuration file corresponding to the first configuration item. If there is no configuration item corresponding to the first configuration item in the target configuration file, the first configuration item is determined as the first target configuration item that differs between the target configuration and the baseline configuration file.
[0066] In some embodiments, based on each first configuration item in the baseline configuration file, if there is a configuration item corresponding to the first configuration item in the target configuration file, it can be determined whether the configuration item is the same as the first configuration item; if the configuration item is not the same as the first configuration item, the first configuration item is determined as the first target configuration item that differs between the target configuration file and the baseline configuration file.
[0067] Step 120: Check the first target configuration item based on the target comparison template to obtain the detection result of the target configuration file; the target comparison template is generated based on the reference configuration file; the target comparison template is used to indicate information of the second target configuration item that allows differences between the target configuration file and the reference configuration file.
[0068] In actual execution, the target comparison template may include information of the second target configuration item, which may be a configuration item that allows differences between the target configuration file and the reference configuration file. The information of the second target configuration item may include at least one of the path, name and type of the second target configuration item.
[0069] In some embodiments, based on a target comparison template, a first target configuration item in which a target configuration file differs from a reference configuration file can be compared with a second target configuration item in which a difference between the target configuration file and the reference configuration file is allowed, and a detection result of the target configuration file is determined based on the comparison result.
[0070] In some embodiments, before verifying the first target configuration item based on the target comparison template, an input for the benchmark configuration file may be obtained to obtain the target comparison template.
[0071] According to the configuration file detection method of the present application, the target configuration file of the target environment is compared with the benchmark configuration file of the benchmark environment to obtain the first target configuration item that is different from the target configuration file and the benchmark configuration file, and the first target configuration item is checked based on the target comparison template for indicating the information of the second target configuration item that is allowed to be different from the target configuration file and the benchmark configuration file. The detection result of the target configuration file is obtained in a way to check whether the first target configuration item that is different from the target configuration file and the benchmark configuration file is a configuration item that is allowed to be different, so as to check the target configuration file, so that the process of checking the target configuration file does not require human participation, thereby improving the detection efficiency.
[0072] In some embodiments, based on the target comparison template, it can be checked whether each first target configuration item is the second target configuration item; when each first target configuration item is the second target configuration item, the detection result is determined as the target configuration file meets the requirements.
[0073] In actual execution, the target comparison template may include information about the second target configuration item. Based on the information about the second target configuration item in the target comparison template, it may be checked whether each first target configuration item is the second target configuration item.
[0074] In some embodiments, the information of the second target configuration item in the target comparison template may include the path, name and type of the second target configuration item. The path, name and type of the second target configuration item may be compared with the path, name and type of the first target configuration item. If the path, name and type of the first target configuration item are consistent with the path, name and type of the first target configuration item of the second target configuration item, the first target configuration item is determined to be the second target configuration item, thereby verifying each first target configuration item.
[0075] In some embodiments, both the first target configuration item and the second target configuration item may include a variable expression and a value determined by the variable expression. In the case where the second target configuration item includes a variable expression and a value determined by the variable expression, the value determined by the variable expression included in the second target configuration item may be an allowed value. For the first target configuration item including a variable expression and a value determined by the variable expression, it can be determined whether the variable expression in the first target configuration item matches the value determined by the variable expression in the second target configuration item. If they match, the first target configuration item is determined to be the second target configuration item, thereby checking each first target configuration item.
[0076] According to the configuration file detection method of the present application, by comparing the target configuration file of the target environment with the benchmark configuration file of the benchmark environment, the first target configuration item that is different from the target configuration file and the benchmark configuration file is obtained, and based on the target comparison template, each first target configuration item is checked whether it is the second target configuration item; in the case that each first target configuration item is the second target configuration item, the detection result is determined as a way for the target configuration file to meet the requirements, and it is checked whether the first target configuration item that is different from the target configuration file and the benchmark configuration file is a configuration item that allows the difference, so as to check the target configuration file, so that the process of checking the target configuration file does not require human participation, thereby improving the detection efficiency.
[0077] In some embodiments, it may be checked whether each first target configuration item is the second target configuration item, and when at least one first target configuration item is not the second target configuration item, the detection result is determined as the target configuration file does not meet the requirement.
[0078] In some embodiments, the information of the second target configuration item in the target comparison template may include the path, name and type of the second target configuration item. The path, name and type of the second target configuration item may be compared with the path, name and type of the first target configuration item. If the path, name and type of the first target configuration item is inconsistent with at least one of the path, name and type of the first target configuration item of the second target configuration item, it is determined that the first target configuration item is not the second target configuration item, thereby checking each first target configuration item.
[0079] In some embodiments, both the first target configuration item and the second target configuration item may include a variable expression and a value determined by the variable expression. In the case where the second target configuration item includes a variable expression and a value determined by the variable expression, the value determined by the variable expression included in the second target configuration item may be an allowed value. For the first target configuration item including a variable expression and a value determined by the variable expression, it may be determined whether the variable expression in the first target configuration item matches the value determined by the variable expression in the second target configuration item. In the case of mismatch, the first target configuration item is determined to be the second target configuration item, thereby checking each first target configuration item.
[0080] In actual execution, it is checked whether each first target configuration item is the second target configuration item. If at least one first target configuration item is not the second target configuration item, the detection result is determined as the target configuration file does not meet the requirements. For example, it is checked whether each of ten first target configuration items is the second target configuration item. If three of the ten first target configuration items are not the second target configuration items, it is determined as the target configuration file does not meet the requirements.
[0081] In some embodiments, when at least one first target configuration item is not a second target configuration item, the first target configuration items in the target configuration file that are not the second target configuration items are marked to facilitate subsequent correction of the marked first target configuration items.
[0082] According to the configuration file detection method of the present application, by comparing the target configuration file of the target environment with the benchmark configuration file of the benchmark environment, the first target configuration item that is different from the target configuration file and the benchmark configuration file is obtained, and based on the target comparison template, each first target configuration item is checked whether it is the second target configuration item; when at least one first target configuration item is not the second target configuration item, the detection result is determined as a method in which the target configuration file does not meet the requirements, and it is checked whether the first target configuration item that is different from the target configuration file and the benchmark configuration file is a configuration item that allows the difference, so as to check the target configuration file, so that the process of checking the target configuration file does not require human participation, thereby improving the detection efficiency.
[0083] In some embodiments, before checking the first target configuration item based on the target comparison template and obtaining the detection result of the target configuration file, a target input for the second target configuration item in the reference configuration file can be obtained; based on the target input, the target comparison template is obtained.
[0084] In some embodiments, it can be determined whether there is a target comparison template. If there is a target comparison template, the second target configuration item can be obtained from the benchmark configuration file based on the existing target comparison template, or the target comparison template can be updated based on the target input. If there is no target comparison template, the benchmark configuration file can be loaded, the target input for the benchmark configuration file can be obtained, and the target comparison template can be obtained based on the target input.
[0085] In actual execution, the target input for the second target configuration item in the benchmark configuration file may be that the user marks the first configuration item in the benchmark configuration file, determines the marked first configuration item as the second target configuration item, and generates a target comparison template based on the second target configuration item in the benchmark configuration file.
[0086] According to the configuration file detection method of the present application, a first target configuration item that is different from a target configuration file and a benchmark configuration file is obtained, a target input for a second target configuration item in the benchmark configuration file is obtained, a target comparison template is obtained based on the target input, and based on the target comparison template, each first target configuration item is checked to see if it is the second target configuration item, and whether the first target configuration item that is different from the target configuration file and the benchmark configuration file is a configuration item that is allowed to have a difference, thereby checking the target configuration file, so that the process of checking the target configuration file does not require human participation, thereby improving the detection efficiency.
[0087] In some embodiments, when a target comparison template already exists, the benchmark configuration file can be loaded based on the target comparison template and the second target configuration item in the benchmark configuration file can be highlighted, and the target comparison template can be updated based on the target input.
[0088] In actual execution, it can be determined whether a target comparison template exists. If a target comparison template corresponding to the target configuration file already exists, the benchmark configuration file can be loaded based on the target comparison template, and the second target configuration item in the benchmark configuration file can be highlighted based on the information of the second target configuration item in the target comparison template.
[0089] In some embodiments, based on the target comparison template, a benchmark configuration file can be loaded and a second target configuration item in the benchmark configuration file can be highlighted. If the second target configuration item highlighted in the benchmark configuration file does not meet the target requirement, for example, the second target configuration item highlighted in the benchmark configuration file is incomplete, the target input can be obtained and the target comparison template can be updated based on the target input.
[0090] In some embodiments, when the second target configuration item highlighted in the baseline configuration file does not meet the target requirements, a target input for the baseline configuration file can be obtained. The target input can be annotated on the first configuration item in the baseline configuration file, and the first configuration item annotated in the target input is further determined as an updated second target configuration item, and the information of the updated second target configuration item is supplemented to the target comparison template to update the target comparison template.
[0091] According to the configuration file detection method of the present application, a first target configuration item that is different between the target configuration file and the benchmark configuration file is obtained. If a target comparison template already exists, the benchmark configuration file can be loaded based on the target comparison template and the second target configuration item in the benchmark configuration file can be highlighted. Based on the target input, the target comparison template is updated. Based on the target comparison template, it is checked whether each first target configuration item is the second target configuration item. The target comparison template is saved and updated, so that repeated comparisons after configuration items are changed are simpler and can be continuously optimized.
[0092] In some embodiments, a baseline configuration file may be loaded in the absence of a target alignment template.
[0093] In actual execution, in the absence of a target comparison template, a benchmark configuration file corresponding to the target configuration file can be loaded, and a target input for the benchmark configuration file can be obtained. The target input can be annotating a first configuration item in the benchmark configuration file, determining the first configuration item annotated in the target input as a second target configuration item, and generating a target comparison template based on information of the second target configuration item.
[0094] In some embodiments, the first configuration item in the benchmark configuration file may include a configuration item name, a configuration value, and a configuration item hierarchy type, and the configuration item type may include a top-level configuration item, a middle-level configuration item, and a bottom-level configuration item. A configuration item path may be generated based on the configuration item hierarchy type. In the case where the configuration item is a top-level configuration item, the path of the configuration item includes the name of the configuration item; in the case where the configuration item is a middle-level configuration item, the path of the configuration item includes the name of the top-level configuration item to which the configuration item belongs and the name of the configuration item; in the case where the configuration item is a bottom-level configuration item, the path of the configuration item includes the name of the top-level configuration item to which the configuration item belongs, the name of the middle-level configuration item, and the name of the configuration item.
[0095] According to the configuration file detection method of the present application, a first target configuration item that is different from a target configuration file and a reference configuration file is obtained. In the absence of a target comparison template, the reference configuration file can be loaded to generate a target comparison template. Based on the target comparison template, each first target configuration item is checked to see if it is the second target configuration item. The first target configuration item that is different from the target configuration file and the reference configuration file is a configuration item that is allowed to be different. In this way, the target configuration file is checked, so that the process of checking the target configuration file does not require human participation, thereby improving the detection efficiency.
[0096] In some embodiments, for each first configuration item in the baseline configuration file, based on the path and name of the configuration item, it can be determined whether there is a second configuration item corresponding to the first configuration item in the target configuration file; if there is no second configuration item corresponding to the first configuration item in the target configuration file, the first configuration item is determined as the first target configuration item.
[0097] In actual execution, the path of the configuration item may be a unique identifier of the configuration item found in the configuration file, the configuration item may be a first configuration item or a second configuration item, and the configuration file may be a target configuration file or a baseline configuration file.
[0098] In some embodiments, for each first configuration item in the reference configuration file, all second configuration items in the target configuration file can be traversed based on the name and path of the first configuration item. If there is a second configuration item in the target configuration file that has the same name and path as the first configuration item, it is determined that there is a second configuration item corresponding to the first configuration item in the target configuration file. On the contrary, if all second configuration items in the target configuration file have different names and paths from the first configuration item, it is determined that there is no second configuration item corresponding to the first configuration item in the target configuration file, and the first configuration item is determined as the first target configuration item.
[0099] According to the configuration file detection method of the present application, for each first configuration item in the benchmark configuration file, based on the path and name of the configuration item, it is determined whether there is a second configuration item corresponding to the first configuration item in the target configuration file; when there is no second configuration item corresponding to the first configuration item in the target configuration file, the first configuration item is determined as the first target configuration item, and the first target configuration item that is different from the target configuration file and the benchmark configuration file is obtained, and based on the target comparison template, each first target configuration item is checked whether it is the second target configuration item, and whether the first target configuration item that is different from the target configuration file and the benchmark configuration file is a configuration item that allows the difference to exist, so as to check the target configuration file, so that the process of checking the target configuration file does not require human participation, thereby improving the detection efficiency.
[0100] In some embodiments, when there is a second configuration item corresponding to the first configuration item in the target configuration file, the first configuration item is compared to see if it is the same as the second configuration item; when the first configuration item is different from the second configuration item, the first configuration item is determined as the first target configuration item.
[0101] In actual execution, when there is a second configuration item corresponding to the first configuration item in the target configuration file, the name, path, expression, configuration value and other information of the first configuration item and the second configuration item can be compared to see whether they are the same. When at least one of the above information is different, the first configuration item is determined to be the first target configuration item; when the above information is the same, it is determined that there is no configuration item in the target configuration file that is different from the first configuration item in the baseline configuration file.
[0102] According to the configuration file detection method of the present application, for each first configuration item in the benchmark configuration file, based on the path and name of the configuration item, it is determined whether there is a second configuration item corresponding to the first configuration item in the target configuration file; when there is a second configuration item corresponding to the first configuration item in the target configuration file, the first configuration item is compared to see whether it is the same as the second configuration item; when the first configuration item is different from the second configuration item, the first configuration item is determined as the first target configuration item, the first target configuration item that is different between the target configuration file and the benchmark configuration file is obtained, and based on the target comparison template, each first target configuration item is checked to see whether it is the second target configuration item, and the first target configuration item that is different between the target configuration file and the benchmark configuration file is a configuration item that allows the difference to exist, so as to check the target configuration file, so that the process of checking the target configuration file does not require manual participation, thereby improving the detection efficiency.
[0103] In some embodiments, for each second target configuration item in the benchmark configuration file, the information of the second target configuration item includes: a path, a name, and a type of the second target configuration item.
[0104] In actual execution, the information of each second target configuration item in the benchmark configuration file can be stored in the target comparison template corresponding to the benchmark configuration file. The path of the second target configuration item can be a unique identifier for finding the second target configuration item in the benchmark configuration file. The type of the second target configuration item includes a class that allows non-existence, such as the name type, and a class that must exist and be the same, such as the value type.
[0105] According to the configuration file detection method of the present application, for each second target configuration item in the baseline configuration file, the information of the second target configuration item includes the path, name and type of the second target configuration item. The type may include a class that is allowed to not exist and a class that must exist and is the same. The flexible design that allows the configuration item to not exist in the target environment can adapt to different environmental configuration requirements and enhance fault tolerance.
[0106] In some embodiments, when the type of the second target configuration item is a value type, the information of the second target configuration item may further include: an allowed value of the second target configuration item.
[0107] In some embodiments, for any first target configuration item whose value is determined by a variable expression, it is checked whether the variable expression in the first target configuration item matches the allowed value of the first configuration item corresponding to the second configuration item; if the two match, the first target configuration item is the second target configuration item; if the two do not match, the first target configuration item is not the second target configuration item.
[0108] In actual execution, any configuration item may include a variable expression and a value determined by the variable expression, and the value determined by the variable expression included in the first configuration item is the allowed value of the first configuration item. For each first target configuration item whose value is determined by the variable expression, it can be checked whether the variable expression in the first target configuration item (i.e., the second configuration item) matches the allowed value of the first configuration item corresponding to the second configuration item.
[0109] In some embodiments, based on field comparison, the variable expression in the first target configuration item can be compared with the allowed value of the first configuration item to verify whether the variable expression in the first target configuration item (i.e., the second configuration item) matches the allowed value of the first configuration item corresponding to the second configuration item.
[0110] In some embodiments, the allowable value of the first configuration item can be a target numerical range, which can be calculated based on the variable expression in the first target configuration item. When the calculation result falls within the target numerical range, it is determined that the variable expression in the first target configuration item matches the allowable value of the first configuration item corresponding to the second configuration item; when the calculation result does not fall within the target numerical range, it is determined that the variable expression in the first target configuration item does not match the allowable value of the first configuration item corresponding to the second configuration item.
[0111] According to the configuration file detection method of the present application, by comparing the target configuration file of the target environment with the benchmark configuration file of the benchmark environment, the first target configuration item in which there is a difference between the target configuration file and the benchmark configuration file is obtained, and based on the target comparison template, for any first target configuration item whose value is determined by the variable expression, it is checked whether the variable expression in the first target configuration item matches the allowed value of the first configuration item corresponding to the second configuration item; when the two match, the first target configuration item is the second target configuration item; when the two do not match, the first target configuration item is not the second target configuration item; when each first target configuration item is the second target configuration item, the detection result is determined as a way for the target configuration file to meet the requirements, and by introducing the parsing and verification functions of the variable expression in the comparison process, the configuration flexibility is ensured, and it is more suitable for complex and changeable application scenarios.
[0112] In some embodiments, for any first target configuration item whose value is determined by a variable expression, in the process of checking whether the variable expression in the first target configuration item matches the allowed value of the first configuration item corresponding to the second configuration item, it can be determined that the variable expression in the first target configuration item matches the allowed value when the allowed value only includes a fixed part of the variable expression and the fixed part of the variable expression in the first target configuration item is the same as the fixed part of the variable expression in the allowed value.
[0113] In actual execution, the fixed part of the variable expression included in the allowed value of the first configuration item can be obtained based on the target input of the user for the first configuration item.
[0114] In some embodiments, a search may be performed in the variable expression of the first target configuration item based on the fixed part of the variable expression included in the allowed value, and when a field of the fixed part of the variable expression included in the allowed value is found in the variable expression of the first target configuration item, it is determined that the variable expression in the first target configuration item matches the allowed value. When the variable expression of the first target configuration item is traversed and no field of the fixed part of the variable expression included in the allowed value is found, it is determined that the variable expression in the first target configuration item does not match the allowed value.
[0115] According to the configuration file detection method of the present application, by comparing the target configuration file of the target environment with the benchmark configuration file of the benchmark environment, the first target configuration item in which there is a difference between the target configuration file and the benchmark configuration file is obtained, and based on the target comparison template, for any first target configuration item whose value is determined by the variable expression, it is checked whether the variable expression in the first target configuration item matches the allowed value of the first configuration item corresponding to the second configuration item; when the two match, the first target configuration item is the second target configuration item; when the two do not match, the first target configuration item is not the second target configuration item; when each first target configuration item is the second target configuration item, the detection result is determined as a way for the target configuration file to meet the requirements, and by introducing the parsing and verification functions of the variable expression in the comparison process, the configuration flexibility is ensured, and it is more suitable for complex and changeable application scenarios.
[0116] In some embodiments, when at least one first target configuration item is not the second target configuration item, after the detection result is determined as the target configuration file not meeting the requirements, a third target configuration item can be highlighted based on the target configuration file; the third target configuration item is the first target configuration item that is not the second target configuration item.
[0117] In actual execution, the third configuration item may be a configuration item that is not allowed to have a difference among the first target configuration items that differ from the reference configuration file in the target configuration file.
[0118] In some embodiments, the third target configuration item may be annotated in the target configuration file, or the third target configuration item may be highlighted, underlined, or any theoretically feasible annotation method may be used to facilitate subsequent acquisition of modifications to the third target configuration item.
[0119] In some embodiments, a missing third target configuration item may be added to the target configuration file, the third target configuration item may be highlighted, and a configuration value input by a user for the third target configuration item may be obtained to complete the modification of the target configuration file.
[0120] In some embodiments, after obtaining the user's modification to the third target configuration item, the modified target configuration file can be compared with the baseline configuration file of the baseline environment to obtain a first target configuration item in which there is a difference between the target configuration file and the baseline configuration file. Based on a target comparison template for indicating information of a second target configuration item that allows a difference between the target configuration file and the baseline configuration file, the first target configuration item is checked to obtain a detection result of the target configuration file.
[0121] According to the configuration file detection method of the present application, after the detection result is determined as the target configuration file not meeting the requirements, the third target configuration item can be highlighted based on the target configuration file, making it easy to supplement and correct the missing or incorrect configuration items through automated means, greatly improving the stability and maintainability of the system.
[0122] In some embodiments, when each first target configuration item is a second target configuration item, after the detection result is determined as the target configuration file meets the requirements, the configuration of the target environment of the target distributed system can be updated based on the target configuration file if the target configuration file has been manually modified after being detected as not meeting the requirements.
[0123] In actual execution, the target configuration file can be applied to all Nacos-based distributed systems, especially scenarios involving multi-environment configuration management and complex configuration file comparison, such as large-scale microservice architecture, DevOps operation and maintenance management, cloud computing platform configuration management, etc.
[0124] According to the configuration file detection method of the present application, the configuration of the target distributed system target environment is updated based on the target configuration file that was once detected as not meeting the requirements and then manually modified, so as to reduce configuration errors caused by manual configuration of the target distributed system target environment.
[0125] In order to better understand the configuration file detection method provided in the embodiment of the present application, further explanation is given below. It should be understood that the following discussion is only exemplary.
[0126] This application provides a configuration file detection method, the specific steps can be as follows Figure 2 As shown:
[0127] Step 1: Obtain a target configuration file from a target configuration file list under a target environment, and obtain a baseline configuration file from a baseline configuration file list under a baseline environment.
[0128] In actual execution, the target configuration file list can be traversed to obtain the undetected target configuration file from the target configuration file list, and based on the target configuration file, the benchmark configuration file list can be traversed to find the benchmark configuration file corresponding to the target configuration file in the benchmark configuration file list.
[0129] In actual execution, both the target configuration file and the benchmark configuration file can be in json format. Both the target configuration file and the benchmark configuration file can include top-level configuration items, middle-level configuration items, bottom-level configuration items, and configuration values of bottom-level configuration items. For example, the content of the target configuration file can be as follows:
[0130]
[0131]
[0132] Among them, sinen is the top-level configuration item, aipv and scheduling are middle-level configuration items, algorithm is the bottom-level configuration item, and operations_optimization is the configuration value of algorithm.
[0133] In some embodiments, all configuration items in the target configuration file and the reference configuration file may include a path, and the path may be a unique identifier for finding the configuration item in the configuration file where the configuration item is located. One configuration item has and only corresponds to one path. The path of the configuration item may be generated based on the hierarchical attributes of the configuration item in the configuration file.
[0134] In some embodiments, a path can be generated for each configuration item layer by layer based on the hierarchical order of top-level configuration items, middle-level configuration items, and bottom-level configuration items in the configuration file, and the configuration file can be a target configuration file and a benchmark configuration file. For example, in the above-mentioned target configuration file, you can start from the top-level top-level configuration item sigen, and generate the paths of the middle-level configuration items and the bottom-level configuration items layer by layer, connecting each layer with a dot ".". For each middle-level configuration item and bottom-level configuration item, a new path will be created, containing all configuration items from the top layer to the current layer, and this process will continue until the bottom-level configuration item is reached. For bottom-level configuration items such as "algorithm" and "pv-model-name", a complete path can be generated. For configuration items that contain variables or default values (such as ${MYSQL_USER:sigen_starrocks}), we only use the key name ("sername" in this example), not the value part. The path to generate each configuration item in the configuration file can be as follows:
[0135] sigen
[0136] sigen.aipv
[0137] sigen.aipv.scheduling
[0138] sigen.aipv.scheduling.algorithm
[0139] sigen.aipv.scheduling.pv-model-name
[0140] sigen.aipv.scheduling.load-model-name
[0141] sigen.aipv.scheduling.strategy-granularity-minute
[0142] sigen.aipv.scheduling.sername
[0143] Step 2: Compare the target configuration file of the target environment with the benchmark configuration file of the benchmark environment to obtain a first target configuration item having a difference between the target configuration and the benchmark configuration file.
[0144] In some embodiments, for each first configuration item in the baseline configuration file, based on the path and name of the configuration item, it can be determined whether there is a second configuration item corresponding to the first configuration item in the target configuration file; if there is no second configuration item corresponding to the first configuration item in the target configuration file, the first configuration item is determined as the first target configuration item.
[0145] In some embodiments, for each first configuration item in the reference configuration file, all second configuration items in the target configuration file can be traversed based on the name and path of the first configuration item. If there is a second configuration item in the target configuration file that has the same name and path as the first configuration item, it is determined that there is a second configuration item corresponding to the first configuration item in the target configuration file. On the contrary, if all second configuration items in the target configuration file have different names and paths from the first configuration item, it is determined that there is no second configuration item corresponding to the first configuration item in the target configuration file, and the first configuration item is determined as the first target configuration item.
[0146] In some embodiments, when there is a second configuration item corresponding to the first configuration item in the target configuration file, the first configuration item is compared to see if it is the same as the second configuration item; when the first configuration item is different from the second configuration item, the first configuration item is determined as the first target configuration item.
[0147] In actual execution, when there is a second configuration item corresponding to the first configuration item in the target configuration file, the name, path, expression, configuration value and other information of the first configuration item and the second configuration item can be compared to see whether they are the same. When at least one of the above information is different, the first configuration item is determined to be the first target configuration item; when the above information is the same, it is determined that there is no configuration item in the target configuration file that is different from the first configuration item in the baseline configuration file.
[0148] Step 3: Obtain the target comparison template corresponding to the benchmark configuration file.
[0149] In actual execution, the target comparison template may include information about the second target configuration item in the benchmark configuration file, and the information about the second target configuration item includes the name, type, and path of the second target configuration item.
[0150] In some embodiments, Figure 3 As shown, a benchmark configuration file under a benchmark environment can be loaded to determine whether there is a target comparison template corresponding to the benchmark configuration file. If there is a target comparison template corresponding to the benchmark configuration file, the target comparison template is loaded, and the second target configuration item in the benchmark configuration file is highlighted based on the target comparison template. It is determined whether the highlighted second target configuration item meets the target requirements. If it does not meet the target requirements, the target input is obtained, and the highlighted second target configuration item is updated. The target input is a manual highlighting of the second target configuration item by the user, such as highlighting, bolding or underlining. If there is no target comparison template corresponding to the benchmark configuration file, the target input is obtained. A target comparison template is generated based on the highlighted portion and the remaining portion in the benchmark configuration file.
[0151] In some embodiments, each line in the target comparison template file can describe the inspection rules of a first target configuration item, including the type of the first target configuration item (name or value), the path of the first target configuration item (config_item), and the allowed value or wildcard (config_value). When the configuration item type is name, only the configuration item name of the first target configuration item is checked. The configuration item or the next level configuration item of the configuration item may not exist in the target configuration file and will not be considered an error. When the configuration item type is value, not only the configuration item name must be checked, but also its specific configuration value must be checked to see if it meets the requirements. The configuration item must exist in the target file, and its value must meet the specified requirements. In the case where the inspection rule of a first target configuration item includes a wildcard, the wildcard can indicate that any value is allowed for the first target configuration item, indicating that the first target configuration item can have different configuration values according to different environments or requirements. Wildcards can be represented by any symbol, such as *, %, etc. For expressions like ${MYSQL_USER:*}, the variable part representing the configuration value is allowed to be different, but the variable itself (such as ${MYSQL_USER}) is fixed.
[0152] In some embodiments, the name type rule in the target comparison template can be generated based on the first configuration item highlighted in the benchmark configuration file, and the value type rule in the target comparison template can be generated based on the first configuration item not highlighted in the benchmark configuration file. For example, in the benchmark configuration file as shown above, the highlighted second target configuration items are sigen, aipv, algorithm, select_best_7, sigen_starrocks, and the generated target comparison template content is as follows:
[0153] config_type,config_item,config_value
[0154] name,sigen,*
[0155] name,sigen.aipv,*
[0156] name,sigen.aipv.scheduling.algorithm,*
[0157] value,sigen.aipv.scheduling.pv-model-name,select_best_7
[0158] value,sigen.aipv.scheduling.strategy-granularity-minute,30
[0159] Among them, name,sigen,*: means that the sigen configuration item and all middle-level configuration items and bottom-level configuration items under the sigen configuration item may not exist in the target configuration file and will not be considered an error; name,sigen.aipv.scheduling.
[0160] algorithm,* indicates that the configuration item sigen.aipv.scheduling.algorithm may not exist in the target configuration file and will not be considered an error. value,sigen.aipv.scheduling.pv-model-name,select_best_7 indicates that the configuration item sigen.aipv.scheduling.pv-model-name must exist and its value must be select_best_7, otherwise it is considered an error. value,sigen.aipv.scheduling.strategy-granularity-minute,30 indicates that the configuration item sigen.aipv.scheduling.strategy-granularity-minute must exist and its value must be 30, otherwise it is considered an error.
[0161] In some embodiments, the target comparison template can flexibly allow for differences in specific configuration items under different environments or requirements while ensuring the consistency of key configuration items. For configuration items that are allowed to not exist in the target configuration file, unnecessary errors can be avoided by defining the name type, and for configuration items that must exist, strict checks of the value type are used to ensure that they are configured correctly.
[0162] In some embodiments, the user only needs to input the target for the first configuration item in the benchmark configuration file, which can be allowed to not exist or can be allowed to have different configuration values, thereby reducing the workload of manual target input and improving the automation level of target comparison template generation, making the detection of large-scale target configuration files more efficient.
[0163] Step 4: Check the first target configuration item based on the target comparison template to obtain the detection result of the target configuration file.
[0164] In actual execution, for each first target configuration item, based on the path of the first target configuration item, the second target configuration item information corresponding to the first target configuration item is searched in the target comparison template. When the second target configuration item information corresponding to the first target configuration item does not exist in the target comparison template, the first target configuration item is defaulted to the second target configuration item. When the second target configuration item information corresponding to the first target configuration item exists in the target comparison template, if the first target configuration item information matches the second target configuration item information, the first target configuration item is determined to be the second target configuration item.
[0165] In some embodiments, when the first target configuration item is a first configuration item in a benchmark configuration file that does not exist in the target configuration file, if the information of the second target configuration item corresponding to the first target configuration item shows that the type of the second target configuration item is name, the first target configuration item is determined to be the second target configuration item, that is, the first target configuration item is allowed to not exist. For example, for the information of the second target configuration item name, sigen, *, if the sigen configuration item does not exist in the target configuration file, this is allowed; for name, sigen.aipv.scheduling.algorithm, *, if the algorithm configuration item does not exist in the target configuration file, this is also allowed. If the information of the second target configuration item corresponding to the first target configuration item shows that the type of the second target configuration item is value, the first target configuration item is not the second target configuration item. For example, for the information of the second target configuration item value, sigen.aipv.scheduling.pv-model-name, select_best_7, if the first target configuration item pv-model-name does not exist in the target configuration file, the first target configuration item pv-model-name is not the second target configuration item.
[0166] In some embodiments, when the first target configuration item is the first configuration item in the benchmark configuration file present in the target configuration file, but is not the same as the first configuration item in the benchmark configuration file, the first target configuration item is checked based on the information of the second target configuration item. If the information of the second target configuration item specifies a configuration value, the configuration value of the first target configuration item must be consistent with the specified configuration value. When the information of the second target configuration item specifies a configuration value and the configuration value of the first target configuration item is consistent with the specified value, the first target configuration item is determined to be the second target configuration item. When the information of the second target configuration item specifies a configuration value and the configuration value of the first target configuration item is inconsistent with the specified value, the first target configuration item is determined not to be the second target configuration item. If the information of the second target configuration item includes a wildcard, the configuration value of the first target configuration item can be any value. For example, for the information of the second target configuration item value, sigen.aipv.scheduling.pv-model-name, select_best_7, when the configuration value of the first target configuration item pv-model-name is select_best_7, the first target configuration item is the second target configuration item, otherwise the first target configuration item is not the second target configuration item. For example, for the information value,sigen.aipv.scheduling.pv-model-name,* of the second target configuration item, if the configuration value of the first target configuration item pv-model-name is any value, the first target configuration item is the second target configuration item. When the information of the second target configuration item includes an expression such as ${MYSQL_USER}, the configuration value of the first target configuration item includes a specified part in the information of the second target configuration item, and the first target configuration item is determined to be the second target configuration item. For example, for the information value,sigen.aipv.scheduling.sername,${MYSQL_USER:*} of the second target configuration item, if the configuration value of the first target configuration item sername includes ${MYSQL_USER}, the first target configuration item is determined to be the second target configuration item.
[0167] In some embodiments, when each first target configuration item is a second target configuration item, the detection result is determined as the target configuration file meets the requirements; when at least one first target configuration item is not a second target configuration item, the detection result is determined as the target configuration file does not meet the requirements.
[0168] Step 5: After the detection result determines that the target configuration file meets the requirements, if the target configuration file has been manually modified after being detected as not meeting the requirements, the configuration of the target environment of the target distributed system can be updated based on the target configuration file.
[0169] In actual execution, after determining that the target configuration file meets the requirements, the target configuration file list can be traversed to load and obtain the next undetected target configuration file, and steps 1 to 4 are executed for the newly loaded target configuration file until all target configuration files in the target environment are detected.
[0170] Step 6: After the detection result determines that the target configuration file does not meet the requirements, the third target configuration item can be highlighted based on the target configuration file, and the third target configuration item can be modified.
[0171] In some embodiments, the third target configuration item may be the first target configuration item in the target configuration file that is not the second target configuration item. The third target configuration item may be highlighted in the target configuration file, such as by highlighting, bolding, underlining, or any other highlighting method, to prompt the user to add missing configuration items or modify erroneous configuration items.
[0172] In some embodiments, steps 1 to 4 may be performed on the modified target configuration file until the target configuration file detection result determines that the target configuration file meets the requirements.
[0173] The embodiment of the present application also provides a configuration file detection device.
[0174] like Figure 4 As shown, the configuration file detection device 400 includes: a comparison module 410 and a verification module 420 .
[0175] The comparison module 410 is used to compare the target configuration file of the target environment with the benchmark configuration file of the benchmark environment to obtain the first target configuration item that is different between the target configuration and the benchmark configuration file; both the target configuration file and the benchmark configuration file are configuration files of the target distributed system based on Nacos; and the configuration items in the benchmark configuration file are correct;
[0176] The inspection module 420 is used to inspect the first target configuration item based on the target comparison template to obtain the detection result of the target configuration file; the target comparison template is generated based on the benchmark configuration file; the target comparison template is used to indicate the information of the second target configuration item that allows differences between the target configuration file and the benchmark configuration file.
[0177] According to the configuration file detection device of the present application, by comparing the target configuration file of the target environment with the benchmark configuration file of the benchmark environment, a first target configuration item that is different from the target configuration file and the benchmark configuration file is obtained, and based on a target comparison template for indicating information of a second target configuration item that is allowed to be different from the target configuration file and the benchmark configuration file, the first target configuration item is checked to obtain a detection result of the target configuration file, and whether the first target configuration item that is different from the target configuration file and the benchmark configuration file is a configuration item that is allowed to be different is checked, so as to check the target configuration file, so that the process of checking the target configuration file does not require human participation, thereby improving the detection efficiency.
[0178] In some embodiments, the inspection module 420 includes:
[0179] A verification unit, configured to verify whether each first target configuration item is a second target configuration item based on a target comparison template;
[0180] The first determining unit is configured to determine the detection result as that the target configuration file meets the requirement when each first target configuration item is the second target configuration item.
[0181] In some embodiments, the inspection module 420 further includes:
[0182] The second determining unit is configured to determine the detection result as the target configuration file not meeting the requirement when at least one first target configuration item is not the second target configuration item.
[0183] In some embodiments, the configuration file detection device 400 further includes:
[0184] A first acquisition module is used to acquire a target input for a second target configuration item in a benchmark configuration file;
[0185] The second acquisition module is used to acquire a target comparison template based on the target input.
[0186] In some embodiments, the configuration file detection device 400 further includes:
[0187] A first loading module is used to load a benchmark configuration file and highlight a second target configuration item in the benchmark configuration file based on the target comparison template when a target comparison template already exists;
[0188] The second acquisition module is specifically used to update the target comparison template based on the target input.
[0189] In some embodiments, the configuration file detection device 400 further includes:
[0190] The second loading module is used to load the benchmark configuration file when there is no target comparison template.
[0191] In some embodiments, the comparison module 410 includes:
[0192] A determination unit, configured to determine, for each first configuration item in the reference configuration file, whether a second configuration item corresponding to the first configuration item exists in the target configuration file based on the path and name of the configuration item;
[0193] The third determining unit is configured to determine the first configuration item as the first target configuration item when there is no second configuration item corresponding to the first configuration item in the target configuration file.
[0194] In some embodiments, the comparison module 410 further includes:
[0195] a comparing unit, configured to compare whether the first configuration item is the same as the second configuration item when there is a second configuration item corresponding to the first configuration item in the target configuration file;
[0196] The fourth determining unit is configured to determine the first configuration item as the first target configuration item when the first configuration item is different from the second configuration item.
[0197] In some embodiments, for each second target configuration item, the information of the second target configuration item includes: a path, a name, and a type of the second target configuration item.
[0198] In some embodiments, when the type of the second target configuration item is a value type, the information of the second target configuration item further includes: an allowed value of the second target configuration item.
[0199] In some embodiments, the testing unit comprises:
[0200] The first verification unit is used to verify, for any first target configuration item whose value is determined by a variable expression, whether the variable expression in the first target configuration item matches the allowed value of the first configuration item corresponding to the second configuration item; if the two match, the first target configuration item is the second target configuration item; if the two do not match, the first target configuration item is not the second target configuration item.
[0201] In some embodiments, the first inspection unit is specifically used to:
[0202] When the allowed value includes only the fixed part of the variable expression, and the fixed part of the variable expression in the first target configuration item is the same as the fixed part of the variable expression in the allowed value, it is determined that the variable expression in the first target configuration item matches the allowed value.
[0203] In some embodiments, the inspection module 420 further includes:
[0204] The display unit is used to highlight a third target configuration item based on the target configuration file; the third target configuration item is a first target configuration item that is not the second target configuration item.
[0205] According to one embodiment of the present application, the inspection module 420 further includes:
[0206] The updating unit is used to update the configuration of the target environment of the target distributed system based on the target configuration file when the target configuration file has been manually modified after being detected as not meeting the requirements.
[0207] The detection device of the configuration file in the embodiment of the present application can be an electronic device, or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or other devices other than the terminal. Exemplary, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a palmtop computer, a vehicle-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), augmented reality (augmented reality, AR) / virtual reality (virtual reality, VR) equipment, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobilepersonal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., and the embodiment of the present application is not specifically limited.
[0208] The configuration file detection device in the embodiment of the present application may be a device having an operating system. The operating system may be a Microsoft (Windows) operating system, an Android (Android) operating system, an IOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0209] The configuration file detection device 400 provided in the embodiment of the present application can realize Figure 1 to Figure 2 To avoid repetition, the various processes implemented by the method embodiment are not described here.
[0210] In some embodiments, Figure 5As shown, an embodiment of the present application further provides an electronic device 500, including a processor 501, a memory 502, and a computer program stored in the memory 502 and executable on the processor 501. When the program is executed by the processor 501, each process of the above-mentioned configuration file detection method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0211] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.
[0212] The embodiment of the present application also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, each process of the above-mentioned configuration file detection method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0213] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.
[0214] An embodiment of the present application also provides a computer program product, including a computer program, which implements the above-mentioned configuration file detection method when executed by a processor.
[0215] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.
[0216] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement each process of the above-mentioned configuration file detection method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0217] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0218] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes 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 sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0219] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0220] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
[0221] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials, or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0222] Although the embodiments of the present application have been shown and described, those skilled in the art will appreciate that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present application, and that the scope of the present application is defined by the claims and their equivalents.
Claims
1. A configuration file detection method, characterized in that: include: Compare the target configuration file of the target environment with the benchmark configuration file of the benchmark environment to obtain a first target configuration item having a difference between the target configuration file and the benchmark configuration file; the target configuration file and the benchmark configuration file are both configuration files of the target distributed system based on Nacos; The configuration items in the benchmark configuration file are all correct; The first target configuration item is tested based on a target comparison template to obtain a test result of the target configuration file; the target comparison template is generated based on the reference configuration file; The target comparison template is used to indicate information of a second target configuration item that allows a difference between the target configuration file and the reference configuration file.
2. The configuration file detection method according to claim 1, characterized in that: The step of inspecting the first target configuration item based on the target comparison template to obtain the inspection result of the target configuration file includes: Based on the target comparison template, checking whether each of the first target configuration items is the second target configuration item; In a case where each of the first target configuration items is also the second target configuration item, the detection result is determined as the target configuration file meeting the requirement.
3. The configuration file detection method according to claim 2, characterized in that: After verifying whether each of the first target configuration items is the second target configuration item based on the target comparison template, the method further includes: In a case where at least one of the first target configuration items is not the second target configuration item, the detection result is determined as the target configuration file not meeting a requirement.
4. The configuration file detection method according to claim 1, characterized in that: Before inspecting the first target configuration item based on the target comparison template to obtain the inspection result of the target configuration file, the method further includes: Obtaining a target input for the second target configuration item in the benchmark configuration file; Based on the target input, the target comparison template is obtained.
5. The configuration file detection method according to claim 4, characterized in that: Before obtaining the target input for the second target configuration item in the benchmark configuration file, the method further includes: In the case where the target comparison template already exists, based on the target comparison template, loading the benchmark configuration file and highlighting the second target configuration item in the benchmark configuration file; The step of obtaining the target comparison template based on the target input includes: Based on the target input, the target comparison template is updated.
6. The configuration file detection method according to claim 4, characterized in that: Before obtaining the target input for the second target configuration item in the benchmark configuration file, the method further includes: In the absence of the target comparison template, the benchmark configuration file is loaded.
7. The configuration file detection method according to claim 1, characterized in that: The step of comparing the target configuration file of the target environment with the reference configuration file of the reference environment to obtain a first target configuration item having a difference between the target configuration and the reference configuration file includes: For each first configuration item in the reference configuration file, based on the path and name of the configuration item, determining whether there is a second configuration item corresponding to the first configuration item in the target configuration file; When there is no second configuration item corresponding to the first configuration item in the target configuration file, the first configuration item is determined as the first target configuration item.
8. The configuration file detection method according to claim 7, characterized in that: After determining whether there is a second configuration item corresponding to the first configuration item in the target configuration file based on the path of the configuration item, the method further includes: In the case where a second configuration item corresponding to the first configuration item exists in the target configuration file, comparing whether the first configuration item is the same as the second configuration item; When the first configuration item is different from the second configuration item, the first configuration item is determined as the first target configuration item.
9. The configuration file detection method according to claim 2, characterized in that: For each of the second target configuration items, the information of the second target configuration item includes: a path, a name, and a type of the second target configuration item.
10. The configuration file detection method according to claim 9, characterized in that: In the case that the type of the second target configuration item is a value type, the information of the second target configuration item further includes: an allowed value of the second target configuration item.
11. The configuration file detection method according to claim 10, characterized in that: The checking, based on the target comparison template, whether each of the first target configuration items is the second target configuration item includes: For any first target configuration item whose value is determined by a variable expression, checking whether the variable expression in the first target configuration item matches the allowed value of the first configuration item corresponding to the second configuration item; If the two match, the first target configuration item is the second target configuration item; if the two do not match, the first target configuration item is not the second target configuration item.
12. The configuration file detection method according to claim 11, characterized in that: The checking whether the variable expression in the first target configuration item matches the allowed value of the first configuration item corresponding to the second configuration item includes: In the case where the allowed value includes only a fixed part of a variable expression, and the fixed part of the variable expression in the first target configuration item is the same as the fixed part of the variable expression in the allowed value, it is determined that the variable expression in the first target configuration item matches the allowed value.
13. The configuration file detection method according to claim 3, characterized in that: After determining the detection result as that the target configuration file does not meet the requirement when at least one of the first target configuration items is not the second target configuration item, the method further includes: Based on the target configuration file, a third target configuration item is highlighted; the third target configuration item is the first target configuration item that is not the second target configuration item.
14. The configuration file detection method according to claim 2, characterized in that: In the case where each of the first target configuration items is the second target configuration item, after determining the detection result as that the target configuration file meets the requirement, the method further includes: In a case where the target configuration file is manually modified after being detected as not meeting the requirements, the configuration of the target environment of the target distributed system is updated based on the target configuration file.
15. A configuration file detection device, characterized in that: include: A comparison module, configured to compare a target configuration file of a target environment with a reference configuration file of a reference environment, and obtain a first target configuration item having a difference between the target configuration and the reference configuration file; The target configuration file and the reference configuration file are both configuration files of the target distributed system based on Nacos; The configuration items in the benchmark configuration file are all correct; A testing module, configured to test the first target configuration item based on a target comparison template and obtain a test result of the target configuration file; The target comparison template is generated based on the benchmark configuration file; The target comparison template is used to indicate information of a second target configuration item that allows a difference between the target configuration file and the reference configuration file.
16. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method for detecting the configuration file according to any one of claims 1 to 14 is implemented.
17. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for detecting a configuration file according to any one of claims 1 to 14 is implemented.
18. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method for detecting a configuration file according to any one of claims 1 to 14 is implemented.