Skip to content
Draft
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 logging/samples/snippets/export_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# limitations under the License.

import os
import re
import random
import re
import string
import time

Expand Down
8 changes: 4 additions & 4 deletions logging/samples/snippets/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
google-cloud-logging==3.10.0
google-cloud-bigquery==3.25.0
google-cloud-storage==2.17.0
google-cloud-pubsub==2.22.0
google-cloud-logging==3.13.0
google-cloud-bigquery==3.40.1
google-cloud-storage==3.7.0
google-cloud-pubsub==2.35.0
1 change: 1 addition & 0 deletions logging/samples/snippets/snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def delete_logger(logger_name):


if __name__ == "__main__":

parser = argparse.ArgumentParser(
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
)
Expand Down
14 changes: 13 additions & 1 deletion logging/samples/snippets/snippets_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@


TEST_LOGGER_NAME = "example_log_{}".format(uuid.uuid4().hex)
TEST_TEXT = "Hello, world."


@pytest.fixture
Expand All @@ -44,13 +45,24 @@ def eventually_consistent_test():
eventually_consistent_test()


def test_write():
def test_write(capsys):

snippets.write_entry(TEST_LOGGER_NAME)

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

eventually_consistent_test()


def test_delete(example_log, capsys):
@backoff.on_exception(backoff.expo, NotFound, max_time=120)
def eventually_consistent_test():
snippets.delete_logger(TEST_LOGGER_NAME)
out, _ = capsys.readouterr()
assert TEST_LOGGER_NAME in out

eventually_consistent_test()
1 change: 1 addition & 0 deletions logging/samples/snippets/usage_guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ def main():
except Exception as error: # pylint: disable=broad-except
print(" ERROR: %r" % (error,))
for item in to_delete:
pass
_backoff_not_found(item.delete)


Expand Down