mirror of
https://github.com/quay/quay.git
synced 2026-01-26 06:21:37 +03:00
workers(quotaregistrysize): fixed wrong condition to run quotasizeworker from PROJQUAY-8086 (PROJQUAY-9460) (#4313)
PROJQUAY-9460 (fix): Total Registry Size Calculation return 0 KB and always queued
This commit is contained in:
@@ -39,7 +39,7 @@ if __name__ == "__main__":
|
||||
time.sleep(100000)
|
||||
|
||||
# Registry size is only viewable by superusers, don't calculate if not used
|
||||
if not all(
|
||||
if not any(
|
||||
[
|
||||
any(
|
||||
[
|
||||
|
||||
@@ -4,6 +4,10 @@ import features
|
||||
from test.fixtures import *
|
||||
from workers.quotaregistrysizeworker import QuotaRegistrySizeWorker
|
||||
|
||||
# since all checks are happening only when the worker is the main process `if __name__ == "__main__:`
|
||||
# we need to re-implement the call/not-call logic as duplicate.
|
||||
# Considering to move it into the `_calculate_registry_size` instead is dropped as dependencies are not clear
|
||||
|
||||
|
||||
def test_registrysizeworker(initialized_db):
|
||||
with patch(
|
||||
@@ -31,6 +35,7 @@ def test_registrysizeworker_recovery(initialized_db):
|
||||
def test_registrysizeworker_no_quotamanagement(initialized_db):
|
||||
# we expect to fail since we do not have quota management enabled
|
||||
features.QUOTA_MANAGEMENT = False
|
||||
features.SUPER_USERS = True
|
||||
app.config.update({"SUPER_USERS": ["someone"]})
|
||||
if features.QUOTA_MANAGEMENT:
|
||||
with patch(
|
||||
@@ -43,8 +48,10 @@ def test_registrysizeworker_no_quotamanagement(initialized_db):
|
||||
|
||||
def test_registrysizeworker_no_superusers(initialized_db):
|
||||
# we expect to fail since we do not have any superusers
|
||||
app.config.update({"SUPER_USERS": [""]})
|
||||
if features.QUOTA_MANAGEMENT:
|
||||
features.QUOTA_MANAGEMENT = True
|
||||
features.SUPER_USERS = True
|
||||
app.config.update({"SUPER_USERS": []})
|
||||
if all([features.QUOTA_MANAGEMENT, features.SUPER_USERS, len(app.config["SUPER_USERS"]) > 0]):
|
||||
with patch(
|
||||
"workers.quotaregistrysizeworker.calculate_registry_size", MagicMock()
|
||||
) as mock_calculate_registry_size:
|
||||
@@ -55,9 +62,11 @@ def test_registrysizeworker_no_superusers(initialized_db):
|
||||
|
||||
def test_registrysizeworker_ldap_superusers(initialized_db):
|
||||
# we expect to succeed since LDAP_SUPERUSERS_FILTER is not empty
|
||||
features.QUOTA_MANAGEMENT = False
|
||||
features.SUPER_USERS = True
|
||||
app.config.update({"LDAP_SUPERUSER_FILTER": "(objectClass=*)"})
|
||||
app.config.update({"SUPER_USERS": []})
|
||||
if not all(
|
||||
if not any(
|
||||
[
|
||||
any(
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user