Skip to content
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
9 changes: 6 additions & 3 deletions logging/cloud-client/export_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
import random
import string

from gcp_devrel.testing import eventually_consistent
import backoff
from google.cloud import logging
import pytest

import export


BUCKET = os.environ['CLOUD_STORAGE_BUCKET']
TEST_SINK_NAME_TMPL = 'example_sink_{}'
TEST_SINK_FILTER = 'severity>=CRITICAL'
Expand Down Expand Up @@ -53,12 +54,14 @@ def example_sink():


def test_list(example_sink, capsys):
@eventually_consistent.call
def _():
@backoff.on_exception(backoff.expo, AssertionError, max_time=60)
def eventually_consistent_test():
export.list_sinks()
out, _ = capsys.readouterr()
assert example_sink.name in out

eventually_consistent_test()


def test_create(capsys):
sink_name = TEST_SINK_NAME_TMPL.format(_random_id())
Expand Down
2 changes: 1 addition & 1 deletion logging/cloud-client/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
backoff==1.10.0
pytest==5.3.2
gcp-devrel-py-tools==0.0.15
17 changes: 10 additions & 7 deletions logging/cloud-client/snippets_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from gcp_devrel.testing import eventually_consistent
import backoff
from google.cloud import logging
import pytest

import snippets


TEST_LOGGER_NAME = 'example_log'


Expand All @@ -31,18 +32,20 @@ def example_log():


def test_list(example_log, capsys):
@eventually_consistent.call
def _():
@backoff.on_exception(backoff.expo, AssertionError, max_time=120)
def eventually_consistent_test():
snippets.list_entries(TEST_LOGGER_NAME)
out, _ = capsys.readouterr()
assert example_log in out

eventually_consistent_test()


def test_write():
snippets.write_entry(TEST_LOGGER_NAME)


def test_delete(example_log):
@eventually_consistent.call
def _():
snippets.delete_logger(TEST_LOGGER_NAME)
def test_delete(example_log, capsys):
snippets.delete_logger(TEST_LOGGER_NAME)
out, _ = capsys.readouterr()
assert TEST_LOGGER_NAME in out