Skip to content

Commit 3e6fb15

Browse files
authored
[Multi-Engine] Cleanup Locust flag (#103) (#104)
* Remove locust flag * Add Locust E2E sample file
1 parent 4278d71 commit 3e6fb15

12 files changed

Lines changed: 47 additions & 63 deletions

.github/workflows/pr_check_load_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
strategy:
2828
matrix:
2929
os: [ubuntu-latest, windows-latest]
30-
configFile: ['sample-test-url.yaml', 'sample-test-jmx.yaml']
30+
configFile: ['sample-test-url.yaml', 'sample-test-jmx.yaml', 'sample-test-locust.yaml']
3131

3232
runs-on: ${{ matrix.os }}
3333
steps:

SampleApp.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import os
2+
from locust import HttpUser, constant_throughput, task
3+
4+
protocol = os.getenv("protocol", "https")
5+
host = os.getenv("domain", "example.com")
6+
base_url = f"{protocol}://{host}"
7+
8+
9+
class WebsiteUser(HttpUser):
10+
host = base_url
11+
wait_time = constant_throughput(1)
12+
13+
@task
14+
def mainPage(self):
15+
self.client.get("/", name="Homepage")

lib/constants.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3-
exports.FeatureFlags = exports.defaultYaml = void 0;
3+
exports.defaultYaml = void 0;
44
exports.defaultYaml = {
55
version: 'v0.1',
66
testId: 'SampleTest',
@@ -48,7 +48,3 @@ exports.defaultYaml = {
4848
}
4949
]
5050
};
51-
var FeatureFlags;
52-
(function (FeatureFlags) {
53-
FeatureFlags.IsLocustEnabled = false;
54-
})(FeatureFlags || (exports.FeatureFlags = FeatureFlags = {}));

lib/main.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -205,20 +205,10 @@ function uploadTestPlan() {
205205
let filepath = map.getTestFile();
206206
let filename = map.getFileName(filepath);
207207
var urlSuffix = "tests/" + testId + "/files/" + filename + "?api-version=" + util.apiConstants.latestVersion;
208-
let fileType = FileType.JMX_FILE;
208+
let fileType = FileType.TEST_SCRIPT;
209209
if (map.getTestKind() == TestKind_1.TestKind.URL) {
210210
fileType = FileType.URL_TEST_CONFIG;
211211
}
212-
else {
213-
//TODO(harshanb): Change to TEST_SCRIPT for all non-URL once Locust is GA
214-
// If IsLocustEnabled is False, then kind cannot be Locust as validations would catch it
215-
if (map.getTestKind() == TestKind_1.TestKind.JMX) {
216-
fileType = FileType.JMX_FILE;
217-
}
218-
else {
219-
fileType = FileType.TEST_SCRIPT;
220-
}
221-
}
222212
urlSuffix = baseURL + urlSuffix + ("&fileType=" + fileType);
223213
let headers = yield map.UploadAndValidateHeader();
224214
let uploadresult = yield util.httpClientRetries(urlSuffix, headers, 'put', 3, filepath, true);

lib/util.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,10 +351,6 @@ function checkValidityYaml(givenYaml) {
351351
return { valid: false, error: `The value "${givenYaml.engineInstances}" for engineInstances is invalid. The value should be an integer between 1 and 400.` };
352352
}
353353
let kind = (_a = givenYaml.testType) !== null && _a !== void 0 ? _a : TestKind_1.TestKind.JMX;
354-
// TODO(harshanb): Remove this once Locust is GA.
355-
if (!constants_1.FeatureFlags.IsLocustEnabled && kind === TestKind_1.TestKind.Locust) {
356-
return { valid: false, error: `The value "${kind}" for testType is invalid. Acceptable values are URL and JMX.` };
357-
}
358354
if (!isValidTestKind(kind)) {
359355
return { valid: false, error: `The value "${kind}" for testType is invalid. Acceptable values are ${EngineUtil.Resources.Strings.allFrameworksFriendly}.` };
360356
}

sample-test-jmx.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: v0.1
22
testName: testId
33
testPlan: SampleApp.jmx
44
testType: JMX
5-
description: 'E2E for the build pipeline'
5+
description: 'E2E for the build pipeline (JMX)'
66
env:
77
- name: domain
88
value: example.com

sample-test-locust.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
version: v0.1
2+
testName: testId
3+
testPlan: SampleApp.py
4+
testType: Locust
5+
description: 'E2E for the build pipeline (Locust)'
6+
env:
7+
- name: domain
8+
value: example.com
9+
- name: protocol
10+
value: https
11+
- name: LOCUST_USERS
12+
value: 1
13+
- name: LOCUST_RUN_TIME
14+
value: 60
15+
autoStop:
16+
errorPercentage: 90
17+
timeWindow: 60

sample-test-url.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ version: v0.1
22
testName: testId
33
testPlan: sample-test.json
44
testType: URL
5-
description: 'E2E for the build pipeline'
5+
description: 'E2E for the build pipeline (URL)'

src/constants.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,3 @@ export const defaultYaml: any =
4646
}
4747
]
4848
}
49-
50-
export module FeatureFlags {
51-
export const IsLocustEnabled = true;
52-
}

src/main.ts

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import * as Util from './engine/Util';
66
import { TestKind } from "./engine/TestKind";
77
import * as fs from 'fs';
88
import { isNullOrUndefined } from 'util';
9-
import { FeatureFlags } from './constants';
109

1110
const resultFolder = 'loadTest';
1211
const reportZipFileName = 'report.zip';
@@ -167,21 +166,11 @@ async function uploadTestPlan()
167166
let filename = map.getFileName(filepath);
168167
var urlSuffix = "tests/"+testId+"/files/"+filename+"?api-version="+util.apiConstants.latestVersion;
169168

170-
let fileType = FileType.JMX_FILE;
171-
if(map.getTestKind() == TestKind.URL){
172-
fileType = FileType.URL_TEST_CONFIG;
173-
}
174-
else {
175-
//TODO(harshanb): Change to TEST_SCRIPT for all non-URL once Locust is GA
176-
// If IsLocustEnabled is False, then kind cannot be Locust as validations would catch it
177-
if (map.getTestKind() == TestKind.JMX) {
178-
fileType = FileType.JMX_FILE;
179-
}
180-
else {
181-
fileType = FileType.TEST_SCRIPT;
182-
}
183-
}
184-
urlSuffix = baseURL + urlSuffix + ("&fileType=" + fileType);
169+
let fileType = FileType.TEST_SCRIPT;
170+
if(map.getTestKind() == TestKind.URL){
171+
fileType = FileType.URL_TEST_CONFIG;
172+
}
173+
urlSuffix = baseURL + urlSuffix + ("&fileType=" + fileType);
185174

186175
let headers = await map.UploadAndValidateHeader();
187176
let uploadresult = await util.httpClientRetries(urlSuffix,headers,'put',3,filepath,true);

0 commit comments

Comments
 (0)