I found a bug in our fix-uuids and check-uuids scripts
That script should output all entries for \:id:.* in all test_ files, sort it and grep for duplicate uuids, if found it takes the filename and linenumber and apply the fix by creating a new uuid to the latest duplicate found.
In this part: https://github.com/SatelliteQE/robottelo/blob/master/scripts/fix_uuids.sh#L52-L81
The command uniq -d is considering the whole output line and not only the \:id:.* so if it find duplicates in the same file it reports, but if duplicates are in different files it will not consider a duplicate because the filename is different.
We need to find a way to make uniq -d to compare only the string after :id: or change it to use awk
@elyezer @kbidarkar @Ichimonji10 as it is a bash issue I think one of you can help to find a solution. I am experimenting with awk but no success yet.
@rochacbruno
Output example:
tests/foreman/cli/test_repository.py: :id: 71388973-50ea-4a20-9406-0aca142014ca
tests/foreman/api/test_repository.py: :id: 71388973-50ea-4a20-9406-0aca142014ca
% sort --help
-n, --numeric-sort compare according to string numerical value
-k, --key=KEYDEF sort via a key; KEYDEF gives location and type
i.e. it would be sort -n -k3 that means sort by third field separated by whitespaces for output above.
% uniq --help
-f, --skip-fields=N avoid comparing the first N fields
i.e. it would be uniq -d -f2 that meansskip first two fields separated by whitespaces that contains name and ':id:' string for output above.
Results:
% grep -r -i $ID_TOKEN tests/foreman/ --include='*.py' | grep 71388973-50ea-4a20-9406-0aca142014ca
tests/foreman/api/test_repository.py: :id: 71388973-50ea-4a20-9406-0aca142014ca
tests/foreman/cli/test_repository.py: :id: 71388973-50ea-4a20-9406-0aca142014ca
% grep -r -i $ID_TOKEN tests/foreman/ --include='*.py' | sort -n -k3 | uniq -d -f2
tests/foreman/api/test_repository.py: :id: 71388973-50ea-4a20-9406-0aca142014ca
Most helpful comment
@rochacbruno
Output example:
i.e. it would be
sort -n -k3that meanssort by third field separated by whitespacesfor output above.i.e. it would be
uniq -d -f2that meansskip first two fields separated by whitespaces that contains name and ':id:' stringfor output above.Results: