Check ACLs for all namespaces

Remove hardcoded list of namespaces with iterating over all directories
in the check of valid ACLs.

Remove parameter, we don't need to pass it in.

Be more verbose and report directories scanned and number of ACL files
read.

Change-Id: I4193ac59b431d31f3ce835c93950745e5b742418
This commit is contained in:
Andreas Jaeger 2019-05-31 20:14:47 +02:00
parent ef188ee2f6
commit 7114e79485
2 changed files with 11 additions and 6 deletions

View File

@ -6,16 +6,18 @@ export TMPDIR=$(/bin/mktemp -d)
trap "rm -rf $TMPDIR" EXIT trap "rm -rf $TMPDIR" EXIT
pushd $TMPDIR pushd $TMPDIR
CONFIGS_LIST_BASE=$OLDPWD/$1 CONFIGS_LIST_BASE=$OLDPWD/gerrit/acls
declare -i NUM_TESTS=0
function check_team_acl { function check_team_acl {
local configs_dir="$1" local configs_dir="$1"
local configs_list local configs_list
local failure=0
echo "Checking" $(basename $configs_dir)
configs_list=$(find $configs_dir -name "*.config") configs_list=$(find $configs_dir -name "*.config")
for config in $configs_list; do for config in $configs_list; do
let "NUM_TESTS+=1"
$OLDPWD/tools/normalize_acl.py $config all > $TMPDIR/normalized $OLDPWD/tools/normalize_acl.py $config all > $TMPDIR/normalized
if ! diff -u $config $TMPDIR/normalized >>config_failures; if ! diff -u $config $TMPDIR/normalized >>config_failures;
then then
@ -25,8 +27,10 @@ function check_team_acl {
} }
# Add more namespaces here, if necessary # Add more namespaces here, if necessary
for namespace in openstack openstack-infra stackforge; do for namespace in $CONFIGS_LIST_BASE/*; do
check_team_acl "${CONFIGS_LIST_BASE}${namespace}" if [ -d $namespace ] ; then
check_team_acl "${namespace}"
fi
done done
num_errors=$(cat config_failures | grep "is not normalized" | wc -l) num_errors=$(cat config_failures | grep "is not normalized" | wc -l)
@ -37,5 +41,6 @@ if [ $num_errors -ne 0 ]; then
fi fi
echo "Gerrit ACL configs are valid!" echo "Gerrit ACL configs are valid!"
echo "Checked $NUM_TESTS ACL files"
popd popd

View File

@ -62,7 +62,7 @@ deps =
commands = commands =
{toxinidir}/tools/check_valid_gerrit_projects.py gerrit/projects.yaml gerrit/acls zuul/main.yaml {toxinidir}/tools/check_valid_gerrit_projects.py gerrit/projects.yaml gerrit/acls zuul/main.yaml
{toxinidir}/tools/check_projects_yaml_alphabetized.sh gerrit/projects.yaml {toxinidir}/tools/check_projects_yaml_alphabetized.sh gerrit/projects.yaml
{toxinidir}/tools/check_valid_gerrit_config.sh gerrit/acls/ {toxinidir}/tools/check_valid_gerrit_config.sh
{toxinidir}/tools/check_gerrit_projects_changed.sh {toxinidir}/tools/check_gerrit_projects_changed.sh
[testenv:venv] [testenv:venv]