Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

Commit

Permalink
refactor k6-constants
Browse files Browse the repository at this point in the history
  • Loading branch information
EddeCCC committed Mar 15, 2023
1 parent dac0fb9 commit f211fbb
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 30 deletions.
12 changes: 6 additions & 6 deletions k6-adapter/src/main/java/dq/adapter/StimulusAdapter.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package dq.adapter;

import dq.dqlang.constants.LoadTestConstants;
import dq.dqlang.constants.accuracy.ConstantLoad;
import dq.dqlang.constants.accuracy.LoadIncrease;
import dq.dqlang.constants.accuracy.LoadPeak;
import dq.dqlang.constants.loadprofile.ConstantLoad;
import dq.dqlang.constants.loadprofile.LoadIncrease;
import dq.dqlang.constants.loadprofile.LoadPeak;
import dq.dqlang.k6.options.*;
import dq.dqlang.loadtest.Stimulus;
import dq.exception.UnknownTermException;
Expand Down Expand Up @@ -50,7 +50,7 @@ public Options adaptStimulus(Stimulus stimulus) {
*/
public Scenario getLoadPeakScenario(Stimulus stimulus) {
LoadTestConstants constants = constantsLoader.load();
LoadPeak loadPeak = constants.getAccuracy().getLoadPeak();
LoadPeak loadPeak = constants.getLoadProfile().getLoadPeak();

String highestLoad = stimulus.getHighestLoad();
int target;
Expand Down Expand Up @@ -88,7 +88,7 @@ public Scenario getLoadPeakScenario(Stimulus stimulus) {
*/
public Scenario getLoadIncreaseScenario(Stimulus stimulus) {
LoadTestConstants constants = constantsLoader.load();
LoadIncrease loadIncrease = constants.getAccuracy().getLoadIncrease();
LoadIncrease loadIncrease = constants.getLoadProfile().getLoadIncrease();

String typeOfIncrease = stimulus.getTypeOfIncrease();
int exponent;
Expand Down Expand Up @@ -141,7 +141,7 @@ private LinkedHashSet<Stage> getIncreasingStages(String stageDuration, int start
*/
public Scenario getConstantLoadScenario(Stimulus stimulus) {
LoadTestConstants constants = constantsLoader.load();
ConstantLoad constantLoad = constants.getAccuracy().getConstantLoad();
ConstantLoad constantLoad = constants.getLoadProfile().getConstantLoad();

String baseLoad = stimulus.getBaseLoad();
int vus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.annotation.JsonProperty;
import dq.dqlang.constants.accuracy.Accuracy;
import dq.dqlang.constants.loadprofile.LoadProfile;
import lombok.Getter;
import lombok.ToString;

Expand All @@ -13,6 +14,8 @@
public class LoadTestConstants {

private Accuracy accuracy;
@JsonProperty("load_profile")
private LoadProfile loadProfile;
@JsonProperty("response_time")
private ResponseTime responseTime;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dq.dqlang.constants.accuracy;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.ToString;

Expand All @@ -9,10 +8,4 @@
public class Accuracy {

private Repetition repetition;
@JsonProperty("load_peak")
private LoadPeak loadPeak;
@JsonProperty("load_increase")
private LoadIncrease loadIncrease;
@JsonProperty("constant_load")
private ConstantLoad constantLoad;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dq.dqlang.constants.accuracy;
package dq.dqlang.constants.loadprofile;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dq.dqlang.constants.accuracy;
package dq.dqlang.constants.loadprofile;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dq.dqlang.constants.accuracy;
package dq.dqlang.constants.loadprofile;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package dq.dqlang.constants.loadprofile;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.ToString;

@Getter
@ToString
public class LoadProfile {

@JsonProperty("load_peak")
private LoadPeak loadPeak;
@JsonProperty("load_increase")
private LoadIncrease loadIncrease;
@JsonProperty("constant_load")
private ConstantLoad constantLoad;
}
4 changes: 3 additions & 1 deletion k6-adapter/src/main/resources/constant/constants.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"repetition": {
"min": 1,
"max": 3
},
}
},
"load_profile": {
"load_peak": {
"high": 10,
"very_high": 15,
Expand Down
29 changes: 16 additions & 13 deletions k6-adapter/src/test/resources/dqlang/constants.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
{
"accuracy": {
"repetition": {
"min": 2,
"max": 10
},
"min": 1,
"max": 3
}
},
"load_profile": {
"load_peak": {
"high": 20,
"very_high": 40,
"extremely_high": 50,
"slow": "5m",
"fast": "2m",
"very_fast": "1m"
"high": 10,
"very_high": 15,
"extremely_high": 30,
"slow": "20s",
"fast": "15s",
"very_fast": "10s",
"cool_down_duration": "5s"
},
"load_increase": {
"start_target": 10,
"end_target": 100,
"stage_duration": "1m",
"end_target": 60,
"stage_duration": "5s",
"linear": 1,
"quadratic": 2,
"cubic": 3
},
"constant_load": {
"low": 10,
"medium": 20,
"high": 40,
"high": 30,
"min_duration": 1000,
"max_duration": 600000
"max_duration": 10000
}
},
"response_time": {
Expand Down

0 comments on commit f211fbb

Please sign in to comment.