CN112052152A - A method and device for simulating testing - Google Patents
A method and device for simulating testing Download PDFInfo
- Publication number
- CN112052152A CN112052152A CN201910491441.9A CN201910491441A CN112052152A CN 112052152 A CN112052152 A CN 112052152A CN 201910491441 A CN201910491441 A CN 201910491441A CN 112052152 A CN112052152 A CN 112052152A
- Authority
- CN
- China
- Prior art keywords
- component
- cluster
- test
- rule
- test data
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000012360 testing method Methods 0.000 title claims abstract description 276
- 238000000034 method Methods 0.000 title claims abstract description 46
- 238000004088 simulation Methods 0.000 claims abstract description 44
- 238000004590 computer program Methods 0.000 claims description 9
- 230000008569 process Effects 0.000 abstract description 22
- 238000005094 computer simulation Methods 0.000 abstract description 10
- 238000010586 diagram Methods 0.000 description 17
- 230000006870 function Effects 0.000 description 11
- 238000004891 communication Methods 0.000 description 7
- 230000003068 static effect Effects 0.000 description 7
- 238000012545 processing Methods 0.000 description 5
- 238000010998 test method Methods 0.000 description 5
- 230000003287 optical effect Effects 0.000 description 4
- 238000012986 modification Methods 0.000 description 3
- 230000004048 modification Effects 0.000 description 3
- 230000001960 triggered effect Effects 0.000 description 3
- 238000012795 verification Methods 0.000 description 3
- 239000000835 fiber Substances 0.000 description 2
- 238000007726 management method Methods 0.000 description 2
- 230000000644 propagated effect Effects 0.000 description 2
- 239000004065 semiconductor Substances 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 239000002131 composite material Substances 0.000 description 1
- 150000001875 compounds Chemical class 0.000 description 1
- 238000010276 construction Methods 0.000 description 1
- 238000011217 control strategy Methods 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 239000000203 mixture Substances 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Prevention of errors by analysis, debugging or testing of software
- G06F11/3668—Testing of software
- G06F11/3672—Test management
- G06F11/3688—Test management for test execution, e.g. scheduling of test suites
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Prevention of errors by analysis, debugging or testing of software
- G06F11/3668—Testing of software
- G06F11/3672—Test management
- G06F11/3684—Test management for test design, e.g. generating new test cases
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Debugging And Monitoring (AREA)
Abstract
本发明公开了一种模拟测试的方法和装置,涉及计算机技术领域。该方法的一具体实施方式包括:根据组件的调用请求获取组件标识及组件所属集群的标识;根据组件标识及集群的标识获取组件的测试数据规则及集群的测试触发规则;根据组件的测试数据规则及集群的测试触发规则返回模拟测试数据。该实施方式可实现对线上集群进行模拟测试,控制了模拟测试数据对线上集群流量的影响,提升了组件模拟测试过程的可控性,使组件的模拟测试过程完全动态化和个性化,支持全场景的组件动态模拟测试。
The invention discloses a method and a device for simulating testing, and relates to the technical field of computers. A specific implementation of the method includes: acquiring the component identifier and the identifier of the cluster to which the component belongs according to the calling request of the component; acquiring the test data rule of the component and the test triggering rule of the cluster according to the component identifier and the identifier of the cluster; according to the test data rule of the component And the test trigger rules of the cluster return the simulated test data. This embodiment can realize the simulation test of the online cluster, control the impact of the simulation test data on the online cluster traffic, improve the controllability of the component simulation test process, and make the component simulation test process completely dynamic and personalized. Supports dynamic simulation testing of components in all scenarios.
Description
技术领域technical field
本发明涉及计算机技术领域,尤其涉及一种模拟测试的方法和装置。The present invention relates to the field of computer technology, and in particular, to a method and device for simulating testing.
背景技术Background technique
当业务系统功能开发完成后,为了验证其功能的正确性、完整性和安全性等,需要对业务系统及其包括的组件进行测试。现有的测试方法多为静态mock(模拟)测试,其实现流程如图1所示。After the functional development of the business system is completed, in order to verify the correctness, integrity and security of its functions, the business system and its components need to be tested. Most of the existing test methods are static mock (simulation) tests, and the implementation process is shown in FIG. 1 .
图1是现有的静态组件mock测试实现流程示意图。当业务系统接收到组件调用请求时,查询组件配置信息以判断组件是否存在并获取组件信息,之后判断请求参数中是否包含有mock请求标识,若未包含则正常调用组件并返回结果,否则判断组件是否支持mock;若不支持则正常调用组件并返回结果,否则判断组件信息中是否有预先配置的mock数据;若没有,则正常调用组件以返回结果,否则,将mock数据作为组件调用结果返回。FIG. 1 is a schematic diagram of the implementation flow of the existing static component mock test. When the business system receives a component call request, it queries the component configuration information to determine whether the component exists and obtains the component information, and then determines whether the request parameter contains the mock request identifier. Whether mock is supported; if not, call the component normally and return the result, otherwise judge whether there is pre-configured mock data in the component information; if not, call the component normally to return the result, otherwise, return the mock data as the result of the component call.
在实现本发明过程中,发明人发现现有技术中至少存在如下问题:In the process of realizing the present invention, the inventor found that there are at least the following problems in the prior art:
组件mock触发规则比较单一,是否带有请求mock标识为入口固定配置,无法针对不同请求(如某个用户或某个入口等)动态触发;组件是否支持mock为组件固定配置,无法针对业务集群进行设置,如功能上线验证多在灰度集群;组件mock数据固定,无法同时支持多人或多场景验证。The component mock triggering rules are relatively simple. Whether or not the request mock is identified as an entry fixed configuration cannot be dynamically triggered for different requests (such as a user or an entry); whether the component supports mock is a component fixed configuration, which cannot be implemented for business clusters. Settings, such as function online verification, are mostly in grayscale clusters; component mock data is fixed and cannot support multi-person or multi-scene verification at the same time.
发明内容SUMMARY OF THE INVENTION
有鉴于此,本发明实施例提供一种模拟测试的方法和装置,能够实现对线上集群进行模拟测试,控制了模拟测试数据对线上集群流量的影响,提升了组件模拟测试过程的可控性,使组件的模拟测试过程完全动态化和个性化,支持全场景的组件动态模拟测试。In view of this, embodiments of the present invention provide a method and device for simulated testing, which can implement simulated testing of online clusters, control the impact of simulated test data on online cluster traffic, and improve the controllability of the component simulation testing process. It makes the simulation testing process of components fully dynamic and personalized, and supports dynamic simulation testing of components in all scenarios.
为实现上述目的,根据本发明实施例的一个方面,提供了一种模拟测试的方法。To achieve the above object, according to an aspect of the embodiments of the present invention, a method for simulating testing is provided.
一种模拟测试的方法,包括:根据组件的调用请求获取组件标识及所述组件所属集群的标识;根据所述组件标识及所述集群的标识获取所述组件的测试数据规则及所述集群的测试触发规则;根据所述组件的测试数据规则及所述集群的测试触发规则返回模拟测试数据。A method for simulating testing, comprising: acquiring a component identifier and an identifier of a cluster to which the component belongs according to a call request of a component; acquiring a test data rule of the component and an identifier of the cluster according to the component identifier and the identifier of the cluster Test triggering rules; return simulated test data according to the test data rules of the component and the test trigger rules of the cluster.
可选地,根据所述组件标识及所述集群的标识获取所述组件的测试数据规则及所述集群的测试触发规则包括:根据所述组件标识及所述集群的标识获取位于所述集群的所述组件的测试数据规则;若获取到所述组件的测试数据规则,则根据所述集群的标识获取所述集群的测试触发规则,否则,正常调用所述组件。Optionally, acquiring the test data rules of the component and the test triggering rules of the cluster according to the component identifier and the cluster identifier includes: acquiring, according to the component identifier and the cluster identifier, the test data rules located in the cluster. The test data rule of the component; if the test data rule of the component is acquired, the test trigger rule of the cluster is acquired according to the identifier of the cluster, otherwise, the component is normally invoked.
可选地,根据所述组件的测试数据规则及所述集群的测试触发规则返回模拟测试数据包括:依次获取所述集群的每个测试触发规则,并判断所述调用请求是否满足任一测试触发规则;若满足任一测试触发规则,则根据所述组件的测试数据规则生成模拟测试数据并返回,否则,正常调用所述组件并返回调用结果。Optionally, returning the simulated test data according to the test data rules of the component and the test trigger rules of the cluster includes: sequentially acquiring each test trigger rule of the cluster, and judging whether the call request satisfies any test trigger. If any test triggering rule is satisfied, generate simulated test data according to the test data rules of the component and return it, otherwise, call the component normally and return the calling result.
可选地,所述集群的测试触发规则不少于一个,且每个测试触发规则具有不同的优先级。Optionally, the cluster has no less than one test triggering rule, and each test triggering rule has a different priority.
可选地,所述组件的测试数据规则及所述集群的测试触发规则支持比较运算和/或正则匹配。Optionally, the test data rules of the component and the test trigger rules of the cluster support comparison operations and/or regular matching.
可选地,所述组件的测试数据规则被配置为树形结构。Optionally, the test data rules of the component are configured in a tree structure.
根据本发明实施例的另一方面,提供了一种模拟测试的装置。According to another aspect of the embodiments of the present invention, an apparatus for simulating a test is provided.
一种模拟测试的装置,包括:标识获取模块,用于根据组件的调用请求获取组件标识及所述组件所属集群的标识;规则获取模块,用于根据所述组件标识及所述集群的标识获取所述组件的测试数据规则及所述集群的测试触发规则;数据返回模块,用于根据所述组件的测试数据规则及所述集群的测试触发规则返回模拟测试数据。A device for simulating testing, comprising: an identification acquisition module for acquiring a component identification and an identification of a cluster to which the component belongs according to a calling request of the component; a rule acquisition module for acquiring according to the component identification and the identification of the cluster Test data rules of the component and test trigger rules of the cluster; a data return module for returning simulated test data according to the test data rules of the component and the test trigger rules of the cluster.
可选地,所述规则获取模块还用于:根据所述组件标识及所述集群的标识获取位于所述集群的所述组件的测试数据规则;若获取到所述组件的测试数据规则,则根据所述集群的标识获取所述集群的测试触发规则,否则,正常调用所述组件。Optionally, the rule obtaining module is further configured to: obtain the test data rule of the component located in the cluster according to the component identifier and the cluster identifier; if the test data rule of the component is obtained, then The test triggering rule of the cluster is acquired according to the identifier of the cluster, otherwise, the component is normally invoked.
可选地,所述数据返回模块还用于:依次获取所述集群的每个测试触发规则,并判断所述调用请求是否满足任一测试触发规则;若满足任一测试触发规则,则根据所述组件的测试数据规则生成模拟测试数据并返回,否则,正常调用所述组件并返回调用结果。Optionally, the data return module is further configured to: obtain each test triggering rule of the cluster in turn, and determine whether the call request satisfies any test triggering rule; Generate simulated test data according to the test data rules of the component and return it, otherwise, call the component normally and return the calling result.
可选地,所述集群的测试触发规则不少于一个,且每个测试触发规则具有不同的优先级。Optionally, the cluster has no less than one test triggering rule, and each test triggering rule has a different priority.
可选地,所述组件的测试数据规则及所述集群的测试触发规则支持比较运算和/或正则匹配。Optionally, the test data rules of the component and the test trigger rules of the cluster support comparison operations and/or regular matching.
可选地,所述组件的测试数据规则被配置为树形结构。Optionally, the test data rules of the component are configured in a tree structure.
根据本发明实施例的又一方面,提供了一种模拟测试的电子设备。According to yet another aspect of the embodiments of the present invention, an electronic device for simulating testing is provided.
一种模拟测试的电子设备,包括:一个或多个处理器;存储装置,用于存储一个或多个程序,当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现本发明实施例所提供的模拟测试的方法。An electronic device for simulating testing, comprising: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, so that all The one or more processors implement the simulation test method provided by the embodiment of the present invention.
根据本发明实施例的再一方面,提供了一种计算机可读介质。According to yet another aspect of the embodiments of the present invention, a computer-readable medium is provided.
一种计算机可读介质,其上存储有计算机程序,所述程序被处理器执行时实现本发明实施例所提供的模拟测试的方法。A computer-readable medium on which a computer program is stored, and when the program is executed by a processor, implements the simulation test method provided by the embodiment of the present invention.
上述发明中的一个实施例具有如下优点或有益效果:通过根据组件的调用请求获取组件标识及组件所属集群的标识;然后根据组件标识及集群的标识获取组件的测试数据规则及集群的测试触发规则;并根据组件的测试数据规则及集群的测试触发规则返回模拟测试数据,实现了将组件的静态模拟测试过程动态化,通过按照集群对组件的模拟测试进行配置,可实现对线上集群进行动态模拟测试,且根据需要设置每次进行动态模拟测试的集群,控制了模拟测试数据对线上集群流量的影响;通过对集群的测试触发规则进行配置,细化了测试的触发场景,进一步将组件的模拟测试过程控制在指定请求内,提升了组件模拟测试过程的可控性;通过对组件的测试数据规则进行配置,使得同一集群同一组件在不同场景下提供不同的组件模拟测试数据,从而使组件的模拟测试过程完全动态化和个性化,支持全场景的组件动态模拟测试。An embodiment of the above invention has the following advantages or beneficial effects: by obtaining the component identification and the identification of the cluster to which the component belongs according to the calling request of the component; then obtaining the test data rule of the component and the test triggering rule of the cluster according to the component identification and the identification of the cluster ; And according to the test data rules of the components and the test trigger rules of the cluster, the simulated test data is returned, which realizes the dynamicization of the static simulation test process of the components. Simulate the test, and set the cluster for each dynamic simulation test as needed, which controls the impact of the simulated test data on the online cluster traffic; by configuring the test trigger rules of the cluster, the test triggering scenarios are refined, and the components are further The simulation test process is controlled within the specified request, which improves the controllability of the component simulation test process; by configuring the test data rules of the components, the same component in the same cluster can provide different component simulation test data in different scenarios, so that the The simulation testing process of components is fully dynamic and personalized, and supports dynamic simulation testing of components in all scenarios.
上述的非惯用的可选方式所具有的进一步效果将在下文中结合具体实施方式加以说明。Further effects of the above non-conventional alternatives will be described below in conjunction with specific embodiments.
附图说明Description of drawings
附图用于更好地理解本发明,不构成对本发明的不当限定。其中:The accompanying drawings are used for better understanding of the present invention and do not constitute an improper limitation of the present invention. in:
图1是现有的静态组件mock测试实现流程示意图;Fig. 1 is a schematic diagram of the implementation flow of the existing static component mock test;
图2是本发明实施例的组件mock测试系统架构示意图;2 is a schematic diagram of the architecture of a component mock test system according to an embodiment of the present invention;
图3是根据本发明实施例的模拟测试的方法的主要步骤示意图;3 is a schematic diagram of main steps of a method for simulating testing according to an embodiment of the present invention;
图4是本发明一个实施例的组件模拟测试的流程示意图;4 is a schematic flowchart of a component simulation test according to an embodiment of the present invention;
图5是本发明一个实施例的组件测试数据规则树结构示意图;5 is a schematic diagram of a component test data rule tree structure according to an embodiment of the present invention;
图6是根据本发明实施例的模拟测试的装置的主要模块示意图;6 is a schematic diagram of main modules of a device for simulating testing according to an embodiment of the present invention;
图7是本发明实施例可以应用于其中的示例性系统架构图;FIG. 7 is an exemplary system architecture diagram to which an embodiment of the present invention may be applied;
图8是适于用来实现本发明实施例的终端设备或服务器的计算机系统的结构示意图。FIG. 8 is a schematic structural diagram of a computer system suitable for implementing a terminal device or a server according to an embodiment of the present invention.
具体实施方式Detailed ways
以下结合附图对本发明的示范性实施例做出说明,其中包括本发明实施例的各种细节以助于理解,应当将它们认为仅仅是示范性的。因此,本领域普通技术人员应当认识到,可以对这里描述的实施例做出各种改变和修改,而不会背离本发明的范围和精神。同样,为了清楚和简明,以下的描述中省略了对公知功能和结构的描述。Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, which include various details of the embodiments of the present invention to facilitate understanding and should be considered as exemplary only. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted from the following description for clarity and conciseness.
当某个业务场景上线后,测试人员需要在线上环境验证功能正确性,但是对于一些功能复杂、包含了大量业务组件的业务场景来说,现有的静态mock测试方法往往很难对场景需要的每个组件构造真实结果数据。例如,对于电商领域常用的业务型聊天机器人来说,当用户向其咨询订单的当前状态时,可能需要其提供订单列表组件以供用户选择要咨询的订单;在用户选择了订单之后,还需要其提供订单状态组件来判断订单当前状态;若订单当前在配送状态,还需要其提供订单物流信息组件来向用户展示该订单当前位置信息,等等。对于该业务场景,在对其进行测试时,需要用测试账号下单,并需要该测试订单进入真实生产,一则耗时长,二则影响线上真实数据,三则如果还需要判断其他瞬时状态,可能无法构造出来。这会使得对业务产品的测试验收变得异常困难。When a business scenario goes online, testers need to verify the correctness of the function in the online environment. However, for some business scenarios with complex functions and a large number of business components, the existing static mock testing methods are often difficult to meet the needs of the scenario. Each component constructs real result data. For example, for a business chatbot commonly used in the e-commerce field, when a user inquires about the current status of an order, it may be required to provide an order list component for the user to select the order to be consulted; It needs to provide an order status component to determine the current status of the order; if the order is currently in the delivery state, it also needs to provide an order logistics information component to display the current location information of the order to the user, and so on. For this business scenario, when testing it, you need to place an order with a test account, and the test order needs to be put into real production. First, it will take a long time, second, it will affect the real online data, and third, if you need to judge other instantaneous states , may not be constructed. This can make test acceptance of business products extremely difficult.
为了解决现有技术中所存在的上述问题,本发明提供了一种模拟测试的方法和装置,旨在通过对组件市场调用mock服务独立拆分,增加按集群对组件进行mock测试配置,控制mock数据对线上集群的流量影响;增加组件mock触发规则动态配置,动态解析请求协议中触发规则参数值,按指定条件或百分比等参数进行动态mock规则触发,进一步精细控制mock数据对指定集群非mock测试流量的影响;同时针对多人多场景验证需求设置组件mock规则,根据不同条件配置不同的组件mock结果,动态为每一个场景或每一个测试人员生成不同的mock数据。在本发明实施例的介绍中,mock测试即指的是模拟测试。In order to solve the above problems existing in the prior art, the present invention provides a method and device for mock testing, which aims to independently split the component market by invoking a mock service, increase the mock test configuration for components by cluster, and control the mock test. The impact of data on the traffic of online clusters; add dynamic configuration of component mock triggering rules, dynamically parse the triggering rule parameter values in the request protocol, trigger dynamic mocking rules according to parameters such as specified conditions or percentages, and further finely control whether mock data is not mocked for specified clusters. Test the impact of traffic; at the same time, set component mock rules for multi-person and multi-scenario verification requirements, configure different component mock results according to different conditions, and dynamically generate different mock data for each scene or each tester. In the introduction of the embodiments of the present invention, the mock test refers to a mock test.
图2是本发明实施例的组件mock测试系统架构示意图。如图2所示,本发明实施例的组件mock测试系统主要包括组件调用方,组件市场,组件mock平台及数据库等几个部分。其中,最主要的是组件市场和组件mock平台两部分。组件市场,主要用于按照集群查询mock触发规则和组件的mock测试数据,并执行mock触发规则,当满足某一条mock触发规则时返回mock数据;组件mock平台,负责集群mock触发规则以及组件mock数据规则的配置,并提供集群mock触发规则数据查询接口以及组件mock数据规则执行生成mock数据接口。FIG. 2 is a schematic diagram of the architecture of a component mock test system according to an embodiment of the present invention. As shown in FIG. 2 , the component mock testing system according to the embodiment of the present invention mainly includes several parts, such as a component caller, a component market, a component mock platform and a database. Among them, the most important are the component market and the component mock platform. The component market is mainly used to query the mock triggering rules and component mock test data according to the cluster, execute the mock triggering rules, and return the mock data when a certain mock triggering rule is satisfied; the component mock platform is responsible for the cluster mock triggering rules and the component mock data The configuration of the rules, and provides the cluster mock trigger rule data query interface and the component mock data rule execution generation mock data interface.
图3是根据本发明实施例的模拟测试的方法的主要步骤示意图。如图3所示,本发明实施例的模拟测试的方法主要包括如下的步骤S301至步骤S303。FIG. 3 is a schematic diagram of main steps of a method for simulating testing according to an embodiment of the present invention. As shown in FIG. 3 , the simulation test method according to the embodiment of the present invention mainly includes the following steps S301 to S303 .
步骤S301:根据组件的调用请求获取组件标识及组件所属集群的标识;Step S301: obtaining the component identifier and the identifier of the cluster to which the component belongs according to the calling request of the component;
步骤S302:根据组件标识及集群的标识获取组件的测试数据规则及集群的测试触发规则;Step S302: Acquire the test data rules of the component and the test trigger rules of the cluster according to the component identification and the cluster identification;
步骤S303:根据组件的测试数据规则及集群的测试触发规则返回模拟测试数据。Step S303: Return the simulated test data according to the test data rules of the component and the test trigger rules of the cluster.
其中,在接收到组件的调用请求时,即可获取该组件信息及其所属的集群信息,因此,即可通过按照集群对组件的模拟测试进行配置,可实现对线上集群进行动态模拟测试,且根据需要设置每次进行动态模拟测试的集群,控制了模拟测试数据对线上集群流量的影响。Among them, when a call request of a component is received, the information of the component and the cluster information to which it belongs can be obtained. Therefore, the dynamic simulation test of the online cluster can be realized by configuring the simulation test of the component according to the cluster. In addition, the cluster for each dynamic simulation test is set according to the needs, which controls the impact of the simulation test data on the online cluster traffic.
在获取到组件标识及集群标识后,即可获取组件的测试数据规则及集群的测试触发规则,并根据集群的测试触发规则判断是否需要进行模拟测试,以及根据组件的测试数据规则确定模拟测试的返回结果。After obtaining the component ID and cluster ID, you can obtain the test data rules of the component and the test trigger rules of the cluster, and judge whether a simulation test is required according to the test trigger rules of the cluster, and determine the simulation test according to the test data rules of the component. Return the result.
根据本发明的一个实施例,在步骤S302中,根据组件标识及集群的标识获取组件的测试数据规则及集群的测试触发规则时,具体可以是:首先,根据组件标识及集群的标识获取位于该集群的该组件的测试数据规则;然后,若获取到该组件的测试数据规则,则根据集群的标识获取该集群的测试触发规则,否则,正常调用该组件。According to an embodiment of the present invention, in step S302, when acquiring the test data rules of the component and the test triggering rules of the cluster according to the component identification and the cluster identification, it may specifically be: The test data rules of the component of the cluster; then, if the test data rules of the component are obtained, the test trigger rules of the cluster are obtained according to the cluster identifier, otherwise, the component is normally called.
在根据规则确定是否需要进行模拟测试以及确定模拟测试的返回结果时,可以先获取集群的测试触发规则再获取组件的测试数据规则,也可先获取组件的测试数据规则再获取集群的测试触发规则,还可以同时获取这两个规则,对于本发明的技术方案来说,其顺序并不限定。When determining whether to perform a simulation test and determining the return result of the simulation test according to the rules, you can first obtain the test trigger rules of the cluster and then obtain the test data rules of the components, or you can first obtain the test data rules of the components and then obtain the test trigger rules of the cluster. , the two rules can also be acquired at the same time, and the order of the technical solutions of the present invention is not limited.
根据本发明的一个实施例,在进行规则判断时,可以先判断组件是否已配置了测试数据规则,若已配置,则进一步判断该集群是否已配置测试触发规则;否则,若未配置,则无需判断集群是否已配置测试触发规则,因为即使集群配置了测试触发规则,若组件未配置测试数据规则,则仍无法返回组件的模拟测试数据,仍需执行正常调用组件并返回调用结果。因此,本发明的实施例通过先获取组件的测试数据规则再获取集群的测试触发规则,可以减化系统的判断和查找流程,节省系统资源,提高模拟测试的效率。According to an embodiment of the present invention, when judging the rules, it is possible to first judge whether the component has been configured with test data rules, and if so, further judge whether the cluster has been configured with test triggering rules; otherwise, if not configured, no need to Determine whether the cluster has been configured with test triggering rules, because even if the cluster is configured with test triggering rules, if the component is not configured with test data rules, the simulated test data of the component cannot be returned, and the component still needs to be called normally and the calling result is returned. Therefore, the embodiments of the present invention can simplify the system judgment and search process, save system resources, and improve the efficiency of simulation testing by first obtaining the test data rules of the components and then obtaining the test trigger rules of the cluster.
根据本发明的另一个实施例,步骤S103在具体执行时可以包括:According to another embodiment of the present invention, step S103 may include:
依次获取集群的每个测试触发规则,并判断调用请求是否满足任一测试触发规则;Obtain each test trigger rule of the cluster in turn, and judge whether the call request satisfies any test trigger rule;
若满足任一测试触发规则,则根据组件的测试数据规则生成模拟测试数据并返回,否则,正常调用组件并返回调用结果。If any of the test triggering rules are met, the simulated test data will be generated according to the test data rules of the component and returned, otherwise, the component will be called normally and the calling result will be returned.
在进行集群的测试触发规则配置时,可根据需要设置不少于一个测试触发规则,且为每个测试触发规则设定不同的优先级。并且,测试触发规则的格式也更为灵活,并不局限于现有技术中在调用请求参数中包括的mock标识,还可以是根据调用请求中任何一个字段的字段值设置测试触发规则等,例如:根据触发请求中的某个字段的字段值进行匹配或比较运算,或者根据触发请求中的某个字段的字段值编码设置一定的模拟测试比例,等等。通过配置测试触发规则可将是否需要进行模拟测试的控制权移交到服务端,并提供精细化控制策略,比如可以配置备用集群才进行mock测试或者是仅某个用户的请求才进行mock测试等。规则可以配置多个,按优先级进行匹配,匹配到任一规则则认为需要进行组件mock测试。需注意的是,每次请求都对应进行一次测试触发规则的触发判定。When configuring test triggering rules for a cluster, you can set at least one test triggering rule as needed, and set different priorities for each test triggering rule. In addition, the format of the test triggering rule is also more flexible, and is not limited to the mock identifier included in the call request parameter in the prior art, but can also be a test triggering rule set according to the field value of any field in the call request, for example : Match or compare operations based on the field value of a field in the trigger request, or set a certain proportion of simulated tests based on the field value encoding of a field in the trigger request, and so on. By configuring test triggering rules, the control right of whether to perform a mock test can be transferred to the server, and refined control strategies can be provided. For example, a standby cluster can be configured to perform a mock test, or only a user's request can be performed to perform a mock test. Multiple rules can be configured, and they are matched according to their priorities. If any rule is matched, it is considered that a component mock test is required. It should be noted that each request corresponds to a trigger judgment of the test trigger rule.
根据本发明的一个实施例,集群的测试触发规则及其执行逻辑例如如下:According to an embodiment of the present invention, the test triggering rule of the cluster and its execution logic are, for example, as follows:
1)根据配置的测试触发规则中的百分比取值字段,从调用请求中解析该字段值,对其进行hashcode(哈希编码)处理后在对100取余,然后判断是否低于测试触发规则中的百分比配置,若低于,则说明未达到比例,执行下一条规则;1) According to the percentage value field in the configured test trigger rule, parse the field value from the call request, perform hashcode (hash encoding) processing on it, and then take the remainder of 100, and then judge whether it is lower than the test trigger rule. If it is lower than the percentage configuration, it means that the percentage has not been reached, and the next rule is executed;
2)否则,若高于该百分比配置,则判断是否有指定条件配置,如用户标识等于某个值。若没有指定条件配置则满足触发百分比,说明满足该测试触发规则,将触发模拟测试的下一步判定;2) Otherwise, if it is higher than the percentage configuration, it is judged whether there is a specified condition configuration, such as the user ID is equal to a certain value. If there is no specified condition configuration, the trigger percentage is satisfied, indicating that the test triggering rule is satisfied, and the next step of the simulation test will be triggered;
3)若有指定条件配置,则动态解析配置字段的字段值,并判断该字段值是等于配置的字段值或在配置的字段值集合中。如果不等于或不在集合中说明条件不匹配,否则说明条件匹配,满足该测试触发规则,将触发模拟测试的下一步判定;3) If there is a specified condition configuration, the field value of the configuration field is dynamically parsed, and it is judged whether the field value is equal to the configured field value or in the configured field value set. If it is not equal to or not in the set, it means that the condition does not match, otherwise it means that the condition matches, and the test triggering rule is satisfied, and the next step of the simulation test will be triggered;
4)判断是否需要对指定条件匹配结果取反,若不需要,则条件不匹配表示不满足测试触发规则,反之为满足测试触发规则。如果需要取反,则条件不匹配表示满足测试触发规则,反之为不满足测试触发规则。4) It is judged whether it is necessary to invert the matching result of the specified condition. If not, the condition does not match, indicating that the test triggering rule is not met, otherwise, the test triggering rule is met. If it needs to be negated, if the condition does not match, it means that the test triggering rule is satisfied, otherwise, the test triggering rule is not satisfied.
图4是本发明一个实施例的组件模拟测试的流程示意图。如图4所示,在接收到一次组件调用请求时,将开始调用组件,首先,获取组件标识及组件所属的集群标识。然后,判断该集群的该组件是否已配置组件测试数据规则,若未配置,则正常调用组件,否则,判断该集群是否已配置集群测试触发规则;若未配置,则正常调用组件,否则,遍历所有的测试触发规则,并判断该组件调用请求是否满足任一测试触发规则;若未触发,则正常调用组件,否则,根据组件测试数据规则获取组件的模拟测试数据。最后,返回组件的调用结果,并结束此次组件调用。FIG. 4 is a schematic flowchart of a component simulation test according to an embodiment of the present invention. As shown in FIG. 4 , when a component invocation request is received, the component will be invoked. First, the component identifier and the cluster identifier to which the component belongs are obtained. Then, judge whether the component of the cluster has been configured with the component test data rules, if not, call the component normally, otherwise, judge whether the cluster has been configured with the cluster test triggering rule; if not, call the component normally, otherwise, traverse the All test triggering rules, and determine whether the component call request satisfies any test triggering rule; if it does not trigger, the component is called normally, otherwise, the simulated test data of the component is obtained according to the component test data rules. Finally, return the call result of the component, and end this component call.
根据本发明的又一个实施例,组件的测试数据规则被配置为树形结构。通过树形结构来配置测试数据规则可简化配置,且可使得规则配置更有层次和条理。According to yet another embodiment of the present invention, the test data rules of the component are configured in a tree structure. Configuring test data rules through a tree structure can simplify configuration and make rule configuration more hierarchical and organized.
图5是本发明一个实施例的组件测试数据规则树结构示意图。如图5所示,其中示出了针对XX集群的YY组件配置的测试数据规则树,根据测试数据规则的优先级顺序,从最上层根节点可以逐级添加规则或者组件结果。当执行规则树时,按规则的优先级顺序依次往下执行,直到找到匹配的组件结果并返回。例如图5中,若规则1满足,则进一步执行规则1.1;若规则1.1满足,则不再继续执行,返回1.1组件结果;否则,执行规则1.2,若规则1.2满足则返回1.2组件结果且不再继续执行。若规则1不满足,则执行规则2,……,直到找到组件结果节点进行返回,如果执行完所有规则都未找到组件结果则返回空。FIG. 5 is a schematic diagram of a tree structure of component test data rules according to an embodiment of the present invention. As shown in FIG. 5 , the test data rule tree configured for the YY component of the XX cluster is shown. According to the priority order of the test data rules, rules or component results can be added level by level from the top root node. When the rule tree is executed, the rules are executed in order of priority until a matching component result is found and returned. For example, in Figure 5, if rule 1 is satisfied, then rule 1.1 is further executed; if rule 1.1 is satisfied, the execution will not continue, and the result of component 1.1 will be returned; otherwise, rule 1.2 will be executed, and if rule 1.2 is satisfied, the result of component 1.2 will be returned and no more Go ahead. If rule 1 is not satisfied, execute rule 2, ... until the component result node is found and return, if no component result is found after executing all rules, it will return empty.
根据本发明实施例的技术方案,规则(包括组件的测试数据规则及集群的测试触发规则)的执行支持比较运算和/或正则匹配,比较运算指的是通过配置触发请求中的某个字段值大于、等于、小于或包含某个固定配置(如配置触发请求中用户名字段的值等于“小明”)来判断是否满足规则;正则匹配指的是通过配置调用请求中的某个字段值匹配某个固定的正则表达式来判断是否满足规则。这里协议中字段值获取同样支持动态解析(支持xxx.xxx.xxx配置方式),这样就可以为请求参数任意配置规则。According to the technical solutions of the embodiments of the present invention, the execution of rules (including test data rules of components and test trigger rules of clusters) supports comparison operations and/or regular matching, and comparison operations refer to a certain field value in the trigger request by configuring Greater than, equal to, less than or contains a certain fixed configuration (for example, the value of the username field in the configuration trigger request is equal to "Xiao Ming") to determine whether the rule is satisfied; regular matching refers to matching a certain field value in the configuration call request A fixed regular expression to determine whether the rule is satisfied. The field value acquisition in this protocol also supports dynamic parsing (supports xxx.xxx.xxx configuration methods), so that rules can be arbitrarily configured for request parameters.
其中,“xxx.xxx.xxx配置方式”是一种复合数据的某个字段的直观表达方式。组件的调用请求即是一个复合数据,使用通用JSON(JavaScript Object Notation,JS对象简谱)数据字符串(一个{}包裹的内容即表达一个JSON串,其由多个“key-value”键值对组成,value本身也可以是JSON串)来表示其字段配置。例如如下的名为message的JSON串:Among them, "xxx.xxx.xxx configuration mode" is an intuitive expression of a field of compound data. The call request of the component is a composite data, using a general JSON (JavaScript Object Notation, JS Object Notation) data string (the content wrapped by a {} expresses a JSON string, which consists of multiple "key-value" key-value pairs composition, the value itself can also be a JSON string) to represent its field configuration. For example the following JSON string named message:
在如上的示例中,字段及字段值的对应关系包括:message.id=123,message.body.type=text,message.body.chatinfo.userPin=wanger。若用户知道字段的某个层级关系,即可根据需要进行灵活配置。在字段值表达上该方式是最直观、简洁的方式,易于理解和配置。In the above example, the correspondence between fields and field values includes: message.id=123, message.body.type=text, message.body.chatinfo.userPin=wanger. If users know a certain hierarchical relationship of fields, they can flexibly configure them as needed. This method is the most intuitive and concise way to express field values, and is easy to understand and configure.
图6是根据本发明实施例的模拟测试的装置的主要模块示意图。如图6所示,本发明实施例的模拟测试的装置600主要包括标识获取模块601、规则获取模块602和数据返回模块603。FIG. 6 is a schematic diagram of main modules of a device for simulating testing according to an embodiment of the present invention. As shown in FIG. 6 , an
标识获取模块601,用于根据组件的调用请求获取组件标识及所述组件所属集群的标识;An
规则获取模块602,用于根据所述组件标识及所述集群的标识获取所述组件的测试数据规则及所述集群的测试触发规则;A
数据返回模块603,用于根据所述组件的测试数据规则及所述集群的测试触发规则返回模拟测试数据。The data return
根据本发明的一个实施例,规则获取模块602还可以用于:According to an embodiment of the present invention, the
根据组件标识及集群的标识获取位于该集群的该组件的测试数据规则;Obtain the test data rules of the component located in the cluster according to the component identifier and the cluster identifier;
若获取到该组件的测试数据规则,则根据集群的标识获取集群的测试触发规则,否则,正常调用该组件。If the test data rules of the component are obtained, the test trigger rules of the cluster are obtained according to the cluster ID; otherwise, the component is called normally.
根据本发明的另一个实施例,数据返回模块603还可以用于:According to another embodiment of the present invention, the
依次获取该集群的每个测试触发规则,并判断调用请求是否满足任一测试触发规则;Obtain each test triggering rule of the cluster in turn, and judge whether the call request satisfies any test triggering rule;
若满足任一测试触发规则,则根据该组件的测试数据规则生成模拟测试数据并返回,否则,正常调用该组件并返回调用结果。If any of the test triggering rules are met, the simulated test data is generated according to the test data rules of the component and returned, otherwise, the component is called normally and the call result is returned.
根据本发明的又一个实施例,集群的测试触发规则不少于一个,且每个测试触发规则具有不同的优先级。如此,在判断是否满足任一测试触发规则时,即可根据设定的优先级依次执行判断,可以实现根据测试触发规则的重要程度来进行判断。According to yet another embodiment of the present invention, there is not less than one test triggering rule of the cluster, and each test triggering rule has a different priority. In this way, when judging whether any test triggering rule is satisfied, the judgment can be performed in sequence according to the set priority, and the judgment can be realized according to the importance of the test triggering rule.
根据本发明的实施例,组件的测试数据规则及集群的测试触发规则支持比较运算和/或正则匹配。According to an embodiment of the present invention, the test data rules of components and the test trigger rules of clusters support comparison operations and/or regular matching.
根据本发明的其中一个实施例,组件的测试数据规则被配置为树形结构。通过树形结构来配置测试数据规则可简化配置,且可使得规则配置更有层次和条理。According to one of the embodiments of the present invention, the test data rules of the components are arranged in a tree structure. Configuring test data rules through a tree structure can simplify configuration and make rule configuration more hierarchical and organized.
根据本发明实施例的技术方案,通过根据组件的调用请求获取组件标识及组件所属集群的标识;然后根据组件标识及集群的标识获取组件的测试数据规则及集群的测试触发规则;并根据组件的测试数据规则及集群的测试触发规则返回模拟测试数据,实现了将组件的静态模拟测试过程动态化,通过按照集群对组件的模拟测试进行配置,可实现对线上集群进行动态模拟测试,且根据需要设置每次进行动态模拟测试的集群,控制了模拟测试数据对线上集群流量的影响;通过对集群的测试触发规则进行配置,细化了测试的触发场景,进一步将组件的模拟测试过程控制在指定请求内,提升了组件模拟测试过程的可控性;通过对组件的测试数据规则进行配置,使得同一集群同一组件在不同场景下提供不同的组件模拟测试数据,从而使组件的模拟测试过程完全动态化和个性化,支持全场景的组件动态模拟测试。According to the technical solution of the embodiment of the present invention, the component identifier and the identifier of the cluster to which the component belongs are obtained by calling the component; The test data rules and the test trigger rules of the cluster return the simulated test data, which realizes the dynamicization of the static simulation test process of the components. It is necessary to set up a cluster for each dynamic simulation test to control the impact of the simulation test data on the online cluster traffic; by configuring the test trigger rules of the cluster, the test trigger scenarios are refined, and the simulation test process of the components is further controlled. Within the specified request, the controllability of the component simulation test process is improved; by configuring the test data rules of the components, the same component in the same cluster can provide different component simulation test data in different scenarios, so as to make the component simulation test process. Fully dynamic and personalized, supporting dynamic simulation testing of components in all scenarios.
图7示出了可以应用本发明实施例的模拟测试的方法或模拟测试的装置的示例性系统架构700。FIG. 7 shows an
如图7所示,系统架构700可以包括终端设备701、702、703,网络704和服务器705。网络704用以在终端设备701、702、703和服务器705之间提供通信链路的介质。网络704可以包括各种连接类型,例如有线、无线通信链路或者光纤电缆等等。As shown in FIG. 7 , the
用户可以使用终端设备701、702、703通过网络704与服务器705交互,以接收或发送消息等。终端设备701、702、703上可以安装有各种通讯客户端应用,例如购物类应用、网页浏览器应用、搜索类应用、即时通信工具、邮箱客户端、社交平台软件等(仅为示例)。The user can use the
终端设备701、702、703可以是具有显示屏并且支持网页浏览的各种电子设备,包括但不限于智能手机、平板电脑、膝上型便携计算机和台式计算机等等。The
服务器705可以是提供各种服务的服务器,例如对用户利用终端设备701、702、703所浏览的购物类网站提供支持的后台管理服务器(仅为示例)。后台管理服务器可以对接收到的产品信息查询请求等数据进行分析等处理,并将处理结果(例如目标推送信息、产品信息--仅为示例)反馈给终端设备。The
需要说明的是,本发明实施例所提供的模拟测试的方法一般由服务器705执行,相应地,模拟测试的装置一般设置于服务器705中。It should be noted that the simulation test method provided by the embodiment of the present invention is generally performed by the
应该理解,图7中的终端设备、网络和服务器的数目仅仅是示意性的。根据实现需要,可以具有任意数目的终端设备、网络和服务器。It should be understood that the numbers of terminal devices, networks and servers in FIG. 7 are only illustrative. There can be any number of terminal devices, networks and servers according to implementation needs.
下面参考图8,其示出了适于用来实现本发明实施例的终端设备或服务器的计算机系统800的结构示意图。图8示出的终端设备或服务器仅仅是一个示例,不应对本发明实施例的功能和使用范围带来任何限制。Referring to FIG. 8 below, it shows a schematic structural diagram of a
如图8所示,计算机系统800包括中央处理单元(CPU)801,其可以根据存储在只读存储器(ROM)802中的程序或者从存储部分808加载到随机访问存储器(RAM)803中的程序而执行各种适当的动作和处理。在RAM 803中,还存储有系统800操作所需的各种程序和数据。CPU 801、ROM 802以及RAM 803通过总线804彼此相连。输入/输出(I/O)接口805也连接至总线804。As shown in FIG. 8, a
以下部件连接至I/O接口805:包括键盘、鼠标等的输入部分806;包括诸如阴极射线管(CRT)、液晶显示器(LCD)等以及扬声器等的输出部分807;包括硬盘等的存储部分808;以及包括诸如LAN卡、调制解调器等的网络接口卡的通信部分809。通信部分809经由诸如因特网的网络执行通信处理。驱动器810也根据需要连接至I/O接口805。可拆卸介质811,诸如磁盘、光盘、磁光盘、半导体存储器等等,根据需要安装在驱动器810上,以便于从其上读出的计算机程序根据需要被安装入存储部分808。The following components are connected to the I/O interface 805: an
特别地,根据本发明公开的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本发明公开的实施例包括一种计算机程序产品,其包括承载在计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信部分809从网络上被下载和安装,和/或从可拆卸介质811被安装。在该计算机程序被中央处理单元(CPU)801执行时,执行本发明的系统中限定的上述功能。In particular, the processes described above with reference to the flowcharts may be implemented as computer software programs in accordance with the disclosed embodiments of the present invention. For example, embodiments disclosed herein include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the method illustrated in the flowchart. In such an embodiment, the computer program may be downloaded and installed from the network via the
需要说明的是,本发明所示的计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本发明中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本发明中,计算机可读的信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读的信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:无线、电线、光缆、RF等等,或者上述的任意合适的组合。It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the above two. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus or device, or a combination of any of the above. More specific examples of computer readable storage media may include, but are not limited to, electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read only memory (ROM), erasable Programmable read only memory (EPROM or flash memory), fiber optics, portable compact disk read only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing. In the present invention, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present invention, however, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code therein. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device . Program code embodied on a computer readable medium may be transmitted using any suitable medium including, but not limited to, wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
附图中的流程图和框图,图示了按照本发明各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,上述模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图或流程图中的每个方框、以及框图或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。The flowchart and block diagrams in the Figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code that contains one or more logical functions for implementing the specified functions executable instructions. It should also be noted that, in some alternative implementations, the functions noted in the blocks may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It is also noted that each block of the block diagrams or flowchart illustrations, and combinations of blocks in the block diagrams or flowchart illustrations, can be implemented in special purpose hardware-based systems that perform the specified functions or operations, or can be implemented using A combination of dedicated hardware and computer instructions is implemented.
描述于本发明实施例中所涉及到的单元或模块可以通过软件的方式实现,也可以通过硬件的方式来实现。所描述的单元或模块也可以设置在处理器中,例如,可以描述为:一种处理器包括标识获取模块、规则获取模块和数据返回模块。其中,这些单元或模块的名称在某种情况下并不构成对该单元或模块本身的限定,例如,标识获取模块还可以被描述为“用于根据组件的调用请求获取组件标识及所述组件所属集群的标识的模块”。The units or modules involved in the embodiments of the present invention may be implemented in a software manner, and may also be implemented in a hardware manner. The described unit or module can also be set in the processor, for example, it can be described as: a processor includes an identification acquisition module, a rule acquisition module and a data return module. Wherein, the names of these units or modules do not constitute a limitation on the unit or module itself, for example, the identification acquisition module can also be described as "used to obtain the component identification and the component according to the invocation request of the component. The module that belongs to the identity of the cluster".
作为另一方面,本发明还提供了一种计算机可读介质,该计算机可读介质可以是上述实施例中描述的设备中所包含的;也可以是单独存在,而未装配入该设备中。上述计算机可读介质承载有一个或者多个程序,当上述一个或者多个程序被一个该设备执行时,使得该设备包括:根据组件的调用请求获取组件标识及所述组件所属集群的标识;根据所述组件标识及所述集群的标识获取所述组件的测试数据规则及所述集群的测试触发规则;根据所述组件的测试数据规则及所述集群的测试触发规则返回模拟测试数据。As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiments; or may exist alone without being assembled into the device. The above-mentioned computer-readable medium carries one or more programs, and when the above-mentioned one or more programs are executed by a device, the device includes: obtaining a component identifier and an identifier of a cluster to which the component belongs according to a call request of the component; The component identifier and the cluster identifier acquire the test data rule of the component and the test trigger rule of the cluster; and return the simulated test data according to the test data rule of the component and the test trigger rule of the cluster.
根据本发明实施例的技术方案,通过根据组件的调用请求获取组件标识及组件所属集群的标识;然后根据组件标识及集群的标识获取组件的测试数据规则及集群的测试触发规则;并根据组件的测试数据规则及集群的测试触发规则返回模拟测试数据,实现了将组件的静态模拟测试过程动态化,通过按照集群对组件的模拟测试进行配置,可实现对线上集群进行动态模拟测试,且根据需要设置每次进行动态模拟测试的集群,控制了模拟测试数据对线上集群流量的影响;通过对集群的测试触发规则进行配置,细化了测试的触发场景,进一步将组件的模拟测试过程控制在指定请求内,提升了组件模拟测试过程的可控性;通过对组件的测试数据规则进行配置,使得同一集群同一组件在不同场景下提供不同的组件模拟测试数据,从而使组件的模拟测试过程完全动态化和个性化,支持全场景的组件动态模拟测试。According to the technical solution of the embodiment of the present invention, the component identifier and the identifier of the cluster to which the component belongs are obtained by calling the component; The test data rules and the test trigger rules of the cluster return the simulated test data, which realizes the dynamicization of the static simulation test process of the components. It is necessary to set up a cluster for each dynamic simulation test to control the impact of the simulation test data on the online cluster traffic; by configuring the test trigger rules of the cluster, the test trigger scenarios are refined, and the simulation test process of the components is further controlled. Within the specified request, the controllability of the component simulation test process is improved; by configuring the test data rules of the components, the same component in the same cluster can provide different component simulation test data in different scenarios, so as to make the component simulation test process. Fully dynamic and personalized, supporting dynamic simulation testing of components in all scenarios.
上述具体实施方式,并不构成对本发明保护范围的限制。本领域技术人员应该明白的是,取决于设计要求和其他因素,可以发生各种各样的修改、组合、子组合和替代。任何在本发明的精神和原则之内所作的修改、等同替换和改进等,均应包含在本发明保护范围之内。The above-mentioned specific embodiments do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modifications, equivalent replacements and improvements made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910491441.9A CN112052152A (en) | 2019-06-06 | 2019-06-06 | A method and device for simulating testing |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910491441.9A CN112052152A (en) | 2019-06-06 | 2019-06-06 | A method and device for simulating testing |
Publications (1)
Publication Number | Publication Date |
---|---|
CN112052152A true CN112052152A (en) | 2020-12-08 |
Family
ID=73609228
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910491441.9A Pending CN112052152A (en) | 2019-06-06 | 2019-06-06 | A method and device for simulating testing |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112052152A (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113177000A (en) * | 2021-05-21 | 2021-07-27 | 拉扎斯网络科技(上海)有限公司 | Order scheduling system testing method and device, storage medium and computer equipment |
CN113779484A (en) * | 2021-01-07 | 2021-12-10 | 北京沃东天骏信息技术有限公司 | A data calculation method and device |
CN113806214A (en) * | 2021-02-10 | 2021-12-17 | 京东科技控股股份有限公司 | Application program testing method and device, computer equipment and storage medium |
CN117761736A (en) * | 2023-12-13 | 2024-03-26 | 湖南矩阵电子科技有限公司 | Navigation signal simulator test method, system, electronic equipment and storage medium |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108268372A (en) * | 2017-07-24 | 2018-07-10 | 深圳壹账通智能科技有限公司 | Mock test processing methods, device, storage medium and computer equipment |
CN108427631A (en) * | 2017-02-14 | 2018-08-21 | 北京京东尚科信息技术有限公司 | A kind of application test systems, method, electronic equipment and readable storage medium storing program for executing |
CN108733554A (en) * | 2017-04-21 | 2018-11-02 | 北京京东尚科信息技术有限公司 | Mock method and apparatus |
-
2019
- 2019-06-06 CN CN201910491441.9A patent/CN112052152A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108427631A (en) * | 2017-02-14 | 2018-08-21 | 北京京东尚科信息技术有限公司 | A kind of application test systems, method, electronic equipment and readable storage medium storing program for executing |
CN108733554A (en) * | 2017-04-21 | 2018-11-02 | 北京京东尚科信息技术有限公司 | Mock method and apparatus |
CN108268372A (en) * | 2017-07-24 | 2018-07-10 | 深圳壹账通智能科技有限公司 | Mock test processing methods, device, storage medium and computer equipment |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113779484A (en) * | 2021-01-07 | 2021-12-10 | 北京沃东天骏信息技术有限公司 | A data calculation method and device |
CN113806214A (en) * | 2021-02-10 | 2021-12-17 | 京东科技控股股份有限公司 | Application program testing method and device, computer equipment and storage medium |
CN113177000A (en) * | 2021-05-21 | 2021-07-27 | 拉扎斯网络科技(上海)有限公司 | Order scheduling system testing method and device, storage medium and computer equipment |
CN117761736A (en) * | 2023-12-13 | 2024-03-26 | 湖南矩阵电子科技有限公司 | Navigation signal simulator test method, system, electronic equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2020233369A1 (en) | Method for improving software integration system on basis of simulated port, and related device | |
CN110858172B (en) | A method and device for generating automatic test code | |
WO2021023149A1 (en) | Method and apparatus for dynamically returning message | |
CN113760948A (en) | Method and device for querying data | |
US11934287B2 (en) | Method, electronic device and computer program product for processing data | |
CN113010405B (en) | A method and device for testing an application program | |
CN112131095B (en) | Pressure testing method and device | |
CN110795328A (en) | Interface testing method and device | |
CN112052152A (en) | A method and device for simulating testing | |
CN108959294B (en) | Method and device for accessing search engine | |
CN113282489B (en) | Interface testing method and device | |
CN110806967B (en) | Unit testing method and unit testing device | |
CN113127335A (en) | System testing method and device | |
CN112015383A (en) | A login method and device | |
CN113434384B (en) | Pressure testing method and device | |
CN118312440A (en) | Automated stress testing method, device, equipment, and readable storage medium | |
CN110968497B (en) | Tree interceptor-based request verification method and device, medium and electronic equipment | |
CN113590483B (en) | Use case operation method and device | |
CN116382640A (en) | Method, device, equipment and storage medium for managing micro-service | |
CN114896244A (en) | Method, apparatus, apparatus, and computer-readable medium for configuring database tables | |
CN115033233A (en) | Interface calling method and device, electronic equipment and storage medium | |
CN116185806A (en) | A testing method and device for a digital currency system | |
CN113778847A (en) | Test report generation method and device | |
CN111949472A (en) | Method and device for recording application logs | |
CN112099841A (en) | Method and system for generating configuration file |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |