summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJeff Bradberry <jeff.bradberry@gmail.com>2024-05-29 20:42:56 +0200
committerJeff Bradberry <jeff.bradberry@gmail.com>2024-06-10 22:36:22 +0200
commit2c3a7fafc5f4462214168d673c69196af06e5d6d (patch)
tree65ae5d5a70fd6714226c689bf68daead01d192b3 /tools
parentMark and rebuild the implicit_parents field for all affected roles (diff)
downloadawx-2c3a7fafc5f4462214168d673c69196af06e5d6d.tar.xz
awx-2c3a7fafc5f4462214168d673c69196af06e5d6d.zip
Add a new test scenario
to trigger the implicit parent not being in the parents and ancestors lists.
Diffstat (limited to 'tools')
-rw-r--r--tools/scripts/ig-hotfix/scenarios/test4.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/scripts/ig-hotfix/scenarios/test4.py b/tools/scripts/ig-hotfix/scenarios/test4.py
new file mode 100644
index 0000000000..9198ac94f3
--- /dev/null
+++ b/tools/scripts/ig-hotfix/scenarios/test4.py
@@ -0,0 +1,26 @@
+from django.db import connection
+from awx.main.models import InstanceGroup
+
+InstanceGroup.objects.filter(name__in=('green', 'yellow', 'red')).delete()
+
+green = InstanceGroup.objects.create(name='green')
+red = InstanceGroup.objects.create(name='red')
+yellow = InstanceGroup.objects.create(name='yellow')
+
+for ig in InstanceGroup.objects.all():
+ print((ig.id, ig.name, ig.use_role_id))
+
+with connection.cursor() as cursor:
+ cursor.execute("UPDATE main_instancegroup SET use_role_id = NULL WHERE name = 'red'")
+ cursor.execute(f"UPDATE main_instancegroup SET use_role_id = {green.use_role_id} WHERE name = 'yellow'")
+
+green.refresh_from_db()
+red.refresh_from_db()
+yellow.refresh_from_db()
+green.save()
+red.save()
+yellow.save()
+
+print("=====================================")
+for ig in InstanceGroup.objects.all():
+ print((ig.id, ig.name, ig.use_role_id))