Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests #152

Merged
merged 5 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion agent/createtest/createtest.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
vars:
rampTime: 1m
loadTime: 1m
totalTime: 2m
serviceUrlAgent: ${SERVICE_URL_AGENT}
load_pattern:
- linear:
Expand Down
1 change: 0 additions & 1 deletion agent/createtest/shorter/createtest.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
vars:
rampTime: 1m
loadTime: 1m
totalTime: 2m
serviceUrlAgent: ${SERVICE_URL_AGENT}
load_pattern:
- linear:
Expand Down
1 change: 0 additions & 1 deletion common/src/util/s3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export function init (): void {
// Where <prefix> is your application name, system name, and service name concatenated with underscores, capitalized, and all dashes replaced with underscores.
// The s3 service name is s3 in the application which is then capitalized to _S3_ below

// We need to error check if we're running on application we don't fall back to the unittests on live
const PREFIX: string = getPrefix(true); // Use the controller if we have one
const bucketName: string | undefined = process.env[`${PREFIX}_S3_BUCKET_NAME`];
log(`${PREFIX}_S3_BUCKET_NAME = ${bucketName}`, LogLevel.DEBUG);
Expand Down
11 changes: 8 additions & 3 deletions common/src/util/sqs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { AGENT_ENV, SYSTEM_NAME, getPrefix } from "./util";
import {
AGENT_APPLICATION_NAME,
AGENT_ENV,
SYSTEM_NAME,
getPrefix
} from "./util";
import {
ChangeMessageVisibilityCommand,
ChangeMessageVisibilityCommandInput,
Expand Down Expand Up @@ -43,7 +48,7 @@ export function init () {
// Controller should have this env variable from the deployment
const systemNames: string[] = AGENT_ENV.split(",");
for (const systemName of systemNames) {
const PREFIX: string = "PEWPEWAGENT_" + systemName.toUpperCase().replace("-", "_");
const PREFIX: string = (AGENT_APPLICATION_NAME + "_" + systemName).toUpperCase().replace("-", "_");
const queueUrlTest: string | undefined = process.env[`${PREFIX}_SQS_SCALE_OUT_QUEUE_URL`];
log(`${PREFIX}_SQS_SCALE_OUT_QUEUE_URL = ${queueUrlTest}`, LogLevel.DEBUG);
if (!queueUrlTest) {
Expand Down Expand Up @@ -72,7 +77,7 @@ export function init () {
// Controller should have this env variable from the deployment
const systemNames: string[] = AGENT_ENV.split(",");
for (const systemName of systemNames) {
const PREFIX: string = "PEWPEWAGENT_" + systemName.toUpperCase().replace("-", "_");
const PREFIX: string = (AGENT_APPLICATION_NAME + "_" + systemName).toUpperCase().replace("-", "_");
const queueUrlTest: string | undefined = process.env[`${PREFIX}_SQS_SCALE_IN_QUEUE_URL`];
log(`${PREFIX}_SQS_SCALE_IN_QUEUE_URL = ${queueUrlTest}`, LogLevel.DEBUG);
if (!queueUrlTest) {
Expand Down
1 change: 1 addition & 0 deletions common/src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { LogLevel, log } from "./log";

export const APPLICATION_NAME: string = process.env.APPLICATION_NAME || "pewpewagent";
export const CONTROLLER_APPLICATION_NAME: string = process.env.CONTROLLER_APPLICATION_NAME || "pewpewcontroller";
export const AGENT_APPLICATION_NAME: string = process.env.AGENT_APPLICATION_NAME || "pewpewagent";
export const CONTROLLER_APPLICATION_PREFIX: string = CONTROLLER_APPLICATION_NAME.toUpperCase().replace(/-/g, "_") + "_";
export const SYSTEM_NAME: string = process.env.SYSTEM_NAME || "unittests";
export const CONTROLLER_ENV = process.env.CONTROLLER_ENV;
Expand Down
1 change: 0 additions & 1 deletion common/test/basicwithenv.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
vars:
rampTime: 1m
loadTime: 1m
totalTime: 2m
serviceUrlAgent: ${SERVICE_URL_AGENT}
test: ${parseInt("${TEST}")}
load_pattern:
Expand Down
1 change: 0 additions & 1 deletion common/test/basicwithfiles.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
vars:
rampTime: 1m
loadTime: 1m
totalTime: 2m
logDir: ${SPLUNK_PATH}
load_pattern:
- linear:
Expand Down
1 change: 0 additions & 1 deletion common/test/basicwithvars.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
vars:
rampTime: 1m
loadTime: 1m
totalTime: 2m
serviceUrlAgent: 127.0.0.1:8080
load_pattern:
- linear:
Expand Down
1 change: 1 addition & 0 deletions common/test/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ export function mockSqs (): AwsStub<SQSServiceInputTypes, SQSServiceOutputTypes,
export function resetMockSqs (): void {
if (_mockedSqsInstance !== undefined) {
_mockedSqsInstance.reset();
_mockedSqsInstance.restore();
sqsConfig.sqsClient = undefined as any;
_mockedSqsInstance = undefined;
}
Expand Down
72 changes: 36 additions & 36 deletions common/test/yamlparser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,44 +136,44 @@ describe("YamlParser", () => {
})
.catch((error) => done(error));
});
});

it(BASIC_FILEPATH_WITH_FILES + " should be valid", (done: Mocha.Done) => {
YamlParser.parseYamlFile(BASIC_FILEPATH_WITH_FILES, { SPLUNK_PATH: UNIT_TEST_FOLDER })
.then((yamlParser: YamlParser) => {
expect(yamlParser).to.not.equal(undefined);
expect(yamlParser.getBucketSizeMs(), "getBucketSizeMs").to.equal(60000);
expect(yamlParser.getTestRunTimeMn(), "getTestRunTimeMn").to.equal(2);
expect(yamlParser.getInputFileNames().length, "getInputFileNames().length").to.equal(1);
expect(yamlParser.getLoggerFileNames().length, "getLoggerFileNames().length").to.equal(2);
done();
})
.catch((error) => done(error));
});
it(BASIC_FILEPATH_WITH_FILES + " should be valid", (done: Mocha.Done) => {
YamlParser.parseYamlFile(BASIC_FILEPATH_WITH_FILES, { SPLUNK_PATH: UNIT_TEST_FOLDER })
.then((yamlParser: YamlParser) => {
expect(yamlParser).to.not.equal(undefined);
expect(yamlParser.getBucketSizeMs(), "getBucketSizeMs").to.equal(60000);
expect(yamlParser.getTestRunTimeMn(), "getTestRunTimeMn").to.equal(2);
expect(yamlParser.getInputFileNames().length, "getInputFileNames().length").to.equal(1);
expect(yamlParser.getLoggerFileNames().length, "getLoggerFileNames().length").to.equal(2);
done();
})
.catch((error) => done(error));
});

it(BASIC_FILEPATH_NO_PEAK_LOAD + " should be valid", (done: Mocha.Done) => {
YamlParser.parseYamlFile(BASIC_FILEPATH_NO_PEAK_LOAD, {})
.then((yamlParser: YamlParser) => {
expect(yamlParser).to.not.equal(undefined);
expect(yamlParser.getBucketSizeMs(), "getBucketSizeMs").to.equal(60000);
expect(yamlParser.getTestRunTimeMn(), "getTestRunTimeMn").to.equal(2);
expect(yamlParser.getInputFileNames().length, "getInputFileNames().length").to.equal(0);
expect(yamlParser.getLoggerFileNames().length, "getLoggerFileNames().length").to.equal(0);
done();
})
.catch((error) => done(error));
});
it(BASIC_FILEPATH_NO_PEAK_LOAD + " should be valid", (done: Mocha.Done) => {
YamlParser.parseYamlFile(BASIC_FILEPATH_NO_PEAK_LOAD, {})
.then((yamlParser: YamlParser) => {
expect(yamlParser).to.not.equal(undefined);
expect(yamlParser.getBucketSizeMs(), "getBucketSizeMs").to.equal(60000);
expect(yamlParser.getTestRunTimeMn(), "getTestRunTimeMn").to.equal(2);
expect(yamlParser.getInputFileNames().length, "getInputFileNames().length").to.equal(0);
expect(yamlParser.getLoggerFileNames().length, "getLoggerFileNames().length").to.equal(0);
done();
})
.catch((error) => done(error));
});

it(BASIC_FILEPATH_HEADERS_ALL + " should be valid", (done: Mocha.Done) => {
YamlParser.parseYamlFile(BASIC_FILEPATH_HEADERS_ALL, {})
.then((yamlParser: YamlParser) => {
expect(yamlParser).to.not.equal(undefined);
expect(yamlParser.getBucketSizeMs(), "getBucketSizeMs").to.equal(60000);
expect(yamlParser.getTestRunTimeMn(), "getTestRunTimeMn").to.equal(2);
expect(yamlParser.getInputFileNames().length, "getInputFileNames().length").to.equal(0);
expect(yamlParser.getLoggerFileNames().length, "getLoggerFileNames().length").to.equal(0);
done();
})
.catch((error) => done(error));
it(BASIC_FILEPATH_HEADERS_ALL + " should be valid", (done: Mocha.Done) => {
YamlParser.parseYamlFile(BASIC_FILEPATH_HEADERS_ALL, {})
.then((yamlParser: YamlParser) => {
expect(yamlParser).to.not.equal(undefined);
expect(yamlParser.getBucketSizeMs(), "getBucketSizeMs").to.equal(60000);
expect(yamlParser.getTestRunTimeMn(), "getTestRunTimeMn").to.equal(2);
expect(yamlParser.getInputFileNames().length, "getInputFileNames().length").to.equal(0);
expect(yamlParser.getLoggerFileNames().length, "getLoggerFileNames().length").to.equal(0);
done();
})
.catch((error) => done(error));
});
});
});
2 changes: 0 additions & 2 deletions controller/components/YamlViewer/story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import React from "react";
const yamlContents = `vars:
rampTime: 1m
loadTime: 1m
totalTime: 2m
serviceUrlAgent: \${SERVICE_URL_AGENT}
load_pattern:
- linear:
Expand All @@ -38,7 +37,6 @@ endpoints:
const yamlContentsLarge = `vars:
rampTime: 1m
loadTime: 1m
totalTime: 2m
logDir: \${SPLUNK_PATH}
load_pattern:
- linear:
Expand Down
1 change: 0 additions & 1 deletion controller/test/basicwithenv.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
vars:
rampTime: 1m
loadTime: 1m
totalTime: 2m
serviceUrlAgent: ${SERVICE_URL_AGENT}
test1: ${TEST1}
test2: ${TEST2}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import React from "react";
const yamlContents = `vars:
rampTime: 1m
loadTime: 1m
totalTime: 2m
serviceUrlAgent: \${SERVICE_URL_AGENT}
load_pattern:
- linear:
Expand All @@ -38,7 +37,6 @@ endpoints:
const yamlContentsLarge = `vars:
rampTime: 1m
loadTime: 1m
totalTime: 2m
logDir: \${SPLUNK_PATH}
load_pattern:
- linear:
Expand Down