-
Notifications
You must be signed in to change notification settings - Fork 171
spec: test the integrity of distro/adaption files #492
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
Conversation
c978bf5
to
0c340d3
Compare
spec/os_mapping_spec.rb
Outdated
|
||
it 'does not have any package mapping repeated in all groups' do | ||
common_packages = find_common_packages(grouped_files) | ||
expect(common_packages).to be_empty, "Common package mappings found in all groups: #{common_packages.join(', ')}" |
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.
thanks, do you mean that one package appears in all distros?
The initial thinking is we can check for each distro, whether there's a common mapping across all its specific mappings.
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.
Hi @rli9 , currently there are 2 function that handle below requirement:
find_duplicated_lines -> no duplicated line between the default OS mapping and each OS-specific mapping, e.g. amazon_linux against "amazon_linux -*".
find_common_packages -> no line is duplicated across all OS-specific mappings. e.g. "a: b" exists in all os specific mappings is not expected.
find_duplicated_lines will check if certain package installed across specific distro, for example when centos contain arping: iputils, centos-7 also contain arping: iputils, then the test will fail.
find_common_packages will check if certain package installed across all the different distro, for example when apache2: httpd contain in all the distro available for example ubuntu (ubuntu, ubuntu-20.04, ubuntu-), centos (centos, centos-), and all the other, then the test will fail.
Would like to check if this is the required checks? Else can we have more details on what is required for this 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.
find_duplicated_lines -> no duplicated line between the default OS mapping and each OS-specific mapping
Thanks, this part is right.
find_common_packages will check if certain package installed across all the different distro
For this, the requirement is to check each distro separately, for example, if ubuntu-* contains same line, then it fails. But ubuntu has no relationship with centos.
spec/os_mapping_spec.rb
Outdated
File.file?(file_path) && !File.symlink?(file_path) && f != 'README.md' | ||
end | ||
|
||
mappings = {} |
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.
consider to use mappings = Hash.new { |h, k| h[k] = [] }, so later "mappings[base_name] ||= []" is not needed.
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.
Thanks for review, I updated mappings and removed the line
spec/os_mapping_spec.rb
Outdated
LKP_SRC_PATH = "#{LKP_SRC}/distro/adaptation".freeze | ||
|
||
def find_duplicated_lines(default_mapping_path, os_specific_mapping_path) | ||
default_mapping_file = File.readlines(default_mapping_path).map(&:strip) |
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.
can here use read_mappings method? and help rename default_mapping_file to default_mapping_lines
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.
Thanks for review, I updated File.readlines to read_mappings and renaled to default_mapping_lines
0c340d3
to
1637dfe
Compare
c9adc8e
to
10b4e6b
Compare
Consider there's PR that reorganize the dir, you don't need to fix the failure, just submit the spec code is fine.
BTW: how about this comment? |
Thanks, we will be working on updating test based on the comment part today |
a981840
to
41c4b2c
Compare
spec/os_mapping_spec.rb
Outdated
end | ||
end | ||
|
||
os_specific_files.combination(2).each do |os_specific_file_1, os_specific_file_2| |
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.
thanks, need do one more change that the comparison is not between 2 files, because it's ok that there's same mapping in debian/10 and debian/11 (but not in 12). It is not ok if there's mapping existing in all debian os-specific files (10, 11, 12), because in this case, the map need be moved to default file.
spec/os_mapping_spec.rb
Outdated
end | ||
end | ||
end | ||
end |
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.
consider to add a new line here
…fault OS mapping and each OS-specific mappings. Fix intel#484 Signed-off-by: Ong, Yen Yee <[email protected]> Signed-off-by: Chiam, Jia Ying <[email protected]> Signed-off-by: yeetengangIntel <[email protected]> Signed-off-by: Wei Shan <[email protected]> Signed-off-by: Seow, Wen Jie <[email protected]>
41c4b2c
to
6742974
Compare
Hi, I have changed the spec test accordingly. I have also manual solved the errors being caught by this spec test and push to another branch. Let me know if you would like me to cherry-pick the commit into this branch. |
Thanks, the code looks good. And it's very helpful if you also have the fix. |
distro/adaptation/fedora/default
Outdated
@@ -364,6 +365,7 @@ nbd-client: nbd | |||
nbd-server: nbd | |||
ncurses-bin: ncurses | |||
netcat-openbsd: nmap-ncat | |||
netpipe-lam: | |||
netpipe-lam: NetPIPE |
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.
thanks, the above 2 lines looks wrong, both mapping to netpipe-lam. And help check failure of Checks 'Ruby / test-packages (fedora/41) (pull_request)"
Removed the duplicated lines in os_specific files and add the duplicated lines which appear in all os_specific to the default file. Signed-off-by: Ong, Yen Yee <[email protected]> Signed-off-by: Chiam, Jia Ying <[email protected]>
3b00c7e
to
02d9751
Compare
The netpipe-lam error solved. Currently working on the github action failure on fedora package. |
Signed-off-by: Seow, Wen Jie <[email protected]>
thanks for the patch |
Fix #484