2016-09-12 2 views
0

Ich möchte alle 5 Minuten nur 1 api Anruf für "ConsumerApi.RunConsumer" machen. Der 'Flow1' sollte kontinuierlich laufen.Ich möchte nur alle 5 Minuten einen Anruf tätigen. Wie kann ich dies mit Gatling erreichen?

ich ein Szenario Klasse hava:

object ConsumerApi { 
//Defines the Consumer API call 
    val PostConsumerApi = http("Consumer API") 
    .post("http://abc.abc.com/v1/execute") 
    .headers(Headers.applicationJson) 
    .check(status is 200) 


    val RunConsumer = scenario("Run the Consumer") 
    .pace(5 minutes) 
    .exitBlockOnFail { 
     exec(PostConsumerApi) 
    } 
    } 

Dann habe ich die Simulation Klasse:

class TestFlow extends Simulation { 
val httpConfTest = http.baseURL(Environment.apiHost) 
val Scenarios = List(
Flow1.Flow1 
    .inject(constantUsersPerSec(10) during (30 minutes)) 
    // Has to run for 30 minutes continuously. 
, 
ConsumerApi.RunConsumer 
    .inject(constantUsersPerSec(1) during (30 minutes)) 
    // has to make only 1 api call every 5 minutes for duration of 30 minutes 
) 
setUp(Scenarios) 
.protocols(httpConfTest).maxDuration(40 minutes)    .assertions(global.responseTime.max.lessThan(Environment.maxResponseTime.toInt)) 
.assertions(global.failedRequests.percent.lessThan(70))   .assertions(global.responseTime.percentile2.lessThan(Environment.maxResponseTime.toInt)) 

}

Antwort

0

Was ist mit dem folgenden:

ConsumerApi.RunConsumer 
    .inject(atOnceUsers(1), 
      nothingFor(5 minutes), 
      atOnceUsers(1), 
      nothingFor(5 minutes), 
      //And so on... 
    ) 
) 

Das könnte dir will t Einen Blick auf die injection documentation für eine detaillierte Beschreibung der verfügbaren Injektionsbausteine.

Verwandte Themen