diff --git a/e2e/e2e.js b/e2e/e2e.js index 581a8b3..815fb8b 100644 --- a/e2e/e2e.js +++ b/e2e/e2e.js @@ -16,6 +16,10 @@ const { utils } = require('../src') const fs = jest.requireActual('fs-extra') const { createHttpsProxy } = require('@adobe/aio-lib-test-proxy') +jest.unmock('node-fetch') +jest.unmock('fs') +jest.unmock('fs-extra') +jest.unmock('fs/promises') jest.unmock('openwhisk') jest.unmock('archiver') jest.setTimeout(60000) @@ -268,52 +272,54 @@ describe('print logs', () => { }, 100000) }) -test('delete non-existing trigger', async () => { - const now = new Date() - const triggerName = `e2eTrigger${now.getTime()}` +describe('trigger', () => { + test('delete non-existing', async () => { + const now = new Date() + const triggerName = `e2eTrigger${now.getTime()}` - // Delete non existing trigger - const call = sdkClient.triggers.delete({ name: triggerName }) - await expect(call).rejects.toThrow('The requested resource does not exist') -}) - -test('basic trigger', async () => { - const now = new Date() - const triggerName = `e2eTrigger${now.getTime()}` + // Delete non existing trigger + const call = sdkClient.triggers.delete({ name: triggerName }) + await expect(call).rejects.toThrow('The requested resource does not exist') + }) - // Create - expect(await sdkClient.triggers.create({ name: triggerName })).toEqual(expect.objectContaining({ name: triggerName, version: '0.0.1' })) - // Get - expect(await sdkClient.triggers.get({ name: triggerName })).toEqual(expect.objectContaining({ name: triggerName, version: '0.0.1' })) - // Delete - expect(await sdkClient.triggers.delete({ name: triggerName })).toEqual(expect.objectContaining({ name: triggerName, version: '0.0.1' })) -}) + test('basic', async () => { + const now = new Date() + const triggerName = `e2eTrigger${now.getTime()}` + + // Create + expect(await sdkClient.triggers.create({ name: triggerName })).toEqual(expect.objectContaining({ name: triggerName, version: '0.0.1' })) + // Get + expect(await sdkClient.triggers.get({ name: triggerName })).toEqual(expect.objectContaining({ name: triggerName, version: '0.0.1' })) + // Delete + expect(await sdkClient.triggers.delete({ name: triggerName })).toEqual(expect.objectContaining({ name: triggerName, version: '0.0.1' })) + }) -test('trigger with feed /whisk.system/alarms/alarm', async () => { - const now = new Date() - const triggerName = `e2eTrigger${now.getTime()}` + test('with feed /whisk.system/alarms/alarm', async () => { + const now = new Date() + const triggerName = `e2eTrigger${now.getTime()}` - // Create - expect(await sdkClient.triggers.create({ name: triggerName, trigger: { feed: '/whisk.system/alarms/alarm', parameters: [{ key: 'cron', value: '* * * * *' }] } })).toEqual(expect.objectContaining({ name: triggerName, version: '0.0.1', annotations: expect.arrayContaining([expect.objectContaining({ key: 'feed' })]) })) - // Get - expect(await sdkClient.triggers.get({ name: triggerName })).toEqual(expect.objectContaining({ name: triggerName, version: '0.0.1' })) - // Delete - expect(await sdkClient.triggers.delete({ name: triggerName })).toEqual(expect.objectContaining({ name: triggerName, version: '0.0.1' })) -}) + // Create + expect(await sdkClient.triggers.create({ name: triggerName, trigger: { feed: '/whisk.system/alarms/alarm', parameters: [{ key: 'cron', value: '* * * * *' }] } })).toEqual(expect.objectContaining({ name: triggerName, version: '0.0.1', annotations: expect.arrayContaining([expect.objectContaining({ key: 'feed' })]) })) + // Get + expect(await sdkClient.triggers.get({ name: triggerName })).toEqual(expect.objectContaining({ name: triggerName, version: '0.0.1' })) + // Delete + expect(await sdkClient.triggers.delete({ name: triggerName })).toEqual(expect.objectContaining({ name: triggerName, version: '0.0.1' })) + }) -test('trigger with feed /whisk.system/alarms/once', async () => { - const now = new Date() - const triggerName = `e2eTrigger${now.getTime()}` + test('with feed /whisk.system/alarms/once', async () => { + const now = new Date() + const triggerName = `e2eTrigger${now.getTime()}` - // add 1 day. "now" is 1 day later. need this for the future alarm - now.setDate(now.getDate() + 1) + // add 1 day. "now" is 1 day later. need this for the future alarm + now.setDate(now.getDate() + 1) - // Create - expect(await sdkClient.triggers.create({ name: triggerName, trigger: { feed: '/whisk.system/alarms/once', parameters: [{ key: 'date', value: now.toISOString() }] } })).toEqual(expect.objectContaining({ name: triggerName, version: '0.0.1', annotations: expect.arrayContaining([expect.objectContaining({ key: 'feed' })]) })) - // Get - expect(await sdkClient.triggers.get({ name: triggerName })).toEqual(expect.objectContaining({ name: triggerName, version: '0.0.1' })) - // Delete - expect(await sdkClient.triggers.delete({ name: triggerName })).toEqual(expect.objectContaining({ name: triggerName, version: '0.0.1' })) + // Create + expect(await sdkClient.triggers.create({ name: triggerName, trigger: { feed: '/whisk.system/alarms/once', parameters: [{ key: 'date', value: now.toISOString() }] } })).toEqual(expect.objectContaining({ name: triggerName, version: '0.0.1', annotations: expect.arrayContaining([expect.objectContaining({ key: 'feed' })]) })) + // Get + expect(await sdkClient.triggers.get({ name: triggerName })).toEqual(expect.objectContaining({ name: triggerName, version: '0.0.1' })) + // Delete + expect(await sdkClient.triggers.delete({ name: triggerName })).toEqual(expect.objectContaining({ name: triggerName, version: '0.0.1' })) + }) }) describe('filter manifest based on built actions', () => { diff --git a/e2e/jest.setup.js b/e2e/jest.setup.js index d5a9039..3bc7e30 100644 --- a/e2e/jest.setup.js +++ b/e2e/jest.setup.js @@ -141,12 +141,12 @@ global.sampleAppConfig = { action: { function: 'actions/action.js', web: 'yes', - runtime: 'nodejs:12' + runtime: 'nodejs:18' }, 'action-zip': { function: 'actions/action-zip', web: 'yes', - runtime: 'nodejs:12' + runtime: 'nodejs:18' } }, sequences: { @@ -209,7 +209,7 @@ global.sampleAppIncludesConfig = { action: { function: 'actions/action.js', web: 'yes', - runtime: 'nodejs:12', + runtime: 'nodejs:18', include: [['*.txt', 'text/']] } } @@ -221,7 +221,7 @@ global.sampleAppIncludesConfig = { action: { function: 'actions/action.js', web: 'yes', - runtime: 'nodejs:12', + runtime: 'nodejs:18', include: [['*.txt', 'text/']] } } @@ -275,12 +275,12 @@ global.namedPackageConfig = { action: { function: 'actions/action.js', web: 'yes', - runtime: 'nodejs:12' + runtime: 'nodejs:18' }, 'action-zip': { function: 'actions/action-zip', web: 'yes', - runtime: 'nodejs:12' + runtime: 'nodejs:18' } }, sequences: { @@ -348,7 +348,7 @@ global.sampleAppReducedConfig = { action: { function: 'actions/action.js', web: 'yes', - runtime: 'nodejs:12' + runtime: 'nodejs:18' } }, triggers: { trigger1: null } @@ -361,7 +361,7 @@ global.sampleAppReducedConfig = { action: { function: 'actions/action.js', web: 'yes', - runtime: 'nodejs:12' + runtime: 'nodejs:18' } }, triggers: { trigger1: null } diff --git a/src/utils.js b/src/utils.js index 390452d..c9740ab 100644 --- a/src/utils.js +++ b/src/utils.js @@ -54,7 +54,7 @@ const DEFAULT_PACKAGE_RESERVED_NAME = 'default' * @property {string} [version] the manifest action version * @property {string} function the path to the action code * @property {string} runtime the runtime environment or kind in which the action - * executes, e.g. 'nodejs:12' + * executes, e.g. 'nodejs:18' * @property {string} [main] the entry point to the function * @property {object} [inputs] the list of action default parameters * @property {Array} [limits] limits for the action diff --git a/test/__fixtures__/custom-webpack/manifest.yml b/test/__fixtures__/custom-webpack/manifest.yml index 9d544a6..0bddced 100644 --- a/test/__fixtures__/custom-webpack/manifest.yml +++ b/test/__fixtures__/custom-webpack/manifest.yml @@ -4,4 +4,4 @@ packages: action: function: actions/actionname/action.js web: yes - runtime: 'nodejs:12' + runtime: 'nodejs:18' diff --git a/test/__fixtures__/named-package/manifest.yml b/test/__fixtures__/named-package/manifest.yml index daa247c..c9d34e6 100644 --- a/test/__fixtures__/named-package/manifest.yml +++ b/test/__fixtures__/named-package/manifest.yml @@ -5,11 +5,11 @@ packages: action: function: actions/action.js web: yes - runtime: 'nodejs:12' + runtime: 'nodejs:18' action-zip: function: actions/action-zip web: yes - runtime: 'nodejs:12' + runtime: 'nodejs:18' sequences: action-sequence: actions: action, action-zip diff --git a/test/__fixtures__/sample-app-includes/manifest.yml b/test/__fixtures__/sample-app-includes/manifest.yml index def8d5d..4cf4b67 100644 --- a/test/__fixtures__/sample-app-includes/manifest.yml +++ b/test/__fixtures__/sample-app-includes/manifest.yml @@ -4,7 +4,7 @@ packages: action: function: actions/action.js web: yes - runtime: 'nodejs:12' + runtime: 'nodejs:18' include: - ["*.txt", "text/"] diff --git a/test/__fixtures__/sample-app-reduced/manifest.yml b/test/__fixtures__/sample-app-reduced/manifest.yml index 147951c..84a54fa 100644 --- a/test/__fixtures__/sample-app-reduced/manifest.yml +++ b/test/__fixtures__/sample-app-reduced/manifest.yml @@ -5,6 +5,6 @@ packages: action: function: actions/action.js web: yes - runtime: 'nodejs:12' + runtime: 'nodejs:18' triggers: trigger1: \ No newline at end of file diff --git a/test/deploy.actions.test.js b/test/deploy.actions.test.js index c3df0e2..ef537bb 100644 --- a/test/deploy.actions.test.js +++ b/test/deploy.actions.test.js @@ -49,12 +49,12 @@ const expectedDistManifest = { actions: { action: { function: path.normalize('dist/actions/sample-app-1.0.0/action.zip'), - runtime: 'nodejs:12', + runtime: 'nodejs:18', web: 'yes' }, 'action-zip': { function: path.normalize('dist/actions/sample-app-1.0.0/action-zip.zip'), - runtime: 'nodejs:12', + runtime: 'nodejs:18', web: 'yes' } }, @@ -246,7 +246,7 @@ test('use deployConfig.filterEntities to deploy only one action', async () => { actions: { action: { function: path.normalize('dist/actions/sample-app-1.0.0/action.zip'), - runtime: 'nodejs:12', + runtime: 'nodejs:18', web: 'yes' } } @@ -285,7 +285,7 @@ test('use deployConfig.filterEntities to deploy only one trigger and one action' actions: { action: { function: path.normalize('dist/actions/sample-app-1.0.0/action.zip'), - runtime: 'nodejs:12', + runtime: 'nodejs:18', web: 'yes' } }, @@ -327,7 +327,7 @@ test('use deployConfig.filterEntities to deploy only one trigger and one action actions: { action: { function: path.normalize('dist/actions/sample-app-1.0.0/action.zip'), - runtime: 'nodejs:12', + runtime: 'nodejs:18', web: 'yes' } }, @@ -375,7 +375,7 @@ test('use deployConfig.filterEntities to deploy only one action and one api', as actions: { action: { function: path.normalize('dist/actions/sample-app-1.0.0/action.zip'), - runtime: 'nodejs:12', + runtime: 'nodejs:18', web: 'yes' } }, @@ -425,12 +425,12 @@ test('use deployConfig.filterEntities to deploy only two actions and one sequenc actions: { action: { function: path.normalize('dist/actions/sample-app-1.0.0/action.zip'), - runtime: 'nodejs:12', + runtime: 'nodejs:18', web: 'yes' }, 'action-zip': { function: path.normalize('dist/actions/sample-app-1.0.0/action-zip.zip'), - runtime: 'nodejs:12', + runtime: 'nodejs:18', web: 'yes' } }, @@ -509,7 +509,7 @@ test('use deployConfig.filterEntities on non existing pkgEntity should work', as actions: { action: { function: path.normalize('dist/actions/sample-app-reduced-1.0.0/action.zip'), - runtime: 'nodejs:12', + runtime: 'nodejs:18', web: 'yes' } }, @@ -644,10 +644,10 @@ test('custom package and action filter', async () => { 'bobby-mcgee': expect.objectContaining({ actions: { action: { - function: path.normalize('dist/actions/bobby-mcgee/action.zip'), runtime: 'nodejs:12', web: 'yes' + function: path.normalize('dist/actions/bobby-mcgee/action.zip'), runtime: 'nodejs:18', web: 'yes' }, 'action-zip': { - function: path.normalize('dist/actions/bobby-mcgee/action-zip.zip'), runtime: 'nodejs:12', web: 'yes' + function: path.normalize('dist/actions/bobby-mcgee/action-zip.zip'), runtime: 'nodejs:18', web: 'yes' } } }) @@ -967,7 +967,7 @@ it('should filter the manifest, ignore the legacy action build', async () => { actions: { 'action-zip': { function: path.normalize('dist/actions/sample-app-1.0.0/action-zip.zip'), - runtime: 'nodejs:12', + runtime: 'nodejs:18', web: 'yes' } }, diff --git a/test/jest.setup.js b/test/jest.setup.js index c0a538e..51b0851 100644 --- a/test/jest.setup.js +++ b/test/jest.setup.js @@ -199,12 +199,12 @@ global.sampleAppConfig = { action: { function: 'actions/action.js', web: 'yes', - runtime: 'nodejs:12' + runtime: 'nodejs:18' }, 'action-zip': { function: 'actions/action-zip', web: 'yes', - runtime: 'nodejs:12' + runtime: 'nodejs:18' } }, sequences: { @@ -229,12 +229,12 @@ global.sampleAppConfig = { action: { function: 'actions/action.js', web: 'yes', - runtime: 'nodejs:12' + runtime: 'nodejs:18' }, 'action-zip': { function: 'actions/action-zip', web: 'yes', - runtime: 'nodejs:12' + runtime: 'nodejs:18' } }, sequences: { @@ -297,7 +297,7 @@ global.sampleAppIncludesConfig = { action: { function: 'actions/action.js', web: 'yes', - runtime: 'nodejs:12', + runtime: 'nodejs:18', include: [['*.txt', 'text/']] } } @@ -309,7 +309,7 @@ global.sampleAppIncludesConfig = { action: { function: 'actions/action.js', web: 'yes', - runtime: 'nodejs:12', + runtime: 'nodejs:18', include: [['*.txt', 'app/']] } } @@ -363,12 +363,12 @@ global.namedPackageConfig = { action: { function: 'actions/action.js', web: 'yes', - runtime: 'nodejs:12' + runtime: 'nodejs:18' }, 'action-zip': { function: 'actions/action-zip', web: 'yes', - runtime: 'nodejs:12' + runtime: 'nodejs:18' } }, sequences: { @@ -436,7 +436,7 @@ global.sampleAppReducedConfig = { action: { function: 'actions/action.js', web: 'yes', - runtime: 'nodejs:12' + runtime: 'nodejs:18' } }, triggers: { trigger1: null } @@ -449,7 +449,7 @@ global.sampleAppReducedConfig = { action: { function: 'actions/action.js', web: 'yes', - runtime: 'nodejs:12' + runtime: 'nodejs:18' } }, triggers: { trigger1: null } diff --git a/test/utils.test.js b/test/utils.test.js index 4280a98..fcb558c 100644 --- a/test/utils.test.js +++ b/test/utils.test.js @@ -1915,7 +1915,7 @@ describe('getActionUrls', () => { thisAction: { function: 'thisAction/thisAction.js', web: 'yes', - runtime: 'nodejs:12' + runtime: 'nodejs:18' } }, sequences: {