Skip to content

Commit 2c8701c

Browse files
committed
clean up
1 parent c6fe535 commit 2c8701c

File tree

5 files changed

+28
-39
lines changed

5 files changed

+28
-39
lines changed

cicd/3-app/load-test.template.yml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ Resources:
3333
Image: !Ref LoadTestImage
3434
Cpu: 0
3535
Memory: 512
36-
Environment:
37-
- Name: PRIVATE_KEY
38-
Value: arn:aws:secretsmanager:us-east-1:475661607190:secret:production/cdo/javabuilder_load_test_key-O3hwTg
39-
- Name: PRIVATE_KEY_PASSWORD
40-
Value: arn:aws:secretsmanager:us-east-1:475661607190:secret:production/cdo/javabuilder_load_test_key_password-MFH2XA
4136
LogConfiguration:
4237
LogDriver: awslogs
4338
Options:
@@ -62,16 +57,3 @@ Resources:
6257
ManagedPolicyArns:
6358
# AWS-managed policy for executing an ECS task
6459
- arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy
65-
Policies:
66-
- PolicyName: JavabuilderLoadTestSecretPolicy
67-
PolicyDocument:
68-
Statement:
69-
# secrets needed for creating JWT tokens for load testing
70-
- Effect: Allow
71-
Action:
72-
- 'secretsmanager:GetSecretValue'
73-
Resource: 'arn:aws:secretsmanager:us-east-1:475661607190:secret:production/cdo/javabuilder_load_test_key-O3hwTg'
74-
- Effect: Allow
75-
Action:
76-
- 'secretsmanager:GetSecretValue'
77-
Resource: 'arn:aws:secretsmanager:us-east-1:475661607190:secret:production/cdo/javabuilder_load_test_key_password-MFH2XA'

javabuilder-authorizer/jwt_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def decode_token(token, origin)
99
begin
1010
if IS_LOAD_TEST
1111
puts "in load test"
12-
# load tests use a simpler authentication scheme
12+
# load tests use a simpler authentication algorithm
1313
return JWT.decode(
1414
token,
1515
LOAD_TEST_KEY,

load-test/scripts/configuration.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const basicTestOptions = {
1+
export const BASIC_TEST_OPTIONS = {
22
scenarios: {
33
// ramp up to 5 VUs over 30 seconds
44
rampUp: {
@@ -29,26 +29,33 @@ export const basicTestOptions = {
2929
};
3030

3131
// TODO: Update to a load testing instance of Javabuilder
32-
export const uploadUrl = `https://javabuilder-molly-http.dev-code.org/seedsources/sources.json?Authorization=`;
33-
export const url = `wss://javabuilder-molly.dev-code.org?Authorization=`;
32+
export const UPLOAD_URL = `https://javabuilder-molly-http.dev-code.org/seedsources/sources.json?Authorization=`;
33+
export const WEBSOCKET_URL = `wss://javabuilder-molly.dev-code.org?Authorization=`;
3434
const origin = "load-test";
3535

36-
export const websocketParams = {
36+
export const WEBSOCKET_PARAMS = {
3737
headers: {
3838
Origin: origin,
3939
},
4040
};
4141

42-
export const uploadParams = {
42+
export const UPLOAD_PARAMS = {
4343
headers: {
4444
Origin: origin,
4545
"Content-Type": "application/json",
4646
},
4747
};
4848

49-
// These will be used for generating the JWT token
49+
// This will be used for generating the JWT token
5050
export const PRIVATE_KEY = null;
5151

5252
// Thresholds for metrics
5353
export const LONG_REQUEST_MS = 5000;
5454
export const EXTRA_LONG_REQUEST_MS = 10000;
55+
56+
// Mini-app types
57+
export const MiniAppType = {
58+
CONSOLE: 'console',
59+
NEIGHBORHOOD: 'neighborhood',
60+
THEATER: 'theater'
61+
};

load-test/scripts/generateToken.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ export default function generateToken(miniAppType) {
2222
options: "{}",
2323
sid: uuidv4()
2424
};
25-
let token = encode(payload);
26-
return token;
25+
return encodeAsJWT(payload);
2726
}
2827

2928
// Generate a JWT using the HS256 algorithm, which relies on a shared secret
@@ -32,7 +31,7 @@ export default function generateToken(miniAppType) {
3231
// so we need to generate the token ourselves using k6's crypto package.
3332
// Logic is modified from: https://gist.github.com/robingustafsson/7dd6463d85efdddbb0e4bcd3ecc706e1
3433
// JWT details: https://jwt.io/introduction
35-
function encode(payload) {
34+
function encodeAsJWT(payload) {
3635
let algorithm = "HS256";
3736
let header = encoding.b64encode(JSON.stringify({ typ: "JWT", alg: algorithm }), "rawurl");
3837
let payloadEncoded = encoding.b64encode(JSON.stringify(payload), "rawurl");

load-test/scripts/hello-world-load-test.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@ import { check, sleep } from "k6";
44
import { Counter, Trend } from "k6/metrics";
55
import { helloWorld } from "./sources.js";
66
import {
7-
basicTestOptions,
8-
uploadParams,
9-
uploadUrl,
10-
websocketParams,
11-
url,
127
LONG_REQUEST_MS,
13-
EXTRA_LONG_REQUEST_MS
8+
EXTRA_LONG_REQUEST_MS,
9+
BASIC_TEST_OPTIONS,
10+
MiniAppType,
11+
UPLOAD_URL,
12+
UPLOAD_PARAMS,
13+
WEBSOCKET_URL,
14+
WEBSOCKET_PARAMS
1415
} from "./configuration.js";
1516
import generateToken from "./generateToken.js";
1617

17-
export const options = basicTestOptions;
18+
export const options = BASIC_TEST_OPTIONS;
1819

1920
const exceptionCounter = new Counter("exceptions");
2021
const errorCounter = new Counter("errors");
@@ -28,13 +29,13 @@ const longWebsocketSessions = new Counter("long_websocket_sessions");
2829
const extraLongWebsocketSessions = new Counter("extra_long_websocket_sessions");
2930

3031
export default function () {
31-
const authToken = generateToken("console");
32+
const authToken = generateToken(MiniAppType.CONSOLE);
3233
const uploadResult = http.put(
33-
uploadUrl + authToken,
34+
UPLOAD_URL + authToken,
3435
helloWorld,
35-
uploadParams
36+
UPLOAD_PARAMS
3637
);
37-
const res = ws.connect(url + authToken, websocketParams, (socket) =>
38+
const res = ws.connect(WEBSOCKET_URL + authToken, WEBSOCKET_PARAMS, (socket) =>
3839
onSocketConnect(socket, Date.now())
3940
);
4041

0 commit comments

Comments
 (0)