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

proxiedtransport's send_request method is missing a parameter #127

Closed
seanmlyons22 opened this issue Feb 11, 2020 · 7 comments
Closed

proxiedtransport's send_request method is missing a parameter #127

seanmlyons22 opened this issue Feb 11, 2020 · 7 comments
Assignees
Labels
Milestone

Comments

@seanmlyons22
Copy link

As of the xmlrpc version in Python version 3.7.6 the send_request method of class Transport that is overridden by proxiedtransport.py::send_request is missing the debug parameter.

Steps to reproduce

  1. Use Python 3.7.6
  2. Have http_proxy and https_proxy set as environment variables
  3. Call getProjects for example
  4. observe exception with traceback that ends in :
http_conn = self.send_request(host, handler, request_body, verbose)
TypeError: send_request() takes 4 positional arguments but 5 were given
@seanmlyons22
Copy link
Author

Another issue is that xmlrpc has specifies the first agrument as the host and not a connection handle. So this would need to be updated.

@lczub lczub self-assigned this Feb 11, 2020
@lczub lczub added the bug label Feb 11, 2020
@lczub
Copy link
Owner

lczub commented Feb 11, 2020

Hello Sean,

thanks for your request. Unfortunately, I have problems to reproduce your issue.
To be honest, I'm not very familiar with the transport and proxie stuff.

We have within testlinkhelper_test.py some pytests to check the setup of the connection with proxie, but none testing the communication itself. Maybe that is the gap, cause the existing tests passed with 3.7.4, 3.7.6 and 3.8.1.

To solve your problem, I need a little more infos

  • have you a more detailed traceback to see the call stack ?
  • would you be able to extend the existing pytests to reproduce your error situation(or with other python statements?)

That would be very helpful,
Regards Luiko

@seanmlyons22
Copy link
Author

seanmlyons22 commented Apr 8, 2020

Hi @lczub ,

I wanted to apologize for taking so long to get back to you (the github notification email was lost in my inbox so I didn't see your reply).

Here is the traceback:

[testlinkclient] <update_structure()>
Traceback (most recent call last):
  File "C:\Users\a0225155\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\a0225155\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "c:\git\slate\slate\__main__.py", line 8, in <module>
    main()
  File "c:\git\slate\slate\main.py", line 347, in main
    app(args)
  File "c:\git\slate\slate\main.py", line 206, in app
    testlink.main(args.no_upload_skipped)
  File "c:\git\slate\slate\testlink\testlink.py", line 29, in main
    tl_client.update_structure(report)
  File "C:\git\slate\.slate\lib\site-packages\testlinkclient\testlinkclient.py", line 120, in update_structure
    self.tls.getTestProjectByName(self.project)
  File "C:\git\slate\.slate\lib\site-packages\testlink\testlinkdecorators.py", line 112, in wrapperAddDevKey
    return methodAPI(self, *argsPositional, **argsOptional)
  File "C:\git\slate\.slate\lib\site-packages\testlink\testlinkdecorators.py", line 100, in wrapperWithArgs
    *argsPositional, **argsOptional)
  File "C:\git\slate\.slate\lib\site-packages\testlink\testlinkapigeneric.py", line 1517, in callServerWithPosArgs
    response = self._callServer(methodNameAPI, argsOptional)
  File "C:\git\slate\.slate\lib\site-packages\testlink\testlinkapigeneric.py", line 1992, in _callServer
    response = getattr(self.server.tl, methodNameAPI)(argsAPI)
  File "C:\Users\a0225155\AppData\Local\Programs\Python\Python37\lib\xmlrpc\client.py", line 1112, in __call__
    return self.__send(self.__name, args)
  File "C:\Users\a0225155\AppData\Local\Programs\Python\Python37\lib\xmlrpc\client.py", line 1452, in __request
    verbose=self.__verbose
  File "C:\Users\a0225155\AppData\Local\Programs\Python\Python37\lib\xmlrpc\client.py", line 1154, in request
    return self.single_request(host, handler, request_body, verbose)
  File "C:\Users\a0225155\AppData\Local\Programs\Python\Python37\lib\xmlrpc\client.py", line 1166, in single_request
    http_conn = self.send_request(host, handler, request_body, verbose)
TypeError: send_request() takes 4 positional arguments but 5 were given

Note that testlinkclient.py is a layer we have built above the TestLinkAPI package.
I'm happy to try and reproduce with a vanilla test or example from the repo.
Do you have some instructions on what I should try?

@lczub
Copy link
Owner

lczub commented Apr 14, 2020

Hello Sean,

thanks for your traceback. A workaround for you might be to directly change the problematic overridden send_request method and add an optional debug argument in src/testlink/proxiedtransport.py

    #def send_request(self, connection, handler, request_body):
    def send_request(self, connection, handler, request_body, debug=False):

The hole content of src/testlink/proxiedtransport.py looks as it is a copy&paste of the py27 xmlrpclib.Transport behavior. It is from 2015 pull request #36 and as you mention, Py3 has changed in the meantime, so it requires a general rework.

This will take a while, because I will first try to set up a proxy test environment to understand, how proxy transport works.

Hope, that above workaround will not direct you to a different hidden P3 proxy isssue.
Hope this helps a little bit.
Stay healthy!
Luiko

@hellboy81
Copy link

hellboy81 commented May 6, 2020

Hi. I have another question.

Why in xmlrpc\client.py

def send_request(self, host, handler, request_body, debug):

and in overridden method from class ProxiedTransport (testlink\proxiedtransport.py)

def send_request(self, connection, handler, request_body, debug=False)

connection as first parameter defined?

After fixing problem with debug parameter I still have problem with connection.

image

This bug can be fixed as follows:

    def send_request(self, host, handler, request_body, debug=False):
        """Send request header

        :param httplib.HTTPConnection connection: Connection handle
        :param str handler: Target RPC handler
        :param str request_body:XML-RPC body
        """

        connection = super().send_request(host, handler, request_body, debug)

Can u also check this code? If it works - can I make pull request?

@lczub
Copy link
Owner

lczub commented May 6, 2020

Hello Hellboy,

thanks for your good questions and suggestions. my problem is, I have currently no proxy test environment.

My impression during the code inspection for #127 (comment) was, that most parts of the overwritten code parts from #36 might be not really necessary any more. But I can not test it currently and haven't found time to rework it. I hope I can do it during teh next weekend.

Luiko

lczub pushed a commit that referenced this issue May 7, 2020
not tested with py27 might be incompatible
lczub pushed a commit that referenced this issue May 7, 2020
@lczub
Copy link
Owner

lczub commented May 7, 2020

Hello seanmlyons22 and hellboy81,

I published I first draft for the proxiedtransport refactoring which should support py27 and py37/py38 on Branch dev127-proxietransport.

It is just tested with simple pytests and not a real proxy test environment

You find the related changed files in commit 891b041. If you could run a test with your proxy environment would be very helpful.

Regards Luiko

@lczub lczub closed this as completed in 891b041 Jun 7, 2020
@lczub lczub added this to the v0.8.2 milestone Jun 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants