-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
[monitoring] fix: use retrying module in the fixture class #3285
Changes from 1 commit
ac2f9b0
cdb488f
c3edce4
a78c2e6
5532261
5f4fcc1
5e9e929
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
pytest==5.3.2 | ||
gcp-devrel-py-tools==0.0.15 | ||
google-cloud-core | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
import random | ||
import string | ||
|
||
from gcp_devrel.testing import eventually_consistent | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In general I'd prefer we stop relying on this module altogether. It's not maintained and a lot of the logic isn't really great for testing. IIRC, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kurtisvg But, I kinda disagree with your two points; for the first point "It's not maintained", we can maintain it, right? I'm happy to do that from now on. For the second point, "lot of the logic isn't really great for testing." Can you elaborate? Maybe you can file a bug on the repo? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still think But I agree that flaky is more suitable with this test. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. RE: maintenance - it doesn't seem worth the effort of us maintaining and releasing a special module just for testing our samples. Are our libraries really so hard to test that we can't find an out of the box solution to reach reasonable tests? (I think the answer is no) RE: logic - IMO, flakey tests are bad tests. Running a test several times hoping at least one passes means that potentially, our users also have to run the sample multiple times to make sure that it's working. Ideally, the snippet should work the first time, every time. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kurtisvg Thanks for the discussion. Let's discuss further off PR :) |
||
from google.cloud import monitoring_v3 | ||
import google.protobuf.json_format | ||
import pytest | ||
|
@@ -74,12 +75,14 @@ def pochan(): | |
yield pochan | ||
|
||
|
||
@eventually_consistent.mark | ||
def test_list_alert_policies(capsys, pochan): | ||
snippets.list_alert_policies(pochan.project_name) | ||
out, _ = capsys.readouterr() | ||
assert pochan.alert_policy.display_name in out | ||
|
||
|
||
@eventually_consistent.mark | ||
def test_enable_alert_policies(capsys, pochan): | ||
snippets.enable_alert_policies(pochan.project_name, False) | ||
out, _ = capsys.readouterr() | ||
|
@@ -97,6 +100,7 @@ def test_enable_alert_policies(capsys, pochan): | |
assert "already enabled" in out | ||
|
||
|
||
@eventually_consistent.mark | ||
def test_replace_channels(capsys, pochan): | ||
alert_policy_id = pochan.alert_policy.name.split('/')[-1] | ||
notification_channel_id = pochan.notification_channel.name.split('/')[-1] | ||
|
@@ -106,6 +110,7 @@ def test_replace_channels(capsys, pochan): | |
assert "Updated {0}".format(pochan.alert_policy.name) in out | ||
|
||
|
||
@eventually_consistent.mark | ||
def test_backup_and_restore(capsys, pochan): | ||
snippets.backup(pochan.project_name, 'backup.json') | ||
out, _ = capsys.readouterr() | ||
|
@@ -117,6 +122,7 @@ def test_backup_and_restore(capsys, pochan): | |
pochan.notification_channel.display_name) in out | ||
|
||
|
||
@eventually_consistent.mark | ||
def test_delete_channels(capsys, pochan): | ||
notification_channel_id = pochan.notification_channel.name.split('/')[-1] | ||
snippets.delete_notification_channels( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason not to pin a version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a temporary workaround. It'll go away.
(Actually, I'll use flaky, so those 2 lines will go away)