Skip to content

Commit

Permalink
Update20231002 (#157)
Browse files Browse the repository at this point in the history
* Removed references to SystemTest (#134)

* Added README instructions for building and link to examples (#136)

* Zip all map (#138)

* add ZipAllMap, and some doc comments and tests

* add doctests to pr.sh

---------

Co-authored-by: Zachery Olson <[email protected]>

* Adds skipBody CLI argument - Skips Request and Response Body in Try Output (#140)

* Cargo version upgrade

* Updated the Guide to include the new available flag options for instructional purposes

* Added the ability to include skipBody argument in TryConfig and modified output to honor new skip flag

* included the new argument in the TmpTryConfig for testing purposes

* change version upgrade back to original as requested

* Removed unnessesary matches as requested

* Changes made to output format as requested

* Format changes as requested

* format changes as requested by Rustfmt in the github checks

* Manually fixed format errors

* Fixed additional fmt failure after updating rust to 1.72

---------

Co-authored-by: Trevor McMaster <[email protected]>

* Updated dependencies and fixed deprecations (#143)

* Updated dependencies and fixed deprecations

* Updated Wasm-pack to match the version in the 0.6.0 scripting branch

* Example wasm tests (#147)

* Added additional tests for all the example yaml files

* Updated the README for the current changes

* Open source PPaaS (#149)

* Added initial common directory

* Added open source agent code

* Added initial controller check-in

- Not fully working. Need to get monorepo set up

* Removed references to familysearch.org

* Added code to the pr script to build the hdr-histogram for the controller

* Attempt to fix the common install/build issues in the controller

* Added code to make a monorepo out of the common, agent, and controller

* Added new PPaaS PR flow

- Renamed the old flows to show what they are testing
- Changed the guide PR to only monitor the guide files
- Added new flow for the PPaaS common, agent, and controller

* Updated the PR flow and added husky

* Added the .env.test files we're missing for the github action

* Changed all catch blocks to catch unknown

- Added type checking around the S3 errors

* Basic working build

* Working version of next buildgit status!

* Fixed storybook by removing reference to deprecated zlib

* Removed references to fslocal.org examples

* Removed husky since it's not needed on all check-ins

* Removed duplication in pr script

* Re-enabled the react build now that it's working

* Fixed the Application Name for the controller for unit tests

* Added code to generage a .env.local for the build

* Changed the .env.local file to environment variables

* Cleaned up the global script to improve performance and nyc output

* Fixed the nyc merge

* Changed the build environment files back to .env so it can be overridden

- environment variables override all .env files.

* Fix tests (#152)

* Removed unneeded vars

* Added mock restore

* Fixed grouping of tests into describe

* Added AGENT_APPLICATION_NAME similar to the controller name

* Removed unneeded comment

* Update node dependencies (#154)

* Updated lock files and a few npm dependencies

* More dependencies updates

- Rolled back dotenv-flow due to breaking change with importing config
- Updated fullcalendar now that the next.js issue appears fixed

* Updated the zip yaml files with the updated yaml files

* Updated Next.js to latest version

* Updates from controller save master branch

* Updated version and dependencies

* Removed old command from README

* Removed references to fsdpt.org

* Removed unneeded vars and added missing ones

* Updates on master PPaaS (#156)

* Updated version and dependencies

* Removed old command from README

* Removed references to fsdpt.org

* Removed unneeded vars and added missing ones

* Updated YamlParser and tests

- Updated config-wasm tests to test validate_legacy_only true and false
- Updated yamlparser tests to test validate_legacy_only true and false
- Updated yamlparser to pass optional parameter validate_legacy_only
- Updated yamlparser to parse missing environment variables, bad durations, and bad hit rates for the new scripting config parser.

* Updated tests for legacy and scripting

- POST pewpew now checks for pre-release in the regex
- Renamed numberedVersion to legacyVersion to more easily differentiate with scriptingVersion

* Added scripting post pewpew tests to unit and integration

* Changed agent version greaterthan to use semver

* Added code to force validation of legacy or scritping to the yaml parser

* Updated TestManager to validate yaml based on passed pewpew version

- parseYamlFile will validate as legacy on any versions before 0.6.0, or as scripting on any >0.6.0-preview
- no version or version latest will parse as any

* Enabled acceptance tests that check against numbered versions of pewpew

* Removed hardcoded latest string

* Initial rename of variables and postTest of legacy against scripting version

* Updated tests to include scripting variants in acceptance and integration post /test

* Added test to test hidden variables not present on editSchedule

---------

Co-authored-by: Zachery Olson <[email protected]>
Co-authored-by: Idel <[email protected]>
  • Loading branch information
3 people committed Oct 4, 2023
1 parent 7a11ff4 commit dfb964a
Show file tree
Hide file tree
Showing 31 changed files with 2,038 additions and 924 deletions.
68 changes: 34 additions & 34 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions agent/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fs/ppaas-agent",
"version": "3.0.0",
"version": "3.0.1",
"description": "Agent Service for running pewpew tests",
"main": "dist/src/app.js",
"scripts": {
Expand Down Expand Up @@ -38,7 +38,8 @@
"dotenv-flow": "^3.2.0",
"expiry-map": "^2.0.0",
"express": "^4.18.2",
"rimraf": "^5.0.0"
"rimraf": "^5.0.0",
"semver": "^7.5.2"
},
"devDependencies": {
"@aws-sdk/client-s3": "^3.363.0",
Expand All @@ -49,6 +50,7 @@
"@types/express": "^4.17.17",
"@types/mocha": "^10.0.0",
"@types/node": "^20.0.0",
"@types/semver": "^7.5.0",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"axios": "~1.5.0",
Expand Down
15 changes: 3 additions & 12 deletions agent/src/pewpewtest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import fs from "fs/promises";
import { getHostname } from "./util/util";
import { join as pathJoin } from "path";
import { platform } from "os";
import semver from "semver";

logger.config.LogFileName = "ppaas-agent";
const logConfig = logger.config;
Expand Down Expand Up @@ -87,18 +88,8 @@ export function versionGreaterThan (currentVersion: string, compareVersion: stri
if (currentVersion === "latest") { return true; }
// If the compareVersion is latest, then only currrentVersion=latest is greater
if (compareVersion === "latest") { return false; }
// compareVersion cannot be a beta;
if (!/^\d+\.\d+\.\d+$/.test(compareVersion)) {
throw new Error("compareVersion cannot be a beta");
}
const currentMatch: string[] | null = currentVersion.match(/^(\d+\.\d+\.\d+)(.*)/);
// If we can't find a version string 0.0.0 at the beginning, we don't know
if (!currentMatch) {
return false;
}
const version = currentMatch[1];
const beta = currentMatch[2];
return beta !== "" ? version > compareVersion : version >= compareVersion;

return semver.gt(currentVersion, compareVersion);
}

// Export for testing
Expand Down
21 changes: 6 additions & 15 deletions agent/test/pewpewtest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,23 +139,14 @@ describe("PewPewTest", () => {
done();
});

it("compare version cannot be a beta", (done: Mocha.Done) => {
try {
versionGreaterThan("0.5.5", "0.5.4-beta");
done(new Error("Should have failed."));
} catch (error) {
expect(`${error}`).include("compareVersion cannot be a beta");
done();
}
it("compare version patch greater than", (done: Mocha.Done) => {
expect(versionGreaterThan("0.5.5", "0.5.6-preview1")).to.equal(false);
done();
});

it("compare version cannot be a beta", (done: Mocha.Done) => {
try {
expect(versionGreaterThan("0.5.10-preview1", "0.5.5")).to.equal(true);
done(new Error("Should have failed."));
} catch (error) {
done();
}
it("compare version patch less than", (done: Mocha.Done) => {
expect(versionGreaterThan("0.5.5", "0.5.5-preview1")).to.equal(true);
done();
});
});

Expand Down
2 changes: 1 addition & 1 deletion common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fs/ppaas-common",
"version": "3.0.0",
"version": "3.0.1",
"description": "Common Code for the PewPewController and PewPewAgent",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
Expand Down
61 changes: 43 additions & 18 deletions common/src/yamlparser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,20 @@ import { readFile } from "fs/promises";
export function parseEnvVarFromError (error: any): string | undefined {
if (typeof error === "string") {
// Format is IndexingIntoJson\("VARIABLE", Null)
const match = error.match(/MissingEnvironmentVariable\("([^"]*)", Marker/);
log("parseYamlFile match: " + JSON.stringify(match), LogLevel.DEBUG, match);
if (match && match.length > 1) {
const expectedVariable = match[1];
log("parseYamlFile missing variable: " + expectedVariable, LogLevel.DEBUG);
// MissingEnvironmentVariable\("VARIABLE", Marker
// Envs(MissingVar(MissingEnvVar("VARIABLE"))))
const matchLegacy = error.match(/MissingEnvironmentVariable\("([^"]*)", Marker/);
log("parseYamlFile match: " + JSON.stringify(matchLegacy), LogLevel.DEBUG, matchLegacy);
if (matchLegacy && matchLegacy.length > 1) {
const expectedVariable = matchLegacy[1];
log("parseYamlFile missing legacy variable: " + expectedVariable, LogLevel.DEBUG);
return expectedVariable;
}
const matchScripting = error.match(/MissingEnvVar\("([^"]*)"\)/);
log("parseYamlFile match: " + JSON.stringify(matchScripting), LogLevel.DEBUG, matchScripting);
if (matchScripting && matchScripting.length > 1) {
const expectedVariable = matchScripting[1];
log("parseYamlFile missing scripting variable: " + expectedVariable, LogLevel.DEBUG);
return expectedVariable;
}
}
Expand All @@ -19,11 +28,19 @@ export function parseEnvVarFromError (error: any): string | undefined {

export function parseDurationFromError (error: any): string | undefined {
if (typeof error === "string") {
// Format is IndexingIntoJson\("VARIABLE", Null)
const match = error.match(/InvalidDuration\("([^"]*)"/);
log("parseYamlFile match: " + JSON.stringify(match), LogLevel.DEBUG, match);
if (match && match.length > 1) {
const duration = match[1];
// Format is InvalidDuration\("value"
// error: DurationError(\"value\")
const matchLegacy = error.match(/InvalidDuration\("([^"]*)"/);
log("parseYamlFile match: " + JSON.stringify(matchLegacy), LogLevel.DEBUG, matchLegacy);
if (matchLegacy && matchLegacy.length > 1) {
const duration = matchLegacy[1];
log("parseYamlFile InvalidDuration: " + duration, LogLevel.DEBUG);
return duration;
}
const matchScripting = error.match(/DurationError\("([^"]*)"\)/);
log("parseYamlFile match: " + JSON.stringify(matchScripting), LogLevel.DEBUG, matchScripting);
if (matchScripting && matchScripting.length > 1) {
const duration = matchScripting[1];
log("parseYamlFile InvalidDuration: " + duration, LogLevel.DEBUG);
return duration;
}
Expand All @@ -33,11 +50,19 @@ export function parseDurationFromError (error: any): string | undefined {

export function parsePeakLoadFromError (error: any): string | undefined {
if (typeof error === "string") {
// Format is IndexingIntoJson\("VARIABLE", Null)
const match = error.match(/InvalidPeakLoad\("([^"]*)"/);
log("parseYamlFile match: " + JSON.stringify(match), LogLevel.DEBUG, match);
if (match && match.length > 1) {
const peakLoad = match[1];
// Format is InvalidPeakLoad\("VALUE"
// HitsPerMinute\", from: \"VALUE\", error: Invalid
const matchLegacy = error.match(/InvalidPeakLoad\("([^"]*)"/);
log("parseYamlFile match: " + JSON.stringify(matchLegacy), LogLevel.DEBUG, matchLegacy);
if (matchLegacy && matchLegacy.length > 1) {
const peakLoad = matchLegacy[1];
log("parseYamlFile InvalidPeakLoad: " + peakLoad, LogLevel.DEBUG);
return peakLoad;
}
const matchScripting = error.match(/HitsPerMinute", from: "([^"]*)", error: Invalid/);
log("parseYamlFile match: " + JSON.stringify(matchScripting), LogLevel.DEBUG, matchScripting);
if (matchScripting && matchScripting.length > 1) {
const peakLoad = matchScripting[1];
log("parseYamlFile InvalidPeakLoad: " + peakLoad, LogLevel.DEBUG);
return peakLoad;
}
Expand All @@ -61,7 +86,7 @@ export class YamlParser {
this.loggerFileNames = loggerFileNames;
}

public static async parseYamlFile (filepath: string, environmentVariables: EnvironmentVariables): Promise<YamlParser> {
public static async parseYamlFile (filepath: string, environmentVariables: EnvironmentVariables, validateLegacyOnly?: boolean): Promise<YamlParser> {
let config: Config | undefined;
try {
const fileBuffer: Buffer = await readFile(filepath);
Expand All @@ -80,8 +105,8 @@ export class YamlParser {
config = new Config(
fileBuffer,
varMap,
typeof logConfig.LoggingLevel === "number" ? undefined : logConfig.LoggingLevel
// TODO: Add version checker
typeof logConfig.LoggingLevel === "number" ? undefined : logConfig.LoggingLevel,
validateLegacyOnly
);
yamlValid = true;
} catch (error: unknown) {
Expand Down
Loading

0 comments on commit dfb964a

Please sign in to comment.