CN114138839A - Test account number implementation method based on database routing - Google Patents

Test account number implementation method based on database routing Download PDF

Info

Publication number
CN114138839A
CN114138839A CN202111485228.0A CN202111485228A CN114138839A CN 114138839 A CN114138839 A CN 114138839A CN 202111485228 A CN202111485228 A CN 202111485228A CN 114138839 A CN114138839 A CN 114138839A
Authority
CN
China
Prior art keywords
database
user
test
request
interceptor
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
Application number
CN202111485228.0A
Other languages
Chinese (zh)
Inventor
刘华龙
陈廷梁
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Shuxin Network Co ltd
Original Assignee
Zhejiang Shuxin Network Co ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Zhejiang Shuxin Network Co ltd filed Critical Zhejiang Shuxin Network Co ltd
Priority to CN202111485228.0A priority Critical patent/CN114138839A/en
Publication of CN114138839A publication Critical patent/CN114138839A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/547Messaging middleware

Abstract

The invention discloses a test account realizing method based on database routing, after the invention is used in an internet project, a user inputs an account and a password to log in a system, a request is sent to a server at a client, the user request is intercepted through an interceptor, user information is obtained and whether the current user is a test user is judged, the server processes the user request logic and initiates a database request according to the user request, the database request is routed to a corresponding database through a database middleware according to the user account information, and the test data and the real data are stored independently. By the method, the influence of the test data on the production environment data is reduced, and the safety, accuracy and authenticity of the data are improved; meanwhile, the problems caused by the deployment of programs on different servers are avoided, the workload of development, operation and maintenance and testing personnel is reduced, the unnecessary waste of resources is reduced, and the working efficiency is improved.

Description

Test account number implementation method based on database routing
Technical Field
The invention relates to the technical field of Internet project testing, and provides a convenient, quick and efficient Internet project testing technical scheme.
Background
In the current internet project development and updating iteration process, the production environment test of the internet project is relatively complicated, and no relatively fixed internet test solution is available. At present, most Internet companies adopt the mode that besides the mode of deployment in a production environment, a project is additionally deployed in a pre-release environment for on-line and pre-and post-project tests, and the newly deployed project pre-release environment and the production environment use the same database; and the scheme is improved by part of companies, the pre-sending environment and the production environment share the same entrance, the user judges which environment the user is to enter according to the user information after logging in, the subsequent flow is the same as the above, and the advantage is that the same user system is shared.
However, the two modes use the same database with the production environment, so that the test data needs to be deleted in time to reduce the influence of the test data on the existing service data, but if the project has similar functions such as real-time data statistical analysis, the accuracy of the data is influenced. In addition, when the later-stage function cycle iteration of the project involves the function change, because the previous test data is deleted, only some false data can be added for testing, the test complexity is increased invisibly, and the test efficiency of testers is reduced; and the test data in the database is frequently deleted in the test process, so that the safety of the data is greatly reduced, and particularly, as the micro-service architecture rises, each set of environment usually needs to occupy a plurality of servers, so that the resource waste is caused.
Disclosure of Invention
The invention aims to provide a test account number implementation method based on database routing, aiming at the defects that part of functions (real-time data statistical analysis and other functions) of a production environment are influenced by test data generated in the test process of a traditional internet project, the test data is deleted by manually operating a production environment database after the test is finished, and the data safety is not facilitated.
The purpose of the invention is realized by the following technical scheme: a test account number realization method based on database routing comprises the following steps:
(1) the method comprises the following steps that an interceptor I and an interceptor II are arranged at a server side, a database middleware, a common database and a test database are deployed, and the common database and the test database are connected with the database middleware; adding a test account identification in user information of a user system for distinguishing a common user account from a test user account;
(2) when a user initiates a request to a server, firstly, intercepting the user request through an interceptor I, requesting user information from a user system in the interceptor I, acquiring a test account identifier in the user information, thereby distinguishing the type of the user, and storing the test account identifier in a cache;
(3) the server side processes the user request logic, initiates a database request according to the user request, intercepts the database request by the interceptor II, acquires the test account identification which is added by the interceptor I and corresponds to the user from the cache in the interceptor II, adds the test account identification to the database request, and then sends the database request to the database middleware;
(4) analyzing a test account identifier in the database request by the database middleware, and forwarding the database request to a corresponding common database or a test database according to the test account identifier;
(5) the database operates the data in the database according to the database request, returns result information, sequentially passes through the database middleware and the server, and finally returns the result information to the user.
Further, if the user is in a non-login state, the test account of the user stored in the cache of the interceptor I is identified as a common user account by default.
Further, the method is realized through Java language, test account identification is set in Threadlocal in the interceptor I and the interceptor II, and Threadlocal is used as cache.
Further, the database middleware adopts the MyCat, the database middleware can adopt the MyCat cluster under the concurrent request of large data volume so as to improve the throughput of projects, and the MyCat is relatively perfect in the aspect of processing database transactions.
Furthermore, the cache adopts a cache middleware Redis, because the data cached in the Redis is stored in the memory, the adding and deleting efficiency of the data information is high, and the expiration time can be set for the data cached in the Redis, so that when an exception occurs in the process of requesting execution, the cached data can be automatically deleted through the expiration time, and the safety is improved.
The invention has the advantages and beneficial effects that:
1. the test account number is added into the production environment, so that a tester can test the production environment, and because the real data and the test data are respectively stored in two mutually independent databases through database routing, the accuracy and the authenticity of the data are ensured.
2. In the process of testing, because resources except the database are shared on the test and the line, the problem caused by non-program factors caused by environment difference in actual test is reduced.
3. In the aspect of resources, the introduction of the test account reduces resource waste caused by resource environment deployment, further saves cost, and reduces workload caused by deployment of various environments by testing and operation and maintenance personnel.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
FIG. 1 is a diagram of a project model according to one embodiment of the present invention;
fig. 2 is a flowchart of a method for implementing a test account based on database routing according to an embodiment of the present invention.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in detail below.
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present invention, but the present invention may be practiced in other ways than those specifically described and will be readily apparent to those of ordinary skill in the art without departing from the spirit of the present invention, and therefore the present invention is not limited to the specific embodiments disclosed below.
As shown in fig. 1 and 2, the present invention provides a test account implementing method based on database routing, which includes the following steps:
(1) the method comprises the following steps that an interceptor I and an interceptor II are arranged at a server side, a database middleware, a common database and a test database are deployed, and the common database and the test database are connected with the database middleware; adding a test account identification in user information of a user system for distinguishing a common user account from a test user account;
(2) when a user initiates a request to a server, firstly, intercepting the user request through an interceptor I, requesting user information from a user system in the interceptor I, acquiring a test account identifier in the user information, thereby distinguishing the type of the user, and storing the test account identifier in a cache;
(3) the server side processes the user request logic, initiates a database request according to the user request, intercepts the database request by the interceptor II, acquires the test account identification which is added by the interceptor I and corresponds to the user from the cache in the interceptor II, adds the test account identification to the database request, and then sends the database request to the database middleware;
(4) analyzing a test account identifier in the database request by the database middleware, and forwarding the database request to a corresponding common database or a test database according to the test account identifier;
(5) the database operates the data in the database according to the database request, returns result information, sequentially passes through the database middleware and the server, and finally returns the result information to the user.
Specifically, if the user is in a non-login state, the test account of the user stored in the cache of the interceptor I is identified as a common user account by default.
Specifically, the method is realized through Java language, test account identification is set in Threadlocal in an interceptor I and an interceptor II, and Threadlocal is used as cache.
Specifically, the database middleware adopts the MyCat, and the database middleware can adopt a MyCat cluster under a large data volume concurrent request so as to improve the throughput of a project, and the MyCat is relatively perfect in the aspect of processing database transactions.
Specifically, by adopting the cache middleware Redis, since the data cached in the Redis is stored in the memory, the adding and deleting efficiency of the data information is high, and the expiration time can be set for the data cached in the Redis, so that when an exception occurs in the process of requesting execution, the cached data can be automatically deleted through the expiration time, and the security is improved.
Example 1
The embodiment is an e-commerce platform-like project. The user roles are divided into four types: administrators, merchant users, customer users, and unregistered guest users. The account types of the users are divided into two types, namely six types which are common user accounts: the method comprises the steps that an administrator common user account, a merchant common user account and a customer common user account are obtained; testing a user account: the administrator tests the user account, the merchant tests the user account, and the customer tests the user account. The platform administrator is mainly responsible for user management of the platform, management of all orders and commodity information, data information classification statistics and the like. The merchant user is mainly responsible for managing the order and commodity information placed by the merchant. The customer user is a consumer, browses the commodities sold by the merchant and places an order according to the demand. The unregistered tourist user is a consumer who does not perform account login, browses commodities, selects the commodities according to the requirement of the consumer, and then registers and purchases the commodities on the platform. The test user account is an account used by an insider in development test of a project, and the stability of the project is ensured by testing problems in the project by using the test user account.
And the merchant user logs in the system by using the test user account password and the common user account password respectively, adds commodity information in the system and shelves newly-added commodities.
The customer user logs in the system by using the test user account password and the common user account password respectively, only the commodity information added by the merchant test user account can be inquired after the customer test user account enters the system, and the commodity information added by the merchant common user account cannot be inquired. After entering the system by using the common user account of the customer, the system can only inquire the commodity information added by the merchant user account with the same type as the current user account.
And the administrator logs in the system by using the test user account password and the common user account password respectively, and the checked commodity information and the order information are only commodity information added to the merchant user account with the same type as the current user account and order information submitted by the consumer user account with the same type as the user account. The same is true in data information classification statistics.
The user of the tourist who does not log in enters the system to check the commodity information under the condition that the user does not log in the account, and only can inquire the commodity information of the merchant who has the user type of the common user account and is on the shelf.
The above description is only for the purpose of illustrating the preferred embodiments of the one or more embodiments of the present disclosure, and is not intended to limit the scope of the one or more embodiments of the present disclosure, and any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the one or more embodiments of the present disclosure should be included in the scope of the one or more embodiments of the present disclosure.

Claims (5)

1. A test account number implementation method based on database routing is characterized by comprising the following steps:
(1) the method comprises the following steps that an interceptor I and an interceptor II are arranged at a server side, a database middleware, a common database and a test database are deployed, and the common database and the test database are connected with the database middleware; adding a test account identification in user information of a user system for distinguishing a common user account from a test user account;
(2) when a user initiates a request to a server, firstly, intercepting the user request through an interceptor I, requesting user information from a user system in the interceptor I, acquiring a test account identifier in the user information, thereby distinguishing the type of the user, and storing the test account identifier in a cache;
(3) the server side processes the user request logic, initiates a database request according to the user request, intercepts the database request by the interceptor II, acquires the test account identification which is added by the interceptor I and corresponds to the user from the cache in the interceptor II, adds the test account identification to the database request, and then sends the database request to the database middleware;
(4) analyzing a test account identifier in the database request by the database middleware, and forwarding the database request to a corresponding common database or a test database according to the test account identifier;
(5) the database operates the data in the database according to the database request, returns result information, sequentially passes through the database middleware and the server, and finally returns the result information to the user.
2. The method of claim 1, wherein if the user is in a non-login state, the test account of the user stored in the cache of the interceptor I is identified as a normal user account by default.
3. The method according to claim 1, wherein the method is implemented by Java language, and the test account id is set in ThreadLocal in interceptor i and interceptor ii, and ThreadLocal is used as cache.
4. The method of claim 1, wherein the database middleware employs MyCat, and wherein the database middleware may employ MyCat clustering under large data volume concurrent requests to improve project throughput.
5. The method according to claim 1, wherein the cache adopts a cache middleware Redis, since the data cached in the Redis is stored in the memory, the efficiency of adding and deleting data information is high, and the data cached in the Redis can be set with an expiration time, so that when an exception occurs in the process of requesting execution, the cached data can be automatically deleted through the expiration time, and the security is improved.
CN202111485228.0A 2021-12-07 2021-12-07 Test account number implementation method based on database routing Pending CN114138839A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111485228.0A CN114138839A (en) 2021-12-07 2021-12-07 Test account number implementation method based on database routing

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111485228.0A CN114138839A (en) 2021-12-07 2021-12-07 Test account number implementation method based on database routing

Publications (1)

Publication Number Publication Date
CN114138839A true CN114138839A (en) 2022-03-04

Family

ID=80384658

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111485228.0A Pending CN114138839A (en) 2021-12-07 2021-12-07 Test account number implementation method based on database routing

Country Status (1)

Country Link
CN (1) CN114138839A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116630034A (en) * 2023-07-21 2023-08-22 杭银消费金融股份有限公司 Wind control data processing system and method

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116630034A (en) * 2023-07-21 2023-08-22 杭银消费金融股份有限公司 Wind control data processing system and method
CN116630034B (en) * 2023-07-21 2023-11-07 杭银消费金融股份有限公司 Wind control data processing system and method

Similar Documents

Publication Publication Date Title
US10135936B1 (en) Systems and methods for web analytics testing and web development
US8745088B2 (en) System and method of performing risk analysis using a portal
CN104572122A (en) Software application data generating device and method
CN109933514B (en) Data testing method and device
CN104424360A (en) Method and system for accessing a set of data tables in a source database
CN109831357B (en) Service verification method, device, storage medium and server
CN113242157B (en) Centralized data quality monitoring method under distributed processing environment
CN104899134A (en) Automatic domain name registration server testing system and method
CN114138839A (en) Test account number implementation method based on database routing
CN114817022A (en) Railway electronic payment platform test method, system, equipment and storage medium
CN113127356A (en) Pressure measurement method and device, electronic equipment and storage medium
CN106874371A (en) A kind of data processing method and device
CN115757995A (en) Method and device for processing characteristic-free data label, computer equipment and storage medium
CN115204733A (en) Data auditing method and device, electronic equipment and storage medium
CN115454851A (en) Interface regression testing method and device, storage medium and electronic device
CN110061864B (en) Method and system for automatically verifying domain name configuration
CN113238940A (en) Interface test result comparison method, device, equipment and storage medium
CN113656314A (en) Pressure test processing method and device
CN114143236A (en) Business system testing method and device, electronic equipment and readable storage medium
CN113918534A (en) Policy processing system and method
CN110650063A (en) Centralized bank third-party software simulation system and method
CN112765128B (en) REPL-based data development method, system and electronic equipment
CN116401319B (en) Data synchronization method and device, electronic equipment and computer readable storage medium
Rafay Performance analysis/measurements with Cassandra and HBase
Günaydın et al. MARKA: A Microservice Architecture-Based Application Performance Comparison Between Docker Swarm and Kubernetes

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