tests/arq/src/test/java/org/jboss/test/arquillian/ce/common/EapClusteringTestBase.java
/**
     * This test starts with a high number of pods. We do lots of HTTP requests
     * sequentially, with a delay of 1 second between them.
     * <p>
     * In parallel, after every N requests we scale down the cluster by 1 pod.
     * This happens in another thread and continues until we reach only one pod
     * in activity.
     * <p>
     * The HTTP requests must continue to work correctly, as the openshift
     * router should redirect them to any working pod.
     *
     * @param url route url
     * @throws Exception
     */
This test starts with a high number of pods. We do lots of HTTP requests
sequentially, with a delay of 1 second between them.

In parallel, after every N requests we scale down the cluster by 1 pod.
This happens in another thread and continues until we reach only one pod
in activity.

The HTTP requests must continue to work correctly, as the openshift
router should redirect them to any working pod.

@param url route url
@throws Exception
This test starts with a high number of pods . We do lots of HTTP requests sequentially with a delay of 1 second between them . In parallel after every N requests we scale down the cluster by 1 pod . This happens in another thread and continues until we reach only one pod in activity . The HTTP requests must continue to work correctly as the openshift router should redirect them to any working pod . @param url route url @throws Exception
@Test
    @RunAsClient
    public void testAppStillWorksWhenScalingDown(@RouteURL("eap-app") URL url) throws Exception {
        final int REQUESTS = 100;
        final int REPLICAS = 5;
        final int STEP = REQUESTS / REPLICAS;
        int replicas = REPLICAS;
        adapter.scaleDeployment("eap-app", replicas);
        for (int i = 1; i <= REQUESTS; i++) {
            Response response = get(url.toString() + "cluster1/Hi");
            assertEquals(url.toString() + "cluster1/Hi", 200, response.getStatusCode());
            String body = response.getBody().asString();
            log.info(String.format("Try %d -  GOT: %s", i, body));
            assertTrue(body.startsWith("Served from node: "));
            if (i % STEP == 0 && replicas > 1) {
                replicas--;
                (new ScaleTo(replicas)).start();
            }
            Thread.sleep(1000);
        }
    }
@ Test @ RunAsClient public void testAppStillWorksWhenScalingDown ( @ RouteURL ( "eap-app" ) URL url ) throws Exception { final int REQUESTS = 100 ; final int REPLICAS = 5 ; final int STEP = REQUESTS / REPLICAS ; int replicas = REPLICAS ; adapter . scaleDeployment ( "eap-app" , replicas ) ; for ( int i = 1 ; i <= REQUESTS ; i ++ ) { Response response = get ( url . toString ( ) + "cluster1/Hi" ) ; assertEquals ( url . toString ( ) + "cluster1/Hi" , 200 , response . getStatusCode ( ) ) ; String body = response . getBody ( ) . asString ( ) ; log . info ( String . format ( "Try %d -  GOT: %s" , i , body ) ) ; assertTrue ( body . startsWith ( "Served from node: " ) ) ; if ( i % STEP == 0 && replicas > 1 ) { replicas -- ; ( new ScaleTo ( replicas ) ) . start ( ) ; } Thread . sleep ( 1000 ) ; } }
This test starts with a high number of pods.
This test starts with a high number of pods .
// Number of HTTP requests we are going to do // Initial number of replicas, will decrease over time until 1 // Decrement the number of replicas on each STEP requests // Setup initial state // Do the requests