Skip to content

Commit

Permalink
Fix flakyness of test_tags (#454)
Browse files Browse the repository at this point in the history
  • Loading branch information
zippolyte committed Oct 2, 2019
1 parent 8e953ea commit e62969e
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions tests/integration/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,28 @@ def test_tags(self):
get_with_retry("Tag", hostname)

# Ready to test
tags = dog.Tag.create(hostname, tags=["test_tag:1", "test_tag:2"], source="datadog")
assert "test_tag:1" in tags["tags"]
assert "test_tag:2" in tags["tags"]
dog.Tag.create(hostname, tags=["test_tag:1", "test_tag:2"], source="datadog")
get_with_retry(
"Tag",
hostname,
retry_condition=lambda r: "test_tag:1" not in r["tags"] or "test_tag:2" not in r["tags"],
retry_limit=30,
source="datadog"
)

# The response from `update` can be flaky, so let's test that it work by getting the tags
dog.Tag.update(hostname, tags=["test_tag:3"], source="datadog")
get_with_retry("Tag", hostname, retry_condition=lambda r: r["tags"] != ["test_tag:3"], source="datadog")

get_with_retry(
"Tag",
operation="get_all",
retry_condition=lambda r: hostname in r["tags"].get("test_tag:3", []),
retry_limit=30
hostname,
retry_condition=lambda r: r["tags"] != ["test_tag:3"],
retry_limit=30,
source="datadog"
)

all_tags = dog.Tag.get_all()
assert "tags" in all_tags

assert dog.Tag.delete(hostname, source="datadog") is None # Expect no response body on success

def test_events(self):
Expand Down

0 comments on commit e62969e

Please sign in to comment.