Skip to content

Commit

Permalink
test housekeeping (#206)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeknovy authored Jan 9, 2022
1 parent 60090b2 commit dbe980d
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/app/scenario.service.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export interface Scenario {
analysisEnabled: boolean;
zeroErrorToleranceEnabled: boolean;
name: string;
keepTestRunsPeriod: number;
thresholds: {
enabled: boolean;
percentile: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ <h6>Thresholds</h6>
</div>
</div>

<div class="form-sub">
<div class="form-group">
<h6>Test runs retention</h6>
<div class="desc text-secondary"><i class="fas fa-info-circle"> </i>
<small> How long to keep test runs. All related data will be deleted as well.</small></div>
<label for="keep-tests-period" class="form-label">Keep tests</label>
<select class="custom-select" id="keep-tests-period" formControlName="keepTestRunsPeriod">
<option *ngFor="let keepTestRunPeriod of keepTestRunPeriods" [ngValue]="keepTestRunPeriod.period">{{ keepTestRunPeriod.description }}</option>
</select>
</div>
</div>

<div class="form-sub">
<h6>Performance analysis</h6>
<div class="form-group">
Expand Down Expand Up @@ -72,9 +84,11 @@ <h6>Delete sample data after processing</h6>
</div>
</div>
</div>

</div>



<div class="modal-footer">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
Expand Down
45 changes: 40 additions & 5 deletions src/app/scenario/scenario-settings/scenario-settings.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,46 @@ export class SettingsScenarioComponent implements OnInit {
enabled: null,
zeroErrorToleranceEnabled: null,
deleteSamples: null,
keepTestRunsPeriod: null,
};

params;

keepTestRunPeriods = [
{
period: 0,
description: "forever",
},
{
period: 7,
description: "7 days",
},
{
period: 14,
description: "14 days"
},
{
period: 30,
description: "30 days",
},
{
period: 90,
description: "90 days"
},
{
period: 180,
description: "180 days",
}
];

constructor(
private route: ActivatedRoute,
private modalService: NgbModal,
private scenarioApiService: ScenarioApiService,
private notification: NotificationMessage,
) { }
) {
}

ngOnInit(): void {
this.route.params.subscribe(_ => this.params = _);
this.scenarioApiService.getScenario(this.params.projectName, this.params.scenarioName).subscribe(_ => {
Expand Down Expand Up @@ -78,6 +108,9 @@ export class SettingsScenarioComponent implements OnInit {
this.formControls.deleteSamples = new FormControl(settings.deleteSamples, [
Validators.required
]);
this.formControls.keepTestRunsPeriod = new FormControl(settings.keepTestRunsPeriod, [
Validators.required
]);
}

createForm() {
Expand All @@ -90,6 +123,7 @@ export class SettingsScenarioComponent implements OnInit {
thresholdErrorRate: this.formControls.errorRate,
zeroErrorToleranceEnabled: this.formControls.zeroErrorToleranceEnabled,
deleteSamples: this.formControls.deleteSamples,
keepTestRunsPeriod: this.formControls.keepTestRunsPeriod,
});
}

Expand All @@ -103,19 +137,20 @@ export class SettingsScenarioComponent implements OnInit {
const {
scenarioName, analysisEnabled,
thresholdEnabled, thresholdErrorRate,
thresholdPercentile, thresholdThroughput, deleteSamples, zeroErrorToleranceEnabled } = this.scenarioSettingsForm.value;
thresholdPercentile, thresholdThroughput, deleteSamples, zeroErrorToleranceEnabled, keepTestRunsPeriod
} = this.scenarioSettingsForm.value;
const { projectName, scenarioName: currentScenarioName } = this.params;

const body = {
scenarioName,
analysisEnabled,
zeroErrorToleranceEnabled,
keepTestRunsPeriod,
deleteSamples,
thresholds: {
enabled: thresholdEnabled,
errorRate: parseFloat(thresholdErrorRate),
errorRate: parseFloat(thresholdErrorRate),
throughput: parseFloat(thresholdThroughput),
percentile: parseFloat(thresholdPercentile)
percentile: parseFloat(thresholdPercentile)
}
};

Expand Down

0 comments on commit dbe980d

Please sign in to comment.