1
1
package api .http .benchmark
2
2
3
3
import com .typesafe .config .ConfigFactory
4
- import hmda .api .protocol .admin .WriteInstitutionProtocol
5
- import hmda .model .institution .Institution
6
4
import io .gatling .core .Predef ._
7
5
import io .gatling .http .Predef ._
8
-
6
+ import scala . concurrent . duration . _
9
7
import scala .language .postfixOps
10
- import spray .json ._
11
8
12
- class FilingSimulation extends Simulation with WriteInstitutionProtocol {
9
+ class FilingSimulation extends Simulation {
13
10
14
11
val config = ConfigFactory .load()
15
12
val host = config.getString(" hmda.benchmark.host" )
16
13
val port = config.getInt(" hmda.benchmark.port" )
17
14
val adminPort = config.getInt(" hmda.benchmark.adminPort" )
18
15
val nrOfUsers = config.getInt(" hmda.benchmark.nrOfUsers" )
19
16
val rampUpTime = config.getInt(" hmda.benchmark.rampUpTime" )
17
+ val feeder = csv(config.getString(" hmda.benchmark.feederFile" ))
20
18
21
19
val institutionIds = (1 to nrOfUsers).toList
22
20
@@ -31,43 +29,34 @@ class FilingSimulation extends Simulation with WriteInstitutionProtocol {
31
29
// .header("cfpb-hmda-institutions", institutionIds.mkString(","))
32
30
.disableCaching
33
31
34
- object InstitutionScenario {
32
+ object Institutions {
35
33
36
- def list (institutionId : String ) = {
37
- exec(http(" Institutions" )
38
- .get(" /institutions" )
39
- .header(" cfpb-hmda-institutions" , institutionId)
40
- .check(status is 200 ))
41
- }
42
-
43
- def create (institutionId : String ) = {
44
- exec(http(" Create Institution" )
45
- .post(s " http:// $host: $adminPort/institutions " )
46
- .body(StringBody (
47
- Institution .empty.copy(id = institutionId, activityYear = 2017 ).toJson.toString
48
- )).asJSON
49
- .check(status is 201 ))
50
- }
34
+ val hmdaFiling =
35
+ feed(feeder)
36
+ .exec(http(" Search" )
37
+ .get(" /institutions" )
38
+ .header(" cfpb-hmda-institutions" , " ${institutionId}" )
39
+ .check(status is 200 ))
40
+ .pause(1 )
41
+ .exec(http(" List Filings" )
42
+ .get(" /institutions/${institutionId}/filings/2017" )
43
+ .header(" cfpb-hmda-institutions" , " ${institutionId}" )
44
+ .check(status is 200 ))
51
45
52
46
def filings (institutionId : String ) = {
53
47
exec(http(" List Filings" )
54
48
.get(s " /institutions/ $institutionId/filings/2017 " )
55
49
.header(" cfpb-hmda-institutions" , institutionId)
56
50
.check(status is 200 ))
57
51
}
52
+
58
53
}
59
54
60
- val listInstitutions = scenario(" List Institutions" ).exec(InstitutionScenario .list(" 4277" ))
61
- val createInstitutions = scenario(" Create Institutions" ).exec(InstitutionScenario .create(" 4277" ))
62
- val listFilings = scenario(" List Filings" ).exec(InstitutionScenario .filings(" 4277" ))
55
+ val user = scenario(" HMDA User" )
56
+ .exec(Institutions .hmdaFiling)
63
57
64
58
setUp(
65
- listInstitutions.inject(
66
- atOnceUsers(1 )
67
- ).protocols(httpProtocol),
68
- createInstitutions.inject(atOnceUsers(1 )).protocols(httpProtocol),
69
- listFilings.inject(atOnceUsers(1 ))
70
- .protocols(httpProtocol)
59
+ user.inject(rampUsers(nrOfUsers) over (rampUpTime seconds)).protocols(httpProtocol)
71
60
)
72
61
73
62
}
0 commit comments