1

I have a REST Service method and need to load test it. Unfortunately i don't have admin rights to my laptop and can not install/download any tool.

Need to know the capacity of the REST service (web project in tomcat) like how many concurrent requests it can handle. I don't require any other information or details.

Here are some details about the REST api:

Method: POST
Technology: Spring MVC
Response object is very complex and huge form, requiring 100's of objects.

Is there any way to do it using core java application (post to a REST URL, get the response, and find maximum concurrent requests supported by API)

In core java i can use apache http, spring or core java 7/8

Amit Mahajan
  • 895
  • 6
  • 34
  • Format a REST request and send it using **curl** commands to the REST URI. Alternatively, you could also use Chrome extensions which help you use REST clients to interact with a REST URI. – worker_bee Jul 18 '17 at 18:52
  • ok, how do i send multiple requests at same time? – Amit Mahajan Jul 18 '17 at 18:53
  • can you show an example for curl from java? and will it work for post? – Amit Mahajan Jul 18 '17 at 18:54
  • why does it have to be from Java? You could use a linux client for this. I assume that the web application is in Java (which you want to test). – worker_bee Jul 18 '17 at 18:56
  • Anyways, for using it with any linux machine (without installing any tools), curl would suit your need. Here are examples for it: http://www.codingpedia.org/ama/how-to-test-a-rest-api-from-command-line-with-curl/ – worker_bee Jul 18 '17 at 18:57
  • No i have windows 7 laptop :( – Amit Mahajan Jul 18 '17 at 19:28
  • Its not my choice to have windows in company laptops, unfortunately most of the companies provide windows laptops :( , i wish they have debian pre-installed everywhere. – Amit Mahajan Jul 18 '17 at 19:29
  • Here's a discussion which talks about using REST clients with Java: https://stackoverflow.com/questions/221442/rest-clients-for-java – worker_bee Jul 18 '17 at 19:30
  • This is not regarding rest client, i think client for single request is not an issue. My requirement is more towards load testing. – Amit Mahajan Jul 18 '17 at 20:45
  • You said you cannot download or install any tool. Does that include jars / libraries? Maven dependencies? I'm asking because there's http://grinder.sourceforge.net/ written in java – maydawn Jul 18 '17 at 21:03
  • Yes even jars, our firewall blocks the download. Anyways i am trying one core java program to flood with REST requests using java URLConnection and java 7 executor service – Amit Mahajan Jul 18 '17 at 21:11

1 Answers1

0

I am able to do load testing using following code using java 7 Executors and URLConnection :

public class POSTProcessor {

    class ManagedProcessor implements Callable {

    public void postMessage() {
        //Test execute single call for REST web service with URLConnection
    }

    @Override
    public Object call() throws Exception {
        postMessage();
        return null;
    }

    }

    public static void main(String[] args) {
        long time1 = System.currentTimeMillis();
        int size = 200;
        ExecutorService loadExecutor = Executors.newFixedThreadPool(size);      
        POSTProcessor threadRunner = new POSTProcessor();
        List jobs = new ArrayList();
        for(int i=0;i<size;i++){
            ManagedProcessor exec = threadRunner.new ManagedProcessor() ;
            jobs.add(exec);
        }
        try {
            loadExecutor.invokeAll(jobs);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        long time2 = System.currentTimeMillis();

        System.out.println("Time delay: " + ( (time2 - time1)/size));
        loadExecutor.shutdown();
    }
}
Amit Mahajan
  • 895
  • 6
  • 34