Skip to content

Commit

Permalink
Merge pull request #53 from ralphbean/fedmsg-backwards-compat
Browse files Browse the repository at this point in the history
Add topic to the message body
  • Loading branch information
chuazhan committed Jun 17, 2022
2 parents 1e5aed3 + 79db2b5 commit 86ddec1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion greenwave/listeners/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def _inc(self, messaging_counter):
messaging_counter.labels(**self.monitor_labels).inc()

def _publish_decision_update(self, decision):
message = {"msg": decision}
message = {"msg": decision, "topic": self.destination}
body = json.dumps(message)
while True:
try:
Expand Down
27 changes: 20 additions & 7 deletions greenwave/tests/test_listeners.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,8 @@ def retrieve_decision(data, _config):
"previous": old_decision,
}
expected_message.update(new_decision)
assert json.loads(mock_call["body"]) == {"msg": expected_message}
expected_body = {"msg": expected_message, "topic": DECISION_UPDATE_TOPIC}
assert json.loads(mock_call["body"]) == expected_body


@pytest.mark.parametrize(
Expand Down Expand Up @@ -492,7 +493,9 @@ def test_remote_rule_decision_change(
"subject_identifier": DUMMY_NVR,
"policies_satisfied": True,
"previous": {"policies_satisfied": False},
}
},
# Duplication of the topic in the body for datanommer, for fedmsg backwards compat
"topic": DECISION_UPDATE_TOPIC,
}


Expand Down Expand Up @@ -690,7 +693,9 @@ def test_decision_change_for_modules(
"subject_identifier": nsvc,
"policies_satisfied": True,
"previous": {"policies_satisfied": False},
}
},
# Duplication of the topic in the body for datanommer, for fedmsg backwards compat
"topic": DECISION_UPDATE_TOPIC,
}


Expand Down Expand Up @@ -753,7 +758,9 @@ def test_decision_change_for_composes(
"subject_identifier": "RHEL-9000",
"policies_satisfied": True,
"previous": {"policies_satisfied": False},
}
},
# Duplication of the topic in the body for datanommer, for fedmsg backwards compat
"topic": DECISION_UPDATE_TOPIC,
}


Expand Down Expand Up @@ -843,7 +850,9 @@ def test_fake_fedora_messaging_msg(mock_retrieve_results, mock_connection):
"subject_identifier": "FEDORA-2019-9244c8b209",
"policies_satisfied": True,
"previous": {"policies_satisfied": False},
}
},
# Duplication of the topic in the body for datanommer, for fedmsg backwards compat
"topic": DECISION_UPDATE_TOPIC,
}


Expand Down Expand Up @@ -910,7 +919,9 @@ def test_container_brew_build(mock_retrieve_results, koji_proxy, mock_connection
"subject_identifier": "example-container",
"policies_satisfied": True,
"previous": {"policies_satisfied": False},
}
},
# Duplication of the topic in the body for datanommer, for fedmsg backwards compat
"topic": DECISION_UPDATE_TOPIC,
}


Expand Down Expand Up @@ -957,7 +968,9 @@ def test_waiverdb_message(mock_connection):
"testcase": "example_test",
"policies_satisfied": True,
"previous": {"policies_satisfied": False},
}
},
# Duplication of the topic in the body for datanommer, for fedmsg backwards compat
"topic": DECISION_UPDATE_TOPIC,
}


Expand Down

0 comments on commit 86ddec1

Please sign in to comment.