Skip to content

PYTHON-3014 Update how events are added to entity map to match specification #785

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion test/test_create_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ def test_store_events_as_entities(self):
self.scenario_runner.TEST_SPEC = spec
self.scenario_runner.setUp()
self.scenario_runner.run_scenario(spec["tests"][0])
self.scenario_runner.entity_map["client0"].close()
final_entity_map = self.scenario_runner.entity_map
self.assertIn("events1", final_entity_map)
self.assertGreater(len(final_entity_map["events1"]), 0)
for event in final_entity_map["events1"]:
self.assertIn("PoolCreatedEvent", event)
self.assertIn("PoolCreatedEvent", event["name"])

def test_store_all_others_as_entities(self):
self.scenario_runner = UnifiedSpecTestMixinV1()
Expand Down Expand Up @@ -130,6 +131,7 @@ def test_store_all_others_as_entities(self):
self.scenario_runner.TEST_SPEC = spec
self.scenario_runner.setUp()
self.scenario_runner.run_scenario(spec["tests"][0])
self.scenario_runner.entity_map["client0"].close()
final_entity_map = self.scenario_runner.entity_map
for entity in ["errors", "failures"]:
self.assertIn(entity, final_entity_map)
Expand Down
6 changes: 5 additions & 1 deletion test/unified_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,11 @@ def add_event(self, event):
if event_name in self._event_types:
super(EventListenerUtil, self).add_event(event)
for id in self._event_mapping[event_name]:
self.entity_map[id].append(str(event))
self.entity_map[id].append({
"name": type(event).__name__,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

repr(event) is better than just the type name because it includes the event name and other additional info (see the __repr__ methods in monitoring.py).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally had it just use str(event). However,

 if ('name' not in event) or (not event['name'].endswith('Event')):
                    self.fail("The workload executor didn't record event name as expected.")

This line from validator.py in drivers-atlas-testing seems to indicate that it expects it to just have the name, and no additional information

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, in that case can we add a new field for the full event repr?

Copy link
Contributor Author

@juliusgeo juliusgeo Nov 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

"observedAt": time.time(),
"description": repr(event)
})

def _command_event(self, event):
if event.command_name.lower() not in self._ignore_commands:
Expand Down