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: Enable specifying flaky tests on fips #16329

Closed
wants to merge 1 commit into from

Conversation

komawar
Copy link
Contributor

@komawar komawar commented Oct 20, 2017

Adds a way to mark a specified test as 'flaky' on fips compliant
systems.

Earlier, the tools/test.py script supported only 'mode',
'system' and 'arch' for test environment specification. This limits the
ability to specify the behavior of tests and setting pre-determined
behavior of the same on other types of systems. As an example, the
feature request below indicates the need to specify certain tests as
'flaky' on fips compliant systems. It hints at future possibility of a
shared library, which in turn may need a specifier for running tests.

This commit introduces a new item in the env dict, called type
which defaults to simple type. It also adds an optional command
line argument --type, which inputs strings. Current functionality
extends to setting simple or fips for this type variable.
However, extending it to further uses is rather simple by adding "if"
conditions at appropriate places in the tools/test.py script.

Fixes: #14746

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)
  • build
  • doc
  • test

@nodejs-github-bot nodejs-github-bot added test Issues and PRs related to the tests. tools Issues and PRs related to the tools directory. labels Oct 20, 2017
@refack
Copy link
Contributor

refack commented Oct 20, 2017

@komawar thanks!

Could you add a "negative control"? a test that fails if hasFipsCrypto, in test/parallel something like:

const common = require('../common');
if (common.hasFipsCrypto) process.exit(1);

Then add an exception in parallel.status. That would serve as documentation as well.

@refack refack self-assigned this Oct 20, 2017
@komawar
Copy link
Contributor Author

komawar commented Oct 20, 2017

@refack Thanks for your review! Surely, let me look into it / wrap my head around this.

@komawar
Copy link
Contributor Author

komawar commented Oct 20, 2017

Just wanted to leave a comment (ease the load on reviewers) on a sample test run which I conducted, here's the commit that details the run and marked tests as flaky (for testing purposes):
komawar@4a957ca

@refack
Copy link
Contributor

refack commented Oct 20, 2017

Sure. Take a look at the current status file:

prefix parallel
# To mark a test as flaky, list the test name in the appropriate section
# below, without ".js", followed by ": PASS,FLAKY". Example:
# sample-test : PASS,FLAKY
[true] # This section applies to all platforms
[$system==win32]
[$system==linux]
[$system==macos]
[$arch==arm || $arch==arm64]
test-npm-install: PASS,FLAKY
[$system==solaris] # Also applies to SmartOS
[$system==freebsd]
[$system==aix]

@komawar
Copy link
Contributor Author

komawar commented Oct 20, 2017

@refack Oh I get it now! (I misread what you were saying there). Surely, I was hoping to get a pointer on how to best test this and here it is! perfect, I will add this.

@refack
Copy link
Contributor

refack commented Oct 20, 2017

Maybe a most verbose way to "fail" the test is to use assert:

if (common.hasFipsCrypto)
  assert.fail(`expected to fail with FIPS enabled`)

Copy link
Member

@gibfahn gibfahn left a comment

Choose a reason for hiding this comment

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

Couple of thoughts

// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
Copy link
Member

Choose a reason for hiding this comment

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

Copyright is not needed in new files AIUI (cc/ @jasnell for confirmation).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file has been removed as per @Trott 's suggestion.

Makefile Outdated
@@ -505,6 +505,9 @@ test-v8 test-v8-intl test-v8-benchmarks test-v8-all:
"$ git clone https://github.com/nodejs/node.git"
endif

test-on-fips:
$(PYTHON) tools/test.py --type=fips
Copy link
Member

Choose a reason for hiding this comment

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

I don't think a separate command is needed here, we have way too many commands as it is. Also we'd really need to provide a fips option for every make target that includes tools/test.py. I think what would be helpful is a way to pass arguments to tools/test.py calls using an environment variable, simillar to CONFIG_FLAGS. That should be done separately, so I'll raise a separate issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok. do you want me to wait until that's been discussed or should we go with something short term here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for that insight. The latest PR excludes these changes.

tools/test.py Outdated
@@ -1427,6 +1427,9 @@ def BuildOptions():
result.add_option('--abort-on-timeout',
help='Send SIGABRT instead of SIGTERM to kill processes that time out',
default=False, action="store_true", dest="abort_on_timeout")
result.add_option("--type",
help="Specifies the environment type the tests will run on, for example 'fips'",
Copy link
Member

Choose a reason for hiding this comment

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

So currently this only supports fips right? I think we should give an exhaustive list of the possible options, so maybe something like:

Specifies the type of build. Options: fips"

That way we can easily expand the list when we add more options (like shared).

Otherwise the for example is misleading.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done. ty

// This test will fail on fips. The corresponding line in
// parallel.status file makes sure this is marked as flaky and passes.
'use strict';
const common = require('../common');
Copy link
Member

Choose a reason for hiding this comment

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

Can you order these as per the writing tests guide? Basically use strict, require common, comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure. thanks for pointing that out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ditto

@komawar
Copy link
Contributor Author

komawar commented Oct 25, 2017

Thanks for your reviews. I will wait until more comments, confirmations and direction has been discussed to update this.

BUILDING.md Outdated
@@ -135,6 +135,15 @@ $ make test
At this point you are ready to make code changes and re-run the tests!
Optionally, continue below.

If you wish to run tests on specific systems, say ``fips``:
Copy link
Member

Choose a reason for hiding this comment

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

Nit: FIPS is not a system. (Is it more correct to call it a "configuration"?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file has been removed as per your suggestion.

BUILDING.md Outdated
```

This particular command will mark the tests specified in the \*.status files as
flaky.
Copy link
Member

Choose a reason for hiding this comment

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

This is confusing. Running make test-on-fips will not mark tests as flaky.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ditto

# Sample test (test-negative-on-fips) has been added to check the
# skip-on-fips feature (issue 14746)
[$type==fips]
test-negative-on-fips: PASS,FLAKY
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this should be part of the PR nor the associated test. We don't have permanent entries in the *.status files. If something is in there, it's because the test is having a problem that needs to be addressed.

I don't believe we generally test the test.py code directly like this. That may not be a great practice, but trying to introduce it in this PR is probably not the way to go.

Copy link
Contributor Author

@komawar komawar Nov 7, 2017

Choose a reason for hiding this comment

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

This file has been removed as per your suggestion.

@Trott Trott added the python PRs and issues that require attention from people who are familiar with Python. label Oct 25, 2017
@Trott
Copy link
Member

Trott commented Oct 25, 2017

This is great and thanks for doing it! I think we only need the changes in test.py here. The changes to Makefile, parallel.status, the new test, and the documentation seem extraneous, which seems weird to say. "Hey, nice PR, but can you remove the tests and the documentation?" Yeah, that suggests a problem with our process. :-D You were probably just following the checklist so apologies for having our documentation make you do work that maybe wasn't necessary. :-(

All that said, I would be excited to have a working skip-FIPS feature in test.py!!!!!! Let's do this thing!

@komawar
Copy link
Contributor Author

komawar commented Nov 7, 2017

@Trott @refack @gibfahn thanks for your reviews. I was hoping that we sort of have a convergence of opinion for this conversation (given the views of three of your differed on the reviews) but in the interest of time, I have avoided the extra commits and the latest PR has just the test.py changes as per @Trott 's suggestion. Hopefully, that is okay with everyone referenced in the review process (and any following reviews)!

I will create a different PR indicating that changes to test.py do not need (for most cases) the related changes as in this earlier PR.

cheers

tools/test.py Outdated
@@ -1427,6 +1427,9 @@ def BuildOptions():
result.add_option('--abort-on-timeout',
help='Send SIGABRT instead of SIGTERM to kill processes that time out',
default=False, action="store_true", dest="abort_on_timeout")
result.add_option("--type",
help="Specifies the type of build. Options: fips"
Copy link
Member

Choose a reason for hiding this comment

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

Nit (non-blocking): Can we format this more like existing options?

For example, using this as a model:

"The style of progress indicator (verbose, dots, color, mono, tap)"

...this would be:

"Type of build (default, fips)"

...or don't list the options at all if they're not enumerated by this file (which I don't see where they are).

Copy link
Member

Choose a reason for hiding this comment

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

The options are default or fips AFAIK.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, the options are default or fips.

You don't see the enumeration as there are no more choices and the existing code parses the type = fips to give you PASS, FAIL, SKIP functionality. It took me some time to figure this out, code is crazy old, pretty complicated to read and I do intend to follow up with a blog entry on this soon(ish), for knowledge sharing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

... also this will have to change a bit for shared case when we might see some enumertaion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Trott (formatting has been done in latest)

@Trott
Copy link
Member

Trott commented Nov 8, 2017

There isn't any pre-existing functionality to already skip a test if an entry for type of fips if I include something like this in a .status file, is there?

[$type==fips]
test-foo-bar: SKIP,FLAKY

@komawar
Copy link
Contributor Author

komawar commented Nov 8, 2017

@Trott

There isn't any pre-existing functionality to already skip a test if an entry for type of fips if I include something like this in a .status file, is there?

Yes, it should work out-of-the-box for:-

[$type==fips]
test-foo-bar: SKIP,FLAKY

Please see an example test I've created here komawar@4a957ca , (had referenced this before but is hard to find so that's okay).

This is one of the reasons I had added the negative sample test here komawar@5bf0d6a as suggested by @refack , itself acts as a bit documentation. But I do agree that we prolly shouldn't change the structure/type of tests in the repo like you mentioned earlier.

Maybe we can have a "mock" test for such things but I don't see where it exists for tools/test.py -- ideas appreciated. May be something for future?

@gibfahn
Copy link
Member

gibfahn commented Nov 8, 2017

So actually I think what would be really useful is if tools/test.py could auto-detect that you're running a fips build, and set the type accordingly.

So instead of having to run tools/test.py --type=fips, you'd just run tools/test.py, and it would work out that node was a fips-enabled one.

You can check that by doing node -p process.versions.openssl and checking that it contains the string fips.

@komawar if you'd be up for implementing that that would be amazing. Let me know if you get stuck anywhere, I did something similar in this file recently, so could help out with it if needed.

@komawar
Copy link
Contributor Author

komawar commented Nov 9, 2017

So instead of having to run tools/test.py --type=fips, you'd just run tools/test.py, and it would work out that node was a fips-enabled one.

You can check that by doing node -p process.versions.openssl and checking that it contains the string fips.

@gibfahn no issues, this looks like a good idea. gonna go at it..

However, I still think we need the --type, may be for future purposes or if you wanted to enforce default (or any other) behavior on specific systems. Thoughts?

@gibfahn
Copy link
Member

gibfahn commented Nov 9, 2017

However, I still think we need the --type, may be for future purposes or if you wanted to enforce default (or any other) behavior on specific systems. Thoughts?

I think you're right, having the --type override the guessed version makes sense. And yes, we'll definitely want more types going forward.

@komawar
Copy link
Contributor Author

komawar commented Nov 9, 2017

So actually I think what would be really useful is if tools/test.py could auto-detect that you're running a fips build, and set the type accordingly.

This has been done.

Adds a way to mark a specified test as 'flaky' on fips compliant
systems.

Earlier, the ``tools/test.py`` script supported only 'mode',
'system' and 'arch' for test environment specification. This limits the
ability to specify the behavior of tests and setting pre-determined
behavior of the same on other types of systems. As an example, the
feature request below indicates the need to specify certain tests as
'flaky' on fips compliant systems. It hints at future possibility of a
shared library, which in turn may need a specifier for running tests.

This commit introduces a new item in the ``env`` dict, called ``type``
which defaults to ``simple`` type. It also adds an optional command
line argument ``--type``, which inputs strings. Current functionality
extends to setting ``simple`` or ``fips`` for this ``type`` variable.
However, extending it to further uses is rather simple by adding "if"
conditions at appropriate places in the ``tools/test.py`` script.

Fixes: issue 14746
@gibfahn
Copy link
Member

gibfahn commented Nov 11, 2017

@Trott what do you think?

@Trott
Copy link
Member

Trott commented Nov 13, 2017

@gibfahn No objections!

@BridgeAR
Copy link
Member

@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Nov 23, 2017
@addaleax
Copy link
Member

Landed in f31cf56

@addaleax addaleax closed this Nov 28, 2017
@addaleax addaleax removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Nov 28, 2017
addaleax pushed a commit that referenced this pull request Nov 28, 2017
Adds a way to mark a specified test as 'flaky' on fips compliant
systems.

Earlier, the ``tools/test.py`` script supported only 'mode',
'system' and 'arch' for test environment specification. This limits the
ability to specify the behavior of tests and setting pre-determined
behavior of the same on other types of systems. As an example, the
feature request below indicates the need to specify certain tests as
'flaky' on fips compliant systems. It hints at future possibility of a
shared library, which in turn may need a specifier for running tests.

This commit introduces a new item in the ``env`` dict, called ``type``
which defaults to ``simple`` type. It also adds an optional command
line argument ``--type``, which inputs strings. Current functionality
extends to setting ``simple`` or ``fips`` for this ``type`` variable.
However, extending it to further uses is rather simple by adding "if"
conditions at appropriate places in the ``tools/test.py`` script.

PR-URL: #16329
Fixes: #14746
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@refack
Copy link
Contributor

refack commented Nov 29, 2017

FYI: This change uses subprocess.check_output which is a python 2.7 only feature
It is failing on our Centos6 CI workers - https://ci.nodejs.org/job/node-test-commit-linux/14398/nodes=centos6-64/console

For the time being I've updated the workers to use python2.7 and opened #17381 to improve this change.

/CC @nodejs/build

@gibfahn
Copy link
Member

gibfahn commented Nov 29, 2017

Thanks for fixing @refack , wonder why it didn't fail pre-land CI.

@refack
Copy link
Contributor

refack commented Nov 29, 2017

wonder why it didn't fail pre-land CI.

It did - node-test-commit-linux/14398 was part or the above mentioned node-test-pull-request/11661

@refack
Copy link
Contributor

refack commented Nov 29, 2017

So apparently it's not simple to upgrade CentOS6 to python2.7, so I'd rather fast-track #17381 then fiddle around with the system config.

@refack refack removed their assignment Nov 29, 2017
MylesBorins pushed a commit that referenced this pull request Dec 12, 2017
Adds a way to mark a specified test as 'flaky' on fips compliant
systems.

Earlier, the ``tools/test.py`` script supported only 'mode',
'system' and 'arch' for test environment specification. This limits the
ability to specify the behavior of tests and setting pre-determined
behavior of the same on other types of systems. As an example, the
feature request below indicates the need to specify certain tests as
'flaky' on fips compliant systems. It hints at future possibility of a
shared library, which in turn may need a specifier for running tests.

This commit introduces a new item in the ``env`` dict, called ``type``
which defaults to ``simple`` type. It also adds an optional command
line argument ``--type``, which inputs strings. Current functionality
extends to setting ``simple`` or ``fips`` for this ``type`` variable.
However, extending it to further uses is rather simple by adding "if"
conditions at appropriate places in the ``tools/test.py`` script.

PR-URL: #16329
Fixes: #14746
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
MylesBorins pushed a commit that referenced this pull request Dec 12, 2017
Adds a way to mark a specified test as 'flaky' on fips compliant
systems.

Earlier, the ``tools/test.py`` script supported only 'mode',
'system' and 'arch' for test environment specification. This limits the
ability to specify the behavior of tests and setting pre-determined
behavior of the same on other types of systems. As an example, the
feature request below indicates the need to specify certain tests as
'flaky' on fips compliant systems. It hints at future possibility of a
shared library, which in turn may need a specifier for running tests.

This commit introduces a new item in the ``env`` dict, called ``type``
which defaults to ``simple`` type. It also adds an optional command
line argument ``--type``, which inputs strings. Current functionality
extends to setting ``simple`` or ``fips`` for this ``type`` variable.
However, extending it to further uses is rather simple by adding "if"
conditions at appropriate places in the ``tools/test.py`` script.

PR-URL: #16329
Fixes: #14746
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
MylesBorins pushed a commit that referenced this pull request Dec 12, 2017
Adds a way to mark a specified test as 'flaky' on fips compliant
systems.

Earlier, the ``tools/test.py`` script supported only 'mode',
'system' and 'arch' for test environment specification. This limits the
ability to specify the behavior of tests and setting pre-determined
behavior of the same on other types of systems. As an example, the
feature request below indicates the need to specify certain tests as
'flaky' on fips compliant systems. It hints at future possibility of a
shared library, which in turn may need a specifier for running tests.

This commit introduces a new item in the ``env`` dict, called ``type``
which defaults to ``simple`` type. It also adds an optional command
line argument ``--type``, which inputs strings. Current functionality
extends to setting ``simple`` or ``fips`` for this ``type`` variable.
However, extending it to further uses is rather simple by adding "if"
conditions at appropriate places in the ``tools/test.py`` script.

PR-URL: #16329
Fixes: #14746
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@MylesBorins MylesBorins mentioned this pull request Dec 12, 2017
gibfahn pushed a commit that referenced this pull request Dec 19, 2017
Adds a way to mark a specified test as 'flaky' on fips compliant
systems.

Earlier, the ``tools/test.py`` script supported only 'mode',
'system' and 'arch' for test environment specification. This limits the
ability to specify the behavior of tests and setting pre-determined
behavior of the same on other types of systems. As an example, the
feature request below indicates the need to specify certain tests as
'flaky' on fips compliant systems. It hints at future possibility of a
shared library, which in turn may need a specifier for running tests.

This commit introduces a new item in the ``env`` dict, called ``type``
which defaults to ``simple`` type. It also adds an optional command
line argument ``--type``, which inputs strings. Current functionality
extends to setting ``simple`` or ``fips`` for this ``type`` variable.
However, extending it to further uses is rather simple by adding "if"
conditions at appropriate places in the ``tools/test.py`` script.

PR-URL: #16329
Fixes: #14746
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@gibfahn
Copy link
Member

gibfahn commented Dec 19, 2017

This would be good to have on v6.x-staging? Could someone backport this with #17381? Guide is here.

gibfahn pushed a commit that referenced this pull request Dec 20, 2017
Adds a way to mark a specified test as 'flaky' on fips compliant
systems.

Earlier, the ``tools/test.py`` script supported only 'mode',
'system' and 'arch' for test environment specification. This limits the
ability to specify the behavior of tests and setting pre-determined
behavior of the same on other types of systems. As an example, the
feature request below indicates the need to specify certain tests as
'flaky' on fips compliant systems. It hints at future possibility of a
shared library, which in turn may need a specifier for running tests.

This commit introduces a new item in the ``env`` dict, called ``type``
which defaults to ``simple`` type. It also adds an optional command
line argument ``--type``, which inputs strings. Current functionality
extends to setting ``simple`` or ``fips`` for this ``type`` variable.
However, extending it to further uses is rather simple by adding "if"
conditions at appropriate places in the ``tools/test.py`` script.

PR-URL: #16329
Fixes: #14746
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@gibfahn gibfahn mentioned this pull request Dec 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python PRs and issues that require attention from people who are familiar with Python. test Issues and PRs related to the tests. tools Issues and PRs related to the tools directory.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: mark tests flaky on FIPS
9 participants