JMeter Parallel Controller having two transaction controller issue - jmeter

I have a Parallel controller and inside this I have 2 transaction controllers.
My one transaction controller passes but other one throws an assertion error.
But in response tree, both transaction controller shows as fail through all steps in the first controller is pass.
Is this due to parallel controller?

It's part of Parallel Controller limitations:
Parallel Controller does not support work with Transaction Controller so if used you can get an unexpected results. If you decide to use these controllers together familiarize yourself with already known problems that described in roadmap

Related

Should we use #Scheduled together with controller method (like #PostMaping) in SpringBoot?

I'm using SpringBatch but I cant find any document or tutorial about Spring's #Scheduled , showing it being used along side with some controller method (annotated with #GetMapping, #PostMapping).
For example, I have this controller method
#Scheduled(cron = "0 */5 * ? * *")
#PostMapping("/create-progress-data")
public ResponseEntity<?> createSomething(#Request Something request) { }
I can easily create another method that do the same thing as in the body of createSomething then put it in a #Component or a Service, but between doing that and just applying #Scheduled on top of the controller method, I don't know which one is better.
I can see that:
Using #Scheduled : code is minimal, works just find. But we're kind of using the controller method in the wrong way. However I don't see it violates Single responsibility point in design pattern.
Create another method and put it in other #Component or #Service: separate the duty of the controller method and the cron job but duplicate the code.
Ps: I need to implement it like this because we need to support two ways to trigger the job. Either via api call (controller method), or periodically (with #Scheduled).
Please notice in this case the code of controller method and the expected cron job is the same.
I believe it is better to separate the two ways of launching your jobs. You can use the controller for API-based on-demand job launches, and use the #Scheduled way for a background process that launches jobs on the defined schedule.
That said, you should take into consideration the concurrency policy for your job definitions. For example, what should your system do if a job launch request comes through the API and tries to launch the same job that has been launched by a schedule (which could be running at that time)?. There are other use cases, but those depend on your requirement.

In Jmeter is there a listener that will just report the Transaction Controller Responses?

When I run tests and look at the aggregate report, I'm getting the Transaction Controllers as well as the actual calls within the controller.
Is there a way to get a listener/report that will just use the transaction controller response time?
summary report will provide transaction controller response times
Note : you have to select generate parent sample in translation controller
Make sure "Generate parent sample" is checked under "Transaction Controller" element.
You should see the expected result

Understanding transactions in Spring Test

I have a little bit trouble with Integration Test and the transactions.
I have a Rest Service System. Behind all I have a JPA-Repository, with a Postgres database. Now to test them I build JunitTest where I made the calls on the System. The test loads the web-context and an other xy-context where I have the configuration of security and database connections. On the test method I have the #Transactional annotation.
The test makes 2 requests (This is only one example I have more of similar scenarios on other Object):
insert a new user
on this user create a Group and after bind this to the user
The test makes the first call, and returns me a id where I use to perform the second call.
The second call take the id and make the post and there I have several problems.
Details of the second call:
Test make a post on a controller
Controller takes the request and forward it to the Service
Service method (with #Transactional) take the request and do:
a research to find the inserted user
insert a group object
update the user with the groupId (generated on point 2)
Now one of the problems I had, it was a AccessDeniedException on point 3.1, because I have also ACL, and I have to check if there are enough permissions.
One of the things that I tried to do is to set:
#Transactional(propagation=Propagation.REQUIRES_NEW)
on the Service Method.
What I get after is the result that the AccessDeniedException was disappeared but the research at 3.1 gives me empty result (the research is ok, because on other scenario I have correct results), but is strange because the first post was ok, and how I understand Spring handles the #Transactions and "commits" to database so that a commit is performed when a transaction is closed. This brings me to an other idea to try: remove the #Transaction annotation on the test, but when i made this, then the database has all the data of this scenario until the end of the tests session (If you have a lot of test this is not desirable), and this is not a very good thing.
Now I wrote a little bit where are my doubts, and problems without posting a lot of code and of privacy problems, but on request I can post little pieces of codes.
It's also probable that the approach is incorrect.
The questions are:
-how can I make this service work?
-It's the correct way to set (propagation=Propagation.REQUIRES_NEW)?
-It's the correct way to set #Transactional on the test? (eventually with a Rollback?)
Txs a lot.
To make test I use mockMvc to make the request and some annotation on the class:
#RunWith(SpringJUnit4ClassRunner.class)
#WebAppConfiguration
#ContextConfiguration(locations = { ..... })
#Transactional
public class tests {
#Test
public void aTest(){
mockMvc = MockMvcBuilders
.webAppContextSetup(webApplicationContext)
.addFilter(new DelegatingFilterProxy("springSecurityFilterChain", webApplicationContext), "/*")
.build();
mockMvc.perform(post(.....))
}
}
To answer your question:
It's the correct way to set #Transactional on the test? (eventually with a Rollback?)
No really, but you can. Because you are doing two requests, the second depends on the first, and http request will not remember your transaction, if you insist to do it, you need flush your session between requests.
It's the correct way to set (propagation=Propagation.REQUIRES_NEW)?
It depends. REQUIRES_NEW means it will start new transaction, the influence is that everything in the existing transaction will be invisible in the new transaction, because the old one is not commited yet! if this server is the entry point of the transaction, it makes no difference, but be aware of the visibility problem.
how can I make this service work?
OK, forget what my answers of the previous questions. If I have to write the test, I will do it this way:
The test is not transactional. If you are doing integration test, you don't need to rollback single tests. If you wanna rollback the commit, then you are having wrong task case, you should have two test cases insert user and update group.
3 parts of the test
Send request to insert user and get the ID (single transaction)
Send request to update group(another transaction)
Send request to fetch the user and do the checks.
Hope this can help you.

JMeter - Requests not getting grouped within controllers in graph output

In my test plan I have a series of steps like Login, HomePage, DoSearch, DoTask, Logout and each has a number of HTTP requests. I have tried using Simple Controllers, Transaction Controllers, keeping transaction controllers within simple controllers, and vice versa but am unable to see the timings at a step level in any graph. It at the most shows me the timings for Login, but other requests are not grouped on either controllers. Tried checking "Generate Parent Sample" and "Include duration..." but no luck.
Can someone let me know what needs to be done here?
You need to add a Listener. Each listener provides different information. I usually just use aggregate report.

Error handling in mvc3 when view is made of many partial views

I have a MVC3 razor application. I have views which are made of multiple partial views. Controller will have to load the data to all the partial views with the help of different service calls.
Now if any of the service call fails, the entire view should not fail - it should continue to show other partial views. and should show error message for the partial view which failed.
Please note here that I do not want to add individual try catch blocks all over the code. Is there any way to achieve this using global error handling?
If loading data for those partials is an I/O intensive task such as network service calls and order is not important (can be done in parallel) => asynchronous controllers seems like a good fit for your scenario. You could register multiple asynchronous operations in the controller action and upon success/failure load the corresponding result/error message into the view model.
One easy alternative here is simply include multiple ajax calls to load the partial views on the client side. If one fails, no problem as it is it's own separate request. Use jQuery's .get() method once your document loads. You can then include multiple wait images and handle each error separately - however you want.

Resources