-
Notifications
You must be signed in to change notification settings - Fork 38
Pulp tests #53
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
Closed
Closed
Pulp tests #53
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
56407a1
wait for api later
evgeni 58ec66a
use the api to create a set of reusable fixtures
evgeni 2534395
use nightly with katello fixes
evgeni eafc744
apypie from git
evgeni b1d1196
be verbose
evgeni d6ab8ec
yum/file
evgeni f0ab4f5
archive some logs
evgeni File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| pytest-testinfra | ||
| paramiko | ||
| apypie @ git+https://github.com/Apipie/apypie.git@foreman |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| --- | ||
| foreman_container_image: "quay.io/evgeni/foreman-rpm" | ||
| foreman_container_tag: "3.12" | ||
| foreman_container_tag: "nightly" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| #!/bin/bash | ||
|
|
||
| vagrant ssh-config > .vagrant/ssh-config | ||
| py.test --hosts=quadlet --sudo --ssh-config=.vagrant/ssh-config tests/*_test.py | ||
| py.test -vv --hosts=quadlet --sudo --ssh-config=.vagrant/ssh-config tests/*_test.py | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change was just merged and can be dropped from the PR. |
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import uuid | ||
|
|
||
| import apypie | ||
| import paramiko | ||
| import pytest | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def ssh_config(): | ||
| config = paramiko.SSHConfig.from_path('./.vagrant/ssh-config') | ||
| return config.lookup('quadlet') | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def foremanapi(ssh_config): | ||
| return apypie.ForemanApi( | ||
| uri=f'https://{ssh_config['hostname']}', | ||
| username='admin', | ||
| password='changeme', | ||
| verify_ssl=False, | ||
| ) | ||
|
|
||
| @pytest.fixture | ||
| def organization(foremanapi): | ||
| org = foremanapi.create('organizations', {'name': str(uuid.uuid4())}) | ||
| yield org | ||
| foremanapi.delete('organizations', org) | ||
|
|
||
| @pytest.fixture | ||
| def product(organization, foremanapi): | ||
| prod = foremanapi.create('products', {'name': str(uuid.uuid4()), 'organization_id': organization['id']}) | ||
| yield prod | ||
| foremanapi.delete('products', prod) | ||
|
|
||
| @pytest.fixture | ||
| def yum_repository(product, organization, foremanapi): | ||
| repo = foremanapi.create('repositories', {'name': str(uuid.uuid4()), 'product_id': product['id'], 'content_type': 'yum', 'url': 'https://fixtures.pulpproject.org/rpm-no-comps/'}) | ||
| yield repo | ||
| foremanapi.delete('repositories', repo) | ||
|
|
||
| @pytest.fixture | ||
| def file_repository(product, organization, foremanapi): | ||
| repo = foremanapi.create('repositories', {'name': str(uuid.uuid4()), 'product_id': product['id'], 'content_type': 'file', 'url': 'https://fixtures.pulpproject.org/file/'}) | ||
| yield repo | ||
| foremanapi.delete('repositories', repo) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import urllib.parse | ||
|
|
||
| import requests | ||
|
|
||
|
|
||
| def _repo_url(repo, ssh_config): | ||
| return urllib.parse.urlunparse(urllib.parse.urlparse(repo['full_path'])._replace(netloc=ssh_config['hostname'])) | ||
|
|
||
|
|
||
| def test_foreman_organization(organization): | ||
| assert organization | ||
|
|
||
| def test_foreman_product(product): | ||
| assert product | ||
|
|
||
| def test_foreman_yum_repository(yum_repository, foremanapi, ssh_config): | ||
| assert yum_repository | ||
| foremanapi.resource_action('repositories', 'sync', {'id': yum_repository['id']}) | ||
| repo_url = _repo_url(yum_repository, ssh_config) | ||
| assert requests.get(f'{repo_url}/repodata/repomd.xml', verify=False) | ||
| assert requests.get(f'{repo_url}/Packages/b/bear-4.1-1.noarch.rpm', verify=False) | ||
|
|
||
|
|
||
| def test_foreman_file_repository(file_repository, foremanapi, ssh_config): | ||
| assert file_repository | ||
| foremanapi.resource_action('repositories', 'sync', {'id': file_repository['id']}) | ||
| repo_url = _repo_url(file_repository, ssh_config) | ||
| assert requests.get(f'{repo_url}/1.iso', verify=False) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| def test_collect_report(host): | ||
| host.run('mkdir -p logs') | ||
| for container, filename in [('foreman', '/var/log/foreman/production.log')]: | ||
| localfile = filename.replace('/', '_') | ||
| host.run(f'podman cp {container}:{filename} logs/{container}-{localfile}') | ||
| host.run('tar caf logs.tar.gz logs/') | ||
| with open('logs.tar.gz', 'wb') as logstar: | ||
| logstar.write(host.file('logs.tar.gz').content) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a duplicate chunk of code now, this is handled on line 146.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you want to review #43 instead? This (and #50) were just there to try out things while other PRs were ongoing