Skip to content

fix: Solve v2 events not scoping created events #180

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
Jan 18, 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
2 changes: 1 addition & 1 deletion sdcclient/monitor/_events_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def post_event(self, name, description=None, severity=None, event_filter=None, t
'name': name,
'description': description,
'severity': severity,
'filter': event_filter,
'scope': event_filter,
'tags': tags
}
edata = {
Expand Down
13 changes: 13 additions & 0 deletions specs/monitor/events_v2_spec.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import time
from datetime import datetime, timedelta
from time import sleep

from expects import expect, have_key, contain, have_keys, be_empty, equal, be_false, be_above_or_equal, have_len
from mamba import it, before, context, description
Expand All @@ -19,6 +20,18 @@
description="This event was created in a CI pipeline for the Python SDK library")
expect(call).to(be_successful_api_call)

with it("is able to create a custom event with a scope"):
call = self.client.post_event(name=self.event_name,
description="This event was created in a CI pipeline for the Python SDK library",
event_filter="host.hostName='ci'")
expect(call).to(be_successful_api_call)
sleep(2) # sleep to guarantee the event is created

ok, res = self.client.get_events()
expect((ok, res)).to(be_successful_api_call)
expect(res).to(have_key("events"))
expect(res["events"]).to(contain(have_key("scope", equal("host.hostName = 'ci'"))))

with it("is able to list the events happened without any filter"):
time.sleep(3) # Wait for the event to appear in the feed
ok, res = self.client.get_events()
Expand Down