mgr/orch: allow for multiline OrchestratorEvent message#36334
Merged
sebastian-philipp merged 1 commit intoceph:masterfrom Jul 30, 2020
Merged
mgr/orch: allow for multiline OrchestratorEvent message#36334sebastian-philipp merged 1 commit intoceph:masterfrom
sebastian-philipp merged 1 commit intoceph:masterfrom
Conversation
Contributor
Author
|
This PR allows for a proper multi-line yaml: |
jschmid1
approved these changes
Jul 29, 2020
sebastian-philipp
approved these changes
Jul 29, 2020
Contributor
|
mind adding something similar to: --- a/src/pybind/mgr/orchestrator/_interface.py
+++ b/src/pybind/mgr/orchestrator/_interface.py
@@ -1642,6 +1642,13 @@ class OrchestratorEvent:
return cls(*match.groups())
raise ValueError(f'Unable to match: "{data}"')
+ def __eq__(self, other):
+ if not isinstance(other, OrchestratorEvent):
+ return False
+
+ return self.created == other.created and self.kind == other.kind \
+ and self.subject == other.subject and self.message == other.message
+
def _mk_orch_methods(cls):
# Needs to be defined outside of for.
diff --git a/src/pybind/mgr/orchestrator/tests/test_orchestrator.py b/src/pybind/mgr/orchestrator/tests/test_orchestrator.py
index 1dd6a964a9..cc1e6e401f 100644
--- a/src/pybind/mgr/orchestrator/tests/test_orchestrator.py
+++ b/src/pybind/mgr/orchestrator/tests/test_orchestrator.py
@@ -1,5 +1,6 @@
from __future__ import absolute_import
+import datetime
import json
import pytest
@@ -278,4 +279,13 @@ events:
assert to_format([object], 'yaml', True, cls) == y
j = json.loads(to_format(object, 'json', False, cls))
- assert to_format(cls.from_json(j), 'yaml', False, cls) == y
\ No newline at end of file
+ assert to_format(cls.from_json(j), 'yaml', False, cls) == y
+
+
+def test_event_multiline():
+ from .._interface import OrchestratorEvent
+ e = OrchestratorEvent(datetime.datetime.utcnow(), 'service', 'subject', 'ERROR', 'message')
+ assert OrchestratorEvent.from_json(e.to_json()) == e
+
+ e = OrchestratorEvent(datetime.datetime.utcnow(), 'service', 'subject', 'ERROR', 'multiline\nmessage')
+ assert OrchestratorEvent.from_json(e.to_json()) == e
would be great to prevent an regressions here. |
c5972a0 to
4c50efe
Compare
Signed-off-by: Michael Fritch <mfritch@suse.com>
4c50efe to
a108612
Compare
Contributor
Author
|
jenkins test dashboard backend |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Multi-line OrchestratorEvent messages break the output of the ls command:
Signed-off-by: Michael Fritch mfritch@suse.com
Checklist
Show available Jenkins commands
jenkins retest this pleasejenkins test classic perfjenkins test crimson perfjenkins test signedjenkins test make checkjenkins test make check arm64jenkins test submodulesjenkins test dashboardjenkins test dashboard backendjenkins test docsjenkins render docsjenkins test ceph-volume alljenkins test ceph-volume tox