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: ACNA-2738 - failing e2e tests because of mocked fs #173

Merged
merged 1 commit into from
Jan 17, 2024
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
84 changes: 45 additions & 39 deletions e2e/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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', () => {
Expand Down
16 changes: 8 additions & 8 deletions e2e/jest.setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -209,7 +209,7 @@ global.sampleAppIncludesConfig = {
action: {
function: 'actions/action.js',
web: 'yes',
runtime: 'nodejs:12',
runtime: 'nodejs:18',
include: [['*.txt', 'text/']]
}
}
Expand All @@ -221,7 +221,7 @@ global.sampleAppIncludesConfig = {
action: {
function: 'actions/action.js',
web: 'yes',
runtime: 'nodejs:12',
runtime: 'nodejs:18',
include: [['*.txt', 'text/']]
}
}
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -348,7 +348,7 @@ global.sampleAppReducedConfig = {
action: {
function: 'actions/action.js',
web: 'yes',
runtime: 'nodejs:12'
runtime: 'nodejs:18'
}
},
triggers: { trigger1: null }
Expand All @@ -361,7 +361,7 @@ global.sampleAppReducedConfig = {
action: {
function: 'actions/action.js',
web: 'yes',
runtime: 'nodejs:12'
runtime: 'nodejs:18'
}
},
triggers: { trigger1: null }
Expand Down
2 changes: 1 addition & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<object>} [limits] limits for the action
Expand Down
2 changes: 1 addition & 1 deletion test/__fixtures__/custom-webpack/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ packages:
action:
function: actions/actionname/action.js
web: yes
runtime: 'nodejs:12'
runtime: 'nodejs:18'
4 changes: 2 additions & 2 deletions test/__fixtures__/named-package/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/__fixtures__/sample-app-includes/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ packages:
action:
function: actions/action.js
web: yes
runtime: 'nodejs:12'
runtime: 'nodejs:18'
include:
- ["*.txt", "text/"]

Expand Down
2 changes: 1 addition & 1 deletion test/__fixtures__/sample-app-reduced/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ packages:
action:
function: actions/action.js
web: yes
runtime: 'nodejs:12'
runtime: 'nodejs:18'
triggers:
trigger1:
24 changes: 12 additions & 12 deletions test/deploy.actions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
},
Expand Down Expand Up @@ -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'
}
}
Expand Down Expand Up @@ -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'
}
},
Expand Down Expand Up @@ -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'
}
},
Expand Down Expand Up @@ -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'
}
},
Expand Down Expand Up @@ -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'
}
},
Expand Down Expand Up @@ -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'
}
},
Expand Down Expand Up @@ -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'
}
}
})
Expand Down Expand Up @@ -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'
}
},
Expand Down
20 changes: 10 additions & 10 deletions test/jest.setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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: {
Expand Down Expand Up @@ -297,7 +297,7 @@ global.sampleAppIncludesConfig = {
action: {
function: 'actions/action.js',
web: 'yes',
runtime: 'nodejs:12',
runtime: 'nodejs:18',
include: [['*.txt', 'text/']]
}
}
Expand All @@ -309,7 +309,7 @@ global.sampleAppIncludesConfig = {
action: {
function: 'actions/action.js',
web: 'yes',
runtime: 'nodejs:12',
runtime: 'nodejs:18',
include: [['*.txt', 'app/']]
}
}
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -436,7 +436,7 @@ global.sampleAppReducedConfig = {
action: {
function: 'actions/action.js',
web: 'yes',
runtime: 'nodejs:12'
runtime: 'nodejs:18'
}
},
triggers: { trigger1: null }
Expand All @@ -449,7 +449,7 @@ global.sampleAppReducedConfig = {
action: {
function: 'actions/action.js',
web: 'yes',
runtime: 'nodejs:12'
runtime: 'nodejs:18'
}
},
triggers: { trigger1: null }
Expand Down
Loading
Loading