Repository: fedora-infra/bodhi

Issue:
Update.greenwave_unsatisfied_requirements seems to be unused
Since talking to GW is handled by js, and Bodhi is working only based on GW decision, Update.greenwave_unsatisfied_requirements  seems to be unused.


Discussion:

Resolving patch:
diff --git a/bodhi/server/migrations/versions/9c0a34961768_remove_the_greenwave_unsatisfied_.py b/bodhi/server/migrations/versions/9c0a34961768_remove_the_greenwave_unsatisfied_.py
new file mode 100644
--- /dev/null
+++ b/bodhi/server/migrations/versions/9c0a34961768_remove_the_greenwave_unsatisfied_.py
@@ -0,0 +1,42 @@
+# Copyright (c) 2019 Sebastian Wojciechowski.
+#
+# This file is part of Bodhi.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+"""
+Remove the greenwave_unsatisfied_requirements field from updates.
+
+Revision ID: 9c0a34961768
+Revises: bdf0e37ab793
+Create Date: 2019-02-07 06:20:33.986578
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '9c0a34961768'
+down_revision = 'bdf0e37ab793'
+
+
+def upgrade():
+    """Drop the greenwave_unsatisfied_requirements from the updates table."""
+    op.drop_column('updates', 'greenwave_unsatisfied_requirements')
+
+
+def downgrade():
+    """Restore greenwave_unsatisfied_requirements field removed in the upgrade() function."""
+    op.add_column('updates',
+                  sa.Column('greenwave_unsatisfied_requirements', sa.UnicodeText(), nullable=True))
diff --git a/bodhi/server/models.py b/bodhi/server/models.py
--- a/bodhi/server/models.py
+++ b/bodhi/server/models.py
@@ -1622,9 +1622,6 @@ class Update(Base):
             Greenwave integration was not enabled when the update was created.
         greenwave_summary_string (unicode): A short summary of the outcome from Greenwave
             (e.g. 2 of 32 required tests failed).
-        greenwave_unsatisfied_requirements (unicode): When test_gating_status is failed, Bodhi will
-            set this to a JSON representation of the unsatisfied_requirements field from Greewave's
-            response.
         compose (Compose): The :class:`Compose` that this update is currently being composed in. The
             update is locked if this is defined.
     """
@@ -1700,7 +1697,6 @@ class Update(Base):
     # Greenwave
     test_gating_status = Column(TestGatingStatus.db_type(), default=None, nullable=True)
     greenwave_summary_string = Column(Unicode(255))
-    greenwave_unsatisfied_requirements = Column(UnicodeText, nullable=True)
 
     @property
     def side_tag_locked(self):
@@ -1944,11 +1940,8 @@ def update_test_gating_status(self):
                 self.test_gating_status = TestGatingStatus.ignored
             else:
                 self.test_gating_status = TestGatingStatus.passed
-            self.greenwave_unsatisfied_requirements = None
         else:
             self.test_gating_status = TestGatingStatus.failed
-            self.greenwave_unsatisfied_requirements = json.dumps(
-                decision.get('unsatisfied_requirements', []))
         self.greenwave_summary_string = decision['summary']
 
     @classmethod


Test patch:
diff --git a/bodhi/tests/server/consumers/test_updates.py b/bodhi/tests/server/consumers/test_updates.py
--- a/bodhi/tests/server/consumers/test_updates.py
+++ b/bodhi/tests/server/consumers/test_updates.py
@@ -18,7 +18,6 @@
 """This test suite contains tests for the bodhi.server.consumers.updates module."""
 
 import copy
-import json
 import mock
 import unittest
 
@@ -175,7 +174,6 @@ def test_gating_required_false(self, sleep):
         update = models.Update.query.filter_by(title=u'bodhi-2.0-1.fc17').one()
         self.assertIsNone(update.test_gating_status)
         self.assertIsNone(update.greenwave_summary_string)
-        self.assertIsNone(update.greenwave_unsatisfied_requirements)
         sleep.assert_called_once_with(1)
 
     @mock.patch.dict('bodhi.server.config.config', {'test_gating.required': True})
@@ -216,8 +214,6 @@ def test_gating_required_true(self, sleep):
         update = models.Update.query.filter_by(title=u'bodhi-2.0-1.fc17').one()
         self.assertEqual(update.test_gating_status, models.TestGatingStatus.failed)
         self.assertEqual(update.greenwave_summary_string, u'what have you done‽')
-        self.assertEqual(update.greenwave_unsatisfied_requirements,
-                         json.dumps(greenwave_response['unsatisfied_requirements']))
         sleep.assert_called_once_with(1)
 
     # We're going to use side effects to mock but still call work_on_bugs and fetch_test_cases so we
diff --git a/bodhi/tests/server/scripts/test_check_policies.py b/bodhi/tests/server/scripts/test_check_policies.py
--- a/bodhi/tests/server/scripts/test_check_policies.py
+++ b/bodhi/tests/server/scripts/test_check_policies.py
@@ -19,7 +19,6 @@
 
 from mock import patch
 import datetime
-import json
 
 from click import testing
 
@@ -51,7 +50,6 @@ def test_policies_satisfied(self):
             update = self.db.query(models.Update).filter(models.Update.id == update.id).one()
             self.assertEqual(update.test_gating_status, models.TestGatingStatus.passed)
             self.assertEqual(update.greenwave_summary_string, 'All tests passed')
-            self.assertIsNone(update.greenwave_unsatisfied_requirements)
 
         expected_query = {
             'product_version': 'fedora-17', 'decision_context': 'bodhi_update_push_stable',
@@ -86,7 +84,6 @@ def test_policies_pending_satisfied(self):
             update = self.db.query(models.Update).filter(models.Update.id == update.id).one()
             self.assertEqual(update.test_gating_status, models.TestGatingStatus.passed)
             self.assertEqual(update.greenwave_summary_string, 'All tests passed')
-            self.assertIsNone(update.greenwave_unsatisfied_requirements)
 
         expected_query = {
             'product_version': 'fedora-17', 'decision_context': 'bodhi_update_push_testing',
@@ -128,8 +125,6 @@ def test_policies_unsatisfied(self):
             update = self.db.query(models.Update).filter(models.Update.id == update.id).one()
             self.assertEqual(update.test_gating_status, models.TestGatingStatus.failed)
             self.assertEqual(update.greenwave_summary_string, '1 of 2 tests are failed')
-            self.assertEqual(update.greenwave_unsatisfied_requirements,
-                             json.dumps(greenwave_response['unsatisfied_requirements']))
 
         expected_query = {
             'product_version': 'fedora-17', 'decision_context': 'bodhi_update_push_stable',