Skip to content
This repository was archived by the owner on Mar 13, 2022. It is now read-only.

Add http_proxy configuration with unittest #15

Merged
merged 3 commits into from
Jul 25, 2017

Conversation

pokoli
Copy link

@pokoli pokoli commented Jun 13, 2017

This PR extends #8 by adding some unit test for the PoolManager and the proxy manager.

@codecov-io
Copy link

codecov-io commented Jun 13, 2017

Codecov Report

Merging #15 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #15   +/-   ##
=======================================
  Coverage   93.64%   93.64%           
=======================================
  Files          11       11           
  Lines         803      803           
=======================================
  Hits          752      752           
  Misses         51       51

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ab3fc54...10d7016. Read the comment docs.

@mbohlool
Copy link
Contributor

@pokoli Sorry that I missed this. Please ping me if I missed a PR like this ever in future. It should not take me more than a couple of days to do a code review. More than that is not usual :)

@mbohlool
Copy link
Contributor

Please resolve the conflicts and ping me after.

rest_test.py Outdated

from mock import patch

from .configuration import configuration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get this from kubernetes package like if you installed the package. CI tests expect that.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks for the hint.

@pokoli pokoli force-pushed the proxy branch 2 times, most recently from 3a573cb to b2b9dfb Compare July 14, 2017 08:48
@pokoli
Copy link
Author

pokoli commented Jul 14, 2017

Running on env TOXENV=py27 ./run_tox.sh tox works as expected, but this si failing on travis.

@mbohlool Any idea?

@mbohlool
Copy link
Contributor

mbohlool commented Jul 14, 2017

from kubernetes.client import configuration
from kubernetes.client import rest

base folder is not a proper python package.

@pokoli
Copy link
Author

pokoli commented Jul 14, 2017

Uou, so much days without kubernetes-client lost my memory :( @mbohlool Thanks for the tips

Now only functional tests are failing, but I dont' think this is related to my change.

@mbohlool
Copy link
Contributor

Closing and reopening to see if it helps with ci failure.

@mbohlool mbohlool closed this Jul 25, 2017
@mbohlool mbohlool reopened this Jul 25, 2017
rest_test.py Outdated

def test_proxy(self):
'Test that proxy is created when the config especifies it'
configuration.http_proxy_url = 'http://proxy.example.com'
Copy link
Contributor

@mbohlool mbohlool Jul 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the problem, you are changing configuration singleton that has effect on other clients. You should create your own version of configuration:

from kubernetes.client import ConfigurationObject
config = ConfigurationObject()
...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, but it does not fix the problem.

Indeed, running py27-functional on my laptop passes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way e2e tests are setup here is not the best. They will pass if there is no cluster to run on. You need to make sure you have a minikube running on default port before run functional tests. We need to fix that but let see what is the problem of this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the problem is still Configuration(). It should be ConfigurationObject(). Configuration() is there for backward compatibility with generated client and still returns the singleton. using ConfigurationObject() should fix things.

rest_test.py Outdated
def test_poolmanager(self):
'Test that a poolmanager is created for rest client'
with patch.object(urllib3, 'PoolManager') as pool:
RESTClientObject(config=Configuration())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you mean to pass a new config or singleton config here? Configuration() is the singleton. ConfigurationObject() will be a new one.

rest_test.py Outdated

def test_proxy(self):
'Test that proxy is created when the config especifies it'
config = Configuration()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config = ConfigurationObject()

@mbohlool
Copy link
Contributor

I pushed a change to use ConfigurationObject and merged this because I want it to be in the release.

@mbohlool mbohlool merged commit 168c5e7 into kubernetes-client:master Jul 25, 2017
@pokoli
Copy link
Author

pokoli commented Jul 26, 2017

@mbohlool thank you for your help and for finishing it!

@pokoli pokoli deleted the proxy branch August 22, 2017 07:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants