Skip to content

Commit 449af8f

Browse files
author
mn-ram
committed
[fix] Add group-scoped cache invalidation task for device group context change #1070
Replace the org-wide invalidate_controller_views_cache call in DeviceGroup.save() with a new group-scoped task invalidate_controller_views_for_group that only clears DeviceChecksumView entries for devices belonging to that group, avoiding unnecessary invalidation of unrelated devices and VPN caches. Also adds assertion in test_status_update_on_group_variable_change to verify the scoped task is enqueued with the correct group_id.
1 parent 966c931 commit 449af8f

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

openwisp_controller/config/tests/test_device.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,8 @@ def test_status_update_on_org_variable_change(self):
440440
c1.templates.add(
441441
self._create_template(
442442
name="t-with-var",
443-
config={"interfaces": [{"name": "eth0", "type": "{{ ssid }}"}]},
444-
default_values={"ssid": "default"},
443+
config={"interfaces": [{"name": "{{ ssid }}", "type": "ethernet"}]},
444+
default_values={"ssid": "eth0"},
445445
)
446446
)
447447
c1.set_status_applied()
@@ -468,8 +468,8 @@ def test_status_update_on_group_variable_change(self):
468468
c1.templates.add(
469469
self._create_template(
470470
name="t-with-var",
471-
config={"interfaces": [{"name": "eth0", "type": "{{ ssid }}"}]},
472-
default_values={"ssid": "default"},
471+
config={"interfaces": [{"name": "{{ ssid }}", "type": "ethernet"}]},
472+
default_values={"ssid": "eth0"},
473473
)
474474
)
475475
c1.set_status_applied()
@@ -480,7 +480,10 @@ def test_status_update_on_group_variable_change(self):
480480
c2.set_status_applied()
481481
dg.context = {"ssid": "OrgA"}
482482
dg.full_clean()
483-
patch_path = "openwisp_controller.config.base.device_group.invalidate_controller_views_for_group"
483+
patch_path = (
484+
"openwisp_controller.config.base.device_group"
485+
".invalidate_controller_views_for_group"
486+
)
484487
with mock.patch(patch_path) as mocked_task:
485488
dg.save()
486489
mocked_task.delay.assert_called_once_with(str(dg.id))

0 commit comments

Comments
 (0)