eolexe / campaigner Goto Github PK
View Code? Open in Web Editor NEWTest exercise
Test exercise
The Test Process
Preparation
Generate 1000 campaigns with the “Campaign generator”, X=50,Y=10,Z=1000, the output file is downloadable.
Import the above data to the server app with data struct or database to make the searching provision ready.
Case A:
POST an user to “http://localhost:3000/search” to verify the search result
Case B:
Use “wrk” (github.com/wg/wrk) to do the performance test
wrk -c 64 -d 10s http://localhost:3000/search_auto
[POST] http://myhost:3000/search
Create an API for campaign searching with user info.
The request will POST a user info, and return the searching result.
Input should be the same as output of the User Generator endpoint: #2
[GET] http://myhost:3000/user
Create a API for user generation.
This endpoint will return a user info defined as following.
There’s a counter for request (starts with 0), each request will increase the counter by 1.
Create a function to generate the following user info when it receive a request.
"user": “u”+counter,
"profile":[
"attr_A" : "A" + random(200)
"attr_B" : "B" + random(200)
...
]
The length of the profile will be increased by 1 everytime when a new user is generated. The attribute name and value contained in the profile need to follow the alphabet order, such as [“attr_A” : “A1”], [“attr_B” : “B23”], etc. When the profile length reaches its maximum length of 26, it gets reset to 1 again, which means it only contains “attr_A”.
The 1st user
{
"user": “u1”,
"profile":[
"attr_A" : "A1"
]
}
The 3rd user
{
"user": “u3”,
"profile":[
"attr_A" : "A23"
"attr_B" : "B132"
"attr_C" : "C45"
]
}
The 27th user
{
"user": “u27”,
"profile":[
"attr_A" : "A109"
]
}
The 28th user
{
"user": “u28”,
"profile":[
"attr_A" : "A109"
"attr_B" : "B87"
]
}
[GET] http://myhost:3000/campaign?x={number}&y={number}&z={number}
The generator has parameters: X (X <= 100) , Y (Y =< 26), Z (Z <= 10000)
Generate Z number of campaigns, each campaign has a target list (length is random and less than Y).
The target has an attribution list (length is random and less than X).
Each campaign has an offer price, which is randomly generated.
Here is a sample output JSON file:
[
{
"compaign_name": "campaign870",
"price":3.25
"target_list" : [
{"target":"attr_A", "attr_list":["A0",...,"A99"]},
{"target":"attr_B", "attr_list":["B0",...,"B36"]},
...
]
},
...
]
GET http://myhost:3000/search_auto
The request for the search API will trigger the function to create a user in step 2 and pass the user to the search function, if the user is a “Targeted User”, then Find the the campaign that has the HIGHEST price, otherwise return “none”.
[POST] http://myhost:3000/import_camp
Create a API to import the campaign data (JSON file) generated by step 1 (#1) , then save them in some data struct or database.
Create a matcher logic that will search through the data persisted in the application using #3 and return the campaign that will best fit to the input data.
Input data of the matcher should be the user profile data, same as generated here #2
Assume there’s 2 campaigns:
{
"compaign_name": "campaign1",
"price":0.25
"target_list" : [
{"target":"attr_A", "attr_list":["A0",...,"A9"]},
{"target":"attr_B", "attr_list":["B0",...,"B16"]},
]
},
{
"compaign_name": "campaign2",
"price":0.35
"target_list" : [
{"target":"attr_A", "attr_list":["A0",...,"A19"]},
]
}
To help you understanding the abstract model, let’s assume some campaign targeting {attr_A = “country”, attr_list=[“US”,“UK”,...]}, {attr_B= “hobby”, attr_list = [“football”,“fishing”,“sports”]}.
gracefull shutdown?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.