Пример #1
0
def test_create_get_delete_metric_descriptor(capsys):
    snippets.create_metric_descriptor()
    snippets.get_metric_descriptor('custom.googleapis.com/my_metric')
    out, _ = capsys.readouterr()
    assert "value_type='DOUBLE'" in out
    snippets.delete_metric_descriptor('custom.googleapis.com/my_metric')
    out, _ = capsys.readouterr()
    assert 'Deleted metric' in out
Пример #2
0
def test_create_get_delete_metric_descriptor(capsys):
    snippets.create_metric_descriptor()
    snippets.get_metric_descriptor('custom.googleapis.com/my_metric')
    out, _ = capsys.readouterr()
    assert 'DOUBLE' in out
    snippets.delete_metric_descriptor('custom.googleapis.com/my_metric')
    out, _ = capsys.readouterr()
    assert 'Deleted metric' in out
Пример #3
0
def test_create_get_delete_metric_descriptor(capsys):
    snippets.create_metric_descriptor()

    @eventually_consistent.call
    def __():
        snippets.get_metric_descriptor('custom.googleapis.com/my_metric')

    out, _ = capsys.readouterr()
    assert 'DOUBLE' in out
    snippets.delete_metric_descriptor('custom.googleapis.com/my_metric')
    out, _ = capsys.readouterr()
    assert 'Deleted metric' in out
Пример #4
0
def custom_metric_descriptor(capsys):
    snippets.create_metric_descriptor(PROJECT_ID)
    out, _ = capsys.readouterr()
    match = re.search(r'Created (.*)\.', out)
    metric_name = match.group(1)
    yield metric_name

    # teardown
    try:
        snippets.delete_metric_descriptor(metric_name)
    except NotFound:
        print("Metric descriptor already deleted")
Пример #5
0
def test_get_delete_metric_descriptor(capsys, custom_metric_descriptor):
    try:

        @eventually_consistent.call
        def __():
            snippets.get_metric_descriptor(custom_metric_descriptor)

        out, _ = capsys.readouterr()
        assert 'DOUBLE' in out
    finally:
        snippets.delete_metric_descriptor(custom_metric_descriptor)
        out, _ = capsys.readouterr()
    assert 'Deleted metric' in out
Пример #6
0
def test_get_delete_metric_descriptor(capsys, custom_metric_descriptor):
    try:
        @backoff.on_exception(
            backoff.expo, (AssertionError, NotFound), max_time=60)
        def eventually_consistent_test():
            snippets.get_metric_descriptor(custom_metric_descriptor)
            out, _ = capsys.readouterr()
            assert 'DOUBLE' in out

        eventually_consistent_test()
    finally:
        snippets.delete_metric_descriptor(custom_metric_descriptor)
        out, _ = capsys.readouterr()
    assert 'Deleted metric' in out
def test_create_get_delete_metric_descriptor(capsys):
    snippets.create_metric_descriptor(snippets.project_id())
    out, _ = capsys.readouterr()
    match = re.search(r'Created (.*)\.', out)
    metric_name = match.group(1)
    try:
        @eventually_consistent.call
        def __():
            snippets.get_metric_descriptor(metric_name)

        out, _ = capsys.readouterr()
        assert 'DOUBLE' in out
    finally:
        snippets.delete_metric_descriptor(metric_name)
        out, _ = capsys.readouterr()
    assert 'Deleted metric' in out
Пример #8
0
def test_create_get_delete_metric_descriptor(capsys):
    snippets.create_metric_descriptor(snippets.project_id())
    out, _ = capsys.readouterr()
    match = re.search(r'Created (.*)\.', out)
    metric_name = match.group(1)
    try:

        @eventually_consistent.call
        def __():
            snippets.get_metric_descriptor(metric_name)

        out, _ = capsys.readouterr()
        assert 'DOUBLE' in out
    finally:
        snippets.delete_metric_descriptor(metric_name)
        out, _ = capsys.readouterr()
    assert 'Deleted metric' in out
def test_create_and_delete_metric_descriptor(capsys):
    snippets.create_metric_descriptor()
    snippets.delete_metric_descriptor('custom.googleapis.com/my_metric')
    out, _ = capsys.readouterr()
    assert 'Deleted metric' in out