From 849bab6cb2ae32f53c1f0159b546305dab9899db Mon Sep 17 00:00:00 2001 From: MariamKhalatova Date: Thu, 22 Feb 2024 22:22:12 +0400 Subject: [PATCH 1/9] feat(tsconfig): upgrade to es2021 --- tsconfig.json | 3 +-- tsconfig.test.json | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index dd55c6569..006fa409c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,7 @@ "esModuleInterop": true, "resolveJsonModule": true, "lib": [ - "es2020", + "ES2021", "DOM" ], "module": "CommonJS", @@ -22,7 +22,6 @@ "noImplicitThis": true, "noUnusedLocals": true, "noUnusedParameters": true, - "resolveJsonModule": true, "skipLibCheck": true, "strict": true, "strictNullChecks": true, diff --git a/tsconfig.test.json b/tsconfig.test.json index 4ca342cb0..bc4505ee6 100644 --- a/tsconfig.test.json +++ b/tsconfig.test.json @@ -9,7 +9,7 @@ "experimentalDecorators": true, "incremental": true, "lib": [ - "es2020" + "ES2021" ], "module": "CommonJS", "noEmitOnError": true, From 379ccbea747dfbe34019002db7777e4a86ff6a26 Mon Sep 17 00:00:00 2001 From: MariamKhalatova Date: Thu, 22 Feb 2024 22:26:05 +0400 Subject: [PATCH 2/9] chore(.gitignore): ignore autogenerated folder in integration tests --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e49bbecec..cf86af1f9 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ yarn-error.log build coverage .env +src/__tests__/integration/manifest From c9d312201ae79d324813c448438a4157849d153c Mon Sep 17 00:00:00 2001 From: MariamKhalatova Date: Thu, 22 Feb 2024 22:27:27 +0400 Subject: [PATCH 3/9] revert(integration): remove impls folder --- src/__tests__/integration/impls/sci-e.yaml | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 src/__tests__/integration/impls/sci-e.yaml diff --git a/src/__tests__/integration/impls/sci-e.yaml b/src/__tests__/integration/impls/sci-e.yaml deleted file mode 100644 index 415557fb1..000000000 --- a/src/__tests__/integration/impls/sci-e.yaml +++ /dev/null @@ -1,21 +0,0 @@ -name: integration-template -description: null -tags: null -initialize: - models: - - name: sci-e - model: SciEModel - path: '@grnsft/if-models' -graph: - children: - child: - pipeline: - - sci-e - config: - sci-e: {} - inputs: - - timestamp: 2023-08-06T00:00 - duration: 3600 - energy-cpu: 10 - energy-memory: 100 - energy-network: 100 From 8d4b14ea683bf9bfd429585a1e7eb01ff6ce6df5 Mon Sep 17 00:00:00 2001 From: MariamKhalatova Date: Thu, 22 Feb 2024 22:29:14 +0400 Subject: [PATCH 4/9] fix(integration): adopt changes after functional refactor --- src/__tests__/integration/helpers/common.ts | 14 +++- src/__tests__/integration/scenarios/sci-e.ts | 64 +++++++++---------- .../integration/templates/integration.yaml | 10 +-- src/__tests__/integration/test-data/sci-e.ts | 6 +- 4 files changed, 50 insertions(+), 44 deletions(-) diff --git a/src/__tests__/integration/helpers/common.ts b/src/__tests__/integration/helpers/common.ts index 05ed5c0cc..47b013e88 100644 --- a/src/__tests__/integration/helpers/common.ts +++ b/src/__tests__/integration/helpers/common.ts @@ -3,9 +3,21 @@ import {promisify} from 'node:util'; export const execPromise = promisify(exec); +const stripAnsi = (text: string) => { + const pattern = [ + '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)', + '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))', + ].join('|'); + + const ansiRegex = new RegExp(pattern, 'g'); + + return text.replaceAll(ansiRegex, ''); +}; + export const getJSONFromText = (text: string) => { + const textWithoutAnsi = stripAnsi(text); const jsonRegex = /\{[^]*\}/; - const jsonMatch = text.match(jsonRegex); + const jsonMatch = textWithoutAnsi.match(jsonRegex); if (jsonMatch) { const jsonString = jsonMatch[0]; diff --git a/src/__tests__/integration/scenarios/sci-e.ts b/src/__tests__/integration/scenarios/sci-e.ts index 1e73cbf8d..3de510133 100644 --- a/src/__tests__/integration/scenarios/sci-e.ts +++ b/src/__tests__/integration/scenarios/sci-e.ts @@ -1,5 +1,5 @@ import {openYamlFileAsObject, saveYamlFileAs} from '../../../util/yaml'; -import {Impl, hasInputs} from '../../../types/impl'; +import {Manifest} from '../../../types/manifest'; import { npmInstallPackage, npmUninstallPackage, @@ -9,8 +9,8 @@ import {sciEInputData} from '../test-data/sci-e'; describe('integration/sci-e', () => { const modelName = 'sci-e'; - const absoluteImplPath = `${__dirname}/../impls/sci-e.yaml`; - const relativeImplPath = 'src/__tests__/integration/impls/sci-e.yaml'; + const absoluteImplPath = `${__dirname}/../manifest/sci-e.yaml`; + const relativeImplPath = 'src/__tests__/integration/manifest/sci-e.yaml'; const implTemplatePath = `${__dirname}/../templates/integration.yaml`; beforeAll(() => { @@ -18,52 +18,46 @@ describe('integration/sci-e', () => { }, 15000); it('output creation without ompl path.', async () => { - const file = await openYamlFileAsObject(implTemplatePath); + const file = await openYamlFileAsObject(implTemplatePath); - file.initialize.models[0].name = modelName; - file.initialize.models[0].path = '@grnsft/if-models'; - file.initialize.models[0].model = 'SciEModel'; - file.graph.children.child.pipeline = [modelName]; - file.graph.children.child.config = {}; - file.graph.children.child.config[modelName] = {}; + file.initialize.plugins[modelName] = { + method: 'SciE', + path: '@grnsft/if-models', + }; - if (hasInputs(file.graph.children.child)) { - file.graph.children.child.inputs = sciEInputData['success-3-params']; - } + file.tree.children.child.pipeline = [modelName]; + file.tree.children.child.config = {}; + file.tree.children.child.config[modelName] = {}; + file.tree.children.child.inputs = sciEInputData['success-3-params']; await saveYamlFileAs(file, absoluteImplPath); // save yaml uses absolute path const response = ( - await execPromise(`npm run impact-engine -- --impl ${relativeImplPath}`) + await execPromise(`npm run if -- --manifest ${relativeImplPath}`) ).stdout; // exec promise uses relative path const finalOmplParsed = getJSONFromText(response); // assertions - if ( - hasInputs(finalOmplParsed.graph.children['child']) && - hasInputs(file.graph.children['child']) - ) { - const path = finalOmplParsed.graph.children['child'].outputs![0]; - const impPath = file.graph.children['child'].inputs[0]; + const path = finalOmplParsed.tree.children['child'].outputs![0]; + const impPath = file.tree.children['child'].inputs[0]; - // assert timestamp - expect( - finalOmplParsed.graph.children['child'].inputs[0].timestamp - ).toEqual(file.graph.children['child'].inputs[0].timestamp); + // assert timestamp + expect(finalOmplParsed.tree.children['child'].inputs[0].timestamp).toEqual( + file.tree.children['child'].inputs[0].timestamp + ); - // assert duration - expect( - finalOmplParsed.graph.children['child'].inputs[0].duration - ).toEqual(file.graph.children['child'].inputs[0].duration); + // assert duration + expect(finalOmplParsed.tree.children['child'].inputs[0].duration).toEqual( + file.tree.children['child'].inputs[0].duration + ); - // assert total energy - const sum = - impPath['energy-cpu'] + - impPath['energy-memory'] + - impPath['energy-network']; + // assert total energy + const sum = + impPath['cpu/energy'] + + impPath['memory/energy'] + + impPath['network/energy']; - expect(path.energy).toEqual(sum); - } + expect(path.energy).toEqual(sum); }); afterAll(() => { diff --git a/src/__tests__/integration/templates/integration.yaml b/src/__tests__/integration/templates/integration.yaml index fc05d9dec..2d1523e91 100644 --- a/src/__tests__/integration/templates/integration.yaml +++ b/src/__tests__/integration/templates/integration.yaml @@ -2,11 +2,11 @@ name: integration-template description: tags: initialize: - models: - - name: ${name} - model: ${model} - path: ${path} -graph: + plugins: + 'sci-e': + model: ${model} + path: ${path} +tree: children: child: pipeline: diff --git a/src/__tests__/integration/test-data/sci-e.ts b/src/__tests__/integration/test-data/sci-e.ts index 1e19f85b0..e6a5acde7 100644 --- a/src/__tests__/integration/test-data/sci-e.ts +++ b/src/__tests__/integration/test-data/sci-e.ts @@ -3,9 +3,9 @@ export const sciEInputData = { { timestamp: '2023-08-06T00:00', duration: 3600, - 'energy-cpu': 10, - 'energy-memory': 100, - 'energy-network': 100, + 'cpu/energy': 10, + 'memory/energy': 100, + 'network/energy': 100, }, ], }; From d69314678c392d70a769cd20d024efd75bee78b9 Mon Sep 17 00:00:00 2001 From: MariamKhalatova Date: Sat, 24 Feb 2024 01:40:55 +0400 Subject: [PATCH 5/9] style: testing DCO setup --- src/__tests__/integration/scenarios/sci-e.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/__tests__/integration/scenarios/sci-e.ts b/src/__tests__/integration/scenarios/sci-e.ts index 3de510133..048a856db 100644 --- a/src/__tests__/integration/scenarios/sci-e.ts +++ b/src/__tests__/integration/scenarios/sci-e.ts @@ -60,6 +60,7 @@ describe('integration/sci-e', () => { expect(path.energy).toEqual(sum); }); + //after afterAll(() => { return npmUninstallPackage('@grnsft/if-models'); }, 15000); From be44e19e5f0d3b72a178dcd4f57ff05e99646191 Mon Sep 17 00:00:00 2001 From: MariamKhalatova Date: Sat, 24 Feb 2024 01:56:13 +0400 Subject: [PATCH 6/9] revert(tests): remove redundant comment --- src/__tests__/integration/scenarios/sci-e.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/__tests__/integration/scenarios/sci-e.ts b/src/__tests__/integration/scenarios/sci-e.ts index 048a856db..3de510133 100644 --- a/src/__tests__/integration/scenarios/sci-e.ts +++ b/src/__tests__/integration/scenarios/sci-e.ts @@ -60,7 +60,6 @@ describe('integration/sci-e', () => { expect(path.energy).toEqual(sum); }); - //after afterAll(() => { return npmUninstallPackage('@grnsft/if-models'); }, 15000); From b1e93d4e44b984aa0fdc532a7a92b1d18602ca9c Mon Sep 17 00:00:00 2001 From: MariamKhalatova Date: Sat, 24 Feb 2024 02:01:16 +0400 Subject: [PATCH 7/9] tests: rename ompl to output DCO Remediation Commit for MariamKhalatova I, MariamKhalatova , hereby add my Signed-off-by to this commit: 849bab6cb2ae32f53c1f0159b546305dab9899db I, MariamKhalatova , hereby add my Signed-off-by to this commit: 379ccbea747dfbe34019002db7777e4a86ff6a26 I, MariamKhalatova , hereby add my Signed-off-by to this commit: c9d312201ae79d324813c448438a4157849d153c I, MariamKhalatova , hereby add my Signed-off-by to this commit: 8d4b14ea683bf9bfd429585a1e7eb01ff6ce6df5 Signed-off-by: MariamKhalatova --- src/__tests__/integration/scenarios/sci-e.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/__tests__/integration/scenarios/sci-e.ts b/src/__tests__/integration/scenarios/sci-e.ts index 3de510133..ecc2307ba 100644 --- a/src/__tests__/integration/scenarios/sci-e.ts +++ b/src/__tests__/integration/scenarios/sci-e.ts @@ -35,19 +35,19 @@ describe('integration/sci-e', () => { await execPromise(`npm run if -- --manifest ${relativeImplPath}`) ).stdout; // exec promise uses relative path - const finalOmplParsed = getJSONFromText(response); + const finalOutputParsed = getJSONFromText(response); // assertions - const path = finalOmplParsed.tree.children['child'].outputs![0]; + const path = finalOutputParsed.tree.children['child'].outputs![0]; const impPath = file.tree.children['child'].inputs[0]; // assert timestamp - expect(finalOmplParsed.tree.children['child'].inputs[0].timestamp).toEqual( - file.tree.children['child'].inputs[0].timestamp - ); + expect( + finalOutputParsed.tree.children['child'].inputs[0].timestamp + ).toEqual(file.tree.children['child'].inputs[0].timestamp); // assert duration - expect(finalOmplParsed.tree.children['child'].inputs[0].duration).toEqual( + expect(finalOutputParsed.tree.children['child'].inputs[0].duration).toEqual( file.tree.children['child'].inputs[0].duration ); From f27eac29286f177d4766b1bb8c52496766353a8d Mon Sep 17 00:00:00 2001 From: MariamKhalatova Date: Sat, 24 Feb 2024 02:03:46 +0400 Subject: [PATCH 8/9] test: rename impl to manifest in integration --- src/__tests__/integration/scenarios/sci-e.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/__tests__/integration/scenarios/sci-e.ts b/src/__tests__/integration/scenarios/sci-e.ts index ecc2307ba..eeec2b303 100644 --- a/src/__tests__/integration/scenarios/sci-e.ts +++ b/src/__tests__/integration/scenarios/sci-e.ts @@ -9,8 +9,8 @@ import {sciEInputData} from '../test-data/sci-e'; describe('integration/sci-e', () => { const modelName = 'sci-e'; - const absoluteImplPath = `${__dirname}/../manifest/sci-e.yaml`; - const relativeImplPath = 'src/__tests__/integration/manifest/sci-e.yaml'; + const absoluteManifestPath = `${__dirname}/../manifest/sci-e.yaml`; + const relativeManifestPath = 'src/__tests__/integration/manifest/sci-e.yaml'; const implTemplatePath = `${__dirname}/../templates/integration.yaml`; beforeAll(() => { @@ -30,16 +30,16 @@ describe('integration/sci-e', () => { file.tree.children.child.config[modelName] = {}; file.tree.children.child.inputs = sciEInputData['success-3-params']; - await saveYamlFileAs(file, absoluteImplPath); // save yaml uses absolute path + await saveYamlFileAs(file, absoluteManifestPath); // save yaml uses absolute path const response = ( - await execPromise(`npm run if -- --manifest ${relativeImplPath}`) + await execPromise(`npm run if -- --manifest ${relativeManifestPath}`) ).stdout; // exec promise uses relative path const finalOutputParsed = getJSONFromText(response); // assertions const path = finalOutputParsed.tree.children['child'].outputs![0]; - const impPath = file.tree.children['child'].inputs[0]; + const manifestPath = file.tree.children['child'].inputs[0]; // assert timestamp expect( @@ -53,9 +53,9 @@ describe('integration/sci-e', () => { // assert total energy const sum = - impPath['cpu/energy'] + - impPath['memory/energy'] + - impPath['network/energy']; + manifestPath['cpu/energy'] + + manifestPath['memory/energy'] + + manifestPath['network/energy']; expect(path.energy).toEqual(sum); }); From da1737398c9057bd9c279e5392216393cb882f28 Mon Sep 17 00:00:00 2001 From: MariamKhalatova Date: Sun, 25 Feb 2024 17:20:48 +0400 Subject: [PATCH 9/9] test(integration): add timeout to sci-e scenario --- src/__tests__/integration/scenarios/sci-e.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/__tests__/integration/scenarios/sci-e.ts b/src/__tests__/integration/scenarios/sci-e.ts index eeec2b303..984c8052e 100644 --- a/src/__tests__/integration/scenarios/sci-e.ts +++ b/src/__tests__/integration/scenarios/sci-e.ts @@ -58,7 +58,7 @@ describe('integration/sci-e', () => { manifestPath['network/energy']; expect(path.energy).toEqual(sum); - }); + }, 15000); afterAll(() => { return npmUninstallPackage('@grnsft/if-models');