diff --git a/src/rockstor/storageadmin/fixtures/test_config_backup.json b/src/rockstor/storageadmin/fixtures/test_config_backup.json index 81536632c..46c79e8c9 100644 --- a/src/rockstor/storageadmin/fixtures/test_config_backup.json +++ b/src/rockstor/storageadmin/fixtures/test_config_backup.json @@ -13,6 +13,20 @@ "role": null } }, +{ + "model": "storageadmin.pool", + "pk": 4, + "fields": { + "name": "rock-pool2", + "uuid": "3176aa98-a939-4f7b-aa6c-70c18570fc8e", + "size": 5242880, + "raid": "single", + "toc": "2023-03-03T21:21:14.952Z", + "compression": "no", + "mnt_options": "", + "role": null + } +}, { "model": "storageadmin.share", "pk": 3, diff --git a/src/rockstor/storageadmin/tests/test_config_backup.py b/src/rockstor/storageadmin/tests/test_config_backup.py index 8ac91eb7f..64ee47303 100644 --- a/src/rockstor/storageadmin/tests/test_config_backup.py +++ b/src/rockstor/storageadmin/tests/test_config_backup.py @@ -30,11 +30,14 @@ """ Fixture creation instructions: -System needs 1 non system pool 'rock-pool', at any raid level. +System needs 2 non system pools: +- 'rock-pool', at any raid level. +- 'rock-pool2', at any raid level. - Create 1 share named 'test_share01' - Create 1 share named 'test_share02' +export DJANGO_SETTINGS_MODULE="settings" poetry run django-admin dumpdata storageadmin.pool storageadmin.share \ --natural-foreign --indent 4 > \ src/rockstor/storageadmin/fixtures/test_config_backup.json @@ -1192,6 +1195,42 @@ class ConfigBackupTests(APITestMixin): "model": "smart_manager.taskdefinition", "pk": 3, }, + { + "model": "smart_manager.taskdefinition", + "pk": 4, + "fields": { + "name": "rockpool_scrub", + "task_type": "scrub", + "json_meta": '{"pool_name": "rock-pool", "pool": "2"}', + "enabled": False, + "crontab": "42 3 * * 5", + "crontabwindow": "*-*-*-*-*-*", + }, + }, + { + "model": "smart_manager.taskdefinition", + "pk": 5, + "fields": { + "name": "boguspool_scrub", + "task_type": "scrub", + "json_meta": '{"pool_name": "bogus-pool", "pool": "99"}', + "enabled": False, + "crontab": "42 3 * * 5", + "crontabwindow": "*-*-*-*-*-*", + }, + }, + { + "model": "smart_manager.taskdefinition", + "pk": 6, + "fields": { + "name": "rockpool2_scrub", + "task_type": "scrub", + "json_meta": '{"pool_name": "rock-pool2", "pool": "3"}', + "enabled": False, + "crontab": "42 3 * * 5", + "crontabwindow": "*-*-*-*-*-*", + }, + }, ] @classmethod @@ -1865,7 +1904,6 @@ def test_validate_taskdef_meta(self): "max_count": "4", } ] - out = [ { "writable": True, @@ -1876,6 +1914,14 @@ def test_validate_taskdef_meta(self): } ] + task_type.append("scrub") + taskdef_meta.append({"pool_name": "rock-pool", "pool": "2"}) + out.append({"pool_name": "rock-pool", "pool": "2"}) + + task_type.append("scrub") + taskdef_meta.append({"pool_name": "rock-pool2", "pool": "3"}) + out.append({"pool_name": "rock-pool2", "pool": "4"}) + for t, m, o in zip(task_type, taskdef_meta, out): ret = validate_taskdef_meta(self.sa_ml, m, t) self.assertEqual( @@ -1893,20 +1939,38 @@ def test_validate_task_definitions(self): - invalid metadata: wrong share ID in backup file (snap_daily_ts02 in sm_ml) - invalid metadata: share does not exist on target system (snap_daily_ts04 in sm_ml) """ - out = [{ - "task_type": "snapshot", - "name": "snap_daily_ts01", - "crontabwindow": "*-*-*-*-*-*", - "enabled": False, - "crontab": "42 3 * * *", - "meta": { - "writable": True, - "visible": True, - "prefix": "snap_daily_ts01", - "share": "3", - "max_count": "4", + out = [ + { + "task_type": "snapshot", + "name": "snap_daily_ts01", + "crontabwindow": "*-*-*-*-*-*", + "enabled": False, + "crontab": "42 3 * * *", + "meta": { + "writable": True, + "visible": True, + "prefix": "snap_daily_ts01", + "share": "3", + "max_count": "4", + }, + }, + { + "task_type": "scrub", + "name": "rockpool_scrub", + "crontabwindow": "*-*-*-*-*-*", + "enabled": False, + "crontab": "42 3 * * 5", + "meta": {"pool_name": "rock-pool", "pool": "2"}, + }, + { + "task_type": "scrub", + "name": "rockpool2_scrub", + "crontabwindow": "*-*-*-*-*-*", + "enabled": False, + "crontab": "42 3 * * 5", + "meta": {"pool_name": "rock-pool2", "pool": "4"}, }, - }] + ] ret = validate_task_definitions(self.sm_ml, self.sa_ml) self.assertEqual( ret,