Skip to content
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

Added new elements to delete event #392

Merged
merged 35 commits into from
Aug 27, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1095e6e
Added canonical_facts to delete method and HostEvent class
aleccohan Aug 2, 2019
79c48c5
Small Changes to a few files for local development
aleccohan Aug 5, 2019
610227f
changed hack_client.py to not upload multiple chunks
aleccohan Aug 5, 2019
5038067
More small changes to try and setup the local dev enviroment
aleccohan Aug 5, 2019
b0d8808
added insights_id to delete event and all canonical facts to HostEven…
aleccohan Aug 7, 2019
4c95079
deleted unecessary comments
aleccohan Aug 7, 2019
c046158
removed utils folder containing unecessary tests
aleccohan Aug 7, 2019
08a275c
Added instructions about adding kafka to hosts file to README
aleccohan Aug 7, 2019
addc78e
Changed original host_id_to_delete.append() into a dictionary & added…
aleccohan Aug 8, 2019
40f6db1
added additional conditions to DeleteHostsTestCase to test changes to…
aleccohan Aug 8, 2019
e6de4f2
Fine tuned tests to work with mac_addresses and ip_addresses
aleccohan Aug 8, 2019
a789023
added account to delete method to help with callback to legacy api
aleccohan Aug 9, 2019
bc5b827
Merge branch 'new_delete_conditions'
aleccohan Aug 9, 2019
d6f8476
tested changes with mock data and removed mock data from events.py
aleccohan Aug 12, 2019
8937269
Merge branch 'master' of https://github.com/RedHatInsights/insights-h…
aleccohan Aug 13, 2019
37ae521
Merge remote-tracking branch 'origin' into added_delete_tests
aleccohan Aug 13, 2019
5595299
Merge branch 'master' of https://github.com/RedHatInsights/insights-h…
aleccohan Aug 14, 2019
8a76897
made suggested changes, used serialization method for not defined can…
aleccohan Aug 13, 2019
4612bf4
ran changes through pre-commit screening & implemented suggestions
aleccohan Aug 14, 2019
db47368
Merge branch 'master' of https://github.com/RedHatInsights/insights-h…
aleccohan Aug 14, 2019
b2299f0
Merge branch 'master' into new_delete_conditions
aleccohan Aug 14, 2019
a698d7f
applied suggestions made, added test for timestamp and type, generate…
aleccohan Aug 14, 2019
1bbf69c
Merged with master
aleccohan Aug 14, 2019
d1b46a2
made changes based on feedback
aleccohan Aug 15, 2019
44b99d3
merged added_delete_tests with new_delete_conditions
aleccohan Aug 15, 2019
1af93ce
made suggested changes to test_api.py
aleccohan Aug 15, 2019
8e1892e
Updated changes based on feedback
aleccohan Aug 2, 2019
2dc997b
Merge branch 'new_delete_conditions' of https://github.com/aleccohan/…
aleccohan Aug 15, 2019
05367ff
removed validations from HostEvent(Schema)
aleccohan Aug 16, 2019
355ba89
Added validate back in to match create/update schema
aleccohan Aug 21, 2019
fd38720
Fix 500 ERROR and adapt ObjectDeletedError to new code
aleccohan Aug 22, 2019
60025fb
Added request_id to the delete event
aleccohan Aug 23, 2019
a2b0c4d
removing validations from Schema
aleccohan Aug 23, 2019
c4c01ef
simplified validations to include specified attributes
aleccohan Aug 26, 2019
b586b70
fixed Delete event tests in test_api.py
aleccohan Aug 26, 2019
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
13 changes: 3 additions & 10 deletions app/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from app.logging import threadctx
from app.models import CanonicalFacts
from app.validators import verify_uuid_format

logger = logging.getLogger(__name__)

Expand All @@ -14,16 +15,8 @@ class HostEvent(Schema):
id = fields.UUID()
timestamp = fields.DateTime(format="iso8601")
type = fields.Str()
account = fields.Str()
insights_id = fields.Str()
rhel_machine_id = fields.Str()
subscription_manager_id = fields.Str()
satellite_id = fields.Str()
fqdn = fields.Str()
bios_uuid = fields.Str()
ip_addresses = fields.List(fields.Str())
mac_addresses = fields.List(fields.Str())
external_id = fields.Str()
account = fields.Str(required=True)
insights_id = fields.Str(validate=verify_uuid_format)
request_id = fields.Str()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does the request ID has a fixed format? Even if so, we probably don’t want to specify it here as we’re only blindly forwarding it.



Expand Down
26 changes: 2 additions & 24 deletions test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1238,36 +1238,14 @@ def __call__(self, e):
timestamp_iso = datetime_mock.utcnow.return_value.isoformat()

self.assertIsInstance(event, dict)
expected_keys = {
"timestamp",
"type",
"id",
"account",
"insights_id",
"rhel_machine_id",
"subscription_manager_id",
"satellite_id",
"bios_uuid",
"ip_addresses",
"fqdn",
"mac_addresses",
"external_id",
}
expected_keys = {"timestamp", "type", "id", "account", "insights_id", "request_id"}
self.assertEqual(set(event.keys()), expected_keys)

self.assertEqual(f"{timestamp_iso}+00:00", event["timestamp"])
self.assertEqual("delete", event["type"])
self.assertEqual(self.added_hosts[0].id, event["id"])
self.assertEqual(self.added_hosts[0].insights_id, event["insights_id"])
self.assertEqual(self.added_hosts[0].rhel_machine_id, event["rhel_machine_id"])
self.assertEqual(self.added_hosts[0].subscription_manager_id, event["subscription_manager_id"])
self.assertEqual(self.added_hosts[0].satellite_id, event["satellite_id"])
self.assertEqual(self.added_hosts[0].bios_uuid, event["bios_uuid"])
self.assertEqual(self.added_hosts[0].fqdn, event["fqdn"])
self.assertEqual(self.added_hosts[0].external_id, event["external_id"])
self.assertEqual(self.added_hosts[0].account, event["account"])
self.assertEqual(self.added_hosts[0].ip_addresses, event["ip_addresses"])
self.assertEqual(self.added_hosts[0].mac_addresses, event["mac_addresses"])
self.assertEqual("-1", event["request_id"])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we test a real forwarded request ID too along with this default unknown one?


# Try to get the host again
response = self.get(url, 200)
Expand Down