googleapis / doc-pipeline

Apache License 2.0
10 stars 11 forks source link

tests.test_generate: test_get_xref[devsite: failed #586

Closed flaky-bot[bot] closed 1 year ago

flaky-bot[bot] commented 1 year ago

Note: #510 was also for this test, but it was closed more than 10 days ago. So, I didn't mark it flaky.


commit: 0e1d5383acf89eb56149017a63c57bd1140d5015 buildURL: Build Status, Sponge status: failed

Test output
@pytest.fixture(scope="module")
    def xref_test_blobs():
        test_bucket, storage_client = init_test()
        bucket = storage_client.get_bucket(test_bucket)

        # Remove all existing test xref blobs.
        blobs_to_delete = bucket.list_blobs(prefix="xrefs/")
        for blob in blobs_to_delete:
>           blob.delete()

tests/test_generate.py:370: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/h/.local/lib/python3.11/site-packages/google/cloud/storage/blob.py:764: in delete
    self.bucket.delete_blob(
/h/.local/lib/python3.11/site-packages/google/cloud/storage/bucket.py:1647: in delete_blob
    client._delete_resource(
/h/.local/lib/python3.11/site-packages/google/cloud/storage/client.py:694: in _delete_resource
    return self._connection.api_request(
/h/.local/lib/python3.11/site-packages/google/cloud/storage/_http.py:72: in api_request
    return call()
/h/.local/lib/python3.11/site-packages/google/api_core/retry.py:366: in retry_wrapped_func
    return retry_target(
/h/.local/lib/python3.11/site-packages/google/api_core/retry.py:204: in retry_target
    return target()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = 
method = 'DELETE'
path = '/b/doc-pipeline-test/o/xrefs%2Fgo-cloud.google.com%2Fgo%2Fstorage-v1.16.0.tar.gz.yml'
query_params = {'generation': 1698810673330904}, data = None
content_type = None, headers = None, api_base_url = None, api_version = None
expect_json = True, _target_object = None, timeout = 60
extra_api_info = 'gccl-invocation-id/6d89e538-999b-402c-adc9-83d93516c7f1'

    def api_request(
        self,
        method,
        path,
        query_params=None,
        data=None,
        content_type=None,
        headers=None,
        api_base_url=None,
        api_version=None,
        expect_json=True,
        _target_object=None,
        timeout=_DEFAULT_TIMEOUT,
        extra_api_info=None,
    ):
        """Make a request over the HTTP transport to the API.

        You shouldn't need to use this method, but if you plan to
        interact with the API using these primitives, this is the
        correct one to use.

        :type method: str
        :param method: The HTTP method name (ie, ``GET``, ``POST``, etc).
                       Required.

        :type path: str
        :param path: The path to the resource (ie, ``'/b/bucket-name'``).
                     Required.

        :type query_params: dict or list
        :param query_params: A dictionary of keys and values (or list of
                             key-value pairs) to insert into the query
                             string of the URL.

        :type data: str
        :param data: The data to send as the body of the request. Default is
                     the empty string.

        :type content_type: str
        :param content_type: The proper MIME type of the data provided. Default
                             is None.

        :type headers: dict
        :param headers: extra HTTP headers to be sent with the request.

        :type api_base_url: str
        :param api_base_url: The base URL for the API endpoint.
                             Typically you won't have to provide this.
                             Default is the standard API base URL.

        :type api_version: str
        :param api_version: The version of the API to call.  Typically
                            you shouldn't provide this and instead use
                            the default for the library.  Default is the
                            latest API version supported by
                            google-cloud-python.

        :type expect_json: bool
        :param expect_json: If True, this method will try to parse the
                            response as JSON and raise an exception if
                            that cannot be done.  Default is True.

        :type _target_object: :class:`object`
        :param _target_object:
            (Optional) Protected argument to be used by library callers. This
            can allow custom behavior, for example, to defer an HTTP request
            and complete initialization of the object at a later time.

        :type timeout: float or tuple
        :param timeout: (optional) The amount of time, in seconds, to wait
            for the server response.

            Can also be passed as a tuple (connect_timeout, read_timeout).
            See :meth:`requests.Session.request` documentation for details.

        :type extra_api_info: string
        :param extra_api_info: (optional) Extra api info to be appended to
            the X-Goog-API-Client header

        :raises ~google.cloud.exceptions.GoogleCloudError: if the response code
            is not 200 OK.
        :raises ValueError: if the response content type is not JSON.
        :rtype: dict or str
        :returns: The API response payload, either as a raw string or
                  a dictionary if the response is valid JSON.
        """
        url = self.build_api_url(
            path=path,
            query_params=query_params,
            api_base_url=api_base_url,
            api_version=api_version,
        )

        # Making the executive decision that any dictionary
        # data will be sent properly as JSON.
        if data and isinstance(data, dict):
            data = json.dumps(data)
            content_type = "application/json"

        response = self._make_request(
            method=method,
            url=url,
            data=data,
            content_type=content_type,
            headers=headers,
            target_object=_target_object,
            timeout=timeout,
            extra_api_info=extra_api_info,
        )

        if not 200 <= response.status_code < 300:
>           raise exceptions.from_http_response(response)
E           google.api_core.exceptions.NotFound: 404 DELETE https://storage.googleapis.com/storage/v1/b/doc-pipeline-test/o/xrefs%2Fgo-cloud.google.com%2Fgo%2Fstorage-v1.16.0.tar.gz.yml?generation=1698810673330904&prettyPrint=false: No such object: doc-pipeline-test/xrefs/go-cloud.google.com/go/storage-v1.16.0.tar.gz.yml

/h/.local/lib/python3.11/site-packages/google/cloud/_http/__init__.py:494: NotFound
flaky-bot[bot] commented 1 year ago

commit: 4bfc0f46d0fca9cdd75be0b019dab98260c6656b buildURL: Build Status, Sponge status: failed

Test output
test_input = 'devsite://dotnet/my-pkg@latest'
expected = 'xrefs/dotnet-my-pkg-2.0.0.tar.gz.yml'
tmpdir = PosixPath('/tmp/pytest-of-kbuilder/pytest-0/test_get_xref_devsite___dotnet2')
xref_test_blobs = None

    @pytest.mark.parametrize(
        "test_input,expected",
        [
            ("http://google.com", "http://google.com"),
            ("devsite://does/not/exist", ""),
            ("devsite://does/not/exist@latest", ""),
            ("devsite://dotnet/my-pkg@1.0.0", "xrefs/dotnet-my-pkg-1.0.0.tar.gz.yml"),
            ("devsite://dotnet/my-pkg", "xrefs/dotnet-my-pkg-2.0.0.tar.gz.yml"),
            ("devsite://dotnet/my-pkg@latest", "xrefs/dotnet-my-pkg-2.0.0.tar.gz.yml"),
            ("devsite://dotnet/v-pkg@latest", "xrefs/dotnet-v-pkg-v4.0.0.tar.gz.yml"),
        ],
    )
    def test_get_xref(test_input, expected, tmpdir, xref_test_blobs):
        test_bucket, storage_client = init_test()
        bucket = storage_client.get_bucket(test_bucket)

        tmpdir = pathlib.Path(tmpdir)
        got = generate.get_xref(test_input, bucket, tmpdir)

        if ":" in expected:
            assert got == expected
            return
        if expected == "":
            assert got == expected
            return
        expected_path = tmpdir / expected
>       assert str(expected_path) == got
E       AssertionError: assert '/tmp/pytest-....0.tar.gz.yml' == ''
E         + /tmp/pytest-of-kbuilder/pytest-0/test_get_xref_devsite___dotnet2/xrefs/dotnet-my-pkg-2.0.0.tar.gz.yml

tests/test_generate.py:414: AssertionError