I've been testing GET endpoints using Gatling Simulations for a while now and have now come across a situation where I need to performance test a DELETE endpoint. When I do integration tests, I can pre-populate the database before each test, then call the DELETE endpoint and have the entry deleted. I believe that for Gatling performance tests there is only a before and after hook for simulations not individual tests.
Any ideas on how I should approach performance testing a DELETE endpoint so that each test has something to delete instead of returning an error that the value does not exist in the database. Or should I just expect the error responses and record timings of those?
Many thanks,
Kris
Related
The developers at my company are in the process of incorporating VSTS into our testing. I am developing unit tests for our code, using the VSTS Rest API to post the results of the tests, grouped in test runs.
My problem is that I am unable to update the test run to show the number of failed tests and the correct pass rate. My demonstration code uses four unit tests, with 3 passing results and 1 failing result. On the page of test runs, it shows 0 Failed tests and a 0% Pass Rate.
Internet searches haven't yielded any information on how those fields are set or calculated. I've done some searching in the documentation for the REST API in the hopes that I would just need to set a certain field when calling the endpoints. Although the Failed Tests and Pass Rate fields are returned as part of the update call, it doesn't seem like you can set those fields directly for a test run. I haven't found any alternate endpoints that affect those fields.
https://learn.microsoft.com/en-us/rest/api/vsts/test/runs/update?view=vsts-rest-5.0
So, the question is, in a nutshell: How do I update the Failed Tests and Pass Rate fields for a VSTS Test Run using the REST API?
I am programming in C#, using HttpClients to call the REST API endpoints, and passing the relevant data via JSON. Everything is created and updated properly in VSTS; it is just these two fields that don't seem to be working.
I am having this issue. I am creating the run, adding test results then closing the test run. On the front end my runs look like this:
Test run stats
However all my results show passes within the run like this
Test results
Can't understand why this is the case as the graphs on the test runs are correctly picking up the passes and fails.
I have to admit I'm quite new to unit testing and there is a lot questions for me.
It's hard to name it but I think it's behaviour test, anyways let me go straight to the example:
I need to test users roles listing to make sure that my endpoint is working correctly and returns all user roles assigned to him.
That means:
I need to create user
I need to create role
I need to assign created role to created user
As we can see there is three operations that must be excecuted before actual test and I believe that in larger applications such list can grow to much larger number of operations and even complex.
The question is how I should test such endpoints: should I just insert raw data to DB, write some code blocks that would do such preparations.
It's probably best if you test the individual units of your service without hitting the service itself, otherwise you're also unit testing the WebApi framework itself.
This will also allow you to mock your database so you don't have to rely on any stored data to run your tests or the authorization to your service.
I am going to write a new endpoint to unlock the domain object, something like:
../domainObject/{id}/unlock
As I apply TDD, I have started to write an API test first. When the test fails, I am going to start writing Integration and Unit tests and implement the real code.
In API test, I need a locked domain data for test fixture setup to test the unlock endpoint that will be created. However, there is no endpoint for locking the domain object on the system. (our Quartz jobs lock the data) I mean, I need to create a data by using the database directly.
I know that in API test, straight forwardly database usage is not the best practice. If you need a test data, you should call the API too. e.g.
../domainObject/{id}/lock
Should this scenario be an exception in this case? Or is there any other practice should I follow?
Thanks.
There is no good or bad practice here, it's all about how much you value end to end testing of the system including the database.
Testing the DB part will require a little more infrastructure, because you'll have to either use an in-memory database for faster test runs, or set up a full-fledged permanent test DB in your dev environment. When doing the latter, it might be a good idea to have a separate test suite for end-to-end tests that runs less frequently than your normal test suite, because it will inevitably be slower.
In that scenario, you'll have preexisting test data always present in the DB and a locked object can be one of them.
If you don't care about all this, you can stub the data store abstraction (repository, DAO or whatever) to return a canned locked object.
I am trying to design a RESTful api for a service that accepts a bunch of parameters and generates a large result. This is my first RESTful project. One tricky part is that the server needs some time (up to a few minutes) to generate the result. My current thought is to use POST to send in all the parameters. The server response can be a job id.
I can then retrieve the result using GET /result/{job_id}. The problem is that the result is not available for the first few minutes. Maybe I can return the resource unavailable at the beginning and the result once it is available. But this feels odd and add some odd logic in the client.
An alternative is to retrieve the job status GET /job_status/{job_id}, where the result might be running/error/done, similar to the http status code, where done status also comes with a result_id. Then I can retrieve it with GET /result/{result_id}.
Either case has some problem with what I have read about GET. In both cases, GET result is not fixed and not cacheable at the beginning while the job is still running. On the other hand, I read somewhere that it is OK to do things like GET /currentWhether or Get /currentTime, which are similar to at least my second approach. So my questions are:
Which one is better? Why?
Should I use GET for such situation?
Or neither one is OK? What would you do?
Thank you very much.
Should I use GET?
For long running operations, here is an approach which tells setting expire or max-age headers to your response properly. Here is the example Best practice for implementing long-running searches with REST
But I recommend The RESTy Long-op Protocol for your case.
Your solution will be more robust and more client friendly.
Is there any way when using the REST API to get the summary of operations that have completed without returning the nodes.
When using the web admin console after doing an operation I get a summary like
1 node inserted
2 relationships inserted
1 node deleted.
In the examples here I notice there is no example of summary information sent back to the client. I would have to return the nodes inserted to know the insert had occurred.
When doing a request over the network often it is a good idea to minimize the data response size. A quick summary would help with this. is it possible to get one from the REST endpoint?
I'm pretty sure this is not possible. It would be a nice addition, though. Have you filed a feature request?