Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spanner: 'TestSpannerClient.test_client_with_grpc_gcp_channel' unit test fails repeatably #5863

Closed
tseaver opened this issue Aug 29, 2018 · 2 comments
Assignees
Labels
api: spanner Issues related to the Spanner API. priority: p2 Moderately-important priority. Fix may not be included in next release. testing type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@tseaver
Copy link
Contributor

tseaver commented Aug 29, 2018

When running the full nox suite, tripped over these errors in the unit_grpc_gcp sessions:

_____________ TestSpannerClient.test_client_with_grpc_gcp_channel ______________

self = <test_spanner_client_v1.TestSpannerClient object at 0x7f557d8ea668>
grpc_gcp_secure_channel = <MagicMock name='secure_channel' id='140005155447752'>
api_config = <MagicMock name='ApiConfig' id='140005155467504'>
merge = <MagicMock name='Merge' id='140005155827784'>
auth_default = <MagicMock name='default' id='140005155256136'>

    @pytest.mark.skipif(not spanner_v1.HAS_GRPC_GCP,
                        reason='grpc_gcp module not available')
    @mock.patch(
        'google.auth.default',
        return_value=(mock.sentinel.credentials, mock.sentinel.projet))
    @mock.patch('google.protobuf.text_format.Merge')
    @mock.patch('grpc_gcp.proto.grpc_gcp_pb2.ApiConfig',
                return_value=mock.sentinel.api_config)
    @mock.patch('grpc_gcp.secure_channel')
    def test_client_with_grpc_gcp_channel(self,
                                          grpc_gcp_secure_channel,
                                          api_config,
                                          merge,
                                          auth_default):
        spanner_target = 'spanner.googleapis.com:443'
        client = spanner_v1.SpannerClient()
        merge.assert_called_once_with(mock.ANY, mock.sentinel.api_config)
        options = [('grpc_gcp.api_config', mock.sentinel.api_config)]
        grpc_gcp_secure_channel.assert_called_once_with(
>           spanner_target, mock.ANY, options=options)

tests/unit/gapic/v1/test_spanner_client_v1.py:578: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

_mock_self = <MagicMock name='secure_channel' id='140005155447752'>
args = ('spanner.googleapis.com:443', <ANY>)
kwargs = {'options': [('grpc_gcp.api_config', sentinel.api_config)]}
self = <MagicMock name='secure_channel' id='140005155447752'>
msg = "Expected 'secure_channel' to be called once. Called 0 times."

    def assert_called_once_with(_mock_self, *args, **kwargs):
        """assert that the mock was called exactly once and with the specified
            arguments."""
        self = _mock_self
        if not self.call_count == 1:
            msg = ("Expected '%s' to be called once. Called %s times." %
                   (self._mock_name or 'mock', self.call_count))
>           raise AssertionError(msg)
E           AssertionError: Expected 'secure_channel' to be called once. Called 0 times.

.nox/unit-grpc-gcp-3-7/lib/python3.7/site-packages/mock/mock.py:947: AssertionError

And a side note: there is really no purpose in running with grpcio-gcp on all supported Pythons: we should trim it back to just 2.7 and 3.6.

@tseaver tseaver added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. testing api: spanner Issues related to the Spanner API. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Aug 29, 2018
@tseaver
Copy link
Contributor Author

tseaver commented Aug 29, 2018

Looks like we need a new release of api_core: the gprc_gcp stuff added in #5533 is not in a release. @crwilcox Can you do that release?

@tseaver
Copy link
Contributor Author

tseaver commented Aug 30, 2018

PR #5865 solves this issue by using development installs of the local packages during nox unit / system test runs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the Spanner API. priority: p2 Moderately-important priority. Fix may not be included in next release. testing type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

2 participants