-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhancement/checking deployments and testing (#1064)
* Added some debugging * A little cleanup * Removed the inline filtering of sources Instead of using the old pipe use(filter) we are going to rely on filtering the sources ahead of time and passing all desired sources to be run. * Moved a logging line * Added the missing active filter
- Loading branch information
Showing
13 changed files
with
200 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,21 @@ | ||
import { handler as fetcher } from './fetch.js'; | ||
import { handler as scheduler } from './scheduler.js'; | ||
import { SQS } from '@aws-sdk/client-sqs'; | ||
import _env from './lib/env.js'; | ||
|
||
const event = { | ||
Records: [ | ||
{ | ||
messageId: '9a70768a-3a75-4690-b1b8-8742264ff4f4', | ||
receiptHandle: | ||
'AQEB5sTdPJrZXryC2sRtG+cOo29FNzp/O+REZkHXZANKoaPJ9+f9nhpNIRs/GM4qoM1iWnJP1jANkUFkvfUovJ44GYYY8ja8UU7kGLu0i0Ngw9hPiIWVFNCmvZ2e/XOXKKkJvBbuKloHg0i92GjmUvsNQ/d249hW2RdHY9Y2sDu0giAi5w0USPNMxIeC1ibedxZnSKWpPngroebepIxaUDwBym29tE+L5xOtGhx6HRLR5qOWwHoiMOepecnM3Q6yhzyW6vY/AaL7DXIoXOVFCAtp0VliBVFWk8sct91dTjDbJMAx8/LEMHtKqXVyKG+Zs4zcOUMmTw1XIk50AOLgTIRQJ1XE/yWKU2bvBcPBbpvOwpPFKwYTaHNUN2ZxpLZAUhh7M0U2rZgYO3sfcOBME8grng==', | ||
body: '[{"url":"http://api.erg.ic.ac.uk","adapter":"laqn","name":"London Air Quality Network","country":"GB","description":"Environmental Research Group","sourceURL":"http://api.erg.ic.ac.uk/AirQuality/Information/Documentation/pdf","contacts":["[email protected]"],"active":true,"datetime":"2022-04-27 06:03:26", "offset": 4 }]', | ||
attributes: [], | ||
messageAttributes: {}, | ||
md5OfBody: 'e29b76c2f919bc4aa0863332ce0198ee', | ||
eventSource: 'aws:sqs', | ||
eventSourceARN: | ||
'arn:aws:sqs:us-east-1:470049585876:realtime-fetcher-queue', | ||
awsRegion: 'us-east-1', | ||
}, | ||
], | ||
}; | ||
|
||
const events = { | ||
Records: [ | ||
{ | ||
messageId: '9a70768a-3a75-4690-b1b8-8742264ff4f4', | ||
receiptHandle: | ||
'AQEB5sTdPJrZXryC2sRtG+cOo29FNzp/O+REZkHXZANKoaPJ9+f9nhpNIRs/GM4qoM1iWnJP1jANkUFkvfUovJ44GYYY8ja8UU7kGLu0i0Ngw9hPiIWVFNCmvZ2e/XOXKKkJvBbuKloHg0i92GjmUvsNQ/d249hW2RdHY9Y2sDu0giAi5w0USPNMxIeC1ibedxZnSKWpPngroebepIxaUDwBym29tE+L5xOtGhx6HRLR5qOWwHoiMOepecnM3Q6yhzyW6vY/AaL7DXIoXOVFCAtp0VliBVFWk8sct91dTjDbJMAx8/LEMHtKqXVyKG+Zs4zcOUMmTw1XIk50AOLgTIRQJ1XE/yWKU2bvBcPBbpvOwpPFKwYTaHNUN2ZxpLZAUhh7M0U2rZgYO3sfcOBME8grng==', | ||
body: '[{"url":"http://api.erg.ic.ac.uk","adapter":"laqn","name":"London Air Quality Network","country":"GB","description":"Environmental Research Group","sourceURL":"http://api.erg.ic.ac.uk/AirQuality/Information/Documentation/pdf","contacts":["[email protected]"],"active":true,"datetime":"2022-04-27 06:03:26", "offset": 4 },{"url": "http://files.airnowtech.org/", "adapter": "airnow-http", "name": "AirNow", "city": "", "country": "", "description": "AirNow adapter using files streamed over http", "sourceURL": "http://www.airnow.gov/", "contacts": [ "[email protected]" ], "active": true, "offset": 10}]', | ||
attributes: [], | ||
messageAttributes: {}, | ||
md5OfBody: 'e29b76c2f919bc4aa0863332ce0198ee', | ||
eventSource: 'aws:sqs', | ||
eventSourceARN: | ||
'arn:aws:sqs:us-east-1:470049585876:realtime-fetcher-queue', | ||
awsRegion: 'us-east-1', | ||
}, | ||
], | ||
}; | ||
|
||
const getMessage = async () => { | ||
const sqs = new SQS(); | ||
return await sqs | ||
.receiveMessage({ | ||
QueueUrl: process.env.QUEUE_NAME, | ||
}) | ||
.then(({ Messages }) => { | ||
if (!Messages) return []; | ||
try { | ||
// use the messageid and body but update the format | ||
// to fit the way that the lambda will see it | ||
event.Records[0].messageId = Messages[0].MessageId; | ||
event.Records[0].body = Messages[0].Body; | ||
return event; | ||
} catch (err) { | ||
console.debug(`Could not parse body: ${Messages[0].Body}`); | ||
console.error(err); | ||
return []; | ||
} | ||
}); | ||
}; | ||
const env = _env(); | ||
|
||
// submit a new set | ||
(async () => { | ||
//let sqs = await scheduler({}, {}); | ||
//sqs.map(q => fetcher(q, {})); | ||
//const event = await getMessage(); | ||
fetcher(); | ||
if (env.deployments) { | ||
console.log(`Testing the scheduler with ${env.deployments}`) | ||
let sqs = await scheduler({}, {}); | ||
let deployments = env.deployments.split(',') | ||
sqs = sqs.filter(s => deployments.includes('all')||deployments.includes(s.name)) | ||
// now for each of these run them through the fetcher | ||
sqs.map(q => fetcher(q, null)); | ||
} else { | ||
console.log(`Testing the fetcher directly`) | ||
fetcher(); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
|
||
'use strict'; | ||
|
||
// Default timeout to use for requests module | ||
export const REQUEST_TIMEOUT = process.env.REQUEST_TIMEOUT || 60000; | ||
export const REQUEST_TIMEOUT = process.env.REQUEST_TIMEOUT || 15000; | ||
export const REQUEST_RETRIES = 3; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.