remove lombok, update scripts threads
This commit is contained in:
parent
e663f89592
commit
68f35280c3
|
@ -55,11 +55,6 @@
|
|||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
package com.baeldung.loadtesting;
|
||||
|
||||
import com.baeldung.loadtesting.model.Transaction;
|
||||
import com.baeldung.loadtesting.repository.TransactionRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@Deprecated
|
||||
public class TransactionController {
|
||||
|
||||
@Autowired
|
||||
private TransactionRepository transactionRepository;
|
||||
|
||||
@PostMapping(path="/addTransaction")
|
||||
public @ResponseBody
|
||||
String saveTransactions(@RequestBody Transaction trnsctn){
|
||||
transactionRepository.save(trnsctn);
|
||||
return "Saved Transaction.";
|
||||
}
|
||||
|
||||
@GetMapping(path="/findAll/{rewardId}")
|
||||
public @ResponseBody Iterable<Transaction> getTransactions(@RequestParam Integer id){
|
||||
return transactionRepository.findByCustomerRewardsId(id);
|
||||
}
|
||||
}
|
|
@ -5,10 +5,7 @@ import javax.persistence.GeneratedValue;
|
|||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
public class CustomerRewardsAccount {
|
||||
|
||||
@Id
|
||||
|
@ -19,4 +16,18 @@ public class CustomerRewardsAccount {
|
|||
public Integer getCustomerId(){
|
||||
return this.customerId;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setCustomerId(Integer customerId) {
|
||||
this.customerId = customerId;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.baeldung.loadtesting.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
|
@ -10,7 +8,6 @@ import java.util.Date;
|
|||
import java.util.Calendar;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
public class Transaction {
|
||||
|
||||
@Id
|
||||
|
@ -27,4 +24,34 @@ public class Transaction {
|
|||
public void setTransactionDate(Date transactionDate){
|
||||
this.transactionDate = transactionDate;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getCustomerRewardsId() {
|
||||
return customerRewardsId;
|
||||
}
|
||||
|
||||
public void setCustomerRewardsId(Integer customerRewardsId) {
|
||||
this.customerRewardsId = customerRewardsId;
|
||||
}
|
||||
|
||||
public Integer getCustomerId() {
|
||||
return customerId;
|
||||
}
|
||||
|
||||
public void setCustomerId(Integer customerId) {
|
||||
this.customerId = customerId;
|
||||
}
|
||||
|
||||
public Date getTransactionDate() {
|
||||
return transactionDate;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
spring.h2.console.enabled=true
|
||||
spring.datasource.url=jdbc:h2:mem:testdb
|
||||
spring.datasource.driverClassName=org.h2.Driver
|
||||
spring.datasource.username=sa
|
||||
spring.datasource.password=password
|
||||
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
|
||||
|
|
@ -17,7 +17,8 @@ class RewardsScenario extends Simulation {
|
|||
.userAgentHeader("Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0")
|
||||
|
||||
val scn = scenario("RewardsScenario")
|
||||
.repeat(10){
|
||||
.repeat(100){
|
||||
|
||||
exec(http("transactions_add")
|
||||
.post("/transactions/add/")
|
||||
.body(StringBody(_ => s"""{ "customerRewardsId":null,"customerId":"${randCustId()}","transactionDate":null }""")).asJson
|
||||
|
@ -36,14 +37,14 @@ class RewardsScenario extends Simulation {
|
|||
.check(jsonPath("$.id").saveAs("rwdId")))
|
||||
}
|
||||
|
||||
.exec(http("transactions_add")
|
||||
.exec(http("transactions_update")
|
||||
.post("/transactions/add/")
|
||||
.body(StringBody("""{ "customerRewardsId":"${rwdId}","customerId":"${custId}","transactionDate":"${txtDate}" }""")).asJson)
|
||||
|
||||
.exec(http("get_reward")
|
||||
.exec(http("get_transactions")
|
||||
.get("/transactions/findAll/${rwdId}"))
|
||||
}
|
||||
setUp(
|
||||
scn.inject(atOnceUsers(100))
|
||||
).protocols(httpProtocol)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
|
||||
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
|
||||
<boolProp name="LoopController.continue_forever">false</boolProp>
|
||||
<stringProp name="LoopController.loops">10</stringProp>
|
||||
<stringProp name="LoopController.loops">100</stringProp>
|
||||
</elementProp>
|
||||
<stringProp name="ThreadGroup.num_threads">100</stringProp>
|
||||
<stringProp name="ThreadGroup.ramp_time">0</stringProp>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
grinder.script = grinder.py
|
||||
grinder.threads = 100
|
||||
grinder.processes = 1
|
||||
grinder.runs = 10
|
||||
grinder.runs = 100
|
||||
grinder.logDirectory = /logs
|
||||
|
|
|
@ -21,20 +21,24 @@ request1.setHeaders(headers)
|
|||
utilities = HTTPPluginControl.getHTTPUtilities()
|
||||
test1.record(request1)
|
||||
random=java.util.Random()
|
||||
log = grinder.logger.info
|
||||
|
||||
class TestRunner:
|
||||
def __call__(self):
|
||||
customerId = str(random.nextInt());
|
||||
|
||||
customerId = str(random.nextInt());
|
||||
|
||||
result = request1.POST("http://localhost:8080/transactions/add", "{"'"customerRewardsId"'":null,"'"customerId"'":"+ customerId + ","'"transactionDate"'":null}")
|
||||
txnId = parseJsonString(result.getText(), "id")
|
||||
|
||||
result = request1.GET("http://localhost:8080/rewards/find/"+ customerId)
|
||||
rwdId = parseJsonString(result.getText(), "id")
|
||||
log("rwdid %s" % rwdId)
|
||||
|
||||
if rwdId == "":
|
||||
result = request1.POST("http://localhost:8080/rewards/add", "{"'"customerId"'":"+ customerId + "}")
|
||||
rwdId = parseJsonString(result.getText(), "id")
|
||||
|
||||
result = request1.POST("http://localhost:8080/transactions/add", "{"'"id"'":" + txnId + ","'"customerRewardsId"'":" + rwdId + ","'"customerId"'":"+ customerId + ","'"transactionDate"'":null}")
|
||||
result = request1.GET("http://localhost:8080/transactions/findAll/" + rwdId)
|
||||
result = request1.GET("http://localhost:8080/transactions/findAll/" + rwdId)
|
||||
|
||||
|
|
Loading…
Reference in New Issue