-
Notifications
You must be signed in to change notification settings - Fork 107
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
CUMULUS-3433 - Update to nodeJs v20 #3636
Conversation
.sort is intermittently failing to order as expected, causing this test to fail in local test at an alarming failure rate. Updating test to be more explicit/remove sort, however this needs to be investigated prior to closing thie branch/PR/ticket
JSON.parse now throws a different error for the merged test case.
This reverts commit adbad84.
This reverts commit a19f9d1.
This reverts commit e652516.
This update has a couple of controversial changes in it: Updating got to v14 means we're using a pure ESM module given sindre's stance on not supporting common exports. That's being done due to incompatible changes in node streams requires at least got v12 Additionally there's a probable outstanding issue in got sindresorhus/got#2341 related to node v20/fs readstreams/nock and/or msw incompatibility (as well as a possible open source contrib)
Updating the existing apache server to return 200 on an existing endpoint is far better than the prior commit approach in that it's a valid/useful unit test as a result, with the technical/less tidy downside of requiring the unit test stack to be working.
- 5432:5432 | ||
- 8080:8080 | ||
- 9200:9200 | ||
- "127.0.0.1:20:20" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a security update to disallow port access from hosts other than localhost.
@@ -388,6 +389,15 @@ LogLevel warn | |||
#Scriptsock cgisock | |||
</IfModule> | |||
|
|||
|
|||
### Configuration to allow PUT endpoint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updates Apache server to have a dummy response to HTTP POST
@@ -350,7 +350,7 @@ variable "rds_admin_access_secret_arn" { | |||
variable "async_operation_image_version" { | |||
description = "docker image version to use for Cumulus async operations tasks" | |||
type = string | |||
default = "48" | |||
default = "49" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test image from changes in this PR was pushed up to v49 in sandbox
packages/db/tests/test-connection.js
Outdated
] | ||
); | ||
t.deepEqual(loggerWarnStub.args[0][0], 'knex failed on attempted connection'); | ||
t.true(loggerWarnStub.args[0][1].errors.map((e) => e.message).includes('connect ECONNREFUSED 127.0.0.1:5400')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was changed as the underlying modules changed behaviors in the update and this can result in an aggregate error with more values than the original test.
@@ -1,6 +1,6 @@ | |||
## Dockerfile to create integration/unit test environment | |||
FROM node:16.19.0-buster | |||
RUN apt update && npm config set unsafe-perm true &&\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool to see unsafe-perm go away here and elsewhere... what was it doing before that's changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NPM changed how it's invoking things in v7, instead of using the uid specified by the user config (nobody in the case of root) it uses the permissions from the folder, which works just fine for our use case.
Also, notably, they dropped support for this option when those changes were made.
bamboo/docker-compose-local.yml
Outdated
@@ -9,20 +9,20 @@ services: | |||
- ../packages/test-data/keys/ssh_client_rsa_key.pub:/ssh_client_rsa_key.pub | |||
- ../packages/test-data:/data | |||
build_env: | |||
image: cumuluss/cumulus-build-env:latest | |||
image: cumuluss/cumulus-build-env:test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this a leftover from testing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch - yes, I'll revert it 👍🏻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packages/common/importGot.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's going on with this? won't we just have to call this as await? is there more going on here than aliasing default to whatever we wanna call it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - this is needed because:
Compiling javascript into a CommonJS typescript module will not allow for dynamic imports. In the use case in @cumulus/ingest
we don't want to make all of the JS not TS compiled as that doesn't generate typemaps and makes downstream TS module users define default/types.
If we wrap the ESM import statement in something like eval
, that works great (tsc doesn't transpile it), however any user of the module that webpacks a lambda using it won't include the dependency (as using a hack like eval
in this case confuses static dependency mapping).
Exporting it from a package as un-compiled JS allows us to:
- Have a helper that imports got in this way to avoid the above issues in typescript modules with allowJs enabled
- Avoid any downstream dependency detection issues
- Handle this issue in a tidy way across the project
// Message should look like this: | ||
// MESSAGE_TYPE = "SHORTPAN"; | ||
// DISPOSITION = "SUCCESSFUL"; | ||
// TIME_STAMP = 2023-03-27T18:10:56.402Z; | ||
nock(url).post(remotePath, regex) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this validation happening somewhere else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, and no. This is one of those cases where we're re-validating library behavior that itself mocks.
got is broken in node20 when used with nock/aws and file readstreams - and other options (axios) don't handle file streaming (as well/at all) . As such, this test is only testing that something attempts to post to the nock'd HTTP endpoint, which is unit tested in the ingest module already via the workaround noted in test-HttpProviderClient
.
Opinion:
In light of the issues with nock/etc, got and node 20 the value here of requiring this is at least somewhat debatable (or at least pushes the bounds of social/unsocial units) given the code being covered by the unit isn't in this task, and we have coverage re: a PAN being sent. Removing this assertion doesn't directly reduce code coverage.
The alternate approaches include:
- Update the HTTP server with a CGI script to actually take any post and write it to the container file system/serve it to validate something is posted and evaluate that response in the unit
- Update the existing integration test to use a HTTP provider. This would also require an HTTP server that will take POST/put
- Exposing the test mock params through the lambda client to this unit test
- Fix got, or implement an alternative to utilize our test mocking structure.
Co-authored-by: etcart <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
talked through the details of importGot and cleared up the last confusion
Summary: Summary of changes
Addresses CUMULUS-3433: Develop amazing new feature
Changes
importGot
helper method to importgot
as an ESM module inCommmonJS typescript/webpack clients.
@cumulus/ingest
unit test HTTPs server to accept localhost POSTrequests, and removed nock dependency from tests involving
fs.Readstream
and
got
due to a likely incompatibility with changes in node v18,got
,fs.Readstream and nock when used in combination in units
(POSTs whose bodys are instances of createReadStream hang with latest node sindresorhus/got#2341)
Reviewers, please note this PR is still in-work in that the following need to occur:
PR Checklist