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

test: split test-crypto-keygen.js #49221

Closed
wants to merge 3 commits into from

Conversation

joyeecheung
Copy link
Member

@joyeecheung joyeecheung commented Aug 17, 2023

To avoid timing out on slow machines in the CI.

Refs: #49202
Refs: #41206

To avoid timing out on ARM machines in the CI.
@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. test Issues and PRs related to the tests. labels Aug 17, 2023
@joyeecheung joyeecheung added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 17, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 17, 2023
@nodejs-github-bot

This comment was marked as outdated.

@joyeecheung
Copy link
Member Author

joyeecheung commented Aug 18, 2023

Added some additional changes other than copy-pasting, locally before the changes:

❯ tools/test.py  'test/parallel/test-crypto-keyge*'
[00:09|% 100|+   2|-   0]: Done

After:

❯ tools/test.py  'test/parallel/test-crypto-keyge*'
[00:01|% 100|+  34|-   0]: Done

This is on a relatively fast machine (it's on ARM, I had to comment out the SKIP in test/parallel/parallel.status locally - they work fine for me though, maybe it's okay to unskip now? cc @tniessen Also they were marked flaky on Windows because they were timing out, maybe it's okay to remove the flaky mark if the split tests are fast enough), on slower machines in the CI there could be a bit more differences

@joyeecheung
Copy link
Member Author

joyeecheung commented Aug 18, 2023

I think the length changes in the last commit should not affect the effectiveness of the tests, but cc @nodejs/crypto to be sure

@joyeecheung joyeecheung added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 18, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 18, 2023
@nodejs-github-bot
Copy link
Collaborator

@aduh95
Copy link
Contributor

aduh95 commented Aug 19, 2023

Also they were marked flaky on Windows because they were timing out, maybe it's okay to remove the flaky mark if the split tests are fast enough

Can we run a stress test to find out?

Copy link
Member

@lpinca lpinca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RSLGTM

@joyeecheung
Copy link
Member Author

Let's see if the stress test job understands wildcard.. https://ci.nodejs.org/job/node-stress-single-test/419/

@joyeecheung
Copy link
Member Author

Welp, it looks like the stress test job does not understand wildcards, let's see if we can pass all the tests into it... https://ci.nodejs.org/job/node-stress-single-test/421/ if it still does not work, I guess we can only rely on the full CI to check.

@joyeecheung joyeecheung added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 24, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 24, 2023
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@panva panva added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Aug 27, 2023
@nodejs-github-bot
Copy link
Collaborator

@panva panva removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Aug 27, 2023
Copy link
Member

@tniessen tniessen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a strong opinion on this. Admittedly, it's a long and slow test, but moving it to pummel or increasing timeouts seems reasonable to me as well. I've said many times that, in my opinion, (short) timeouts cause more problems than they solve.

Comment on lines +65 to +97
// Tests that a key pair can be used for encryption / decryption.
function testEncryptDecrypt(publicKey, privateKey) {
const message = 'Hello Node.js world!';
const plaintext = Buffer.from(message, 'utf8');
for (const key of [publicKey, privateKey]) {
const ciphertext = publicEncrypt(key, plaintext);
const received = privateDecrypt(privateKey, ciphertext);
assert.strictEqual(received.toString('utf8'), message);
}
}

// Tests that a key pair can be used for signing / verification.
function testSignVerify(publicKey, privateKey) {
const message = Buffer.from('Hello Node.js world!');

function oldSign(algo, data, key) {
return createSign(algo).update(data).sign(key);
}

function oldVerify(algo, data, key, signature) {
return createVerify(algo).update(data).verify(key, signature);
}

for (const signFn of [sign, oldSign]) {
const signature = signFn('SHA256', message, privateKey);
for (const verifyFn of [verify, oldVerify]) {
for (const key of [publicKey, privateKey]) {
const okay = verifyFn('SHA256', message, key, signature);
assert(okay);
}
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions have very generic names but very specific implementations. For example, testEncryptDecrypt works with certain asymmetric key pairs only, whereas most encryption and decryption operations in cryptography rely on symmetric keys.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a suggestions for the names? i think generally it's fine to have very generic names in the test commons - that's what we've been doing for many tests utils too. The point is just sharing code among tests. The were named that way in one long test test anyway, so keeping the name doesn't make much of a difference.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The were named that way in one long test test anyway, so keeping the name doesn't make much of a difference.

Yes, in a test file that exclusively used asymmetric encryption. But moving them into common, these functions become available to all tests.

I don't want to make this more work for you than it has to be, so I am fine with leaving the names as they are.

@joyeecheung
Copy link
Member Author

moving it to pummel or increasing timeouts seems reasonable to me as well

Mind that moving to pummel means usually people do not run them locally (we don't run them in make test). Increasing timeouts in the test runner for all tests isn't a great idea IMO - two minutes are already a lot. If a test doesn't finish in two minutes, either it's actually failing for some reason, or something should be done to them or the test suites would just take too long to complete. Unless there's a way to introduce per-test timeouts in the test runner.

@joyeecheung joyeecheung added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. labels Aug 31, 2023
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Aug 31, 2023
@nodejs-github-bot
Copy link
Collaborator

Landed in a81d5e1...b781eaf

nodejs-github-bot pushed a commit that referenced this pull request Aug 31, 2023
To avoid timing out on ARM machines in the CI.

PR-URL: #49221
Refs: #49202
Refs: #41206
Reviewed-By: Luigi Pinca <[email protected]>
nodejs-github-bot pushed a commit that referenced this pull request Aug 31, 2023
nodejs-github-bot pushed a commit that referenced this pull request Aug 31, 2023
UlisesGascon pushed a commit that referenced this pull request Sep 10, 2023
To avoid timing out on ARM machines in the CI.

PR-URL: #49221
Refs: #49202
Refs: #41206
Reviewed-By: Luigi Pinca <[email protected]>
UlisesGascon pushed a commit that referenced this pull request Sep 10, 2023
UlisesGascon pushed a commit that referenced this pull request Sep 10, 2023
@UlisesGascon UlisesGascon mentioned this pull request Sep 10, 2023
alexfernandez pushed a commit to alexfernandez/node that referenced this pull request Nov 1, 2023
To avoid timing out on ARM machines in the CI.

PR-URL: nodejs#49221
Refs: nodejs#49202
Refs: nodejs#41206
Reviewed-By: Luigi Pinca <[email protected]>
alexfernandez pushed a commit to alexfernandez/node that referenced this pull request Nov 1, 2023
alexfernandez pushed a commit to alexfernandez/node that referenced this pull request Nov 1, 2023
targos pushed a commit that referenced this pull request Nov 27, 2023
To avoid timing out on ARM machines in the CI.

PR-URL: #49221
Refs: #49202
Refs: #41206
Reviewed-By: Luigi Pinca <[email protected]>
targos pushed a commit that referenced this pull request Nov 27, 2023
targos pushed a commit that referenced this pull request Nov 27, 2023
sercher added a commit to sercher/graaljs that referenced this pull request Apr 25, 2024
To avoid timing out on ARM machines in the CI.

PR-URL: nodejs/node#49221
Refs: nodejs/node#49202
Refs: nodejs/node#41206
Reviewed-By: Luigi Pinca <[email protected]>
sercher added a commit to sercher/graaljs that referenced this pull request Apr 25, 2024
sercher added a commit to sercher/graaljs that referenced this pull request Apr 25, 2024
sercher added a commit to sercher/graaljs that referenced this pull request Apr 25, 2024
To avoid timing out on ARM machines in the CI.

PR-URL: nodejs/node#49221
Refs: nodejs/node#49202
Refs: nodejs/node#41206
Reviewed-By: Luigi Pinca <[email protected]>
sercher added a commit to sercher/graaljs that referenced this pull request Apr 25, 2024
sercher added a commit to sercher/graaljs that referenced this pull request Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. needs-ci PRs that need a full CI run. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants