I am using fiddler core to inject headers on web requests.
The tests run fine with a single thread. However when running the tests with multiple threads. The tests fails.
Its seems that fiddler core is not able to handle multiple instances.
Any ideas?
FiddlerCore, by design, operates on multiple network requests in parallel. The most likely explanation is that your own code inside FiddlerCore isn't threadsafe.
Related
We have migrated/refactored one of our micro-service from request per thread model (sync) to Reactive (async). Development is complete and started stress testing the reactive service. We are looking for the help on how to perform the activity for reactive APIs
What we have done?
Our service makes HTTP call for an external service. During our stress test, we mocked the external service call. Instead of making a network call, we introduced delay using Thread.sleep() method and returning mock response in our service component(where we make actual HTTP call to the external service).
With this approach, we are observing our reactive service is getting crashed even with very small requests volume. Just to add, we follow similar approach while testing other sync services (request per thread model).
What can we try next?
To have infrastructure closer to what will be live environment, I would suggest to run separate mock server, preferably on separate machine, so it will not steal resources from your service.
You can do it easily with wiremock - see running as standalone page.
When you run wiremock as proxy, you can record and playback real requests from your service.
To make this mock more real, you can add delay for mock responses - it will simulate external service "processing time".
reactive services have a very small thread pool which is optimized to be utilized at 100%.
If you introduce something blocking like Thread.sleep() you are basically removing this ability. What makes reactive, "reactive" is its ability to switch execution threads if something is blocking.
Thread.sleep() holds the thread where it is, and it cant switch to doing something else, basically crippling its entire functionality.
You should never Thread.sleep() in a reactive application, unless you are using OnSubscribe and placing each call on a separate scheduler, which in turn sort of makes your reactive application "non-reactive" and instead fallbacks to default standard servlet application behavior.
We have lot many vendors and not all have sandboxed environments made available to test integration.
I was looking to mock them and thus would host them myself, we are using karate extensively as our BDD tool.
How can multiple mock services be hosted using single project?(Multiple Feature files)
How can I achieve different hostname for different mock services?
Can it be used as a regular server running for long?
Similar question : Using mocks in Karate DSL feature file with stanalone run
How can multiple mock services be hosted using single project
Refer the answer you linked. Use Java code for the best way to start multiple mocks.
How can I achieve different hostname for different mock services?
Normally you change your services config to point to where the mock is running, typically localhost + : + portNumber - also refer the docs on using Karate as am HTTP proxy, and also search the net on modifying etc.hosts entry if needed.
Can it be used as a regular server running for long?
Keep in mind that Karate is a "mock" :) but if you don't keep adding data to what is in-memory it should be fine. No guarantees though :P
I have a spring boot project with websocket and I want to test the project sending multiple request to the socket from different users. I want to use threads to imitate the users that send data from the web app but I don't know exactly how to make the test. Can anyone help me, and show one simple test for an websocket using threads?
You can use JMeter for testing your websocket project.
For further reading:
https://www.blazemeter.com/blog/websocket-testing-apache-jmeter
http://www.baeldung.com/websockets-spring
Good example:
https://github.com/Fyro-Ing/JMeter-WebSocket-StompSampler
When writing a Spring Boot application using STOMP on websockets, I struggled a lot to find out how to configure a test client.
I ended up writing a little library called Jackstomp to make it easier to create type-safe tests for STOMP WS applications using JSON as message body.
I haven't used it with multiple threads, but you should be able to easily use it within each thread to create independent clients for each user and perform basic operations. (Please note that a different client should be used in each thread).
The point is that you can really express a synchronous flow for each client, including actively querying for received events.
Even if you don't use this library, you can look at the code to get a grasp of the different things to setup.
I have REST web service which needs to be tested. I am using Mockito for mocking DAO classes and RestAssured for testing REST methods through URI. Is there any way to test REST service without running it separately with Tomcat? Or how to run application on Tomcat with mocked classes before test cases?
There is a tutorial that shows you how to use maven to start an embedded instance of tomcat and run tests against your service using RestAssured:
http://www.hascode.com/2011/09/rest-assured-vs-jersey-test-framework-testing-your-restful-web-services/
You start tomcat in one shell and run your tests in another.
However, I strongly recommend using the jersey test framework which transparently spins up an embedded container. In this case you wouldn't use RestAssured at all, but the jersey test client. Your tests will run more quickly and with less fuss. It's well documented here: https://jersey.github.io/documentation/latest/test-framework.html. The tutorial also demonstrates this approach, though it doesn't seem to me that the client is correctly constructed.
In the past I've also tested REST resources by calling the implementing class methods directly. Though this doesn't test the correct mapping of the http query parameters/body to java method parameters, it was often sufficient (especially when I'm also coding the client side code).
I want to load test an application having its own WCF service using Visual Studio 2012. I tried creating a web performance test and use it with load test but, web performance is not recording the intermediate request send to service which is very much required.
Using CodedUI with it not feasible since it does not put on that much load and and its interactive.
The application is on different server and service too.
Any suggestion to accomplish this in VS2012.
Use dedicated "Unit Tests" for this. VS Load Tests can execute Coded UI/Web Performance or Unit Test.
In your Unit Tests, simply use a standard WCF proxy, channelfactory or RestClient.
Just check that you dispose well a Web Service Proxy class