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

[RFR] Added openshift tests + Minor fixes in image info parsing #166

Merged
merged 1 commit into from
Sep 1, 2017

Conversation

gshefer
Copy link
Contributor

@gshefer gshefer commented Aug 10, 2017

  • Added openshift tests (tests/test_openshift.py)
    • Option to run tests with both mock provider and real provider, default is mock.
  • Fix image info parsing which was problematic in case we had more than one ':' in the image name. (happens when we have tag, in this case we have 2, one for the ID and one for the tag)

@gshefer gshefer changed the title [WIPTEST] Added openshift tests + Minor fixes in image info parsing [RFR] Added openshift tests + Minor fixes in image info parsing Aug 10, 2017
@dajoRH dajoRH changed the title [RFR] Added openshift tests + Minor fixes in image info parsing [WIP] Added openshift tests + Minor fixes in image info parsing Aug 10, 2017
@dajoRH dajoRH added lint-ok and removed needs-lint labels Aug 10, 2017
@gshefer gshefer changed the title [WIP] Added openshift tests + Minor fixes in image info parsing [RFR] Added openshift tests + Minor fixes in image info parsing Aug 14, 2017
@dajoRH dajoRH removed the WIP label Aug 14, 2017
Copy link
Contributor

@mfalesni mfalesni left a comment

Choose a reason for hiding this comment

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

Not bad for start, some changes needed, maybe @RonnyPfannschmidt can chime in as well?


def mocked_image_data():
out = [200, {'items': []}]
for i in xrange(fauxfactory.gen_integer(2, 20)):
Copy link
Contributor

Choose a reason for hiding this comment

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

xrange is not supported in python3

# If you prefer to use a real provider, fill HOSTNAME, USERNAME and TOKEN
HOSTNAME = None
USERNAME = None
TOKEN = None
Copy link
Contributor

Choose a reason for hiding this comment

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

These should probably be pulled from environment.

assert wait_for(lambda: label_key in resource.list_labels(),
message="Waiting for label {} of {} {} to be exist..."
.format(label_key, resource.__class__.__name__, resource.name),
delay=5, timeout='1M')
Copy link
Contributor

Choose a reason for hiding this comment

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

make a newline before lambda, that will free up some space on the line, and use type(resource) instead of resource.__class__. That may then fit the .format on the previous line, making it look better.

Copy link
Contributor

Choose a reason for hiding this comment

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

And wait_for returns a tuple if I am not mistaken, you may want to grab the actual value returned. Or you can just remove the assert and go with TimedOutError.

provider.o_api.get.return_value = provider.api.get.return_value = mocked_image_data()
provider.list_docker_image()
provider.list_image()
provider.list_image_openshift()
Copy link
Contributor

Choose a reason for hiding this comment

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

this should check that the output is correct.

gen_service.provider.api.get.return_value = [200, {
'spec': {
'sessionAffinity': 'ClientIP',
'clusterIP': '123.456.789.101'
Copy link
Contributor

Choose a reason for hiding this comment

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

This should probably use some valid local network IP.

res = gen_dc.create()
assert res[0] in (200, 201)
assert wait_for(lambda: gen_dc.exists(),
message="Waiting for dc {} to be exist..."
Copy link
Contributor

Choose a reason for hiding this comment

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

Just "to exist", otherwise all your base are belong to us :)



# Specify whether to use a mock provider or real one.
MOCKED = os.environ.get('MOCKED', 'true').lower() == 'true'
Copy link
Contributor

Choose a reason for hiding this comment

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

just for documentation we might want to consider putting the mocked/non-mocked variants into plugin objects at some point

while doing that we could also create a better handling than the env vars provide

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Issue created: #170

@mshriver
Copy link
Collaborator

Assigning to mfalesni since he just needs to re-review

@mfalesni mfalesni merged commit e3a9fce into RedHatQE:master Sep 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants