package com.bedatadriven.appengine.cloudsql;

import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response;


public class SlowQuery implements Runnable {
    private WebTarget root;

    public SlowQuery(WebTarget root) {
        this.root = root;
    }
    
    @Override
    public void run() {
        while(true) {
            Response response = root
                    .path("greetings/latest")
                    .queryParam("maxResults", 50000)
                    .request()
                    .get();

            if (response.getStatus() != 200 && response.getStatus() != 503) {
                System.out.println("Slow query brought VM down.");
                System.exit(-1);
            }
            try {
                Thread.sleep(200);
            } catch (InterruptedException e) {
                System.out.println("SlowQuery interrupted, stopping.");
                return;
            }
        }
    }
}

@@ -616,89 +616,38 @@
     
-System.out.println(%22Slow query brought VM down.%22);%0A                System.exit(-1
+RequestSubmitter.FAILURES.inc(
 );%0A 

Allow up to 10 failed requests during SlowQuery test