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 new test to ensure that CCEs are removed from the avail file #11590

Merged
merged 3 commits into from
Feb 19, 2024

Conversation

Mab879
Copy link
Member

@Mab879 Mab879 commented Feb 14, 2024

Description:

This test ensures that any assigned CCE isn't in the respective avail file.

Rationale:

Help reviewers catch errors.

@Mab879 Mab879 added the Infrastructure Our content build system label Feb 14, 2024
@Mab879 Mab879 added this to the 0.1.73 milestone Feb 14, 2024
This test ensures that any assigned CCE isn't in the respective avail
file.
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

@jan-cerny jan-cerny self-assigned this Feb 15, 2024
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 tried it and it successfully detected CCE in a rule that isn't removed from the pool.

@@ -0,0 +1,72 @@
#! /usr/bin/python3
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
#! /usr/bin/python3
#!/usr/bin/python3

"run.")
parser.add_argument('-p', '--products', required=True,
help='Comma separated list (no spaces) of products to check')
parser.add_argument('-l', '--cee-list', type=str, required=True,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
parser.add_argument('-l', '--cee-list', type=str, required=True,
parser.add_argument('-l', '--cce-list', type=str, required=True,

if(PYTHON_VERSION_MAJOR GREATER 2)
add_test(
NAME "cce_avail_check-${TEST_NAME_SUFFIX}"
COMMAND env "PYTHONPATH=$ENV{PYTHONPATH}" "${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/cces-removed.py" --root "${CMAKE_SOURCE_DIR}" --json "${CMAKE_SOURCE_DIR}/build/rule_dirs.json" --products "${PRODUCTS}" --cee-list "${CCE_LIST_PATH}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
COMMAND env "PYTHONPATH=$ENV{PYTHONPATH}" "${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/cces-removed.py" --root "${CMAKE_SOURCE_DIR}" --json "${CMAKE_SOURCE_DIR}/build/rule_dirs.json" --products "${PRODUCTS}" --cee-list "${CCE_LIST_PATH}"
COMMAND env "PYTHONPATH=$ENV{PYTHONPATH}" "${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/cces-removed.py" --root "${CMAKE_SOURCE_DIR}" --json "${CMAKE_SOURCE_DIR}/build/rule_dirs.json" --products "${PRODUCTS}" --cce-list "${CCE_LIST_PATH}"


cce_avail_check("rhel-all" "rhel7,rhel8,rhel9" "${CMAKE_SOURCE_DIR}/shared/references/cce-redhat-avail.txt")
cce_avail_check("sle12" "sle12" "${CMAKE_SOURCE_DIR}/shared/references/cce-sle12-avail.txt")
cce_avail_check("sle15" "sle15" "${CMAKE_SOURCE_DIR}/shared/references/cce-sle12-avail.txt")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
cce_avail_check("sle15" "sle15" "${CMAKE_SOURCE_DIR}/shared/references/cce-sle12-avail.txt")
cce_avail_check("sle15" "sle15" "${CMAKE_SOURCE_DIR}/shared/references/cce-sle15-avail.txt")

Mab879 added a commit to Mab879/content that referenced this pull request Feb 15, 2024
Mab879 added a commit to Mab879/content that referenced this pull request Feb 15, 2024
@Mab879
Copy link
Member Author

Mab879 commented Feb 15, 2024

/packit retest-failed

not_removed = avail_cces.intersection(cces_in_use)
if len(not_removed) != 0:
for cce in not_removed:
print(f"CCE {cce} not removed from {args.cee_list}.", file=sys.stderr)
Copy link
Collaborator

Choose a reason for hiding this comment

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

here is one more place with the typo

Copy link

codeclimate bot commented Feb 16, 2024

Code Climate has analyzed commit dc85741 and detected 0 issues on this pull request.

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 58.3% (0.0% change).

View more on Code Climate.

@jan-cerny
Copy link
Collaborator

/packit retest-failed

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 tried to create a forgotten CCE and this test has detected it.

@Mab879
Copy link
Member Author

Mab879 commented Feb 18, 2024

/packit retest-failed

1 similar comment
@jan-cerny
Copy link
Collaborator

/packit retest-failed

@jan-cerny jan-cerny merged commit 087d023 into ComplianceAsCode:master Feb 19, 2024
44 checks passed
@Mab879 Mab879 deleted the add_cce_avail_test branch February 19, 2024 15:08
benruland pushed a commit to sig-bsi-grundschutz/content that referenced this pull request Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Infrastructure Our content build system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants