I have written a REST API and now my requirement is to load test it for 1k calls or something. Problem is the request json has an unique attribute - Cnumber which needs to be changed for every request.
json request:
{
"Code": "WEB",
"Pfix": null,
"Name": "Ronaldo",
"Cnumber": "C7"
}
how can I make this request for 1K users concurrently with Cnumber changes in every request?
Depending on what you're trying to achieve:
Incrementing number can be generated using __counter() function like:
{ "Code": "WEB", "Pfix": null, "Name": "Ronaldo", "Cnumber": "${__counter(FALSE,)}" }
Random number can be generated using __Random() function
{ "Code": "WEB", "Pfix": null, "Name": "Ronaldo", "Cnumber": "${__Random(1,2147483647,)}" }
Random alphanumeric string can be generated using __RandomString() function like:
{ "Code": "WEB", "Pfix": null, "Name": "Ronaldo", "Cnumber": "${__RandomString(2,abcdefjhijklmnopqrstuvwxyz0123456789,)}" }
Current thread number: __threadNum() function
{ "Code": "WEB", "Pfix": null, "Name": "Ronaldo", "Cnumber": "${__threadNum}" }
GUID-like structure: __UUID() function
{ "Code": "WEB", "Pfix": null, "Name": "Ronaldo", "Cnumber": "${__UUID}" }
More information on JMeter Functions concept: Apache JMeter Functions - An Introduction
You could use a timestamp...
{ "Code": "WEB", "Pfix": null, "Name": "Ronaldo", "Cnumber": "C${__time}" }
Cnumber with timestamp example image
Related
I have 2 topics to receive data from API, those I can Successfully executed through code. Now I'm trying to execute through rest api using postman tool. now i'm getting InvalidRequestException. Before attempting request I fetched the external tasks using camunda get external-task api and my topics showing there.Later I tried to use /external-task/fetchAndLock API to send input variables.
External tasks response is:
http://localhost:8080/engine-rest/external-task
[
{
"activityId": "Activity_0jokenq",
"activityInstanceId": "Activity_0jokenq:0623e6f2-4837-11ec-8c7e-02426d005d3a",
"errorMessage": null,
"executionId": "0623e6f1-4837-11ec-8c7e-02426d005d3a",
"id": "0623e6f3-4837-11ec-8c7e-02426d005d3a",
"lockExpirationTime": null,
"processDefinitionId": "Process_0qcjqnm:1:da2ae20a-4836-11ec-8c7e-02426d005d3a",
"processDefinitionKey": "Process_0qcjqnm",
"processDefinitionVersionTag": null,
"processInstanceId": "0623bfdb-4837-11ec-8c7e-02426d005d3a",
"retries": null,
"suspended": false,
"workerId": null,
"topicName": "yvalue",
"tenantId": null,
"priority": 0,
"businessKey": null
},
{
"activityId": "Activity_1xxpyet",
"activityInstanceId": "Activity_1xxpyet:0623e6f6-4837-11ec-8c7e-02426d005d3a",
"errorMessage": null,
"executionId": "0623e6f5-4837-11ec-8c7e-02426d005d3a",
"id": "0623e6f7-4837-11ec-8c7e-02426d005d3a",
"lockExpirationTime": null,
"processDefinitionId": "Process_0qcjqnm:1:da2ae20a-4836-11ec-8c7e-02426d005d3a",
"processDefinitionKey": "Process_0qcjqnm",
"processDefinitionVersionTag": null,
"processInstanceId": "0623bfdb-4837-11ec-8c7e-02426d005d3a",
"retries": null,
"suspended": false,
"workerId": null,
"topicName": "testingtopic",
"tenantId": null,
"priority": 0,
"businessKey": null
}
]
my request is:
POST http://localhost:8080/engine-rest/external-task/fetchAndLock
{
"workerId": 1,
"maxTasks": 100,
"topics": [
{
"topicName": "testingtopic",
"lockDuration": 100000,
"variables": {
"a": {
"value": 1,
"type": "long"
},
"b": {
"value": 2,
"type": "long"
},
"id": {
"value": 1,
"type": "long"
}
}
}
],
"asyncResponseTimeout": 5
}
my BPMN diagram is:
Sorry mistake was mine I mentioned wrongly in request body. I mentioned
"variables": {}
But it's a array of json "variables": []
I mentioned here just variable names "variables": ["a","b","id"]
Later I used POST /external-task/{id}/complete request to pass with values to complete the process
I have started using the dropwizard to develop a REST server. The Issue as long resource-method return an EntityType (say Enrolment), the out put is as expected but I have decided to send custom status codes using the below code
Response.status(Response.Status.PRECONDITION_FAILED)
.entity(Entity.json(new enrolment, AdapterResponseStatus.FAILURE)))
.build();
Everything is fine but the out put now contains a few more extra extra attributes as shown below.
{
"entity":
{
"id": 1267,
"courseId": "5798890",
"userName": "user#abc.com",
"tenantId": "tenant1",
"status": "approved",
"link": "/enrollments/null"
},
"variant":
{
"language": null,
"mediaType":
{
"type": "application",
"subtype": "json",
"parameters":
{
},
"wildcardType": false,
"wildcardSubtype": false
},
"encoding": null,
"languageString": null
},
"annotations":
[
],
"mediaType":
{
"type": "application",
"subtype": "json",
"parameters":
{
},
"wildcardType": false,
"wildcardSubtype": false
},
"language": null,
"encoding": null
}
I was expecting "entity" property alone but was getting other attributes. Is there any to get rid of them as no one is going to consuming them?
Those tags appear even if I replace my entity object (enrolment) with an empty string.
If you look at the signature of the ResponseBuilder's entity method, it takes the object directly; unlike Jersey client which requires a special Entity object that coincidentally has annotations and variants fields within.
Change your code to this:
Response.status(Response.Status.PRECONDITION_FAILED)
.entity(new Enrolment())
.build();
I am migrating code to v2.2 of the API and need to separate the clicks/impressions between unique and non unique.
The API docs ask us to pass count and uu as values for the aggregateBy modifier which if i pass uu it returns an error->
/v2.2/appid12345/app_insights/story_impressions?aggregateBy=uu
{
"error": {
"message": "(#100) Param aggregateBy must be one of {COUNT, USERS, TOPK, SUM, USD_SUM, UNKNOWN_USERS}",
"type": "OAuthException",
"code": 100
}
}
But if i pass USERS as the error message states i get json returned
/v2.2/appid12345/app_insights/story_impressions?aggregateBy=USERS
{
"data": [
{
"time": "2015-01-15T08:00:00+0000",
"value": "56"
},
{
"time": "2015-01-16T08:00:00+0000",
"value": "128"
},
{
"time": "2015-01-17T08:00:00+0000",
"value": "196"
},
{
"time": "2015-01-18T08:00:00+0000",
"value": "420"
},
{
"time": "2015-01-19T08:00:00+0000",
"value": "304"
},
{
"time": "2015-01-20T08:00:00+0000",
"value": "176"
},
{
"time": "2015-01-21T08:00:00+0000",
"value": "128"
}
]
}
My questions is- can i assume the USERS value with the modifier returns the unique count? and the COUNT values returns the non unique?
Its been reported to facebook as a bug
https://developers.facebook.com/bugs/412068288957160/
For example, for user:django, the url I want to retrieve thru github-api is not
https://github.com/django
but
http://www.djangoproject.com/
as shown below in the red ellipse:
The user search api does not return this url in the response.
The Data that returns from the service would be as follows:
https://api.github.com/users/django
{
"public_gists": 0,
"type": "Organization",
"followers": 240,
"login": "django",
"created_at": "2008-10-06T19:43:18Z",
"html_url": "https://github.com/django",
"avatar_url": "https://secure.gravatar.com/avatar/fd542381031aa84dca86628ece84fc07?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-org-420.png",
"company": null,
"email": null,
"blog": "http://www.djangoproject.com/",
"following": 0,
"name": "Django",
"location": "Internet",
"url": "https://api.github.com/orgs/django",
"id": 27804,
"public_repos": 49
}
As you can see, that URL is in the blog field.
Adding the LIMIT option to an FQL causes MORE results to return than without the LIMIT.
For an example:
SELECT post_id, actor_id, message,description,type FROM stream WHERE source_id = me()
returns 4 results:
{ "data": [
{
"post_id": "1458319848_4164228991531",
"actor_id": 1458319848,
"message": "Oh happy days!",
"description": null,
"type": 46
},
{
"post_id": "1458319848_4081409841104",
"actor_id": 1458319848,
"message": "",
"description": "Caroline Natan and Or Karlinsky are now friends.",
"type": null
},
{
"post_id": "1458319848_4076275592751",
"actor_id": 1458319848,
"message": "",
"description": "Caroline Natan changed her Interested In.",
"type": null
},
{
"post_id": "1458319848_4075703458448",
"actor_id": 100001179537125,
"message": "",
"description": null,
"type": 237
}]}
But using:
SELECT post_id, actor_id, message,description,type FROM stream WHERE source_id = me() LIMIT 9
returns 5 results:
{"data": [
{
"post_id": "1458319848_4164228991531",
"actor_id": 1458319848,
"message": "Oh happy days!",
"description": null,
"type": 46
},
{
"post_id": "1458319848_4081409841104",
"actor_id": 1458319848,
"message": "",
"description": "Caroline Natan and Or Karlinsky are now friends.",
"type": null
},
{
"post_id": "1458319848_4076275592751",
"actor_id": 1458319848,
"message": "",
"description": "Caroline Natan changed her Interested In.",
"type": null
},
{
"post_id": "1458319848_4075703458448",
"actor_id": 100001179537125,
"message": "",
"description": null,
"type": 237
},
{
"post_id": "1458319848_4069875152744",
"actor_id": 100000876758120,
"message": "",
"description": null,
"type": 237
}]}
Of course this DOESN'T MAKE ANY SENSE!
Am I missing something here? if so, what? Also I've read this, I didn't see anything regarding the problem described here.
Thanks in advance.
The article you linked to actually addresses this issue:
You might notice that the number of results returned is not always equal to the “limit” specified. This is expected behavior. Query parameters are applied on our end before checking to see if the results returned are visible to the viewer. Because of this, it is possible that you might get fewer results than expected.
Which basically means that facebook filters the results after it executes the query.
In your example, in the first query, there's an implicit limit, say 5. Out of these 5 results, 1 is filtered out because of visibility restrictions and you get 4.
In the second query, the server gets 10 results, filters 5 of them out based on visibility and returns 5 to you.