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

Create additional integration test cases #143

Merged
merged 6 commits into from
Feb 6, 2020
Merged

Conversation

querti
Copy link
Contributor

@querti querti commented Jan 21, 2020

No description provided.

@cd-red-bot
Copy link

Can one of the admins verify this patch?

@rbikar
Copy link
Member

rbikar commented Jan 21, 2020

run tests

tests/integration/test_association.py Outdated Show resolved Hide resolved
@querti
Copy link
Contributor Author

querti commented Jan 22, 2020

run tests

@querti
Copy link
Contributor Author

querti commented Jan 22, 2020

@emilyzheng Can you also review pls?

@querti
Copy link
Contributor Author

querti commented Jan 22, 2020

run tests

1 similar comment
@rbikar
Copy link
Member

rbikar commented Jan 22, 2020

run tests

@rbikar
Copy link
Member

rbikar commented Jan 23, 2020

run tests

separated_modules = [(module[:module.find(' ')], module[module.find(' ') + 1:])
for module in modules]

for module in separated_modules:
Copy link
Member

Choose a reason for hiding this comment

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

Just a thought here.
This serves as a validation of testing data.
I think in future, it should be better to reset testing repositories/units on pulp server before testing to some baseline state.
This can get messed easily and testing then will be unreliable.

This also applies for other parts of code, but this should solved in different task since it might require non trivial effort.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently, the data is only reset before the whole test suite is run. It should be possible to reset it between each test, even though it would make the runtime significantly higher. Another solution might be to prepare exclusive data for each test, so that tests wouldn't interfere with each other. For now, the suite works with the existing data, but additional data would probably be needed in the future if additional test cases are added.

Copy link
Member

Choose a reason for hiding this comment

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

"mod_name, mod_profile in separated_modules" would be more readable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed


modules = query_repo_modules(None, 'ubi', repo_url, full_data=True)
assert len(modules) == 1, 'Unexpected repo modules found.'
separated_module = (modules[0][:modules[0].find(' ')], modules[0][modules[0].find(' ') + 1:])
Copy link
Member

Choose a reason for hiding this comment

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

Looks to me a bit crude parsing of yum list module output.
Please consider moving this to some helper method which parse yum output. It's also use on line 270

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added a helper function

assert len(modules) == 1, 'Unexpected repo modules found.'
separated_module = (modules[0][:modules[0].find(' ')], modules[0][modules[0].find(' ') + 1:])
assert separated_module[0] == 'httpd', 'Unknown module in repo.'
assert '[d]' in separated_module[1], 'Module httpd should have defaults.'
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this also assert which profile is default? Not just that there some profile was set as default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The test should now check for which profile is default

repo_url = repo_url = get_repo_url(repo['url'])
break
repo_rpms = query_repo_rpms(None, 'ubi', repo_url)
assert expected1[0] in repo_rpms and expected1[1] in repo_rpms, \
Copy link
Member

Choose a reason for hiding this comment

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

It's kind of difficult to review this because I don't how module's artifacts list looks...


debug_repos = get_repos_from_cs(cfg.content_sets.debuginfo.output, skip_dot_version=True)
for repo in debug_repos:
repo_url = repo_url = get_repo_url(repo['url'])
Copy link
Member

Choose a reason for hiding this comment

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

What's the intention here?
Also on 575, 549 and other lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy-paste gone wrong. I have fixed it

repo_url = repo_url = get_repo_url(repo['url'])
break
repo_rpms = query_repo_rpms(None, 'ubi', repo_url)
expected1 = ['httpd-2.4.6-88.el7.x86_64.rpm', 'httpd-tools-2.4.6-88.el7.x86_64.rpm',
Copy link
Member

Choose a reason for hiding this comment

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

What's the deal with expected1[1] item? Doesn't seem tested in any way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is tested.

@querti
Copy link
Contributor Author

querti commented Jan 24, 2020

run tests

separated_modules = [(module[:module.find(' ')], module[module.find(' ') + 1:])
for module in modules]

for module in separated_modules:
Copy link
Member

Choose a reason for hiding this comment

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

"mod_name, mod_profile in separated_modules" would be more readable

cfg = load_ubiconfig('associate-md.yaml')
rpm_repos = get_repos_from_cs(cfg.content_sets.rpm.output, skip_dot_version=True)
for repo in rpm_repos:
repo_url = repo_url = get_repo_url(repo['url'])
Copy link
Member

Choose a reason for hiding this comment

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

I think you have extra repo_url = here, also you break out of the loop after first cycle. Do you need to iterate through the repos at all then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is a generator.

modules = query_repo_modules(None, 'ubi', repo_url, full_data=True)
assert len(modules) == 1, 'Unexpected repo modules found.'
separated_module = separate_modules(modules)[0]
assert separated_module[0] == 'httpd', 'Unknown module in repo.'
Copy link
Member

Choose a reason for hiding this comment

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

btw, maybe slightly better could be expected:x found:y message

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

for rpm in repo_rpms:
if 'glibc' in rpm:
found_archs.append(rpm.split('.')[-2])
assert all(arch in found_archs for arch in ['i686', 'x86_64']), \
Copy link
Member

Choose a reason for hiding this comment

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

isn't better to test found_arch == set([expected arches])? Then you can omit test bellow

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed.

repo_rpms = query_repo_rpms(None, 'ubi', repo_url)
assert all('glibc' not in rpm for rpm in repo_rpms), \
'No glibc rpms should be in the output repo.'

Copy link
Member

Choose a reason for hiding this comment

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

I wonder if you should also add here to test check input data. That you make it easier to distinguish between failure due missing input data and wrong ubi-pop functionality.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Jenkins job restores all of the data before running the test suite. Also, Emily told me that I would either need to use the pa_tool or parse the database directly to check the input data. Is setting this up for such an edge case worth it?

@querti
Copy link
Contributor Author

querti commented Jan 27, 2020

run tests

@querti
Copy link
Contributor Author

querti commented Feb 4, 2020

run tests

@querti querti merged commit ecc9e63 into master Feb 6, 2020
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

Successfully merging this pull request may close these issues.

None yet

4 participants