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

Add a product stability test #10606

Merged
merged 6 commits into from
May 24, 2023

Conversation

matejak
Copy link
Member

@matejak matejak commented May 22, 2023

Description:

With the recent introduction of the product class in #10529 and planned introduction of product properties in #10554, a mechanism that can make sure that changes to product properties are under control seems to be needed.
The following test makes sure that if product properties are changed, such changes are confirmed.

It may be that in order to avoid situations s.a. the need to update all test references manually when a new property is introduced, the test script could have this as an option. Automatic update of references would still show in the PR diff, which would preserve the element of confirmation.

Rationale:

Review Hints:

  • Build a product, modify the compiled product yaml or the test reference, and either run the stable-products tests, or the test script directly.

@matejak matejak added this to the 0.1.68 milestone May 22, 2023
@github-actions
Copy link

Start a new ephemeral environment with changes proposed in this pull request:

Fedora Environment
Open in Gitpod

Oracle Linux 8 Environment
Open in Gitpod

@matejak
Copy link
Member Author

matejak commented May 23, 2023

I propose to waive the codeclimate findings, because some of the similarity issues are not worth the attention.

return msg


def describe_change(difference, name):
Copy link
Collaborator

Choose a reason for hiding this comment

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

This function seems to be useful but unfortunately it isn't called anywhere.


import ssg.products

import tests.test_profile_stability as stability
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of importing the test_profile_stability I would prefer to extract the shared code to a separate file.

if not compiled_product:
msg = ("Unexpectedly unable to find compiled product file corresponding"
"to the test file {ref}, although the corresponding product has been built. "
"This indicates that a profile we have tests for is missing."
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably should be a product, not a profile.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually if the file doesn't exist, the product loader will throw an error by itself. This is an extremely unlikely scenario, as the built product directory existence has been checked before. Therefore, I remove the exception handling, as the traceback is good enough for such unlikely cases, and the less code the better.

return result


def get_references(ref_root):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would be a better name get_reference_files

@jan-cerny jan-cerny self-assigned this May 23, 2023
@codeclimate
Copy link

codeclimate bot commented May 23, 2023

Code Climate has analyzed commit c2d7846 and detected 2 issues on this pull request.

Here's the issue category breakdown:

Category Count
Duplication 2

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 52.5% (0.0% change).

View more on Code Climate.

Copy link
Collaborator

@jan-cerny jan-cerny left a comment

Choose a reason for hiding this comment

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

I have seen the code. Then, I have seen that both affected test cases pass in the "Build, Test on Fedora Latest (Container)" GitHub CI jobs. I have examined manually that when I change add and remove some product properties or profile items the test cases start to fail. For example:

[jcerny@thinkpad build{pr/10606}]$ ctest --verbose -R stable-products
UpdateCTestConfiguration  from :/home/jcerny/work/git/scap-security-guide/build/DartConfiguration.tcl
UpdateCTestConfiguration  from :/home/jcerny/work/git/scap-security-guide/build/DartConfiguration.tcl
Test project /home/jcerny/work/git/scap-security-guide/build
Constructing a list of tests
Done constructing a list of tests
Updating test list for fixtures
Added 0 tests to meet fixture requirements
Checking test dependency graph...
Checking test dependency graph end
test 16
    Start 16: stable-products

16: Test command: /usr/bin/env "PYTHONPATH=/home/jcerny/work/git/scap-security-guide" "/usr/bin/python3" "/home/jcerny/work/git/scap-security-guide/tests/test_product_stability.py" "/home/jcerny/work/git/scap-security-guide/build" "/home/jcerny/work/git/scap-security-guide/tests/data/product_stability"
16: Working Directory: /home/jcerny/work/git/scap-security-guide/build/tests
16: Test timeout computed to be: 10000000
16: Following properties got different values in the rhel9 product:
16:  - faillock_path from '/var/log/faillock' -> '/var/log/faillock.d'
16: If changes to mentioned products are intentional, copy those compiled files, so they become the new reference:
16: cp '/home/jcerny/work/git/scap-security-guide/build/rhel9/product.yml' '/home/jcerny/work/git/scap-security-guide/tests/data/product_stability/rhel9.yml'
16: If those changes are unwanted, take a look at product properties that likely cause these changes.
1/1 Test #16: stable-products ..................***Failed    0.26 sec

0% tests passed, 1 tests failed out of 1

Label Time Summary:
quick    =   0.26 sec*proc (1 test)

Total Test time (real) =   0.26 sec

The following tests FAILED:
	 16 - stable-products (Failed)
Errors while running CTest
Output from these tests are in: /home/jcerny/work/git/scap-security-guide/build/Testing/Temporary/LastTest.log
Use "--rerun-failed --output-on-failure" to re-run the failed cases verbosely.
[jcerny@thinkpad build{pr/10606}]$ ctest --verbose -R stable-products
UpdateCTestConfiguration  from :/home/jcerny/work/git/scap-security-guide/build/DartConfiguration.tcl
UpdateCTestConfiguration  from :/home/jcerny/work/git/scap-security-guide/build/DartConfiguration.tcl
Test project /home/jcerny/work/git/scap-security-guide/build
Constructing a list of tests
Done constructing a list of tests
Updating test list for fixtures
Added 0 tests to meet fixture requirements
Checking test dependency graph...
Checking test dependency graph end
test 16
    Start 16: stable-products

16: Test command: /usr/bin/env "PYTHONPATH=/home/jcerny/work/git/scap-security-guide" "/usr/bin/python3" "/home/jcerny/work/git/scap-security-guide/tests/test_product_stability.py" "/home/jcerny/work/git/scap-security-guide/build" "/home/jcerny/work/git/scap-security-guide/tests/data/product_stability"
16: Working Directory: /home/jcerny/work/git/scap-security-guide/build/tests
16: Test timeout computed to be: 10000000
16: Following properties were added to the rhel9 product:
16:  - my_variable
16: Following properties got different values in the rhel9 product:
16:  - dconf_gdm_dir from 'distro.d' -> 'gdm.d'
16: If changes to mentioned products are intentional, copy those compiled files, so they become the new reference:
16: cp '/home/jcerny/work/git/scap-security-guide/build/rhel9/product.yml' '/home/jcerny/work/git/scap-security-guide/tests/data/product_stability/rhel9.yml'
16: If those changes are unwanted, take a look at product properties that likely cause these changes.
1/1 Test #16: stable-products ..................***Failed    0.26 sec

0% tests passed, 1 tests failed out of 1

Label Time Summary:
quick    =   0.26 sec*proc (1 test)

Total Test time (real) =   0.27 sec

The following tests FAILED:
	 16 - stable-products (Failed)
Errors while running CTest
Output from these tests are in: /home/jcerny/work/git/scap-security-guide/build/Testing/Temporary/LastTest.log
Use "--rerun-failed --output-on-failure" to re-run the failed cases verbosely.

@jan-cerny
Copy link
Collaborator

I'm OK with the Code Climate because it is common that argument parsing function in Python code look similar.

@jan-cerny jan-cerny merged commit 4004945 into ComplianceAsCode:master May 24, 2023
31 of 32 checks passed
@jan-cerny jan-cerny added Infrastructure Our content build system Test Suite Update in Test Suite. labels Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Infrastructure Our content build system Test Suite Update in Test Suite.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants