0

I have a test suite with about 300 test cases. These test cases are HTTP API Calls. All are 'GET' API calls. The initial test cases execute fine. But towards the end of the execution, the error "error: [Errno 24] Too many open files" is thrown. This causes the test cases to fail even though we do not have any functional issue in the system under test.

How to fix this issue?

The error in the report is:

error: [Errno 24] Too many open files   
08:55:00.484    DEBUG   Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/HttpLibrary/__init__.py", line 229, in GET
self.app.get(path, {}, self.context.request_headers)

File "/Library/Python/2.7/site-packages/webtest/app.py", line 286, in get

File "/Library/Python/2.7/site-packages/HttpLibrary/livetest.py", line 153, in do_request

File "/Library/Python/2.7/site-packages/HttpLibrary/livetest.py", line 126, in _do_httplib_request

File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 973, in request

File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1007, in _send_request

File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 969, in endheaders

File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 829, in _send_output

File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 791, in send

File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 772, in connect

File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 571, in create_connection
Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
Deepti K
  • 590
  • 2
  • 9
  • 26
  • strange. I am doing hundreds of GET in my Robot suite and have no issues. Could you tell us what library you use for your REST calls ? And could you share a sample test? – Laurent Bristiel Sep 02 '14 at 09:30
  • We are using the library called "robotframework-httplibrary" for running HTTP API Tests. When I say test suite, I have one file with 300 test cases. Where as RF recommends mot more then 10 cases per file. – Deepti K Sep 02 '14 at 09:47
  • Are you certain it is the GET calls that ultimately cause the error? Is it possible you have some custom keywords that open files without closing them that you might be calling from a setup function? – Bryan Oakley Sep 02 '14 at 10:42
  • I do not have a custom keyword which opens a file. – Deepti K Sep 03 '14 at 09:17

2 Answers2

1

You have to increase the number of maximum open files on your machine.

Here is an article how this can be accomplished in ubuntu.

Similar problem is answered on SO.

Community
  • 1
  • 1
Miroslav Genov
  • 116
  • 2
  • 4
1

Increasing number of max files open (like proposed by Hinata) is indeed a short-term solution, but I am surprised that you hit this limit in the first place. I don't see why successive GET would open so many files.

My recommendation would be to try out another library to check if this problem remains. You can try out Robot Framework Requests one or you can directly call Requests Python lib. You might want to take a look at a short blog post about this topic I wrote.

Laurent Bristiel
  • 6,819
  • 34
  • 52