From 6cc58bfe12b91ff988a0f8eba9f09fcecde3dc92 Mon Sep 17 00:00:00 2001 From: juanq4 Date: Tue, 8 Oct 2024 12:30:36 -0400 Subject: [PATCH] wip --- lib/index.js | 56 ++++--------------- ...iption-load.yml => test-jwks-endpoint.yml} | 2 +- load-test/test-traffic-hitting-login-page.yml | 2 +- 3 files changed, 14 insertions(+), 46 deletions(-) rename load-test/{test-subscription-load.yml => test-jwks-endpoint.yml} (91%) diff --git a/lib/index.js b/lib/index.js index f840481..9fcdb7d 100644 --- a/lib/index.js +++ b/lib/index.js @@ -51,7 +51,6 @@ const impl = { * @returns {boolean} true if file exists, false otherwise */ fileExists: (filePath) => { - console.log("fileExists"); try { return fs.lstatSync(filePath).isFile(); } catch (ex) { @@ -70,7 +69,6 @@ const impl = { * script.yml file if the prior two conditions do not hold. */ findScriptPath: (scriptPath) => { - console.log("findScriptPath"); if (scriptPath) { if (impl.fileExists(scriptPath)) { if (path.isAbsolute(scriptPath)) { @@ -100,7 +98,6 @@ const impl = { * @returns {Promise.} */ getScriptText: (options) => { - console.log("getScriptText"); // Priority: `--si`, `--stdIn`, `-d`, `--data`, `-p`, `--path`, ./script.yml, $(npm root -g)/script.yml if (options.si || options.stdIn) { return stdin(); @@ -125,16 +122,12 @@ const impl = { * @param input The input to attempt parsing * @returns {*} The parsed artillery script */ - parseScript: (input) => { - console.log("parseScript"); - return yaml.safeLoad(input); - }, + parseScript: (input) => yaml.safeLoad(input), /** * Replace the given input flag with the `-d` flag, providing the stringification of the given script as its value. */ replaceArgv: (script) => { - console.log("replaceArgv"); const flags = [ { flag: "-si", bool: true }, { flag: "--stdIn", bool: true }, @@ -165,7 +158,6 @@ const impl = { * @returns {{allowance: number, required: number}} */ scriptConstraints: (script) => { - console.log("scriptConstraints"); const networkBuffer = 2; // seconds to allow for network transmission const resultsBuffer = 3; // seconds to allow for processing overhead (validation, decision making, results calculation) const settings = platformSettings.getSettings(script); @@ -196,7 +188,6 @@ const impl = { }, generateScriptDefaults: (options) => { - console.log("generateScriptDefaults"); const opts = options || {}; opts.endpoint = opts.endpoint || "http://aws.amazon.com"; opts.duration = opts.duration || 5; @@ -213,7 +204,6 @@ const impl = { * @return {string} The string containing a JSON object that comprises the default script. */ generateScript: (options) => { - console.log("generateScript"); // fallback to defaults const opts = impl.generateScriptDefaults(options); // extract and combine options into generated script @@ -257,7 +247,6 @@ scenarios: * @param service The service to validate for deployment preconditions */ validateServiceForDeployment: (service) => { - console.log("validateServiceForDeployment"); if ( service && service.functions && @@ -368,7 +357,6 @@ scenarios: * @param cwd Function to get the current working directory path */ validateServiceForInvocation: (options, script, cwd = process.cwd) => { - console.log("validateServiceForInvocation"); let toss = false; try { const localService = require(path.join(cwd(), "package.json")); // eslint-disable-line global-require, import/no-dynamic-require @@ -397,7 +385,6 @@ scenarios: * Copy artillery lambda files to temp dir. */ populateArtilleryLambda: (tempPath) => { - console.log("populateArtilleryLambda"); console.log(tempPath); const sourceArtilleryLambdaPath = path.join(__dirname, "lambda"); let anyFailedCopies = false; @@ -424,7 +411,6 @@ scenarios: * Install artillery lambda dependencies to temp dir. */ installArtilleryLambdaDependencies: (tempPath) => { - console.log("installArtilleryLambdaDependencies"); npm.install(tempPath); }, @@ -432,7 +418,6 @@ scenarios: * Get the user's slsart info. */ readUserSAConfig: () => { - console.log("readUserSAConfig"); let infoJSON = null; // Read user's existing SA config or provide the (empty) default @@ -447,16 +432,13 @@ scenarios: /** * Save the user's slsart info. */ - writeUserSAConfig: (config) => { - console.log("writeUserSAConfig"); - return fs.writeFileSync(constants.UserConfigPath, JSON.stringify(config)); - }, + writeUserSAConfig: (config) => + fs.writeFileSync(constants.UserConfigPath, JSON.stringify(config)), /** * Checks for each of the asset files in the target dir. */ allServerlessFilesExist: (targetPath) => { - console.log("allServerlessFilesExist"); let slsFilesMissing = false; // Check for each of the necessary Artillery Lambda files. @@ -489,7 +471,6 @@ scenarios: * @return {boolean} True if the temp path exists and has valid Artillery Lambda. */ verifyTempArtilleryLambda: (tempPath) => { - console.log("verifyTempArtilleryLambda"); if ( tempPath && // The temp path is not null, fs.existsSync(tempPath) && // it exists, @@ -513,7 +494,6 @@ scenarios: * @returns {Promise.string} - path to temp Artillery Lambda assets */ tempArtilleryLambda: () => { - console.log("tempArtilleryLambda"); const userConfig = impl.readUserSAConfig(); // Check for existing temp directory with Artillery Lambda already available. @@ -560,7 +540,6 @@ scenarios: * @returns {string} - path to service config */ findServicePath: () => { - console.log("findServicePath"); const cwd = process.cwd(); const localServerlessPath = path.join(cwd, "serverless.yml"); @@ -577,7 +556,6 @@ scenarios: * contain CLI parameters to pass to SLS. */ serverlessRunner: (options) => { - console.log("serverlessRunner"); // pretend that SLS was called. process.argv[1] = Serverless.dirname; // proceed with using SLS @@ -667,7 +645,6 @@ scenarios: * use when you need the names of resources in the cloud */ serverlessLoader: () => { - console.log("serverlessRunner"); const serverless = new Serverless({ interactive: false, servicePath: impl.findServicePath(), @@ -694,9 +671,8 @@ module.exports = { * @return {Promise} A promise that completes after the deployment of the function and reporting of that * deployment. */ - deploy: (options) => { - console.log("deploy"); - return impl.serverlessLoader().then((serverless) => { + deploy: (options) => + impl.serverlessLoader().then((serverless) => { impl.validateServiceForDeployment(serverless.service); console.log(`${os.EOL}\tDeploying function...${os.EOL}`); @@ -704,8 +680,7 @@ module.exports = { return impl.serverlessRunner(options).then(() => { console.log(`${os.EOL}\tDeploy complete.${os.EOL}`); }); - }); - }, + }), /** * Send a script to the remote function. Prefer a script identified by the `-s` or `--script` option over a * `script.yml` file in the current working directory over the global `script.yml`. @@ -713,9 +688,8 @@ module.exports = { * @return {Promise} A promise that completes after the invocation of the function with the script given * by the user (or a fallback option). */ - invoke: (options) => { - console.log("invoke"); - return impl + invoke: (options) => + impl .getScriptText(options) .then(impl.parseScript) .then((input) => { @@ -769,14 +743,12 @@ module.exports = { return result; }); - }); - }, + }), /** * Kill an invoked lambda that is actively executing. */ kill: (options) => { - console.log("kill"); let funcName; const lambdaOptions = {}; @@ -864,7 +836,6 @@ module.exports = { * completion. */ remove: (options) => { - console.log("remove"); console.log(`${os.EOL}\tRemoving function...${os.EOL}`); return impl.serverlessRunner(options).then(() => { @@ -878,7 +849,6 @@ module.exports = { * @param options The user's supplied options. */ script: (options) => { - console.log("script"); const destPath = options.out || "script.yml"; if (impl.fileExists(destPath)) { return BbPromise.reject( @@ -916,9 +886,8 @@ module.exports = { * create and deploy a custom function definition. * @returns {Promise} A promise that completes after the generation of function assets for subequent deployment. */ - configure: (options) => { - console.log("options"); - return new BbPromise((resolve, reject) => { + configure: (options) => + new BbPromise((resolve, reject) => { const conflicts = []; const cwd = process.cwd(); // identify conflicts @@ -991,8 +960,7 @@ module.exports = { } console.log(completeMessage.join("")); } - }); - }, + }), }; // TODO remove before publishing? diff --git a/load-test/test-subscription-load.yml b/load-test/test-jwks-endpoint.yml similarity index 91% rename from load-test/test-subscription-load.yml rename to load-test/test-jwks-endpoint.yml index 7f5f8ac..5756395 100644 --- a/load-test/test-subscription-load.yml +++ b/load-test/test-jwks-endpoint.yml @@ -11,6 +11,6 @@ config: scenarios: - name: "Perform Q4 IDP Login http journey to console" flow: - - log: "Area: Traffic hittin login page" + - log: "Area: JWKS Endpoint" - get: url: "oauth/jwks" diff --git a/load-test/test-traffic-hitting-login-page.yml b/load-test/test-traffic-hitting-login-page.yml index 579eb9a..e752981 100644 --- a/load-test/test-traffic-hitting-login-page.yml +++ b/load-test/test-traffic-hitting-login-page.yml @@ -4,7 +4,7 @@ config: max: 10000 # fail if max response time exceeds 5000ms maxErrorRate: 8 # fail if error rate exceeds 0% phases: - - duration: 100 # 5 min + - duration: 300 # 5 min arrivalRate: 4 # 4 users per second ~ 200 per minutecala: 4, 8, 12, 20 rampTo: 6 #range of users per second name: "Q4 IDP Login Load Test 300-166->333-228179506-all"