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

One test failure on OpenSUSE #233

Closed
jayvdb opened this issue Apr 13, 2020 · 18 comments
Closed

One test failure on OpenSUSE #233

jayvdb opened this issue Apr 13, 2020 · 18 comments
Assignees

Comments

@jayvdb
Copy link

jayvdb commented Apr 13, 2020

  • Which version of Django are you using?: 1.11.28 and 2.2.12
  • Which version of django-rosetta are you using?: 0.9.3
  • Have you looked trough recent issues and checked this isn't a duplicate? Yes
[   43s] ======================================================================
[   43s] FAIL: test_47_azure_ajax_translation (rosetta.tests.tests.RosettaTestCase)
[   43s] ----------------------------------------------------------------------
[   43s] Traceback (most recent call last):
[   43s]   File "/usr/lib/python2.7/site-packages/vcr/cassette.py", line 106, in __call__
[   43s]     return type(self)(self.cls, args_getter)._execute_function(function, args, kwargs)
[   43s]   File "/usr/lib/python2.7/site-packages/vcr/cassette.py", line 120, in _execute_function
[   43s]     return self._handle_function(fn=handle_function)
[   43s]   File "/usr/lib/python2.7/site-packages/vcr/cassette.py", line 144, in _handle_function
[   43s]     return fn(cassette)
[   43s]   File "/usr/lib/python2.7/site-packages/vcr/cassette.py", line 113, in handle_function
[   43s]     return function(*args, **kwargs)
[   43s]   File "/home/abuild/rpmbuild/BUILD/django-rosetta-0.9.3/rosetta/tests/tests.py", line 965, in test_47_azure_ajax_translation
[   43s]     self.assertContains(r, '"Salut tout le monde"')
[   43s]   File "/usr/lib/python2.7/site-packages/django/test/testcases.py", line 393, in assertContains
[   43s]     self.assertTrue(real_count != 0, msg_prefix + "Couldn't find %s in response" % text_repr)
[   43s] AssertionError: Couldn't find '"Salut tout le monde"' in response
@mbi
Copy link
Owner

mbi commented Apr 13, 2020

Interesting. Which version of Python? Any way you could print the contents of r?

@jayvdb
Copy link
Author

jayvdb commented Apr 13, 2020

It occurs on Python 2.7 and Python 3.8

All of the dependencies can be seen at https://build.opensuse.org/package/live_build_log/home:jayvdb:branches:devel:languages:python:misc/python-django-rosetta/openSUSE_Tumbleweed/x86_64

And the .spec https://build.opensuse.org/package/show/home:jayvdb:branches:devel:languages:python:misc/python-django-rosetta
( I have disabled that test to workaround this failure )

I'll try to print out r

@jayvdb
Copy link
Author

jayvdb commented Apr 13, 2020

r = {"translation": "Salut tout le monde", "success": true}

@mbi
Copy link
Owner

mbi commented Apr 13, 2020

Hmm, could you please also print type(r) ?

Clearly the failing assertion

[   43s]     self.assertContains(r, '"Salut tout le monde"')

...should be True if r is a string, and will fail if r is e.g. a dict (the latter shouldn't be the case.)

Which version of requests is installed? Is it going to use a system package for requests ?

@mbi
Copy link
Owner

mbi commented Apr 13, 2020

Scratch that, r is a Django JsonResponse here.

@mbi
Copy link
Owner

mbi commented Apr 13, 2020

I just pushed and published 0.9.4 which officially supports and tests against Python 3.8, and which might or might not address this issue.

@jayvdb
Copy link
Author

jayvdb commented Apr 13, 2020

Perfect. Thanks.

@jayvdb jayvdb closed this as completed Apr 13, 2020
@jayvdb
Copy link
Author

jayvdb commented Apr 13, 2020

Hoo hum. It worked on my local build, but failed on the online build workers. I havent encountered that before!

@jayvdb jayvdb reopened this Apr 13, 2020
@mbi
Copy link
Owner

mbi commented Apr 14, 2020

Okay, can't reproduce this either locally or in CI, will need more info.

@jayvdb
Copy link
Author

jayvdb commented Apr 15, 2020

It was accepted to the openSUSE "python" collection with my little hack to disable the test:
https://build.opensuse.org/package/show/devel:languages:python:django/python-django-rosetta , and into the central collection https://build.opensuse.org/package/show/openSUSE:Factory/python-django-rosetta

I've branched that, commented out my sed, and the test fails as before.

https://build.opensuse.org/package/show/home:jayvdb:branches:devel:languages:python:django/python-django-rosetta

I'll keep digging around it.

@jayvdb
Copy link
Author

jayvdb commented Jun 18, 2021

I re-tested, and this is still failing on v0.9.6.

@jayvdb
Copy link
Author

jayvdb commented Dec 26, 2021

Retested, and still failing on v0.9.8 .

I get a better backtrace now

[  146s] ERROR: test_47_azure_ajax_translation (rosetta.tests.tests.RosettaTestCase)
[  146s] ----------------------------------------------------------------------
[  146s] Traceback (most recent call last):
[  146s]   File "/usr/lib/python3.6/site-packages/urllib3/connection.py", line 175, in _new_conn
[  146s]     (self._dns_host, self.port), self.timeout, **extra_kw
[  146s]   File "/usr/lib/python3.6/site-packages/urllib3/util/connection.py", line 73, in create_connection
[  146s]     for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
[  146s]   File "/usr/lib64/python3.6/socket.py", line 745, in getaddrinfo
[  146s]     for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
[  146s] socket.gaierror: [Errno -3] Temporary failure in name resolution
[  146s] 
[  146s] During handling of the above exception, another exception occurred:
[  146s] 
[  146s] Traceback (most recent call last):
[  146s]   File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 706, in urlopen
[  146s]     chunked=chunked,
[  146s]   File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 382, in _make_request
[  146s]     self._validate_conn(conn)
[  146s]   File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 1010, in _validate_conn
[  146s]     conn.connect()
[  146s]   File "/usr/lib/python3.6/site-packages/vcr/stubs/__init__.py", line 286, in connect
[  146s]     return self.real_connection.connect(*args, **kwargs)
[  146s]   File "/usr/lib/python3.6/site-packages/urllib3/connection.py", line 358, in connect
[  146s]     conn = self._new_conn()
[  146s]   File "/usr/lib/python3.6/site-packages/urllib3/connection.py", line 187, in _new_conn
[  146s]     self, "Failed to establish a new connection: %s" % e
[  146s] urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7f12c19ccc50>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution
[  146s] 
[  146s] During handling of the above exception, another exception occurred:
[  146s] 
[  146s] Traceback (most recent call last):
[  146s]   File "/usr/lib/python3.6/site-packages/requests/adapters.py", line 449, in send
[  146s]     timeout=timeout
[  146s]   File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 756, in urlopen
[  146s]     method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
[  146s]   File "/usr/lib/python3.6/site-packages/urllib3/util/retry.py", line 574, in increment
[  146s]     raise MaxRetryError(_pool, url, error or ResponseError(cause))
[  146s] urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.cognitive.microsofttranslator.com', port=443): Max retries exceeded with url: /translate?api-version=3.0&from=en&to=fr (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f12c19ccc50>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))
[  146s] 
[  146s] During handling of the above exception, another exception occurred:
[  146s] 
[  146s] Traceback (most recent call last):
[  146s]   File "/usr/lib/python3.6/site-packages/vcr/cassette.py", line 100, in __call__
[  146s]     return type(self)(self.cls, args_getter)._execute_function(function, args, kwargs)
[  146s]   File "/usr/lib/python3.6/site-packages/vcr/cassette.py", line 114, in _execute_function
[  146s]     return self._handle_function(fn=handle_function)
[  146s]   File "/usr/lib/python3.6/site-packages/vcr/cassette.py", line 138, in _handle_function
[  146s]     return fn(cassette)
[  146s]   File "/usr/lib/python3.6/site-packages/vcr/cassette.py", line 107, in handle_function
[  146s]     return function(*args, **kwargs)
[  146s]   File "/usr/lib/python3.6/site-packages/django/test/utils.py", line 387, in inner
[  146s]     return func(*args, **kwargs)
[  146s]   File "/home/abuild/rpmbuild/BUILD/django-rosetta-0.9.8/rosetta/tests/tests.py", line 983, in test_47_azure_ajax_translation
[  146s]     reverse('rosetta.translate_text') + '?from=en&to=fr&text=hello%20world'
[  146s]   File "/usr/lib/python3.6/site-packages/django/test/client.py", line 742, in get
[  146s]     response = super().get(path, data=data, secure=secure, **extra)
[  146s]   File "/usr/lib/python3.6/site-packages/django/test/client.py", line 398, in get
[  146s]     **extra,
[  146s]   File "/usr/lib/python3.6/site-packages/django/test/client.py", line 473, in generic
[  146s]     return self.request(**r)
[  146s]   File "/usr/lib/python3.6/site-packages/django/test/client.py", line 719, in request
[  146s]     self.check_exception(response)
[  146s]   File "/usr/lib/python3.6/site-packages/django/test/client.py", line 580, in check_exception
[  146s]     raise exc_value
[  146s]   File "/usr/lib/python3.6/site-packages/django/core/handlers/exception.py", line 47, in inner
[  146s]     response = get_response(request)
[  146s]   File "/usr/lib/python3.6/site-packages/django/core/handlers/base.py", line 181, in _get_response
[  146s]     response = wrapped_callback(request, *callback_args, **callback_kwargs)
[  146s]   File "/usr/lib/python3.6/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
[  146s]     return view_func(request, *args, **kwargs)
[  146s]   File "/home/abuild/rpmbuild/BUILD/django-rosetta-0.9.8/rosetta/views.py", line 698, in translate_text
[  146s]     translated_text = translate(text, language_from, language_to)
[  146s]   File "/home/abuild/rpmbuild/BUILD/django-rosetta-0.9.8/rosetta/translate_utils.py", line 21, in translate
[  146s]     return translate_by_azure(text, from_language, to_language, AZURE_CLIENT_SECRET)
[  146s]   File "/home/abuild/rpmbuild/BUILD/django-rosetta-0.9.8/rosetta/translate_utils.py", line 64, in translate_by_azure
[  146s]     data=json.dumps(request_data),
[  146s]   File "/usr/lib/python3.6/site-packages/requests/api.py", line 117, in post
[  146s]     return request('post', url, data=data, json=json, **kwargs)
[  146s]   File "/usr/lib/python3.6/site-packages/requests/api.py", line 61, in request
[  146s]     return session.request(method=method, url=url, **kwargs)
[  146s]   File "/usr/lib/python3.6/site-packages/requests/sessions.py", line 542, in request
[  146s]     resp = self.send(prep, **send_kwargs)
[  146s]   File "/usr/lib/python3.6/site-packages/requests/sessions.py", line 655, in send
[  146s]     r = adapter.send(request, **kwargs)
[  146s]   File "/usr/lib/python3.6/site-packages/requests/adapters.py", line 516, in send
[  146s]     raise ConnectionError(e, request=request)
[  146s] requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.cognitive.microsofttranslator.com', port=443): Max retries exceeded with url: /translate?api-version=3.0&from=en&to=fr (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f12c19ccc50>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))

@mbi
Copy link
Owner

mbi commented Dec 26, 2021

Okay, interesting: a DNS lookup on api.cognitive.microsofttranslator.com is failing during the test execution.

I can reproduce the error if I turn off networking on my machine. Does the test environment have internet access?

@jayvdb
Copy link
Author

jayvdb commented Dec 26, 2021

These VMs have no network at all.

@mbi mbi closed this as completed in ff6d3ff Dec 26, 2021
@mbi
Copy link
Owner

mbi commented Dec 26, 2021

Can you please test a run on the latest HEAD? It seems to be fixed by ff6d3ff

mbi added a commit that referenced this issue Dec 26, 2021
@jayvdb
Copy link
Author

jayvdb commented Dec 26, 2021

Not easy to get git versions onto boxes that dont have internet ;-)

In any case, it is a very low priority. I'll ping here if it isnt fixed in the next release.

@mbi
Copy link
Owner

mbi commented Dec 26, 2021

Thanks. I'm pretty confident it should pass now.

@jayvdb
Copy link
Author

jayvdb commented Dec 26, 2021

Ya, likewise. Much appreciated. We got there in the end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants