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

feat(cb2-11277): Upgrade cvs-svc-test-number from AWS SDK v2 to v3 #127

Closed
wants to merge 12 commits into from
1 change: 1 addition & 0 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
- name: Setup local dynamo
run: npm run tools-setup
- name: Build and test
timeout-minutes: 20
run: npm run prepush
env:
AWS_ACCESS_KEY_ID: foo
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Icon
Network Trash Folder
Temporary Items
.apdisk

.env
# Idea specific hidden files
.idea/**

Expand Down
24,837 changes: 11,936 additions & 12,901 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,16 @@
"author": "",
"license": "ISC",
"dependencies": {
"@aws-sdk/client-dynamodb": "^3.549.0",
"@aws-sdk/lib-dynamodb": "^3.549.0",
"@smithy/smithy-client": "^2.5.1",
"aws-lambda": "^1.0.7",
"aws-sdk": "^2.1451.0",
"aws-xray-sdk": "^3.5.1",
"aws-xray-sdk": "^3.6.0",
"joi": "^14.3.1",
"lodash": "^4.17.21",
"node-yaml": "4.0.1",
"path-parser": "^4.2.0",
"reflect-metadata": "^0.1.13",
"serverless-dynamodb": "^0.2.43",
"ts-node-register": "^1.0.0",
"uuid": "^9.0.0"
},
Expand All @@ -78,6 +79,7 @@
"@types/uuid": "^9.0.3",
"audit-filter": "^0.5.0",
"aws-lambda-mock-context": "^3.2.1",
"aws-sdk-client-mock": "^4.0.0",
"babel-jest": "^29.6.4",
"husky": "^7.0.4",
"jest": "29.6.1",
Expand All @@ -87,8 +89,9 @@
"npm-run-all": "^4.1.5",
"patch-package": "^8.0.0",
"prettier": "^2.3.2",
"serverless": "^2.45.2",
"serverless-offline": "^5.12.1",
"serverless": "^3.38.0",
"serverless-dynamodb": "^0.2.52",
"serverless-offline": "^13.3.4",
"serverless-plugin-tracing": "^2.0.0",
"serverless-plugin-typescript": "^2.1.4",
"swagger-jsdoc": "^6.2.8",
Expand Down
2 changes: 1 addition & 1 deletion scripts/getDBPid.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
!/bin/sh

# Config of port is done at the moment in serverless.yml and script handled for us
lsof -i:8008 | awk '{print $2}' | grep -v '^PID'
lsof -i:8008 | awk '{print $2}' | tail -1
24 changes: 15 additions & 9 deletions scripts/setup.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable @typescript-eslint/ban-ts-comment */
/* eslint-disable import/no-import-module-exports */
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-explicit-any */
import { spawn } from 'child_process';
// eslint-disable-next-line import/no-import-module-exports
import { exec } from 'child_process';

// We hook to serverless offline when firing its process
const SERVER_OK = 'Offline [HTTP] listening on http://localhost:3008';
const SERVER_OK = 'http://localhost:3008';
// Serverless fires a local dynamo-db instance which is killed once the parent process is terminated
// the current serverless script checks whether a local instance is running but does not error when binding fails
// we force throwing an error so we always start from a clean slate if java.io.IOException: Failed to bind to 0.0.0.0/0.0.0.0:8006
const DYNAMO_LOCAL_ERROR_THREAD = 'Exception in thread "main"';

// eslint-disable-next-line arrow-body-style
const setupServer = (process: any) => {
return new Promise((resolve, reject) => {
return new Promise((resolve) => {
process.stdout.setEncoding('utf-8').on('data', (stream: any) => {
console.log(stream);
console.log('stdout', stream);
if (stream.includes(SERVER_OK)) {
resolve(process);
}
});

process.stderr.setEncoding('utf-8').on('data', (stream: any) => {
console.log('stderr', stream);
if (stream.includes(DYNAMO_LOCAL_ERROR_THREAD)) {
throw new Error('Internal Java process crashed');
} else if (stream.includes(SERVER_OK)) {
resolve(process);
}
reject(stream);
});

process.on('exit', (code: any, signal: any) => {
Expand All @@ -38,7 +39,12 @@ const setupServer = (process: any) => {
});
};

const server = spawn('npm', ['run', 'start'], {});
const server = exec('npm run start &', (error) => {
if (error) {
// eslint-disable-next-line @typescript-eslint/no-base-to-string, @typescript-eslint/restrict-template-expressions
console.error(`error starting server: ${error}`);
}
});

module.exports = async () => {
console.log('\nSetting up Integration tests...\n\n');
Expand Down
4 changes: 2 additions & 2 deletions serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ resources:
WriteCapacityUnits: 1
custom:
serverless-offline:
port: 3008
dynamodb:
lambdaPort: 3008
serverless-dynamodb:
start:
port: 8008
inMemory: true
Expand Down
4 changes: 3 additions & 1 deletion src/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-explicit-any */
import { APIGatewayProxyResult, Callback, Context, Handler } from 'aws-lambda';
import {
APIGatewayProxyResult, Callback, Context, Handler,
} from 'aws-lambda';
import Path from 'path-parser';
import { Configuration, IFunctionEvent } from './utils/Configuration';
import { HTTPResponse } from './utils/HTTPResponse';
Expand Down
Loading
Loading