Pulp Smash

Pulp Smash is a test suite for Pulp. It lets you execute a workflow like this:

pip install pulp-smash
python -m pulp_smash  # follow the instructions

Pulp Smash is a GPL-licensed Python library, but no knowledge of Python is required to execute the tests. Just install the application, run it, and follow the prompts.

Pulp Smash has a presence on the following websites:

Documentation contents:

Introductory Video

Location: Pulp SmashIntroductory Video

This video demonstrates how to install Pulp, demonstrates how to install, configure and run Pulp Smash, shows where to find more information, and covers some additional information. It covers much of the same information as the text-based documentation.

This video is designed to be viewed full-screen.

For more videos on Pulp and Pulp Smash, see the Pulp Vimeo group.

Installation

Location: Pulp SmashInstallation

Installing Pulp Smash into a virtual environment [1] is recommended. To create and activate a virtual environment:

pyvenv env
source env/bin/activate  # run `deactivate` to exit environment

To install Pulp Smash from PyPi:

pip install pulp-smash  # prepend `python -m` on Python 3.3

To install Pulp Smash from source (GitHub):

git clone https://github.com/PulpQE/pulp-smash.git
cd pulp-smash
python setup.py install

To install Pulp Smash from source in “develop mode,” where changes to source files are reflected in the working environment:

git clone https://github.com/PulpQE/pulp-smash.git
cd pulp-smash
pip install -r requirements.txt -r requirements-dev.txt

For an explanation of key concepts and more installation strategies, see Installing Python Modules.

[1]See Virtual Environments and Packages for an explanation of virtual environments. The pyvenv and virtualenv tools are similar, but the former ships with Python as of Python 3.3, whereas the latter is a third party tool.

Usage

Location: Pulp SmashUsage

After installing Pulp Smash, open a terminal and execute the following:

python -m pulp_smash

Usage instructions will be printed.

About

Location: Pulp SmashAbout

Why does Pulp Smash exist? What are its goals, and what does it not do?

Why Pulp Smash?

Pulp Smash exists to make testing Pulp easy.

Scope and Limitations

Portability

Pulp Smash should be usable in any environment that supports:

In addition, we recommend that GNU Make or a compatible clone be available.

This level of portability [1] allows Pulp Smash to be accessible [2].

Provisioning

Pulp Smash is not concerned with provisioning systems. Users must bring their own systems.

Destructiveness

Pulp Smash is highly destructive! You should not use Pulp Smash for testing if you care about the state of the target system. Pulp Smash will do the following to a system under test, and possibly more:

  • It will drop databases.
  • It will forcefully delete files from the filesystem.
  • It will stop and start system services.

Pulp Smash treats the system(s) under test as cattle, not pets. [3]

Contributing

Contributions are encouraged. The easiest way to contribute is to submit a pull request on GitHub, but patches are welcome no matter how they arrive.

Learning Pulp Smash

Not sure where to start? Consider reading an existing test module, creating a development environment, and tackling an open issue.

The Introductory Module is a great candidate for study.

Installation provides a recipe for creating a virtualenv-based development environment. To verify the sanity of your development environment, cd into the Pulp Smash source code directory and execute make all.

The Pulp Smash issues list includes test cases that should be automated and added to the test suite.

Code Standards

Please adhere to the following guidelines:

  • Pull requests must pass the Travis CI continuous integration tests. These tests are automatically run whenever a pull request is submitted. If you want to locally verify your changes before submitting a pull request, execute make all.
  • Test failures must not be introduced. Consider running all new and modified tests and copy-pasting the output from the test run as a comment in the GitHub pull request. The simplest way to run the test suite is with python3 -m unittest pulp_smash.tests. See the unittest Command-Line Interface and python3 -m pulp_smash for more information.
  • Each commit in a pull request must be atomic and address a single issue. Try asking yourself: “can I revert this commit?” Knowing how to rewrite history may help. In addition, please take the time to write a good commit message. While not strictly necessary, consider: commits are (nearly) immutable, and getting commit messages right makes for a more pleasant review process, better release notes, and easier use of tools like git log, git blame or git bisect.
  • The pull request must not raise any other outstanding concerns. For example, do not author a commit that adds a 10MB binary blob without exceedingly good reason. As another example, do not add a test that makes dozens of concurrent requests to a public service such as docker hub.

Review Process

Changes that meet the code standards will be reviewed by a Pulp Smash developer and are likely to be merged.

Though commits are accepted as-is, they are frequently accompanied by a follow-up commit in which the reviewer makes a variety of changes, ranging from simple typo corrections and formatting adjustments to whole-sale restructuring of tests. This can take quite a bit of effort and time. If you’d like to make the review process faster and have more assurance your changes are being accepted with little to no modifications, take the time to really make your changes shine: ensure your code is DRY, matches existing formatting conventions, is organized into easy-to-read blocks, has isolated unit test assertions, and so on.

Join the #pulp IRC channel on freenode if you have further questions.

Labels

Issues are categorized with labels. Pull requests are categorized with GitHub’s pull request reviews feature.

The specific meaning of (issue) labels is as follows.

Issue Type: Bug
This label denotes an issue that describes a specific counter-productive behaviour. For example, an issue entitled “test X contains an incorrect assertion” is a great candidate for this label.
Issue Type: Discussion
This label denotes an issue that broadly discusses some topic. Feature requests should be given this label. If a discussion results in a specific and concrete plan of action, a new issue should be opened, where that issue outlines a specific solution and has a label of “Issue Type: Plan”.
Issue Type: Plan
This label denotes an issue that outlines a specific, concrete plan of action for improving Pulp Smash. Open-ended discussions (including feature requests) should go into issues labeled “Issue Type: Discussion.”
Issue Type: Test Case
This label indicates that an issue is asking for a test case to be automated. (Issues with this label are a special type of plan.)
[1]Portable software cannot make assumptions about its environment. It cannot reference /etc/pki/tls/certs/ca-bundle.crt or call yum. Instead, it must use standardized mechanisms for interacting with its environment. This separation of concerns should lead to an application with fewer responsibilities. Fewer responsibilities means fewer bugs and more focused developers.
[2]An inaccessible project is a dead project. Labeling a project “open source” and licensing it under a suitable terms does not change that fact. People have better things to do than bang their head against a wall.
[3]The “pets vs cattle” analogy is widely attributed to Bill Baker of Microsoft.

Introductory Module

Location: Pulp SmashIntroductory Module

pulp_smash.tests.platform.api_v2.test_login is one of the shortest, simplest and most heavily commented modules in Pulp Smash. Reading through this module will give you a mental framework for understanding other modules and making your own changes. It is included here for convenience.

# coding=utf-8
"""Test the API's `authentication`_ functionality.

.. _authentication:
    https://docs.pulpproject.org/en/latest/dev-guide/integration/rest-api/authentication.html
"""
# Why The Comments?
# =================
#
# This module serves as an introduction to Pulp Smash. This module was picked
# because it's one of the simplest in the test suite. A "how to understand Pulp
# Smash tests" section in the documentation should link to this module.
#
# Encoding
# --------
#
# The encoding declaration at the beginning of this file tells Python which
# encoding scheme was used when creating this document, and therefore how to
# decode the bytes in this document. If omitted, Python might use an UTF-8
# decoder, or a utf-8 decoder, or something else, and that can be problematic.
# Try running this script with Python in a variety of environments:
#
#     #!/usr/bin/env python3
#     # …
#     import sys
#     print(sys.getdefaultencoding())
#
# Shebang
# -------
#
# There is no shebang at the top of this file. That's because this file is not
# meant to be executed directly. Instead, a "test runner" program will import
# this module, and it will decide if and how to execute the code herein.
# Several test runners can run Pulp Smash tests, but with varying degrees of
# compatibility. The "unittest" test runner is best supported. [1]
#
# Docstrings
# ----------
#
# The docstrings throughout this module comply with reStructuredText syntax.
# [2] However, a tool like `rst2html` cannot extract and compile the docstrings
# from this file. Instead, the Sphinx documentation generator must be used. [3]
# It knows how to extract docstrings, and it knows how to treat directives like
# the `:meth:` directive. See the README file in the root of this repository
# for more information.
#
# Package Structure
# -----------------
#
# Why is this module placed where it is?
#
# First, a path such as `pulp_smash.tests.platform.api_v2.test_login` is
# human-readable. This module of Pulp Smash tests relies on the base platform's
# API version 2 interface, and it tests logging in.
#
# Second, Pulp has a plug-in architecture, where the base platform is always
# present, and everything else is optional. Pulp Smash's packages are
# structured to reflect that plug-in architecture. This makes it easy for a
# test case to know which plug-ins it may reference. For example, test cases in
# `pulp_smash.tests.rpm` may reference the RPM plug-in, but must not reference
# the Puppet plugin. This also makes it easier to automatically skip tests. For
# example, if the RPM plug-in is not installed on the Pulp system under test,
# all test cases in `pulp_smash.tests.rpm` are skipped.
#
# No per-plugin test skipping logic is present in this module. Elsewhere, be on
# the look-out for `setUpModule` functions and mentions of the `load_tests`
# protocol. [4]
#
# Imports
# -------
#
# The imports are listed in the order recommended by PEP 8: double-underscore,
# standard library, third party and local. [5][6] In addition, blocks of
# imports are sorted alphabetically, and "import x" statements are placed
# before "from x import y" statements.
#
# [1] https://docs.python.org/3.5/library/unittest.html
# [2] http://docutils.sourceforge.net/docs/user/rst/quickstart.html
# [3] http://www.sphinx-doc.org/en/stable/
# [4] https://docs.python.org/3/library/unittest.html#load-tests-protocol
# [5] https://www.python.org/dev/peps/pep-0008/#imports
# [6] https://docs.python.org/3/library/__future__.html
import unittest

from pulp_smash import api, config, selectors
from pulp_smash.constants import ERROR_KEYS, LOGIN_KEYS, LOGIN_PATH


class LoginTestCase(unittest.TestCase):
    """Tests for logging in."""

    # The `TestCase` class provides a lot of functionality, and it's a Good
    # Idea to read the unittest documentation. [1] Right now, you just need to
    # know that, when a test runner executes a `TestCase` class:
    #
    # * The `test*` methods run in alphabetic order.
    # * A failure in one `test*` method doesn't affect any other `test*`
    #   method.
    #
    # [1] https://docs.python.org/3/library/unittest.html

    def test_success(self):
        """Successfully log in to the server.

        Assert that:

        * The response has an HTTP 200 status code.
        * The response body is valid JSON and has correct keys.
        """
        # The object returned by `config.get_config()` tells the new `Client`
        # object where the Pulp server is, what the authentication credentials
        # are, and so on.
        #
        # There are several assertions that can be made about the login API
        # call. Rather than logging in logging in once for every test, we log
        # in just once, and make multiple assertions about that log in.
        response = api.Client(config.get_config()).post(LOGIN_PATH)
        with self.subTest(comment='check response status code'):
            self.assertEqual(response.status_code, 200)
        with self.subTest(comment='check response body'):
            self.assertEqual(frozenset(response.json().keys()), LOGIN_KEYS)

    def test_failure(self):
        """Unsuccessfully log in to the server.

        Assert that:

        * The response has an HTTP 401 status code.
        * The response body is valid JSON and has correct keys.
        """
        # By default, `Client` objects munge every response they receive. They
        # act cautiously, and do things like raise an exception if the response
        # has an HTTP 4XX or 5XX status code. We don't want that to happen in
        # this test case. So, we pass the `Client` object a non-default
        # function with which to munge responses. In addition, we override the
        # default authentication handling for just this one API call.
        #
        # The API and CLI clients are interesting and capable classes. Read
        # about them.
        cfg = config.get_config()
        response = (
            api.Client(cfg, api.echo_handler).post(LOGIN_PATH, auth=('', ''))
        )
        with self.subTest(comment='check response status code'):
            self.assertEqual(response.status_code, 401)
        # The `version` attribute should correspond to the version of the Pulp
        # server under test. This block of code says "if bug 1412 is not fixed
        # in Pulp version X, then skip this test."
        if selectors.bug_is_testable(1412, cfg.version):
            with self.subTest(comment='check response body'):
                self.assertEqual(frozenset(response.json().keys()), ERROR_KEYS)

API Documentation

Location: Pulp SmashAPI Documentation

This is the Pulp Smash API documentation. It is mostly auto generated from the source code. Beware that Pulp Smash is very new. Its API is not stable. This section of the documentation should be treated as a handy reference for developers, not a gospel.

pulp_smash

Location: Pulp SmashAPI Documentationpulp_smash

The root of Pulp Smash’s namespace.

pulp_smash.__main__

Location: Pulp SmashAPI Documentationpulp_smash.__main__

The entry point for Pulp Smash’s user interface.

pulp_smash.__main__.main()

Provide usage instructions to the user.

pulp_smash.api

Location: Pulp SmashAPI Documentationpulp_smash.api

A client for working with Pulp’s API.

Working with an API can require repetitive calls to perform actions like check HTTP status codes. In addition, Pulp’s API has specific quirks surrounding its handling of href paths and HTTP 202 status codes. This module provides a customizable client that makes it easier to work with the API in a safe and concise manner.

class pulp_smash.api.Client(server_config, response_handler=None, request_kwargs=None, pulp_system=None)

A convenience object for working with an API.

This class is a wrapper around the requests.api module provided by Requests. Each of the functions from that module are exposed as methods here, and each of the arguments accepted by Requests’ functions are also accepted by these methods. The difference between this class and the Requests functions lies in its configurable request and response handling mechanisms.

This class is flexible enough that it should be usable with any API, but certain defaults have been set to work well with Pulp.

As an example of basic usage, let’s say that you’d like to create a user, then read that user’s information back from the server. This is one way to do it:

>>> from pulp_smash.api import Client
>>> from pulp_smash.config import get_config
>>> client = Client(get_config())
>>> response = client.post('/pulp/api/v2/users/', {'login': 'Alice'})
>>> response = client.get(response.json()['_href'])
>>> print(response.json())

Notice how we never call response.raise_for_status()? We don’t need to because, by default, Client instances do this. Handy!

How does this work? Each Client object has a callback function, response_handler, that is given a chance to munge each server response. How else might this callback be useful? Well, notice how we call json() on each server response? That’s kludgy. Let’s write our own callback that takes care of this for us:

>>> from pulp_smash.api import Client
>>> from pulp_smash.config import get_config
>>> def response_handler(server_config, response):
...     response.raise_for_status()
...     return response.json()
>>> client = Client(get_config(), response_handler=response_handler)
>>> response = client.post('/pulp/api/v2/users/', {'login': 'Alice'})
>>> response = client.get(response['_href'])
>>> print(response)

Pulp Smash ships with several response handlers. See:

As mentioned, this class has configurable request and response handling mechanisms. We’ve covered response handling mechanisms — let’s move on to request handling mechanisms.

When a client is instantiated, a pulp_smash.config.PulpSmashConfig must be passed to the constructor, and configuration options are copied from the PulpSmashConfig to the client. These options can be overridden on a per-object or per-request basis. Here’s an example:

>>> from pulp_smash.api import Client
>>> from pulp_smash.config import PulpSmashConfig
>>> cfg = config.PulpSmashConfig(
...     pulp_auth=('username', 'password'),
...     systems=[
...         config.PulpSystem(
...             hostname='example.com',
...             roles={'api': {
...                'scheme': 'https',
...                'verify': '~/Documents/my.crt',
...             }}
...         )
...     ]
... )
>>> client = api.Client(cfg)
>>> client.request_kwargs['url'] == 'https://example.com'
True
>>> client.request_kwargs['verify'] == '~/Documents/my.crt'
True
>>> response = client.get('/index.html')  # Use my.crt for SSL verification
>>> response = client.get('/index.html', verify=False)  # Disable SSL
>>> response = client.get('/index.html')  # Use my.crt for SSL verification
>>> client.request_kwargs['verify'] = None
>>> response = client.get('/index.html')  # Do default SSL verification

Anything accepted by the Requests functions may be placed in request_kwargs or passed in to a specific call. You can set verify for example.

The url argument is slightly special. When making a call, it is possible to pass in a relative URL, as shown in the examples above. (e.g. /index.html.) The default URL and passed-in URL are joined like so:

>>> urljoin(request_kwargs['url'], passed_in_url)

This allows one to easily use the hrefs returned by Pulp in constructing new requests.

The remainder of this docstring contains design notes. They are useful to advanced users and developers.

Requests’ requests.api.post method has the following signature:

def post(url, data=None, json=None, **kwargs)

Pulp supports only JSON for most of its API endpoints, so it makes sense for us to demote data to being a regular kwarg and list json as the one and only positional argument.

We make json a positional argument for post(), put() and patch(), but not the other methods. Why? Because HTTP OPTIONS, GET, HEAD and DELETE must not have bodies. This is stated by the HTTP/1.1 specification, and network intermediaries such as caches are at liberty to drop such bodies.

Why the sentinel? Imagine the following scenario: a user provides a default JSON payload in self.request_kwargs, but they want to skip sending that payload for just one request. How can they do that? With client.post(url, None).

delete(url, **kwargs)

Send an HTTP DELETE request.

get(url, **kwargs)

Send an HTTP GET request.

head(url, **kwargs)

Send an HTTP HEAD request.

options(url, **kwargs)

Send an HTTP OPTIONS request.

patch(url, json=<object object>, **kwargs)

Send an HTTP PATCH request.

post(url, json=<object object>, **kwargs)

Send an HTTP POST request.

put(url, json=<object object>, **kwargs)

Send an HTTP PUT request.

request(method, url, **kwargs)

Send an HTTP request.

Arguments passed directly in to this method override (but do not overwrite!) arguments specified in self.request_kwargs.

pulp_smash.api.echo_handler(server_config, response)

Immediately return response.

pulp_smash.api.json_handler(server_config, response)

Like safe_handler, but also return a JSON-decoded response body.

Do what pulp_smash.api.safe_handler() does. In addition, decode the response body as JSON and return the result.

pulp_smash.api.poll_spawned_tasks(server_config, call_report, pulp_system=None)

Recursively wait for spawned tasks to complete. Yield response bodies.

Recursively wait for each of the spawned tasks listed in the given call report to complete. For each task that completes, yield a response body representing that task’s final state.

Parameters:
  • server_config – A pulp_smash.config.PulpSmashConfig object.
  • call_report – A dict-like object with a call report structure.
  • pulp_system – The system from where to pool the task. If None is provided then the first system found with api role will be used.
Returns:

A generator yielding task bodies.

Raises:

Same as poll_task().

pulp_smash.api.poll_task(server_config, href, pulp_system=None)

Wait for a task and its children to complete. Yield response bodies.

Poll the task at href, waiting for the task to complete. When a response is received indicating that the task is complete, yield that response body and recursively poll each child task.

Parameters:
  • server_config – A pulp_smash.config.PulpSmashConfig object.
  • href – The path to a task you’d like to monitor recursively.
  • pulp_system – The system from where to pool the task. If None is provided then the first system found with api role will be used.
Returns:

An generator yielding response bodies.

Raises:

pulp_smash.exceptions.TaskTimedOutError – If a task takes too long to complete.

pulp_smash.api.safe_handler(server_config, response)

Check status code, wait for tasks to complete, and check tasks.

Inspect the response’s HTTP status code. If the response has an HTTP Accepted status code, inspect the returned call report, wait for each task to complete, and inspect each completed task.

Raises:

requests.exceptions.HTTPError if the response status code is in the 4XX or 5XX range.

Raises:

pulp_smash.cli

Location: Pulp SmashAPI Documentationpulp_smash.cli

A client for working with Pulp systems via their CLI.

class pulp_smash.cli.BaseServiceManager

A base service manager.

Each subclass must implement the abstract methods to provide the service management on a single or multiple systems.

Subclasses should take advantage of the helper methods offered by this class in order to manage services and check the proper service manager softeare available on a system.

This base class also offers a context manager to temporary disable SELinux. It is useful when managing services on RHEL systems earlier than 7 which has SELinux issues when running on Jenkins.

Make sure to call this class __init__ method on the subclass __init__ method to ensure the helper methods functionality.

restart(services)

Restart the given services.

Parameters:services – A list or tuple of services to be restarted.
start(services)

Start the given services.

Parameters:services – A list or tuple of services to be started.
stop(services)

Stop the given services.

Parameters:services – A list or tuple of services to be stopped.
class pulp_smash.cli.Client(server_config, response_handler=None, pulp_system=None)

A convenience object for working with a CLI.

This class provides the ability to execute shell commands on either the local system or a remote system. Here is a pedagogic usage example:

>>> from pulp_smash import cli, config
>>> system = (
...     config.PulpSystem('localhost', {'shell': {'transport': 'local'}})
... )
>>> cfg = config.PulpSmashConfig(systems=[system])
>>> client = cli.Client(cfg, pulp_system=system)
>>> response = client.run(('echo', '-n', 'foo'))
>>> response.returncode == 0
True
>>> response.stdout == 'foo'
True
>>> response.stderr == ''
True

The above example shows how various classes fit together. It’s also verbose: smartly chosen defaults mean that most real code is much more concise.

You can customize how Client objects execute commands and handle responses by fiddling with the two public instance attributes:

machine
A Plumbum machine. run() delegates all command execution responsibilities to this object.
response_handler
A callback function. Each time machine executes a command, the result is handed to this callback, and the callback’s return value is handed to the user.

If pulp_system.roles['shell']['transport'] is 'local' or 'ssh, machine will be set so that commands run locally or over SSH, respectively. If pulp_system.roles['shell']['transport'] is None, the constructor will guess how to set machine by comparing the hostname embedded in pulp_system.hostname against the current system’s hostname. If they match, machine is set to execute commands locally; and vice versa.

Parameters:
run(args, **kwargs)

Run a command and return self.response_handler(result).

This method is a thin wrapper around Plumbum’s BaseCommand.run method, which is itself a thin wrapper around the standard library’s subprocess.Popen class. See their documentation for detailed usage instructions. See pulp_smash.cli.Client for a usage example.

class pulp_smash.cli.CompletedProcess(args, returncode, stdout, stderr)

A process that has finished running.

This class is similar to the subprocess.CompletedProcess class available in Python 3.5 and above. Significant differences include the following:

  • All constructor arguments are required.
  • check_returncode() returns a custom exception, not subprocess.CalledProcessError.

All constructor arguments are stored as instance attributes.

Parameters:
  • args – A string or a sequence. The arguments passed to pulp_smash.cli.Client.run().
  • returncode – The integer exit code of the executed process. Negative for signals.
  • stdout – The standard output of the executed process.
  • stderr – The standard error of the executed process.
check_returncode()

Raise an exception if returncode is non-zero.

Raise pulp_smash.exceptions.CalledProcessError if returncode is non-zero.

Why not raise subprocess.CalledProcessError? Because stdout and stderr are not included when str() is called on a CalledProcessError object. A typical message is:

"Command '('ls', 'foo')' returned non-zero exit status 2"

This information is valuable. One could still make subprocess.CalledProcessError work by overloading args:

>>> if isinstance(args, (str, bytes)):
...     custom_args = (args, stdout, stderr)
... else:
...     custom_args = tuple(args) + (stdout, stderr)
>>> subprocess.CalledProcessError(args, returncode)

But this seems like a hack.

In addition, it’s generally good for an application to raise expected exceptions from its own namespace, so as to better abstract away dependencies.

class pulp_smash.cli.GlobalServiceManager(cfg)

A service manager that manage services across all Pulp systems.

Each instance of this class will manage services on all Pulp systems available on the pulp_smash.config.PulpSmashConfig object provided.

This means that asking this service manager, for example, to start httpd it will iterate over all the available systems and will start the service on every system that has the api role. The example below illustrate this:

>>> from pulp_smash import cli, config
>>> svc_mgr = cli.GlobalServiceManager(config.get_config())
>>> svc_manager.start(['httpd'])

The GlobalServiceManager object will create clients and check if is running as root on demand for every system when managing services. If on a given deployment it has 4 systems and only 2 have the related services available then a connection will be done to those 2 an not on all 4.

Also, the GlobalServiceManager object will try to cache as much information as possible to avoid doing many connections.

Parameters:cfg (pulp_smash.config.PulpSmashConfig) – Information about the Pulp deployment.
Raises:pulp_smash.exceptions.NoKnownServiceManagerError – If unable to find any service manager on one of the target systems.
restart(services)

Restart the services on every system that has the services.

Parameters:services – An iterable of service names.
Returns:A dict mapping the affected systems’ hostnames with a list of pulp_smash.cli.CompletedProcess objects.
start(services)

Start the services on every system that has the services.

Parameters:services – An iterable of service names.
Returns:A dict mapping the affected systems’ hostnames with a list of pulp_smash.cli.CompletedProcess objects.
stop(services)

Stop the services on every system that has the services.

Parameters:services – An iterable of service names.
Returns:A dict mapping the affected systems’ hostnames with a list of pulp_smash.cli.CompletedProcess objects.
class pulp_smash.cli.PackageManager(cfg)

A package manager on a system.

Each instance of this class represents the package manager on a system. An example may help to clarify this idea:

>>> from pulp_smash import cli, config
>>> pkg_mgr = cli.PackageManager(config.get_config())
>>> completed_process = pkg_mgr.install('vim')
>>> completed_process = pkg_mgr.uninstall('vim')

In the example above, the pkg_mgr object represents the package manager on the host referenced by pulp_smash.config.get_config().

Upon instantiation, a PackageManager object talks to its target system and uses simple heuristics to determine which package manager is used. As a result, it’s possible to manage packages on heterogeneous systems with homogeneous commands.

Upon instantiation, a PackageManager object also talks to its target system and determines whether it is running as root. If not root, all commands are prefixed with “sudo”. Please ensure that Pulp Smash can either execute commands as root or can successfully execute sudo. You may need to edit your ~/.ssh/config file.

Parameters:cfg (pulp_smash.config.PulpSmashConfig) – Information about the target system.
Raises:pulp_smash.exceptions.NoKnownPackageManagerError – If unable to find any package manager on the target system.
install(*args)

Install the named packages.

Return type:pulp_smash.cli.CompletedProcess
uninstall(*args)

Uninstall the named packages.

Return type:pulp_smash.cli.CompletedProcess
upgrade(*args)

Upgrade the named packages.

Return type:pulp_smash.cli.CompletedProcess
class pulp_smash.cli.ServiceManager(cfg, pulp_system)

A service manager on a system.

Each instance of this class represents the service manager on a system. An example may help to clarify this idea:

from pulp_smash import cli, config >>> svc_mgr = cli.ServiceManager(config.get_config(), pulp_system) >>> completed_process_list = svc_manager.stop([‘httpd’]) >>> completed_process_list = svc_manager.start([‘httpd’])

In the example above, the svc_mgr object represents the service manager on the host referenced by pulp_system.

Upon instantiation, a ServiceManager object talks to its target system and uses simple heuristics to determine which service manager is available. As a result, it’s possible to manage services on heterogeneous systems with homogeneous commands.

Upon instantiation, a ServiceManager object also talks to its target system and determines whether it is running as root. If not root, all commands are prefixed with “sudo”. Please ensure that Pulp Smash can either execute commands as root or can successfully execute sudo. You may need to edit your ~/.ssh/config file.

Parameters:
Raises:

pulp_smash.exceptions.NoKnownServiceManagerError – If unable to find any service manager on the target system.

restart(services)

Restart the given services.

Parameters:services – An iterable of service names.
Returns:An iterable of pulp_smash.cli.CompletedProcess objects.
start(services)

Start the given services.

Parameters:services – An iterable of service names.
Returns:An iterable of pulp_smash.cli.CompletedProcess objects.
stop(services)

Stop the given services.

Parameters:services – An iterable of service names.
Returns:An iterable of pulp_smash.cli.CompletedProcess objects.
pulp_smash.cli.code_handler(completed_proc)

Check the process for a non-zero return code. Return the process.

Check the return code by calling completed_proc.check_returncode(). See: pulp_smash.cli.CompletedProcess.check_returncode().

pulp_smash.cli.echo_handler(completed_proc)

Immediately return completed_proc.

pulp_smash.config

Location: Pulp SmashAPI Documentationpulp_smash.config

Tools for managing information about test systems.

Pulp Smash needs to know what servers it can talk to and how to talk to those systems. For example, it needs to know the protocol, hostname and port of a Pulp server (e.g. ‘https://example.com:250‘) and how to authenticate with that server. pulp_smash.config.PulpSmashConfig eases the task of managing that information.

class pulp_smash.config.PulpSmashConfig(pulp_auth=None, pulp_version=None, systems=None)

Information about a Pulp deployment.

This object stores a set of information about a Pulp deployment and its systems. A typical usage of this object is as follows:

>>> import requests
>>> from pulp_smash.config import PulpSmashConfig
>>> cfg = PulpSmashConfig(
...     pulp_auth=('username', 'password'),
...     pulp_version='2.12.2',
...     systems=[
...         PulpSystem(
...             hostname='pulp.example.com',
...             roles={
...                 'amqp broker': {'service': 'qpidd'},
...                 'api': {
...                     'scheme': 'https',
...                     'verify': False,  # Disable SSL verification
...                 },
...                 'mongod': {},
...                 'pulp cli': {},
...                 'pulp celerybeat': {},
...                 'pulp resource manager': {},
...                 'pulp workers': {},
...                 'shell': {
...                     'transport': 'ssh',
...                 },
...             },
...         )
...     ]
... )
>>> response = requests.post(
...     cfg.base_url + '/pulp/api/v2/actions/login/',
...     **cfg.get_requests_kwargs()
... )

All methods dealing with files obey the XDG Base Directory Specification. Please read the specification for insight into the logic of those methods.

In addition, the file-facing methods respect the PULP_SMASH_CONFIG_FILE environment variable. By default, the methods work with a file named settings.json, but the environment variable overrides that default. If set, the environment variable should be a file name like settings2.json (or a relative path), not an absolute path.

Parameters:
  • pulp_auth – A two-tuple. Credentials to use when communicating with the server. For example: ('username', 'password').
  • pulp_version – A string, such as ‘1.2’ or ‘0.8.rc3’. Defaults to ‘1!0’ (epoch 1, version 0). Must be compatible with the packaging library’s packaging.version.Version class.
  • systems – A list of pulp_smash.config.PulpSystem. Mapping every system on a given Pulp deployment.
base_url

Map old config base_url to the system with api role.

cli_transport

Map old config cli_transport to the system with shell role.

get_base_url(pulp_system=None)

Generate the base URL for a given pulp_sytem.

If pulp_system is None then the first system found with the api role will be chosen.

get_requests_kwargs(pulp_system=None)

Get kwargs for use by the Requests functions.

This method returns a dict of attributes that can be unpacked and used as kwargs via the ** operator. For example:

>>> cfg = PulpSmashConfig().read()
>>> requests.get(cfg.base_url + '…', **cfg.get_requests_kwargs())

This method is useful because client code may not know which attributes should be passed from a PulpSmashConfig object to Requests. Consider that the example above could also be written like this:

>>> cfg = PulpSmashConfig().get()
>>> requests.get(
...     cfg.base_url + '…',
...     auth=tuple(cfg.pulp_auth),
...     verify=cfg.get_systems('api')[0].roles['api']['verify'],
... )

But this latter approach is more fragile. The user must remember to get a system with api role to check for the verify config, then convert pulp_auth config to a tuple, and it will require maintenance if cfg gains or loses attributes.

get_systems(role)

Return a list of systems fulfilling the given role.

Parameters:role – The role to filter the available systems, see pulp_smash.config.ROLES for more information.
read(xdg_config_file=None, xdg_config_dir=None)

Read a configuration file.

Parameters:
  • xdg_config_file – A string. The name of the file to manipulate.
  • xdg_config_dir – A string. The XDG configuration directory in which the configuration file resides.
Returns:

A new pulp_smash.config.PulpSmashConfig object. The current object is not modified by this method.

Return type:

PulpSmashConfig

Raises:

warnings.DecprecationWarning if the configuration file uses the old format instead of the new system with roles based format.

static services_for_roles(roles)

Return the services based on the roles.

verify

Map old config verify to the system with api role.

version

Map old config version to the pulp_version.

class pulp_smash.config.PulpSystem(hostname, roles)
hostname

Alias for field number 0

roles

Alias for field number 1

pulp_smash.config.get_config()

Return a copy of the global PulpSmashConfig object.

This method makes use of a cache. If the cache is empty, the configuration file is parsed and the cache is populated. Otherwise, a copy of the cached configuration object is returned.

Returns:A copy of the global server configuration object.
Return type:pulp_smash.config.PulpSmashConfig
pulp_smash.config.validate_config(config_dict)

Validate the config file schema.

Parameters:config_dict – A dictionary returned by json.load or json.loads after reading the config file.
Raises:pulp_smash.exceptions.ConfigValidationError – If the any validation error is found.

pulp_smash.constants

Location: Pulp SmashAPI Documentationpulp_smash.constants

Values usable by multiple test modules.

pulp_smash.constants.CALL_REPORT_KEYS = frozenset({'spawned_tasks', 'result', 'error'})

See: Call Report.

pulp_smash.constants.CONSUMER_PATH = '/pulp/api/v2/consumers/'

See: Consumer APIs.

pulp_smash.constants.CONTENT_SOURCES_PATH = '/etc/pulp/content/sources/conf.d'

See: Content Sources.

pulp_smash.constants.CONTENT_UNITS_PATH = '/pulp/api/v2/content/units/'

See: Search for Units.

pulp_smash.constants.CONTENT_UPLOAD_PATH = '/pulp/api/v2/content/uploads/'

See: Creating an Upload Request.

pulp_smash.constants.DOCKER_IMAGE_URL = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/docker/busybox:latest.tar'

The URL to a Docker image as created by docker save.

pulp_smash.constants.DOCKER_UPSTREAM_NAME = 'library/busybox'

The name of a repository present in each of the two docker feeds.

pulp_smash.constants.DOCKER_V1_FEED_URL = 'https://index.docker.io'

The URL to a V1 Docker registry.

This URL can be used as the “feed” property of a Pulp Docker registry.

pulp_smash.constants.DOCKER_V2_FEED_URL = 'https://registry-1.docker.io'

The URL to a V2 Docker registry.

This URL can be used as the “feed” property of a Pulp Docker registry.

pulp_smash.constants.DRPM = 'drpms/test-alpha-1.1-1_1.1-2.noarch.drpm'

The path to a DRPM file in one of the DRPM repositories.

This path may be joined with DRPM_SIGNED_FEED_URL or DRPM_UNSIGNED_FEED_URL.

pulp_smash.constants.DRPM_SIGNED_FEED_COUNT = 4

The number of packages available at DRPM_SIGNED_FEED_URL.

pulp_smash.constants.DRPM_SIGNED_FEED_URL = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/drpm-signed/'

The URL to a signed DRPM repository.

pulp_smash.constants.DRPM_SIGNED_URL = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/drpm-signed/drpms/test-alpha-1.1-1_1.1-2.noarch.drpm'

The URL to a DRPM file.

Built from DRPM_SIGNED_FEED_URL and DRPM.

pulp_smash.constants.DRPM_UNSIGNED_FEED_COUNT = 4

The number of packages available at DRPM_UNSIGNED_FEED_URL.

pulp_smash.constants.DRPM_UNSIGNED_FEED_URL = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/drpm-unsigned/'

The URL to an unsigned DRPM repository.

pulp_smash.constants.DRPM_UNSIGNED_URL = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/drpm-unsigned/drpms/test-alpha-1.1-1_1.1-2.noarch.drpm'

The URL to a unsigned DRPM file.

Built from DRPM_UNSIGNED_FEED_URL and DRPM.

pulp_smash.constants.ERROR_KEYS = frozenset({'traceback', 'http_status', '_href', 'exception', 'error', 'error_message'})

See: Exception Handling.

No href field should be present. See Issue #1310.

pulp_smash.constants.FILE_FEED_COUNT = 3

The number of packages available at FILE_FEED_URL.

pulp_smash.constants.FILE_FEED_URL = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/file/'

The URL to a file repository.

pulp_smash.constants.FILE_MIXED_FEED_URL = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/file-mixed/'

The URL to a file repository containing invalid and valid entries.

pulp_smash.constants.FILE_URL = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/file/1.iso'

The URL to an ISO file at FILE_FEED_URL.

pulp_smash.constants.GROUP_CALL_REPORT_KEYS = frozenset({'_href', 'group_id'})

See: Group Call Report.

pulp_smash.constants.LOGIN_KEYS = frozenset({'key', 'certificate'})

See: User Certificates.

pulp_smash.constants.LOGIN_PATH = '/pulp/api/v2/actions/login/'

See: Authentication.

pulp_smash.constants.ORPHANS_PATH = 'pulp/api/v2/content/orphans/'

See: Orphaned Content.

pulp_smash.constants.OSTREE_BRANCH = 'fedora-atomic/f21/x86_64/updates/docker-host'

A branch in OSTREE_FEED. See OSTree Importer Configuration.

pulp_smash.constants.OSTREE_FEED = 'https://repos.fedorapeople.org/pulp/pulp/demo_repos/test-ostree-small'

The URL to a URL of OSTree branches. See OSTree Importer Configuration.

pulp_smash.constants.PLUGIN_TYPES_PATH = '/pulp/api/v2/plugins/types/'

See: Retrieve All Content Unit Types.

pulp_smash.constants.PULP_FIXTURES_BASE_URL = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/'

A URL at which generated pulp fixtures are hosted.

pulp_smash.constants.PULP_FIXTURES_KEY_ID = '269d9d98'

The 32-bit ID of the public key used to sign various fixture files.

To calculate a new key ID, find the public key used by Pulp Fixtures (it should be in the Pulp Fixtures source code repository) and use GnuPG to examine it:

$ gpg "$public_key_file"
pub   rsa2048 2016-08-05 [SC]
      6EDF301256480B9B801EBA3D05A5E6DA269D9D98
uid           Pulp QE
sub   rsa2048 2016-08-05 [E]

The last 32 bits (8 characters) of the key ID are what Pulp wants — in this example, 269D9D98.

pulp_smash.constants.PULP_SERVICES = {'pulp_celerybeat', 'httpd', 'pulp_resource_manager', 'pulp_workers'}

Core Pulp services.

There are services beyond just these that Pulp depends on in order to function correctly. For example, an AMQP broker such as RabbitMQ or Qpid is integral to Pulp’s functioning. However, if resetting Pulp (such as in pulp_smash.utils.reset_pulp()), this is the set of services that should be restarted.

pulp_smash.constants.PUPPET_FEED_2 = 'http://forge.puppetlabs.com'

The URL to a repository of Puppet modules.

pulp_smash.constants.PUPPET_MODULE_1 = {'name': 'dummypuppet', 'version': '0.1.0', 'author': 'pulpqe'}

Information about a Puppet module available via Pulp Fixtures.

pulp_smash.constants.PUPPET_MODULE_2 = {'name': 'pulp', 'version': '1.0.0', 'author': 'pulp'}

Information about a Puppet module available at PUPPET_FEED_2.

pulp_smash.constants.PUPPET_MODULE_URL_1 = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/puppet/pulpqe-dummypuppet.tar.gz'

The URL to a Puppet module module available via Pulp Fixtures.

Test cases that require a single module should use this URL, and test cases that require a feed should use PUPPET_MODULE_URL_2. Doing so shifts load away from the Puppet Forge.

Why do both URLs exist? Because simulating the Puppet Forge’s behaviour is unreasonably hard.

Pulp Fixtures is designed to create data that can be hosted by a simple HTTP server, such as python3 -m http.server. A dynamic API, such as the Puppet Forge API, cannot be simulated. We could create a static tree of files, where that tree of files is the same as what the Puppet Forge would provide in response to a certain HTTP GET request. However:

  • The Puppet Forge API will inevitably change over time as bugs are fixed and features are added. This will make a static facsimile of the Puppet Forge API outdated. This is more than a mere inconvenience: outdated information is also confusing!
  • Without an in-depth understanding of each and every file the Puppet Forge yields, it is probable that static fixtures will be wrong from the get-go.
pulp_smash.constants.PUPPET_MODULE_URL_2 = 'http://forge.puppetlabs.com/v3/files/pulp-pulp-1.0.0.tar.gz'

The URL to a Puppet module available at PUPPET_FEED_2.

pulp_smash.constants.PUPPET_QUERY_2 = 'pulp-pulp-1.0.0'

A query that can be used to search for Puppet modules.

Built from PUPPET_MODULE_2.

Though the Puppet Forge API supports a variety of search types, Pulp only supports the ability to search for modules. As a result, it is impossible to create a Puppet repository and sync only an exact module or set of modules. This query intentionally returns a small number of Puppet modules. A query which selected a large number of modules would produce tests that took a long time and abused the free Puppet Forge service.

Beware that the Pulp API takes given Puppet queries and uses them to construct URL queries verbatim. Thus, if the user gives a query of “foo bar”, the following URL is constructed:

In an attempt to avoid this error, this query is encoded before being submitted to Pulp.

pulp_smash.constants.PYTHON_EGG_URL = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/python-pypi/packages/3a/e3/a6954c4134a899c0006515fbd40208922572947e960b35d0d19fd5a1b3d0/shelf-reader-0.1.tar.gz'

The URL to a Python egg at PYTHON_PYPI_FEED_URL.

pulp_smash.constants.PYTHON_PYPI_FEED_URL = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/python-pypi/'

The URL to the PyPI Python repository.

pulp_smash.constants.PYTHON_WHEEL_URL = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/python-pypi/packages/77/e0/2156a3da94ee16466a5936394caf7e89873a9b46eed72a9912bc90e42dbf/shelf_reader-0.1-py2-none-any.whl'

The URL to a Python egg at PYTHON_PYPI_FEED_URL.

pulp_smash.constants.REPOSITORY_EXPORT_DISTRIBUTOR = 'export_distributor'

A distributor_type_id to export a repository.

See: Export Distributors.

pulp_smash.constants.REPOSITORY_GROUP_EXPORT_DISTRIBUTOR = 'group_export_distributor'

A distributor_type_id to export a repository group.

See: Export Distributors.

pulp_smash.constants.REPOSITORY_GROUP_PATH = '/pulp/api/v2/repo_groups/'

See: Repository Group APIs

pulp_smash.constants.REPOSITORY_PATH = '/pulp/api/v2/repositories/'

See: Repository APIs.

pulp_smash.constants.RPM = 'bear-4.1-1.noarch.rpm'

The name of an RPM file. See pulp_smash.constants.RPM_SIGNED_URL.

pulp_smash.constants.RPM2 = 'camel-0.1-1.noarch.rpm'

The name of an RPM. See pulp_smash.constants.RPM2_UNSIGNED_URL.

pulp_smash.constants.RPM2_UNSIGNED_URL = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/rpm-unsigned/camel-0.1-1.noarch.rpm'

The URL to an unsigned RPM file.

Built from RPM_UNSIGNED_FEED_URL and RPM2.

pulp_smash.constants.RPM_ALT_LAYOUT_FEED_URL = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/rpm-alt-layout/'

The URL to a signed RPM repository. See RPM_SIGNED_URL.

pulp_smash.constants.RPM_ERRATUM_ID = 'RHEA-2012:0058'

The ID of an erratum.

The package contained on this erratum is defined by pulp_smash.constants.RPM_ERRATUM_RPM_NAME and the erratum is present on repository which feed is pulp_smash.constants.RPM_SIGNED_FEED_URL.

pulp_smash.constants.RPM_ERRATUM_RPM_NAME = 'gorilla'

The name of the RPM present on an erratum.

The erratum ID is defined by pulp_smash.constants.RPM_ERRATUM_ID.

pulp_smash.constants.RPM_ERRATUM_URL = 'https://repos.fedorapeople.org/repos/pulp/pulp/fixtures/rpm-erratum/erratum.json'

The URL to an JSON erratum file for an RPM repository.

pulp_smash.constants.RPM_INCOMPLETE_FILELISTS_FEED_URL = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/rpm-incomplete-filelists/'

The URL to a repository with an incomplete filelists.xml file.

pulp_smash.constants.RPM_INCOMPLETE_OTHER_FEED_URL = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/rpm-incomplete-other/'

The URL to a repository with an incomplete other.xml file.

pulp_smash.constants.RPM_MIRRORLIST_BAD = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/rpm-mirrorlist-bad'

The URL to a mirrorlist file containing only invalid entries.

pulp_smash.constants.RPM_MIRRORLIST_GOOD = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/rpm-mirrorlist-good'

The URL to a mirrorlist file containing only valid entries.

pulp_smash.constants.RPM_MIRRORLIST_MIXED = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/rpm-mirrorlist-mixed'

The URL to a mirrorlist file containing invalid and valid entries.

pulp_smash.constants.RPM_MISSING_FILELISTS_FEED_URL = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/rpm-missing-filelists/'

A repository that’s missing its filelists.xml file.

pulp_smash.constants.RPM_MISSING_OTHER_FEED_URL = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/rpm-missing-other/'

A repository that’s missing its other.xml file.

pulp_smash.constants.RPM_MISSING_PRIMARY_FEED_URL = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/rpm-missing-primary/'

A repository that’s missing its primary.xml file.

pulp_smash.constants.RPM_NAMESPACES = {'metadata/common': 'http://linux.duke.edu/metadata/common', 'metadata/repo': 'http://linux.duke.edu/metadata/repo', 'metadata/rpm': 'http://linux.duke.edu/metadata/rpm'}

Namespaces used by XML-based RPM metadata.

Many of the XML files generated by the createrepo utility make use of these namespaces. Some of the files that use these namespaces are listed below:

metadata/common
Used by repodata/primary.xml.
metadata/repo
Used by repodata/repomd.xml.
metadata/rpm
Used by repodata/repomd.xml.
pulp_smash.constants.RPM_PKGLISTS_UPDATEINFO_FEED_URL = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/rpm-pkglists-updateinfo/'

A repository whose updateinfo file has multiple <pkglist> sections.

pulp_smash.constants.RPM_SIGNED_FEED_COUNT = 32

The number of packages available at RPM_SIGNED_FEED_URL.

pulp_smash.constants.RPM_SIGNED_FEED_URL = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/rpm-signed/'

The URL to a signed RPM repository. See RPM_SIGNED_URL.

pulp_smash.constants.RPM_SIGNED_URL = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/rpm-signed/bear-4.1-1.noarch.rpm'

The URL to an RPM file.

Built from RPM_SIGNED_FEED_URL and RPM.

pulp_smash.constants.RPM_UNSIGNED_FEED_COUNT = 32

The number of packages available at RPM_UNSIGNED_FEED_URL.

pulp_smash.constants.RPM_UNSIGNED_FEED_URL = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/rpm-unsigned/'

The URL to an unsigned RPM repository. See RPM_SIGNED_URL.

pulp_smash.constants.RPM_UNSIGNED_URL = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/rpm-unsigned/bear-4.1-1.noarch.rpm'

The URL to an unsigned RPM file.

Built from RPM_UNSIGNED_FEED_URL and RPM.

pulp_smash.constants.RPM_WITH_NON_ASCII_URL = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/rpm-with-non-ascii/rpm-with-non-ascii-1-1.fc25.noarch.rpm'

The URL to an RPM with non-ascii metadata in its header.

pulp_smash.constants.RPM_WITH_NON_UTF_8_URL = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/rpm-with-non-utf-8/rpm-with-non-utf-8-1-1.fc25.noarch.rpm'

The URL to an RPM with non-UTF-8 metadata in its header.

pulp_smash.constants.RPM_WITH_PULP_DISTRIBUTION_FEED_URL = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/rpm-with-pulp-distribution/'

The URL to a RPM repository with a PULP_DISTRIBUTION.xml file.

pulp_smash.constants.SRPM = 'test-srpm02-1.0-1.src.rpm'

An SRPM file at pulp_smash.constants.SRPM_SIGNED_FEED_URL.

pulp_smash.constants.SRPM_SIGNED_FEED_COUNT = 3

The number of packages available at SRPM_SIGNED_FEED_URL.

pulp_smash.constants.SRPM_SIGNED_FEED_URL = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/srpm-signed/'

The URL to a signed SRPM repository.

pulp_smash.constants.SRPM_SIGNED_URL = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/srpm-signed/test-srpm02-1.0-1.src.rpm'

The URL to an SRPM file.

Built from SRPM_SIGNED_FEED_URL and SRPM.

pulp_smash.constants.SRPM_UNSIGNED_FEED_COUNT = 3

The number of packages available at SRPM_UNSIGNED_FEED_COUNT.

pulp_smash.constants.SRPM_UNSIGNED_FEED_URL = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/srpm-unsigned/'

The URL to an unsigned SRPM repository.

pulp_smash.constants.SRPM_UNSIGNED_URL = 'https://repos.fedorapeople.org/pulp/pulp/fixtures/srpm-unsigned/test-srpm02-1.0-1.src.rpm'

The URL to an unsigned SRPM file.

Built from SRPM_UNSIGNED_FEED_URL and SRPM.

pulp_smash.constants.USER_PATH = '/pulp/api/v2/users/'

See: User APIs.

pulp_smash.exceptions

Location: Pulp SmashAPI Documentationpulp_smash.exceptions

Custom exceptions defined by Pulp Smash.

exception pulp_smash.exceptions.BugStatusUnknownError

We have encountered a bug whose status is unknown to us.

See pulp_smash.selectors for more information on how bug statuses are used.

exception pulp_smash.exceptions.BugTPRMissingError

We have encountered a bug with no “Target Platform Release” field.

See pulp_smash.selectors for more information.

exception pulp_smash.exceptions.CallReportError

A call report contains an error.

For more information about pulp’s task handling, see Synchronous and Asynchronous Calls and Task Management.

exception pulp_smash.exceptions.CalledProcessError

Indicates a CLI process has a non-zero return code.

See pulp_smash.cli.CompletedProcess() for more information.

exception pulp_smash.exceptions.ConfigFileNotFoundError

We cannot find the requested Pulp Smash configuration file.

See pulp_smash.config for more information on how configuration files are handled.

exception pulp_smash.exceptions.ConfigFileSectionNotFoundError

We cannot read the requested Pulp Smash configuration file section.

See pulp_smash.config for more information on how configuration files are handled.

exception pulp_smash.exceptions.ConfigValidationError(error_messages, *args, **kwargs)

The configuration file has validation errors.

See pulp_smash.config.validate_config() for more information on how
configuration validation is handled.
exception pulp_smash.exceptions.NoKnownBrokerError

We cannot determine the AMQP broker used by a system.

An “AMQP broker” is a tool such as RabbitMQ or Apache Qpid.

exception pulp_smash.exceptions.NoKnownPackageManagerError

We cannot determine the package manager used by a system.

A “package manager” is a tool such as yum or dnf.

exception pulp_smash.exceptions.NoKnownServiceManagerError

We cannot determine the service manager used by a system.

A “service manager” is a tool such as systemctl or service.

exception pulp_smash.exceptions.TaskReportError(msg, task, *args, **kwargs)

A task contains an error.

For more information about pulp’s task handling, see Synchronous and Asynchronous Calls and Task Management.

exception pulp_smash.exceptions.TaskTimedOutError

We timed out while polling a task and waiting for it to complete.

See pulp_smash.api.poll_spawned_tasks() and pulp_smash.api.poll_task() for more information on how task polling is handled.

pulp_smash.selectors

Location: Pulp SmashAPI Documentationpulp_smash.selectors

Tools for selecting and deselecting tests.

pulp_smash.selectors.bug_is_testable(bug_id, pulp_version)

Tell the caller whether bug bug_id should be tested.

Parameters:
  • bug_id – An integer bug ID, taken from https://pulp.plan.io.
  • pulp_version – A packaging.version.Version object telling the version of the Pulp server we are testing.
Returns:

True if the bug is testable, or False otherwise.

Raises:

TypeError if bug_id is not an integer.

Raises:

pulp_smash.exceptions.BugStatusUnknownError – If the bug has a status Pulp Smash does not recognize.

pulp_smash.selectors.bug_is_untestable(bug_id, pulp_version)

Return the inverse of bug_is_testable().

pulp_smash.selectors.require(version_string)

Optionally skip a test method, based on a version string.

This decorator concisely encapsulates a common pattern for skipping tests. It can be used like so:

>>> from pulp_smash.config import get_config
>>> from pulp_smash.utils import require
>>> from unittest import TestCase
>>> class MyTestCase(TestCase):
...
...     @classmethod
...     def setUpClass(cls):
...         cls.cfg = get_config()
...
...     @require('2.7')  # References `self.cfg`
...     def test_foo(self):
...         pass  # Add a test for Pulp 2.7+ here.

Notice that cls.cfg is assigned to. This is a requirement.

Parameters:version_string – A PEP 440 compatible version string.
pulp_smash.selectors.skip_if(func, var_name, result)

Optionally skip a test method, based on a condition.

This decorator checks to see if func(getattr(self, var_name)) equals result. If so, a unittest.SkipTest exception is raised. Otherwise, nothing happens, and the decorated test method continues as normal. Here’s an example:

>>> import unittest
>>> from pulp_smash.selectors import skip_if
>>> class MyTestCase(unittest.TestCase):
...
...     @classmethod
...     def setUpClass(cls):
...         cls.my_var = False
...
...     @skip_if(bool, 'my_var', False)
...     def test_01_skips(self):
...         pass
...
...     def test_02_runs(self):
...         type(self).my_var = True
...
...     @skip_if(bool, 'my_var', False)
...     def test_03_runs(self):
...         pass
Parameters:var_name – A valid variable name.

pulp_smash.tests

Location: Pulp SmashAPI Documentationpulp_smash.tests

Tests for Pulp.

This package and its sub-packages contain functional tests for Pulp. These tests should be run against live Pulp systems. These tests may target all of the different interfaces exposed by Pulp, including its API and CLI. These tests are entirely different from the unit tests in tests.

A given Pulp server may have an arbitrary set of plugins installed. As a result, not all of the tests in Pulp Smash should be run against a given Pulp server. Consequently, tests are organized on a per-plugin basis. Tests for the Docker plugin are in pulp_smash.tests.docker, tests for the OSTree plugin are in pulp_smash.tests.ostree, and so on. Several other factors also determine whether a test should be run, such as whether a given bug has been fixed in the version of Pulp under test. However, plugins are the broadest determinant of which tests should be run, so they direct the test suite structure.

Selecting and deselecting tests is a common task, and module pulp_smash.selectors has a collection of tools for this problem area. At a minimum, every test* module should define a setUpModule function that checks for the presence of needed Pulp plugins and raises a SkipTest exception if needed. For convenience, functions such as pulp_smash.tests.docker.utils.set_up_module() can be used for this purpose. For example:

>>> from pulp_smash.tests.docker.utils import set_up_module as setUpModule

By default, Requests refuses to make insecure HTTPS connections. You can override this behaviour by passing verify=False. For example:

requests.get('https://insecure.example.com', verify=False)

If you do this, Requests will make the connection. However, an InsecureRequestWarning will be raised. This is problematic. If a user has explicitly stated that they want insecure HTTPS connections and they are pestered about that fact, the user is effectively trained to ignore warnings.

This module attempts to solve that problem. When this module is imported, a filter is prepended to the warning module’s list of filters. The filter states that InsecureRequestWarning warnings should be ignored. Note that this has no effect on whether SSL verification is performed. Insecure HTTPS connections are still blocked by default. The filter only has an effect on whether InsecureRequestWarning messages are displayed.

This filtering has a drawback: the warning module’s filtering system is process-wide. Imagine an application which uses both Pulp Smash and some other library, and imagine that the other library generates InsecureRequestWarning warnings. The filter created here will suppress the warnings raised by that application. The warnings.catch_warnings context manager is not a good solution to this problem, as it is thread-unsafe.

This filtering is also limited: any Python code which executes after this module is imported can also manipulate the warning module’s list of filters, and can therefore override the effects of this module. Unfortunately, the unittest test runner from the standard library does just that. As of this writing (with Python 3.5.3), the following filter (among others) is prepended to the warning module’s filter list whenever a test case is executed:

>>> from warnings import filters
>>> filters[1]
('default', None, <class 'Warning'>, None, 0)

This filter matches all warnings — including InsecureRequestWarning — and causes them to be emitted. In theory, this does not occur if -W 'ignore::requests.packages.urllib3.exceptions.InsecureRequestWarning' is passed when calling python -m unittest. A more efficacious solution is to use a different test runner.

pulp_smash.tests.docker

Location: Pulp SmashAPI Documentationpulp_smash.tests.docker

This package contains tests for the Docker plugin.

pulp_smash.tests.docker.api_v2

Location: Pulp SmashAPI Documentationpulp_smash.tests.docker.api_v2

This package contains tests for the Docker plugin with the Pulp v2 API.

pulp_smash.tests.docker.api_v2.test_crud

Location: Pulp SmashAPI Documentationpulp_smash.tests.docker.api_v2.test_crud

Test CRUD for Docker repositories.

This module contains tests for creating Docker repositories. It is intended to also contain read, update, and delete tests.

class pulp_smash.tests.docker.api_v2.test_crud.CrudTestCase(methodName='runTest')

CRUD a minimal Docker repository.

static create_body()

Return a dict for creating a repository.

static update_body()

Return a dict for creating a repository.

class pulp_smash.tests.docker.api_v2.test_crud.CrudWithFeedTestCase(methodName='runTest')

CRUD a Docker repository with a feed.

static create_body()

Return a dict, with a feed, for creating a repository.

class pulp_smash.tests.docker.api_v2.test_crud.UpdateTestCase(methodName='runTest')

Show it is possible to update a distributor for a docker repository.

classmethod setUpClass()

Create a docker repo with a distributor, and update the distributor.

Do the following:

  1. Create a docker repository and add a distributor.
  2. Update the distributor. Use the distributor’s href in the request.
  3. Update the distributor. Use the repository’s href in the request, and ensure the distributor is updated by packing certain data in the request body.
test_status_codes()

Verify each of the server’s responses has a correct status code.

test_update_accepted()

Verify the information sent to the server can be read back.

pulp_smash.tests.docker.api_v2.test_crud.setUpModule()

Skip tests on Pulp versions lower than 2.8.

pulp_smash.tests.docker.api_v2.test_duplicate_uploads

Location: Pulp SmashAPI Documentationpulp_smash.tests.docker.api_v2.test_duplicate_uploads

Tests for how well Pulp can deal with duplicate uploads.

This module targets Pulp #1406 and Pulp Smash #81. The test procedure is as follows:

  1. Create a new feed-less repository.
  2. Upload content and import it into the repository. Assert the upload and import was successful.
  3. Upload identical content and import it into the repository.

The second upload should silently fail for all Pulp releases in the 2.x series.

class pulp_smash.tests.docker.api_v2.test_duplicate_uploads.DuplicateUploadsTestCase(methodName='runTest')

Test how well Pulp can deal with duplicate content unit uploads.

classmethod setUpClass()

Create a Docker repository.

pulp_smash.tests.docker.api_v2.test_sync

Location: Pulp SmashAPI Documentationpulp_smash.tests.docker.api_v2.test_sync

Tests that sync docker repositories.

class pulp_smash.tests.docker.api_v2.test_sync.UpstreamNameTestsMixin

Provides tests that sync a repository and override upstream_name.

Any class inheriting from this mixin must also inherit from pulp_smash.utils.BaseAPITestCase.

test_invalid_upstream_name()

Sync the repository and pass an invalid upstream_name.

Verify the sync request is rejected with an HTTP 400 status code.

test_valid_upstream_name()

Sync the repository and pass a valid upstream_name.

Verify the sync succeeds.

class pulp_smash.tests.docker.api_v2.test_sync.UpstreamNameV1TestCase(methodName='runTest')

Sync a v1 docker repository with various upstream_name options.

This test targets Pulp #2230.

classmethod setUpClass()

Create a docker repository with an importer.

The importer has no upstream_name set. it must be passed via override_config when a sync is requested.

class pulp_smash.tests.docker.api_v2.test_sync.UpstreamNameV2TestCase(methodName='runTest')

Sync a v2 docker repository with various upstream_name options.

This test targets Pulp #2230.

classmethod setUpClass()

Create a docker repository with an importer.

The importer has no upstream_name set. it must be passed via override_config when a sync is requested.

pulp_smash.tests.docker.api_v2.test_sync.setUpModule()

Skip tests on Pulp versions lower than 2.8.

pulp_smash.tests.docker.api_v2.test_tags

Location: Pulp SmashAPI Documentationpulp_smash.tests.docker.api_v2.test_tags

Tests that work with tags on docker repositories.

class pulp_smash.tests.docker.api_v2.test_tags.DockerTagTestCase(methodName='runTest')

Tests for docker repository tagging feature.

get_latest_tags()

Return all tags in this test’s repo with a name of “latest”.

Starting with Pulp 2.13, docker schema v2 is supported. As a result, a tag or manifest may be included in search results twice, with a differing schema_version. For convenience, if the Pulp system under test is version 2.13 or newer, only schema v1 is targeted. (The choice of schema version 1 is arbitrary.) See Pulp #2099.

Returns:A list of docker tags.
get_manifests()

Return all manifests in this test’s repo.

If the Pulp system under test is version 2.13 or newer, only return schema v1 manifests. See get_latest_tags().

setUp()

Create and sync a docker repository.

test_create_tag()

Check if a tag can be created.

test_update_tag()

Check if a tag can be updated to a new manifest.

Do the following:

  1. Find the tag in this test’s docker repository whose name is “latest.” Make note of the manifest it references.
  2. Pick some other manifest. Update the repository so that the “latest” tag references the chosen manifest.
  3. Find the tag in this test’s docker repository whose name is “latest.” Assert it references the chosen manifest.
test_update_tag_another_repo()

Check if tagging fail for a manifest from another repo.

test_update_tag_invalid_manifest()

Check if tagging fail for a invalid manifest.

pulp_smash.tests.docker.api_v2.test_tags.create_docker_repo(cfg, upstream_name, use_v1=False)

Create a docker repository.

Parameters:
  • cfg (pulp_smash.config.PulpSmashConfig) – Information about a Pulp host.
  • upstream_name – The Docker container upstream name.
  • use_v1 – If True use Docker V1 feed URL else use Docker V2 feed URL.
Returns:

Detailed information about the created repository.

pulp_smash.tests.docker.api_v2.test_tags.import_upload(cfg, repo, params)

Create or update a docker repository.

Parameters:
  • cfg (pulp_smash.config.PulpSmashConfig) – Information about a Pulp host.
  • repo – A dict of information about the targed repository.
  • params – A dict of information to pass as import_upload body.
Returns:

A dict of information about the creation/update report.

pulp_smash.tests.docker.api_v2.test_tags.setUpModule()

Skip tests on Pulp versions lower than 2.12.

pulp_smash.tests.docker.api_v2.utils

Location: Pulp SmashAPI Documentationpulp_smash.tests.docker.api_v2.utils

Utility functions for Docker API tests.

pulp_smash.tests.docker.api_v2.utils.gen_repo()

Return a semi-random dict that used for creating a Docker repo.

pulp_smash.tests.docker.cli

Location: Pulp SmashAPI Documentationpulp_smash.tests.docker.cli

Tests that communicate with the server via the pulp-admin CLI client.

pulp_smash.tests.docker.cli.test_copy

Location: Pulp SmashAPI Documentationpulp_smash.tests.docker.cli.test_copy

Tests for copying docker units between repositories.

class pulp_smash.tests.docker.cli.test_copy.CopyAllImagesTestCase(methodName='runTest')

Test copying all images from one repository to another.

classmethod setUpClass()

Create and sync a docker repository with a v1 registry.

test_positive_copy_output()

Assert that the list of image_ids in the copy output are correct.

test_positive_units_copied()

Assert that all units were copied.

class pulp_smash.tests.docker.cli.test_copy.CopyAllManifestsTestCase(methodName='runTest')

Test copying all manifests from one repository to another.

classmethod setUpClass()

Create and sync a docker repository with a v2 registry.

test_positive_copy_output()

Verify the pulp-admin docker repo copy stdout looks correct.

Assert that stdout references the correct number of manifests.

test_positive_units_copied()

Assert that all units were copied.

class pulp_smash.tests.docker.cli.test_copy.CopyAllTagsTestCase(methodName='runTest')

Test copying all Tags from one repository to another.

classmethod setUpClass()

Create and sync a docker repository with a v2 registry.

test_positive_copy_output()

Assert that the list of tags in the copy output are correct.

test_positive_units_copied()

Assert that all units were copied.

pulp_smash.tests.docker.cli.test_crud

Location: Pulp SmashAPI Documentationpulp_smash.tests.docker.cli.test_crud

CRUD tests for docker repositories.

These tests can also be accomplished via the API. However, there is value in showing that the pulp-admin CLI client correctly interfaces with the API.

class pulp_smash.tests.docker.cli.test_crud.CreateTestCase(methodName='runTest')

Create docker repositories, both successfully and unsuccessfully.

setUp()

Provide a server config and a repository ID.

tearDown()

Delete created resources.

test_basic()

Create a docker repository. Only provide a repository ID.

Assert the return code is 0.

test_duplicate_ids()

Create two docker repositories with identical IDs.

Assert only the first repository is created.

test_with_feed_upstream_name()

Create a docker repository. Provide a feed and upstream name.

Assert the return code is 0.

class pulp_smash.tests.docker.cli.test_crud.DeleteV2TestCase(methodName='runTest')

Delete a populated v2 repository.

There was a bug in the Docker server plugin that caused a traceback when repos were deleted. This test ensures that that operation works correctly.

https://pulp.plan.io/issues/1296

classmethod setUpClass()

Provide a server config and a repository ID.

test_data_gone()

Assert that the published data was cleaned up.

test_repo_gone()

Assert that the repo is not in the pulp-admin output anymore.

test_success()

Assert that the CLI reported success.

class pulp_smash.tests.docker.cli.test_crud.UpdateDistributorTestCase(methodName='runTest')

Update a docker repository and use the --repo-registry-id flag.

This test case targets Pulp issue 1710. According to this bug, updating and using the --repo-registry-id flag would trigger a traceback.

classmethod setUpClass()

Provide a server config and a repository ID.

classmethod tearDownClass()

Delete created resources.

test_repo_registry_id_flag()

Verify the information sent to the server can be read back.

test_stdout()

Inspect the stdout emitted by pulp-admin when updating.

class pulp_smash.tests.docker.cli.test_crud.UpdateEnableV1TestCase(methodName='runTest')

Update a docker repository’s –enable-v1 flag.

There was a bug in pulp-admin wherein the –enable-v1 flag could be set during repository creation, but not while updating repositories. This test ensures that behavior functions correctly.

classmethod setUpClass()

Provide a server config and a repository ID.

classmethod tearDownClass()

Delete created resources.

test_change_enable_v1_flag()

Test that the the –enable-v1 flag was successful.

test_success()

Assert that the CLI reported success.

class pulp_smash.tests.docker.cli.test_crud.UpdateEnableV2TestCase(methodName='runTest')

Update a docker repository’s –enable-v2 flag.

There was a bug in pulp-admin wherein the –enable-v2 flag could be set during repository creation, but not while updating repositories. This test ensures that behavior functions correctly.

classmethod setUpClass()

Provide a server config and a repository ID.

classmethod tearDownClass()

Delete created resources.

test_change_enable_v2_flag()

Test that the the –enable-v2 flag was successful.

test_success()

Assert that the CLI reported success.

pulp_smash.tests.docker.cli.test_sync_publish

Location: Pulp SmashAPI Documentationpulp_smash.tests.docker.cli.test_sync_publish

Tests for syncing and publishing docker repositories.

pulp_smash.tests.docker.cli.test_sync_publish.IMAGE_MANIFEST_V2_SCHEMA_1 = {'$schema': 'http://json-schema.org/schema#', 'title': 'Image Manifest Version 2, Schema 1', 'properties': {'signatures': {'items': {'type': 'object', 'properties': {'protected': {'type': 'string'}, 'header': {'type': 'object', 'properties': {'jwk': {'type': 'object', 'properties': {'x': {'type': 'string'}, 'crv': {'type': 'string'}, 'kty': {'type': 'string'}, 'kid': {'type': 'string'}, 'y': {'type': 'string'}}}, 'alg': {'type': 'string'}}}, 'signature': {'type': 'string'}}}, 'type': 'array'}, 'name': {'type': 'string'}, 'architecture': {'type': 'string'}, 'tag': {'type': 'string'}, 'history': {'items': {'type': 'object', 'properties': {'v1Compatibility': {'type': 'string'}}}, 'type': 'array'}, 'schemaVersion': {'type': 'integer'}, 'fsLayers': {'items': {'type': 'object', 'properties': {'blobSum': {'type': 'string'}}}, 'type': 'array'}}, 'type': 'object', 'description': 'Derived from: https://docs.docker.com/registry/spec/manifest-v2-1/'}

A schema for docker v2 image manifests, schema 1.

pulp_smash.tests.docker.cli.test_sync_publish.IMAGE_MANIFEST_V2_SCHEMA_2 = {'$schema': 'http://json-schema.org/schema#', 'title': 'Image Manifest Version 2, Schema 2', 'properties': {'layers': {'items': {'type': 'object', 'properties': {'urls': {'items': {'type': 'string'}, 'type': 'array'}, 'digest': {'type': 'string'}, 'mediaType': {'type': 'string'}, 'size': {'type': 'integer'}}}, 'type': 'array'}, 'config': {'type': 'object', 'properties': {'digest': {'type': 'string'}, 'mediaType': {'type': 'string'}, 'size': {'type': 'integer'}}}, 'mediaType': {'type': 'string'}, 'schemaVersion': {'type': 'integer'}}, 'type': 'object', 'description': 'Derived from: https://docs.docker.com/registry/spec/manifest-v2-2/'}

A schema for docker v2 image manifests, schema 2.

class pulp_smash.tests.docker.cli.test_sync_publish.InvalidFeedTestCase(methodName='runTest')

Show Pulp behaves correctly when syncing a repo with an invalid feed.

test_all()

Create a docker repo with an invalid feed and sync it.

class pulp_smash.tests.docker.cli.test_sync_publish.RepoRegistryIdTestCase(methodName='runTest')

Show Pulp can publish repos with varying repo_registry_id values.

The repo_registry_id setting defines a repository’s name as seen by clients such as the Docker CLI. It’s traditionally a two-part name such as docker/busybox, but according to Pulp #2368, it can contain an arbitrary number of slashes. This test case verifies that the repo_registry_id can be set to values containing varying numbers of slashes.

create_sync_publish_repo(repo_registry_id)

Create, sync and publish a Docker repository.

Also, schedule the repository for deletion with addCleanup.

Parameters:repo_registry_id – Passed to pulp_smash.tests.docker.cli.utils.repo_create().
Returns:Nothing.
test_one_slash()

Give repo_registry_id one slash.

test_two_slashes()

Give repo_registry_id two slashes.

test_zero_slashes()

Give repo_registry_id zero slashes.

class pulp_smash.tests.docker.cli.test_sync_publish.SyncNonNamespacedV2TestCase(methodName='runTest')

Create, sync and publish a non-namespaced repository.

test_all()

Create, sync and publish a non-namespaced repository.

class pulp_smash.tests.docker.cli.test_sync_publish.SyncPublishMixin

Tools for test cases that test repository syncing and publishing.

This class must be mixed in to a class that inherits from unittest.TestCase.

static adjust_url(url)

Return a URL that can be used for talking with Crane.

The URL returned is the same as url, except that the scheme is set to HTTP, and the port is set to (or replaced by) 5000.

Parameters:url – A string, such as https://pulp.example.com/foo.
Returns:A string, such as http://pulp.example.com:5000/foo.
static make_crane_client(cfg)

Make an API client for talking with Crane.

Create an API client for talking to Crane. The client returned by this method is similar to the following client:

>>> client = api.Client(cfg, api.json_handler)

However:

  • The client’s base URL is adjusted as described by adjust_url().
  • The client will send an accept:application/json header with each request.
Parameters:cfg (pulp_smash.config.PulpSmashConfig) – Information about a Pulp deployment.
Returns:An API client for talking with Crane.
Return type:pulp_smash.api.Client
verify_proc(proc)

Assert proc.stdout has correct contents.

Assert “Task Succeeded” is present and “Task Failed” is absent.

class pulp_smash.tests.docker.cli.test_sync_publish.SyncPublishV1TestCase(methodName='runTest')

Create, sync, publish and interact with a Docker v1 repository.

classmethod setUpClass()

Maybe skip this test case, and execute pulp-admin login.

classmethod tearDownClass()

Destroy resources created by this test case.

test_01_set_up()

Create, sync and publish a repository.

Specifically, do the following:

  1. Create, sync and publish a Docker repository. Set the repository’s feed to a v1 feed.
  2. Make Crane immediately re-read the metadata files published by Pulp. (Restart Apache.)
test_02_get_crane_repositories()

Issue an HTTP GET request to /crane/repositories.

Assert that the response is as described by Crane Admin.

class pulp_smash.tests.docker.cli.test_sync_publish.SyncPublishV2TestCase(methodName='runTest')

Create, sync, publish and interact with a Docker v2 repository.

classmethod setUpClass()

Maybe skip this test case, and execute pulp-admin login.

classmethod tearDownClass()

Destroy resources created by this test case.

test_01_set_up()

Create, sync and publish a repository.

Specifically, do the following:

  1. Create, sync and publish a Docker repository. Set the repository’s feed to a v2 feed.
  2. Make Crane immediately re-read the metadata files published by Pulp. (Restart Apache.)
test_02_get_crane_repositories()

Issue an HTTP GET request to /crane/repositories.

Assert that the response is as described by Crane Admin.

test_02_get_manifest_v1()

Issue an HTTP GET request to /v2/{repo_id}/manifests/latest.

Pass a header of accept:application/vnd.docker.distribution.manifest.v1+json. Assert that the response is as described by Image Manifest Version 2, Schema 1.

This test targets Pulp #2336.

test_02_get_manifest_v2()

Issue an HTTP GET request to /v2/{repo_id}/manifests/latest.

Pass a header of accept:application/vnd.docker.distribution.manifest.v2+json. Assert that the response is as described by Image Manifest Version 2, Schema 2.

This test targets Pulp #2336.

pulp_smash.tests.docker.cli.test_sync_publish.setUpModule()

Execute pulp-admin login.

pulp_smash.tests.docker.cli.utils

Location: Pulp SmashAPI Documentationpulp_smash.tests.docker.cli.utils

Utility functions for docker CLI tests.

All of the functions in this module share a common structure. The first argument is a pulp_smash.config.PulpSmashConfig, and all other arguments correspond to command-line options. Most arguments are named after a flag. For example, an argument to_repo_id corresponds to the flag --to-repo-id.

For the meaning of each argument, see pulp-admin.

pulp_smash.tests.docker.cli.utils.repo_copy(server_config, unit_type, from_repo_id=None, to_repo_id=None)

Execute pulp-admin docker repo copy {unit_type}.

pulp_smash.tests.docker.cli.utils.repo_create(server_config, enable_v1=None, enable_v2=None, feed=None, repo_id=None, repo_registry_id=None, upstream_name=None)

Execute pulp-admin docker repo create.

pulp_smash.tests.docker.cli.utils.repo_delete(server_config, repo_id)

Execute pulp-admin docker repo delete.

pulp_smash.tests.docker.cli.utils.repo_list(server_config, repo_id=None, details=False)

Execute pulp-admin docker repo list.

pulp_smash.tests.docker.cli.utils.repo_publish(server_config, repo_id, bg=None, force_full=None)

Execute pulp-admin docker repo publish run.

Execute pulp-admin docker repo search {unit_type}.

pulp_smash.tests.docker.cli.utils.repo_sync(server_config, repo_id)

Execute pulp-admin docker repo sync run.

pulp_smash.tests.docker.cli.utils.repo_update(server_config, enable_v1=None, enable_v2=None, feed=None, repo_id=None, upstream_name=None, repo_registry_id=None)

Execute pulp-admin docker repo update.

pulp_smash.tests.docker.utils

Location: Pulp SmashAPI Documentationpulp_smash.tests.docker.utils

Utilities for Docker tests.

pulp_smash.tests.docker.utils.set_up_module()

Skip tests if the Docker plugin is not installed.

See pulp_smash.tests for more information.

pulp_smash.tests.ostree

Location: Pulp SmashAPI Documentationpulp_smash.tests.ostree

Functional tests for Pulp’s ostree plugin.

pulp_smash.tests.ostree.api_v2

Location: Pulp SmashAPI Documentationpulp_smash.tests.ostree.api_v2

Tests that communicate with the server via the v2 API.

pulp_smash.tests.ostree.api_v2.test_crud

Location: Pulp SmashAPI Documentationpulp_smash.tests.ostree.api_v2.test_crud

Test the CRUD API endpoints OSTree repositories.

This module assumes that the tests in pulp_smash.tests.platform.api_v2.test_repository hold true. The following trees of assumptions are explored in this module:

It is possible to create an OSTree repo with feed (CreateTestCase).
It is possible to create a repository without a feed (CreateTestCase).
  It is possible to create distributors for a repo
    It is not possible to create distributors to have conflicting paths
    It is not possible to update distrubutors to have conflicting paths
class pulp_smash.tests.ostree.api_v2.test_crud.CreateDistributorsTestCase(methodName='runTest')

Show Pulp can create OSTree distributors and prevent path conflicts.

This test case targets:

classmethod setUpClass()

Create a pair of repositories.

Ensure the first repo has a distributor with a relative path. Succeeding tests will give the second repository distributors with relative paths, where those paths may or may not conflict with the first repository’s distributor’s relative path. This test splits the distributors across two repositories to ensure that Pulp correctly checks new relative paths against the existing relative paths in all repositories.

test_invalid_v1()

Create a distributor whose relative path is invalid.

Re-use the same relative path. For example, if an existing relative path is foo/bar, then this relative path would be foo/bar.

test_invalid_v2()

Create a distributor whose relative path is invalid.

Extend an existing relative path. For example, if an existing relative path is foo/bar, then this relative path would be foo/bar/biz.

test_invalid_v3()

Create a distributor whose relative path is invalid.

Prepend a slash onto an existing relative path. For example, if an existing relative path is foo/bar, then this relative path would be /foo/bar.

test_valid_v1()

Create a distributor whose relative path is valid.

Create a unique relative path. For example, if an existing relative path is foo/bar, then this relative path might be biz/baz.

test_valid_v2()

Create a distributor whose relative path is valid.

Create a relative path that contains three segments. Most other tests in this module have relative paths with two segments.

class pulp_smash.tests.ostree.api_v2.test_crud.CrudTestCase(methodName='runTest')

CRUD a minimal OSTree repository.

static create_body()

Return a dict for creating a repository.

static update_body()

Return a dict for creating a repository.

class pulp_smash.tests.ostree.api_v2.test_crud.CrudWithFeedTestCase(methodName='runTest')

CRUD an OSTree repository with a feed.

static create_body()

Return a dict, with a feed, for creating a repository.

class pulp_smash.tests.ostree.api_v2.test_crud.UpdateDistributorsTestCase(methodName='runTest')

Test the update of ostree distributors.

This test case targets:

classmethod setUpClass()

Create a pair of repositories.

Ensure each repo has a distributor with a relative path. Succeeding tests will update the second repository’s distributor with varying relative paths, where those paths may or may not conflict with the first repository’s distributor’s relative path. This test splits the distributors across two repositories to ensure that Pulp correctly checks new relative paths against the existing relative paths in all repositories.

test_invalid_v1()

Update a distributor’s relative path with an invalid value.

Re-use an existing relative path. For example, if an existing relative path is foo/bar, then this relative path would be foo/bar.

test_invalid_v2()

Update a distributor’s relative path with an invalid value.

Extend an existing relative path. For example, if an existing relative path is foo/bar, then this relative path would be foo/bar/biz.

test_invalid_v3()

Update a distributor’s relative path with an invalid value.

Prepend a slash to an existing relative path. For example, if an existing relative path is foo/bar, then this relative path would be /foo/bar.

test_valid_v1()

Update a distributor’s relative path with a valid value.

Use a unique value for the new relative path. For example, if an existing relative path is foo/bar, then the new relative path might be biz/baz.

test_valid_v2()

Update a distributor’s relative path with a valid value.

Use a three-segment value for the new relative path. Most other tests in this module have relative paths with two segments.

pulp_smash.tests.ostree.api_v2.test_publish

Location: Pulp SmashAPI Documentationpulp_smash.tests.ostree.api_v2.test_publish

Tests that publish OSTree repositories.

class pulp_smash.tests.ostree.api_v2.test_publish.PublishTestCase(methodName='runTest')

Create, sync and publish an OSTree repository.

test_all()

Create, sync and publish an OSTree repository.

Verify that:

  • The distributor’s last_publish attribute is None after the sync. This demonstrates that auto_publish correctly defaults to False.
  • The distributor’s last_publish attribute is not None after the publish.

pulp_smash.tests.ostree.api_v2.test_sync

Location: Pulp SmashAPI Documentationpulp_smash.tests.ostree.api_v2.test_sync

Tests that sync OSTree repositories.

This module assumes that the tests in pulp_smash.tests.platform.api_v2.test_repository and pulp_smash.tests.ostree.api_v2.test_crud hold true. The following trees of assumptions are explored in this module:

It is possible to create an OSTree repo with feed (test_crud).
├── When a valid feed and branch are given the repo syncs successfully
│   without reporting errors (CreateValidFeedTestCase).
└── When an invalid feed or branch is given, repo syncs fail and errors are
    reported (SyncInvalidFeedTestCase).

It is possible to create a repository without a feed (test_crud).
└── Running sync on this repository fails with errors reported
    (SyncWithoutFeedTestCase).
class pulp_smash.tests.ostree.api_v2.test_sync.SyncInvalidBranchesTestCase(methodName='runTest')

Create an OSTree repository with invalid branches and sync it.

classmethod setUpClass()

Create and sync an OSTree repository.

class pulp_smash.tests.ostree.api_v2.test_sync.SyncInvalidFeedTestCase(methodName='runTest')

Create an OSTree repository with an invalid feed and sync it.

classmethod setUpClass()

Set cls.body.

class pulp_smash.tests.ostree.api_v2.test_sync.SyncMissingAttrsTestCase(methodName='runTest')

Create an OSTree repository with no feed or branches and sync it.

classmethod setUpClass()

Create and sync an OSTree repository.

class pulp_smash.tests.ostree.api_v2.test_sync.SyncTestCase(methodName='runTest')

Create an OSTree repository with a valid feed and branch, and sync it.

The sync should complete with no errors reported.

classmethod setUpClass()

Create an OSTree repository with a valid feed and branch.

test_task_progress_report()

Assert no task’s progress report contains error details.

pulp_smash.tests.ostree.utils

Location: Pulp SmashAPI Documentationpulp_smash.tests.ostree.utils

Utilities for interacting with OS tree.

pulp_smash.tests.ostree.utils.gen_distributor()

Return a semi-random dict for use in creating an OSTree distributor.

For more information, see the generic repository CRUD documentation and the OSTree distributor configuration documentation.

pulp_smash.tests.ostree.utils.gen_repo()

Return a semi-random dict for use in creating an OSTree repository.

pulp_smash.tests.ostree.utils.set_up_module()

Skip tests if the OSTree plugin is not installed.

See pulp_smash.tests for more information.

pulp_smash.tests.platform

Location: Pulp SmashAPI Documentationpulp_smash.tests.platform

Functional tests for the Pulp platform.

According to the documentation:

Pulp can be viewed as consisting of two parts, the platform (which includes both the server and client applications) and plugins (which provide support for a particular set of content types).

This package contains tests for the Pulp platform. These tests target plugin-agnostic functionality. These tests should not rely on any plugin-specific functionality, such as the ability to work with RPMs or ISOs.

pulp_smash.tests.platform.api_v2

Location: Pulp SmashAPI Documentationpulp_smash.tests.platform.api_v2

Tests that communicate with the server via the v2 API.

pulp_smash.tests.platform.api_v2.test_consumer

Location: Pulp SmashAPI Documentationpulp_smash.tests.platform.api_v2.test_consumer

Test the consumer API endpoints.

class pulp_smash.tests.platform.api_v2.test_consumer.BindConsumerTestCase(methodName='runTest')

Show that one can bind a consumer to a repository.

test_all()

Bind a consumer to a distributor.

Do the following:

  1. Create a repository with a distributor.
  2. Create a consumer.
  3. Bind the consumer to the distributor.

Assert that:

  • The response has an HTTP 200 status code.
  • The response body contains the correct values.

pulp_smash.tests.platform.api_v2.test_content_applicability

Location: Pulp SmashAPI Documentationpulp_smash.tests.platform.api_v2.test_content_applicability

Test the API’s content applicability functionality.

When a user asks Pulp to regenerate content applicability, Pulp responds with a call report and starts executing tasks in series. Starting with Pulp 2.8, it is possible for a user to explicitly request that Pulp execute tasks in parallel instead. This functionality is only available for certain API calls, and when this is done, Pulp returns a group call report instead of a regular call report. (See pulp_smash.constants.CALL_REPORT_KEYS and pulp_smash.constants.GROUP_CALL_REPORT_KEYS.) SeriesTestCase and ParallelTestCase test these two use cases, respectively.

class pulp_smash.tests.platform.api_v2.test_content_applicability.FailureTestCase(methodName='runTest')

Fail to generate content applicability for consumers and repos.

classmethod setUpClass()

Make calls to the server and save the responses.

test_body()

Assert each response is JSON and doesn’t look like a call report.

test_status_code()

Assert each response has an HTTP 400 status code.

class pulp_smash.tests.platform.api_v2.test_content_applicability.ParallelTestCase(methodName='runTest')

Ask Pulp to regenerate content applicability for consumers and repos.

Do so in parallel. See pulp_smash.tests.platform.api_v2.test_content_applicability.

setUp()

Ensure this test only runs on Pulp 2.8 and later.

classmethod setUpClass()

Make calls to the server and save the responses.

test_body()

Assert each response is JSON and has a correct structure.

class pulp_smash.tests.platform.api_v2.test_content_applicability.SeriesTestCase(methodName='runTest')

Ask Pulp to regenerate content applicability for consumers and repos.

Do so in series. See pulp_smash.tests.platform.api_v2.test_content_applicability.

classmethod setUpClass()

Make calls to the server and save the responses.

test_body()

Assert each response is JSON and has a correct structure.

pulp_smash.tests.platform.api_v2.test_login

Location: Pulp SmashAPI Documentationpulp_smash.tests.platform.api_v2.test_login

Test the API’s authentication functionality.

class pulp_smash.tests.platform.api_v2.test_login.LoginTestCase(methodName='runTest')

Tests for logging in.

test_failure()

Unsuccessfully log in to the server.

Assert that:

  • The response has an HTTP 401 status code.
  • The response body is valid JSON and has correct keys.
test_success()

Successfully log in to the server.

Assert that:

  • The response has an HTTP 200 status code.
  • The response body is valid JSON and has correct keys.

pulp_smash.tests.platform.api_v2.test_repository

Location: Pulp SmashAPI Documentationpulp_smash.tests.platform.api_v2.test_repository

Test the repository API endpoints.

The assumptions explored in this module have the following dependencies:

It is possible to create an untyped repository.
├── It is impossible to create a repository with a duplicate ID
│   or other invalid attributes.
├── It is possible to read a repository, including its importers and
│   distributors.
├── It is possible to update a repository.
└── It is possible to delete a repository.
class pulp_smash.tests.platform.api_v2.test_repository.CreateFailureTestCase(methodName='runTest')

Establish that repositories are not created in documented scenarios.

classmethod setUpClass()

Create several repositories.

Each repository is created to test a different failure scenario. The first repository is created in order to test duplicate ids.

test_body_status_code()

Assert that each response body has the expected HTTP status code.

test_exception_keys_json()

Assert the JSON body returned contains the correct keys.

test_location_header()

Assert that the Location header is correctly set in the response.

test_status_code()

Assert that each response has the expected HTTP status code.

class pulp_smash.tests.platform.api_v2.test_repository.CreateSuccessTestCase(methodName='runTest')

Establish we can create repositories.

classmethod setUpClass()

Create several repositories.

Create one repository with the minimum required attributes, and a second with all available attributes except importers and distributors.

test_attributes()

Assert that each repository has the requested attributes.

test_location_header()

Assert the Location header is correctly set in each response.

According to RFC 7231, the HTTP Location header may be either an absolute or relative URL. Thus, given this request:

GET /index.html HTTP/1.1
Host: www.example.com

These two responses are equivalent:

HTTP/1.1 302 FOUND
Location: http://www.example.com/index.php
HTTP/1.1 302 FOUND
Location: /index.php

This test abides by the RFC and allows Pulp to return either absolute or relative URLs.

test_status_code()

Assert each response has an HTTP 201 status code.

class pulp_smash.tests.platform.api_v2.test_repository.ReadUpdateDeleteTestCase(methodName='runTest')

Establish we can read, update and delete repositories.

This test case assumes the assertions in CreateSuccessTestCase hold true.

classmethod setUpClass()

Create three repositories and read, update and delete them.

test_read()

Assert the “read” response body contains the correct attributes.

test_read_details()

Assert the read with details has the correct attributes.

test_read_imp_distrib()

Assert reading with importers/distributors returns correct attrs.

test_status_code()

Assert each response has a correct HTTP status code.

test_update_attributes_result()

Assert the “update” response body has the correct attributes.

test_update_spawned_tasks()

Assert the “update” response body mentions no spawned tasks.

pulp_smash.tests.platform.api_v2.test_user

Location: Pulp SmashAPI Documentationpulp_smash.tests.platform.api_v2.test_user

Test the user API endpoints.

The assumptions explored in this module have the following dependencies:

It is possible to create a user.
├── It is impossible to create a duplicate user.
├── It is possible to read a user.
├── It is possible to update a user.
│   └── It is possible to search for a (updated) user.
└── It is possible to delete a user.
class pulp_smash.tests.platform.api_v2.test_user.CreateTestCase(methodName='runTest')

Establish that we can create users. No prior assumptions are made.

classmethod setUpClass()

Create several users.

Create one user with the minimum required attributes, and another with all available attributes.

test_attrs()

Assert that each user has the requested attributes.

test_password()

Assert that responses do not contain passwords.

test_status_code()

Assert that each response has an HTTP 201 status code.

class pulp_smash.tests.platform.api_v2.test_user.ReadUpdateDeleteTestCase(methodName='runTest')

Establish that we can read, update and delete users.

This test case assumes that the assertions in CreateTestCase are valid.

classmethod setUpClass()

Create three users and read, update and delete them respectively.

test_create_duplicate_user()

Verify one cannot create a user with a duplicate login.

test_password_not_in_response()

Ensure read and update responses do not contain a password.

Target https://bugzilla.redhat.com/show_bug.cgi?id=1020300.

test_status_code()

Ensure read, update and delete responses have 200 status codes.

test_updated_user()

Assert the updated user has the assigned attributes.

test_updated_user_password()

Assert one can log in with a user with an updated password.

test_use_deleted_user()

Assert one cannot read, update or delete a deleted user.

class pulp_smash.tests.platform.api_v2.test_user.SearchTestCase(methodName='runTest')

Establish we can search for users.

This test case assumes the assertions in ReadUpdateDeleteTestCase are valid.

classmethod setUpClass()

Create a user and add it to the ‘super-users’ role.

Search for:

  • Nothing at all:
  • All users having only the super-users role.
  • All users having no roles.
  • A user by their login.
  • A non-existent user by their login.

Assert the global search includes our user.

test_login_filter_exclusion()

Search for a non-existent user via the “login” filter.

test_login_filter_inclusion()

Search for a user via the “login” filter.

test_roles_filter_exclusion()

Assert that the “roles” filter can be used for exclusion.

test_roles_filter_inclusion()

Assert that the “roles” filter can be used for inclusion.

test_status_codes()

Assert each response has an HTTP 200 status code.

pulp_smash.tests.platform.cli

Location: Pulp SmashAPI Documentationpulp_smash.tests.platform.cli

Tests that communicate with the server via the CLI.

pulp_smash.tests.platform.cli.test_content_sources

Location: Pulp SmashAPI Documentationpulp_smash.tests.platform.cli.test_content_sources

Tests for list/refresh/delete content sources.

class pulp_smash.tests.platform.cli.test_content_sources.RefreshAndDeleteContentSourcesTestCase(methodName='runTest')

Test whether pulp-admin client can refresh and delete content source.

This test case targets Pulp #1692`_ and Pulp Smash #141. The content sources documentation describes the CLI syntax. The test steps are as follows:

  1. Create configuration file of a content source.
  2. Check whether the content sources list is empty.
  3. Refresh all content sources. Verify no errors are reported.
  4. Refresh a specified content source. Verify no errors are reported.
  5. Remove the specified content source. Verify that the source is actually deleted.
classmethod setUpClass()

Create a content source.

test_delete_content_sources()

Check if a content source can be deleted.

test_list_content_sources()

Check if content sources can be listed.

test_refresh_all_sources()

Refresh all content sources.

test_refresh_content_source()

Refresh a specific content source.

pulp_smash.tests.platform.cli.test_content_sources.generate_content_source(server_config, name, **kwargs)

Generate a content source file and returns its remote path.

See Defining a Content Source for more information.

Parameters:
  • server_config – A pulp_smash.config.PulpSmashConfig object.
  • name – file name and content source id (string inside []).
  • kwargs – each item will be converted to content source properties where the key is the property name and the value its value.
Returns:

the remote path of the created content source file.

pulp_smash.tests.platform.cli.test_pulp_manage_db

Location: Pulp SmashAPI Documentationpulp_smash.tests.platform.cli.test_pulp_manage_db

Tests for the pulp-manage-db executable.

pulp-manage-db should only run when REQUIRED_SERVICES are running and when CONFLICTING_SERVICES are stopped. See:

class pulp_smash.tests.platform.cli.test_pulp_manage_db.BaseTestCase(methodName='runTest')

An abstract base class for the test cases in this module.

classmethod setUpClass()

Maybe skip this test case.

tearDown()

Start all of Pulp’s services.

pulp_smash.tests.platform.cli.test_pulp_manage_db.CONFLICTING_SERVICES = frozenset({'pulp_celerybeat', 'pulp_resource_manager', 'pulp_workers'})

If any of these services are running, pulp-manage-db will abort.

class pulp_smash.tests.platform.cli.test_pulp_manage_db.NegativeTestCase(methodName='runTest')

Assert pulp-manage-db doesn’t run when inappropriate.

test_celerybeat_running()

Test with pulp_celerybeat running.

test_conflicting_running()

Test with CONFLICTING_SERVICES running.

test_required_stopped()

Test with REQUIRED_SERVICES stopped.

test_resource_manager_running()

Test with pulp_resource_manager running.

This test targets Pulp #2684.

test_workers_running()

Test with pulp_workers running.

This test targets Pulp #2684.

class pulp_smash.tests.platform.cli.test_pulp_manage_db.PositiveTestCase(methodName='runTest')

Assert pulp-manage-db runs when appropriate.

test_conflicting_stopped()

Test with CONFLICTING_SERVICES stopped.

pulp_smash.tests.platform.cli.test_pulp_manage_db.REQUIRED_SERVICES = frozenset({'mongod'})

If any of these services are stopped, pulp-manage-db will abort.

pulp_smash.tests.platform.cli.test_pulp_manage_db.setUpModule()

Log in.

pulp_smash.tests.platform.cli.test_pulp_manage_db.tearDownModule()

Reset Pulp, in case one of the test cases breaks Pulp.

pulp_smash.tests.platform.cli.test_selinux

Location: Pulp SmashAPI Documentationpulp_smash.tests.platform.cli.test_selinux

Tests to verify that Pulp has proper SELinux permissions.

pulp_smash.tests.platform.cli.test_selinux.CELERY_LABEL = ':system_r:celery_t:s0'

A label commonly applied to celery processes.

The “user” segment of the label is intentionally omitted, as it is known to vary. See Pulp Smash #444 (comment).

class pulp_smash.tests.platform.cli.test_selinux.FileLabelsTestCase(methodName='runTest')

Test that files have correct SELinux labels.

This test case targets Pulp Smash #442.

classmethod setUpClass()

Create a CLI client.

test_pulp_celery_fc()

Test files listed in pulp-celery.fc.

test_pulp_server_fc()

Test files listed in pulp-server.fc.

test_pulp_streamer_fc()

Test files listed in pulp-streamer.fc.

pulp_smash.tests.platform.cli.test_selinux.HTTPD_LABEL = ':system_r:httpd_t:s0'

A label commonly applied to httpd processes.

The “user” segment of the label is intentionally omitted, as it is known to vary. See Pulp Smash #444 (comment).

pulp_smash.tests.platform.cli.test_selinux.PS_FIELDS = ('label', 'args')

The fields that ps should display. See man ps for details.

class pulp_smash.tests.platform.cli.test_selinux.Process(label, args)

A single line of output from ps.

args

Alias for field number 1

label

Alias for field number 0

class pulp_smash.tests.platform.cli.test_selinux.ProcessLabelsTestCase(methodName='runTest')

Test that Pulp processes have correct SELinux labels.

This test case targets Pulp Smash #444.

classmethod setUpClass()

Get all of the processes running on the target Pulp system.

test_celerybeat()

Verify the label of the Pulp celerybeat process.

It should have a label of CELERY_LABEL.

test_httpd()

Verify the labels of the wsgi:pulp* processes.

They should have a label of HTTPD_LABEL.

test_reserved_resource_worker_0()

Verify the labels of the reserved_resource_worker-0 processes.

They should have a label of CELERY_LABEL.

test_resource_manager()

Verify the labels of the resource_manager processes.

They should have a label of CELERY_LABEL.

pulp_smash.tests.puppet

Location: Pulp SmashAPI Documentationpulp_smash.tests.puppet

Functional tests for Pulp’s Puppet plugin.

pulp_smash.tests.puppet.api_v2

Location: Pulp SmashAPI Documentationpulp_smash.tests.puppet.api_v2

Tests that communicate with the server via the v2 API.

pulp_smash.tests.puppet.api_v2.test_crud

Location: Pulp SmashAPI Documentationpulp_smash.tests.puppet.api_v2.test_crud

Tests that CRUD Puppet repositories.

class pulp_smash.tests.puppet.api_v2.test_crud.CRUDTestCase(methodName='runTest')

Test that one can create, update, read and delete a test case.

static create_body()

Return a dict for creating a repository.

static update_body()

Return a dict for creating a repository.

pulp_smash.tests.puppet.api_v2.test_duplicate_uploads

Location: Pulp SmashAPI Documentationpulp_smash.tests.puppet.api_v2.test_duplicate_uploads

Tests for how well Pulp can deal with duplicate uploads.

This module targets Pulp #1406 and Pulp Smash #81. The test procedure is as follows:

  1. Create a new feed-less repository.
  2. Upload content and import it into the repository. Assert the upload and import was successful.
  3. Upload identical content and import it into the repository.

The second upload should silently fail for all Pulp releases in the 2.x series.

class pulp_smash.tests.puppet.api_v2.test_duplicate_uploads.DuplicateUploadsTestCase(methodName='runTest')

Test how well Pulp can deal with duplicate content unit uploads.

classmethod setUpClass()

Create a Puppet repository.

pulp_smash.tests.puppet.api_v2.test_install_distributor

Location: Pulp SmashAPI Documentationpulp_smash.tests.puppet.api_v2.test_install_distributor

Tests for puppet_install_distributor.

For more information check puppet_install_distributor

class pulp_smash.tests.puppet.api_v2.test_install_distributor.InstallDistributorTestCase(methodName='runTest')

Test Puppet install distributor.

test_all()

Test puppet_install_distributor.

Do the following:

  1. Create a puppet repository with a puppet_install_distributor
  2. Upload a puppet module
  3. Publish the repository
  4. Check if the puppet_install_distributor config was properly used

pulp_smash.tests.puppet.api_v2.test_sync_publish

Location: Pulp SmashAPI Documentationpulp_smash.tests.puppet.api_v2.test_sync_publish

Test the API endpoints for puppet repositories.

This module assumes that the tests in pulp_smash.tests.platform.api_v2.test_repository hold true. The following trees of assumptions are explored in this module:

It is possible to create an puppet repo with a feed. (CreateTestCase)
├── If a valid feed is given, the sync completes and no errors are
│   reported for both valid and ivalid query. (SyncValidFeedTestCase)
└── If an invalid feed is given, the sync completes and errors are
    reported. (SyncInvalidFeedTestCase)

It is possible to create an puppet repo without a feed. (CreateTestCase)
└── It is possible to upload an puppet module to a repository, copy the
    repository's content to a second repository, add distributor to
    both repositories, publish them and query modules back. Data integrity
    of modules queried from pulp server is preserved. (PublishTestCase)

Assertions not explored in this module include:

  • Given an puppet repository without a feed, sync requests fail.
  • It is not possible to create two puppet repos with the same relative URL.
  • It is possible to upload a directory of puppet modules to an repository.
  • It is possible to upload content and copy it into multiple repositories.
  • It is possible to get content into a repository via a sync and publish it.
  • Functionality of puppet_install_distributor which install puppet module on pulp server.
  • Functionality of puppet_file_distributor which makes puppet modules available in single directory on pulp server over HTTPS.
class pulp_smash.tests.puppet.api_v2.test_sync_publish.CreateTestCase(methodName='runTest')

Create two puppet repos, with and without feed URLs respectively.

classmethod setUpClass()

Create two puppet repositories, with and without feed URLs.

test_id_notes()

Validate the id and notes attributes for each repo.

test_importer_config()

Validate the config attribute of each importer.

test_importer_type_id()

Validate the importer_type_id attribute of each importer.

test_number_importers()

Each repository should have only one importer.

class pulp_smash.tests.puppet.api_v2.test_sync_publish.PublishTestCase(methodName='runTest')

Test repository syncing, publishing and data integrity.

Test uploading custom puppet module to repository, copying content between repositories, querying puppet modules from pulp server and integrity of downloaded modules. Three query formats are tested as are provided by different puppet versions:

  • puppet version <= 3.3
  • 3.3 < puppet version < 3.6
  • puppet version > 3.6
classmethod setUpClass()

Upload puppet module to a repo, copy it to another, publish and download.

Create two puppet repositories, both without feeds. Upload an module to the first repository. Copy its content to the second repository. Add distributors to the repositories, publish repositories and download modules back from them.

test_call_report_errors()

Verify each call report is error-free.

test_call_report_keys()

Verify each call report has a sane structure.

test_free()

Verify the response body for ending an upload.

Delete an Upload Request

test_malloc()

Verify the response body for creating an upload request.

test_publish_errors()

Verify publishing a call report doesn’t generate any errors.

test_publish_keys()

Verify publishing a repository generates a call report.

test_repo_units_consistency()

Verify the two puppet repositories have the same content units.

test_status_code()

Verify the HTTP status code of each server response.

test_unit_integrity()

Verify the integrity of the puppet modules downloaded from Pulp.

test_upload()

Verify the response body for uploading bits.

class pulp_smash.tests.puppet.api_v2.test_sync_publish.SyncInvalidFeedTestCase(methodName='runTest')

If an invalid feed is given a sync should complete with errors.

classmethod setUpClass()

Create a puppet repository with an invalid feed and sync it.

test_error_details()

Assert each task’s progress report contains error details.

test_number_tasks()

Assert only one task was spawned.

test_status_code()

Assert the call to sync a repository returns an HTTP 202.

test_task_error_traceback()

Assert the task’s “error” and “traceback” fields are non-null.

class pulp_smash.tests.puppet.api_v2.test_sync_publish.SyncNoFeedTestCase(methodName='runTest')

Create and sync a puppet repository with no feed.

At least one of the sync tasks should fail. The task should fail in a graceful manner, without e.g. an internal tracebacks. This test targets Pulp #2628.

test_all()

Create and sync a puppet repository with no feed.

class pulp_smash.tests.puppet.api_v2.test_sync_publish.SyncValidFeedTestCase(methodName='runTest')

Create and sync puppet repositories with valid feeds.

sync_repo(repo)

Sync a repository, and verify no tasks contain an error message.

test_matching_query()

Sync a repository with a query that matches units.

Assert that:

test_non_matching_query()

Sync a repository with a query that doesn’t match any units.

Assert that:

class pulp_smash.tests.puppet.api_v2.test_sync_publish.SyncValidManifestFeedTestCase(methodName='runTest')

A valid Puppet manifest should sync correctly.

classmethod setUpClass()

Create repository with the feed pointing to a valid manifest.

test_number_tasks()

Assert only one task was spawned.

test_status_code()

Assert the call to sync a repository returns an HTTP 202.

test_task_progress_report()

Assert each task’s progress report shows no errors.

pulp_smash.tests.puppet.api_v2.utils

Location: Pulp SmashAPI Documentationpulp_smash.tests.puppet.api_v2.utils

Utility functions for Puppet API tests.

pulp_smash.tests.puppet.api_v2.utils.gen_distributor()

Return a semi-random dict for use in creating a Puppet distributor.

pulp_smash.tests.puppet.api_v2.utils.gen_install_distributor()

Return a semi-random dict used for creating a Puppet install distributor.

The caller must fill the install_path distributor_config option otherwise Pulp will throw an error when creating the distributor.

pulp_smash.tests.puppet.api_v2.utils.gen_repo()

Return a semi-random dict that used for creating a puppet repo.

pulp_smash.tests.puppet.cli

Location: Pulp SmashAPI Documentationpulp_smash.tests.puppet.cli

Tests that communicate with the server via the CLI.

pulp_smash.tests.puppet.cli.test_sync

Location: Pulp SmashAPI Documentationpulp_smash.tests.puppet.cli.test_sync

Tests that sync Puppet repositories.

class pulp_smash.tests.puppet.cli.test_sync.SyncDownloadedContentTestCase(methodName='runTest')

Test whether Pulp can associate already-downloaded content with a repo.

Consider the following scenario:

  1. Create a repository with a feed and sync it.
  2. Create a second repository with the same feed and sync it.

When the second repository is synced, Pulp should recognize that the needed content units are already present, and it should associate them with the second repository. However, according to Pulp #1937, Pulp fails to do this, and the second repository will not be populated.

This test case tests Pulp #1937 and the corresponding Pulp Smash issue, Pulp Smash #269.

test_sync_downloaded_content()

Create two repositories with the same feed, and sync them serially.

More specifically, this test creates two puppet repositories with identical feeds, syncs them serially, and verifies that both have equal non-zero content unit counts.

class pulp_smash.tests.puppet.cli.test_sync.SyncFromPuppetForgeTestCase(methodName='runTest')

Test whether one can sync modules from the Puppet Forge.

According to Pulp #1846, Pulp sometimes fails to sync modules available on the Puppet forge. There is no consistency regarding which modules fail to sync: according to one comment, Pulp only detects 40 modules (of ~1,800), and according to another comment, Pulp syncs 4,089 of 4,128 modules.

How do we test this? The ideal test case is to repeatedly sync the entire Puppet Forge and check for sync failures, until the probability of another random failure is low. This is problematic: we’re abusing the Puppet Forge and extending the test time. A more realistic test is to sync a small number of modules and ensure that no errors occur. This provides much less assurance, but it does at least show that a sync from the Puppet Forge can complete.

pulp_smash.tests.puppet.api_v2.test_sync_publish already syncs from the Puppet Forge, but Pulp #1846 specifically uses the CLI.

The end result is a test case that syncs an unknown number of Puppet modules and which provides only minimal assurance that syncs from the Puppet Forge work. Unfortunately, we cannot do better.

test_sync_puppet_forge()

Create a Puppet repository and trigger a sync.

pulp_smash.tests.puppet.cli.test_sync.get_num_units_in_repo(server_config, repo_id)

Tell how many puppet modules are in a repository.

Parameters:
Returns:

The number of puppet modules in a repository, as an int.

pulp_smash.tests.puppet.cli.test_sync.setUpModule()

Skip this module of tests if appropriate.

See Pulp #2574.

pulp_smash.tests.puppet.utils

Location: Pulp SmashAPI Documentationpulp_smash.tests.puppet.utils

Utilities for Puppet tests.

pulp_smash.tests.puppet.utils.set_up_module()

Skip tests if the Puppet plugin is not installed.

See pulp_smash.tests for more information.

pulp_smash.tests.python

Location: Pulp SmashAPI Documentationpulp_smash.tests.python

Functional tests for Pulp’s Python plugin.

pulp_smash.tests.python.api_v2

Location: Pulp SmashAPI Documentationpulp_smash.tests.python.api_v2

Tests that communicate with the server via the v2 API.

pulp_smash.tests.python.api_v2.test_crud

Location: Pulp SmashAPI Documentationpulp_smash.tests.python.api_v2.test_crud

Tests that CRUD Python repositories.

class pulp_smash.tests.python.api_v2.test_crud.CRUDTestCase(methodName='runTest')

Test that one can create, update, read and delete a test case.

static create_body()

Return a dict for creating a repository.

static update_body()

Return a dict for creating a repository.

pulp_smash.tests.python.api_v2.test_duplicate_uploads

Location: Pulp SmashAPI Documentationpulp_smash.tests.python.api_v2.test_duplicate_uploads

Tests for how well Pulp can deal with duplicate uploads.

This module targets Pulp #1406 and Pulp Smash #81. The test procedure is as follows:

  1. Create a new feed-less repository.
  2. Upload content and import it into the repository. Assert the upload and import was successful.
  3. Upload identical content and import it into the repository.

The second upload should silently fail for all Pulp releases in the 2.x series.

class pulp_smash.tests.python.api_v2.test_duplicate_uploads.DuplicateUploadsTestCase(methodName='runTest')

Test how well Pulp can deal with duplicate content unit uploads.

classmethod setUpClass()

Create a Python repo. Upload a Python package into it twice.

pulp_smash.tests.python.api_v2.test_sync_publish

Location: Pulp SmashAPI Documentationpulp_smash.tests.python.api_v2.test_sync_publish

Test the sync and publish API endpoints for Python repositories.

class pulp_smash.tests.python.api_v2.test_sync_publish.BaseTestCase(methodName='runTest')

A base class for the test cases in this module.

Test cases derived from this class (should) do the following:

  1. Create and populate a Python repository. The procedure for populating the repository varies in each child class.
  2. Create a second Python repository, and sync it from the first.

In each step, the verify_* methods are used if appropriate.

classmethod setUpClass()

Create class-wide variables.

classmethod tearDownClass()

Delete fixtures and orphans.

test_01_first_repo()

Create, populate and publish a Python repository.

Subclasses must override this method.

test_02_second_repo()

Create a second Python repository, and sync it from the first.

See:

Note that, for Pulp #140 to be fully tested, an additional test case should be created wherein one Pulp application syncs from another completely independent Pulp application.

verify_package_types(cfg, repo)

Assert sdist and bdist_wheel shelf-reader packages were synced.

This test targets Pulp #1883.

verify_sync(cfg, call_report)

Verify the call to sync a Python repository succeeded.

Assert that:

  • The call report has an HTTP 202 status code.
  • None of the tasks spawned by the “sync” request contain errors.
class pulp_smash.tests.python.api_v2.test_sync_publish.SyncTestCase(methodName='runTest')

Test whether content can be synced into a Python repository.

test_01_first_repo()

Create, sync content into and publish a Python repository.

See:

class pulp_smash.tests.python.api_v2.test_sync_publish.UploadTestCase(methodName='runTest')

Test whether content can be uploaded to a Python repository.

test_01_first_repo()

Create, upload content into and publish a Python repository.

See:

pulp_smash.tests.python.api_v2.test_sync_publish.get_details(cfg, repo)

Return detailed information about a Python repository.

pulp_smash.tests.python.api_v2.test_sync_publish.get_repo_path(cfg, repo)

Return the root path to a published Python repository.

pulp_smash.tests.python.api_v2.utils

Location: Pulp SmashAPI Documentationpulp_smash.tests.python.api_v2.utils

Utility functions for Python API tests.

pulp_smash.tests.python.api_v2.utils.gen_distributor()

Return a semi-random dict for use in creating a Python distributor.

pulp_smash.tests.python.api_v2.utils.gen_repo()

Return a semi-random dict for use in creating a Python repository.

pulp_smash.tests.python.utils

Location: Pulp SmashAPI Documentationpulp_smash.tests.python.utils

Utilities for Python tests.

pulp_smash.tests.python.utils.set_up_module()

Skip tests if the Python plugin is not installed.

See pulp_smash.tests for more information.

pulp_smash.tests.rpm

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm

Functional tests for Pulp’s RPM plugin.

pulp_smash.tests.rpm.api_v2

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.api_v2

Tests that communicate with the server via the v2 API.

pulp_smash.tests.rpm.api_v2.test_broker

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.api_v2.test_broker

Tests for Pulp’s “broker reconnect” feature.

Tests for #55:

> Pulp offers a collection of behaviors known as “reconnect support” for the > Pulp Broker. Here are the expected behaviors: > > * If you start a Pulp service that connects to the broker and the broker is > not running or is not network accessible for some reason, the Pulp services > will wait-and-retry. It has a backoff behavior, but the important part is > that Pulp services don’t exit if they can’t connect due to availability, > and when the availability problem is resolved, the Pulp services reconnect. > * If you have a Pulp service connected to the broker and the broker shuts > down, the Pulp services need the wait-and-retry as described above. Once > the broker becomes available again the Pulp services should reconnect.

There are two scenarios to test here:

  • support for initially connecting to a broker, and
  • support for reconnecting to a broker that goes missing.

Both scenarios are executed by pulp_smash.tests.rpm.api_v2.test_broker.BrokerTestCase.

class pulp_smash.tests.rpm.api_v2.test_broker.BrokerTestCase(methodName='runTest')

Test Pulp’s support for broker connections and reconnections.

health_check()

Execute step three of the test plan.

setUp()

Provide a server config and Pulp services to stop and start.

tearDown()

Ensure Pulp services and AMQP broker are running.

Stop all relevant services, then start them again. This approach is slow, but see when broker reconnect test fails, all following tests fail.

test_broker_connect()

Test Pulp’s support for initially connecting to a broker.

Do the following:

  1. Stop both the broker and several other services.
  2. Start the several other resources, wait, and start the broker.
  3. Test Pulp’s health. Create an RPM repository, sync it, add a distributor, publish it, and download an RPM.
test_broker_reconnect()

Test Pulp’s support for reconnecting to a broker that goes missing.

Do the following:

  1. Start both the broker and several other services.
  2. Stop the broker, wait, and start it again.
  3. Test Pulp’s health. Create an RPM repository, sync it, add a distributor, publish it, and download an RPM.

This test targets:

pulp_smash.tests.rpm.api_v2.test_character_encoding

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.api_v2.test_character_encoding

Tests for Pulp’s character encoding handling.

RPM files have metadata embedded in their headers. This metadata should be encoded as utf-8, and Pulp should gracefully handle cases where invalid byte sequences are encountered.

class pulp_smash.tests.rpm.api_v2.test_character_encoding.UploadNonAsciiTestCase(methodName='runTest')

Test whether one can upload an RPM with non-ascii metadata.

Specifically, do the following:

  1. Create an RPM repository.
  2. Upload and import pulp_smash.constants.RPM_WITH_NON_ASCII_URL into the repository.
test_all()

Test whether one can upload an RPM with non-ascii metadata.

class pulp_smash.tests.rpm.api_v2.test_character_encoding.UploadNonUtf8TestCase(methodName='runTest')

Test whether one can upload an RPM with non-utf-8 metadata.

Specifically, do the following:

  1. Create an RPM repository.
  2. Upload and import pulp_smash.constants.RPM_WITH_NON_UTF_8_URL into the repository.

This test case targets Pulp #1903.

test_all()

Test whether one can upload an RPM with non-ascii metadata.

pulp_smash.tests.rpm.api_v2.test_comps_xml

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.api_v2.test_comps_xml

Verify an RPM repository’s comps.xml file.

Each RPM repository has a repodata directory, in which various XML files containing metadata are present. This module houses test cases which verify the comps.xml file. For a sample comps.xml file, search through pulp_smash.constants.RPM_SIGNED_FEED_URL.

class pulp_smash.tests.rpm.api_v2.test_comps_xml.SyncRepoTestCase(methodName='runTest')

Sync in content from another RPM repository and publish it.

More specifically, this test case does the following:

  1. Create a repository with a feed and a distributor.
  2. Sync and publish the repository.
  3. Verify the comps.xml file available in the published repository.
classmethod setUpClass()

Create, sync and publish a repository. Fetch its comps.xml.

test_first_level_element()

Verify the top-level element is named “comps”.

test_langpacks_element()

Verify a langpacks element is in comps.xml.

Support for package langpacks has been added in Pulp 2.9. Consequently, this test is skipped on earlier versions of Pulp.

test_second_level_elements()

Verify the correct second-level elements are present.

class pulp_smash.tests.rpm.api_v2.test_comps_xml.UploadPackageGroupsTestCase(methodName='runTest')

Upload custom package groups to an RPM repository and publish it.

More specifically, this test case does the following:

  1. Create a repository without a feed.
  2. Add yum distributor to the repository.
  3. Generate several custom package groups. Upload each of them to Pulp, and import them into the repository.
  4. Publish the repository.
  5. Verify the comps.xml file available in the published repository.
classmethod setUpClass()

Create an RPM repository, upload package groups, and publish.

test_conditional_requires()

Assert requires attributes are correct on conditional packages.

This test assumes test_packagelist_values() has passed.

test_count()

Assert there is one “group” element per imported group unit.

test_default_default()

Assert that the default value of default tag is ‘false’.

test_default_uservisible()

Assert that the default value of uservisible tag is ‘false’.

test_display_order_occurences()

Assert display_order occurs once if omitted from the unit.

test_display_order_value()

Assert display_order is “1024” if omitted from the unit.

This test may be skipped if Pulp #1787 is open.

test_has_groups()

Assert that each imported group unit appears in the XML.

test_ids_alone()

Assert each “group” element has one “id” child element.

test_ids_unique()

Assert each group ID is unique.

test_one_task_per_import()

Assert only one task is spawned per package group upload.

test_packagelist_values()

Assert packagelist contains packagereq elements with correct text.

This test verifies that, for each of the 4 possible types of package in a group, the packagelist in the group XML contains exactly the package names in the uploaded unit.

test_root()

Assert the root element of the tree has a tag of “comps”.

test_single_elements()

Assert that certain tags appear under groups exactly once.

test_tasks_result()

Assert each task’s result success flag (if present) is true.

This test assumes test_one_task_per_import() passes.

test_tasks_state()

Assert each task’s state is “finished”.

This test assumes test_one_task_per_import() passes.

test_translated_string_count()

Assert that the XML has correct number of translated strings.

Some fields (name, description) are translatable. The tags for these fields are expected to appear once per translation, plus once for the untranslated string. This test verifies that this is the case.

test_translated_string_values()

Assert that the XML has correct values for translated strings.

Some fields (name, description) are translatable. The tags for these fields are expected to appear once per translation, plus once for the untranslated string. This test verifies that each translated string matches exactly the string provided when the group unit was imported.

test_verbatim_boolean_fields()

Assert boolean fields on a unit appear correctly in generated XML.

This test is similar to test_verbatim_string_fields(), but additionally verifies that boolean values are serialized as expected in the XML (i.e. as text ‘true’ or ‘false’).

test_verbatim_string_fields()

Assert string fields on a unit appear unmodified in generated XML.

This test covers fields from a group unit which are expected to be serialized as-is into top-level tags under a <group>. For example, this test asserts that the ‘name’ attribute on a group unit will appear in the generated XML as:

<group>
    <name>some-value</name>
    ...
</group>
class pulp_smash.tests.rpm.api_v2.test_comps_xml.UploadTwiceTestCase(methodName='runTest')

Upload a package group twice.

The first upload should create a new package group, and the second should update the existing package group. See: Pulp #2514.

test_all()

Upload a package group to a repository twice.

pulp_smash.tests.rpm.api_v2.test_comps_xml.setUpModule()

Possibly skip the tests in this module.

Skip tests if Pulp #2277 affects us.

pulp_smash.tests.rpm.api_v2.test_crud

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.api_v2.test_crud

Tests that CRUD RPM repositories.

For information on repository CRUD operations, see Creation, Deletion and Configuration.

class pulp_smash.tests.rpm.api_v2.test_crud.CrudTestCase(methodName='runTest')

CRUD a minimal RPM repository.

static create_body()

Return a dict for creating a repository.

static update_body()

Return a dict for updating a repository.

class pulp_smash.tests.rpm.api_v2.test_crud.CrudWithFeedTestCase(methodName='runTest')

CRUD an RPM repository with a feed URL.

static create_body()

Return a dict for creating a repository.

class pulp_smash.tests.rpm.api_v2.test_crud.FeedURLUnquoteTestCase(methodName='runTest')

Check that feed URLs are unquoted.

See https://pulp.plan.io/issues/2520.

test_all()

Ensure Pulp unquote feed URLs.

class pulp_smash.tests.rpm.api_v2.test_crud.LastUnitAddedTestCase(methodName='runTest')

Tests for ensuring proper last_unit_added behavior.

setUp()

Perform common set-up tasks.

test_update_on_copy()

Check if copying units into a repo updates last_unit_added.

Do the following:

  1. Create a repository with a feed and sync it.
  2. Create a second repository. Assert the second repository’s last_unit_added attribute is null.
  3. Copy a content unit from first repository to the second. Assert the second repository’s last_unit_added attribute is non-null.
  4. Publish the second repository. Assert its last_unit_added attribute is non-null.
test_update_on_sync()

Check if syncing a repo updates last_unit_added.

Do the following:

  1. Create a repository with a feed.
  2. Assert the repository’s last_unit_added attribute is null.
  3. Sync the repository.
  4. Assert the repository’s last_unit_added attribute is non-null.
class pulp_smash.tests.rpm.api_v2.test_crud.PulpDistributionTestCase(methodName='runTest')

Check if a feed with PULP_DISTRIBUTION.xml syncs properly.

See https://pulp.plan.io/issues/1086

test_all()

Check for content synced from a feed with PULP_DISTRIBUTION.xml.

class pulp_smash.tests.rpm.api_v2.test_crud.RPMDistributorTestCase(methodName='runTest')

RPM distributor tests.

test_update_checksum_type()

Check if RPM distributor can receive null checksum_type.

See: https://pulp.plan.io/issues/2134.

class pulp_smash.tests.rpm.api_v2.test_crud.RepositoryGroupCrudTestCase(methodName='runTest')

CRUD a minimal RPM repositories’ groups.

For information on repositories’ groups CRUD operations, see Creation, Delete, and Update <http://docs.pulpproject.org/en/latest/dev-guide/integration/rest-api/repo/groups/cud.html>

classmethod setUpClass()

Create, update, read and delete a repository group.

test_create()

Assert the created repository group has all requested attributes.

Walk through each of the attributes present on the create body and verify the attribute is present in the repository group.

test_read()

Assert the repo group update response has the requested changes.

test_status_codes()

Assert each response has a correct status code.

test_update()

Assert the repo group update response has the requested changes.

pulp_smash.tests.rpm.api_v2.test_download_policies

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.api_v2.test_download_policies

Tests for Pulp’s download policies, such as “background” and “on demand”.

Beware that the test cases for the “on demand” download policy will fail if Pulp’s Squid server is not configured to return an appropriate hostname or IP when performing redirection.

class pulp_smash.tests.rpm.api_v2.test_download_policies.BackgroundTestCase(methodName='runTest')

Ensure the “background” download policy works.

classmethod setUpClass()

Create an RPM repository with a valid feed and sync it.

Do the following:

  1. Reset Pulp, including the Squid cache.
  2. Create a repository with the “background” download policy.
  3. Sync and publish the repository.
  4. Download an RPM from the repository.
test_repo_local_units()

Assert that all content is downloaded for the repository.

test_request_history()

Assert that the request was serviced directly by Pulp.

If Pulp did not have the content available locally, it would redirect the client to the streamer and the rpm request would contain a history entry for that redirect.

test_rpm_checksum()

Assert the checksum of the downloaded RPM matches the metadata.

test_spawned_download_task()

Assert that a download task was spawned as a result of the sync.

class pulp_smash.tests.rpm.api_v2.test_download_policies.FixFileCorruptionTestCase(methodName='runTest')

Ensure the “on demand” download policy can fix file corruption.

classmethod get_rpm_abs_path()

Return the absolute path to pulp_smash.constants.RPM.

classmethod setUpClass()

Create an RPM repository and issue a task to download the repo.

Do the following:

  1. Reset Pulp.
  2. Create a repository with the “on demand” download policy.
  3. Sync and publish the repository.
  4. Trigger a repository download.
  5. Corrupt a file in the repository.
  6. Trigger a repository download, without unit verification.
  7. Trigger a repository download, with unit verification.
test_corruption_occurred()

Assert corrupting a unit changes its checksum.

This is to ensure we actually corrupted the RPM and validates further testing.

test_start_end_checksums()

Verify Pulp’s behaviour when verify_all_units is true.

Assert that the pre-corruption checksum of the unit is the same as the post-redownload checksum of the unit.

test_units_after_download()

Assert all units are downloaded after download_repo finishes.

test_units_before_download()

Assert no content units were downloaded besides metadata units.

test_verify_all_units_false()

Verify Pulp’s behaviour when verify_all_units is false.

Assert that the checksum of the corrupted unit is unchanged, indicating that Pulp did not verify (or re-download) the checksum of the corrupted unit.

test_verify_all_units_true()

Verify Pulp’s behaviour when verify_all_units is true.

Assert that the checksum of the corrupted unit is changed, indicating that Pulp did verify the checksum of the corrupted unit, and subsequently re-downloaded the unit.

class pulp_smash.tests.rpm.api_v2.test_download_policies.OnDemandTestCase(methodName='runTest')

Ensure the “on demand” download policy works.

classmethod setUpClass()

Create an RPM repository with a valid feed and sync it.

Do the following:

  1. Reset Pulp, including the Squid cache.
  2. Create a repository with the “on demand” download policy.
  3. Sync and publish the repository.
  4. Download an RPM from the published repository.
  5. Download the same RPM to ensure it is served by the cache.
test_local_units()

Assert no content units were downloaded besides metadata.

test_repository_units()

Assert there is at least one content unit in the repository.

test_request_history()

Assert the initial request received a 302 Redirect.

test_rpm_cache_control_header()

Assert the request has the Cache-Control header set.

test_rpm_cache_lookup_header()

Assert the first request resulted in a cache miss from Squid.

test_rpm_checksum()

Assert the checksum of the downloaded RPM matches the metadata.

test_same_rpm_cache_header()

Assert the second request resulted in a cache hit from Squid.

test_same_rpm_checksum()

Assert the checksum of the second RPM matches the metadata.

class pulp_smash.tests.rpm.api_v2.test_download_policies.SwitchPoliciesTestCase(methodName='runTest')

Ensure that repo’s download policy can be updated and works.

Each test exercises a different download policy permutation by doing the following:

  1. Create a repository configuring to one download policy
  2. Read the repository and check if the download policy was properly set.
  3. Update the repository to a different download policy.
  4. Read the repository and check if the download policy was updated.
  5. Sync the repository
  6. Assert that the final download policy was used and works properly.
assert_background(repo, tasks)

Assert that background download policy is properly working.

assert_immediate(repo, tasks)

Assert that immediate download policy is properly working.

assert_on_demand(repo)

Assert that on_demand download policy is properly working.

repository_setup(first, second)

Set up a repository for download policy switch test.

Create a repository using the first download policy, assert it was set, update to the second download policy, assert it was set, then sync the repository and finally poll the spawned tasks.

Return a tuple with the repository and tasks.

setUp()

Make sure Pulp and Squid are reset.

test_background_to_immediate()

Check if switching from background to immediate works.

test_background_to_on_demand()

Check if switching from background to on_demand works.

test_immediate_to_background()

Check if switching from immediate to background works.

test_immediate_to_on_demand()

Check if switching from immediate to on_demand works.

test_on_demand_to_background()

Check if switching from on_demand to background works.

test_on_demand_to_immediate()

Check if switching from on_demand to immediate works.

pulp_smash.tests.rpm.api_v2.test_download_policies.setUpModule()

Skip tests if the RPM plugin is not installed.

pulp_smash.tests.rpm.api_v2.test_duplicate_uploads

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.api_v2.test_duplicate_uploads

Tests for how well Pulp can deal with duplicate uploads.

This module targets Pulp #1406 and Pulp Smash #81. The test procedure is as follows:

  1. Create a new feed-less repository.
  2. Upload content and import it into the repository. Assert the upload and import was successful.
  3. Upload identical content and import it into the repository.

The second upload should silently fail for all Pulp releases in the 2.x series.

class pulp_smash.tests.rpm.api_v2.test_duplicate_uploads.DuplicateUploadsTestCase(methodName='runTest')

Test how well Pulp can deal with duplicate unit uploads.

classmethod setUpClass()

Create an RPM repository. Upload an RPM into it twice.

pulp_smash.tests.rpm.api_v2.test_export

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.api_v2.test_export

Test the API’s Export Distributors feature.

This module assumes that the tests in pulp_smash.tests.platform.api_v2.test_repository and pulp_smash.tests.rpm.api_v2.test_sync_publish hold true.

class pulp_smash.tests.rpm.api_v2.test_export.BaseExportChecksumTypeTestCase(*args, **kwargs)

Base class for repo and repo group export with checksum type tests.

get_export_entity()

Provide the export entity.

The entity can be either a repository or a repository group.

get_export_entity_type()

Provide the export entity type.

Return repos for repository and repo_group for repository group.

get_repomd_iso_publish_path(export_dir, distributor)

Provide the repomd.xml publish path within an exported ISO.

Repository and repository group exports have a different path to repomd.xml file within the exported ISO.

get_repomd_publish_path(export_dir, distributor)

Provide the repomd.xml publish path.

Repository and repository group exports have a different path to repomd.xml file.

classmethod setUpClass()

Create and sync a repository.

Also skips the test if Pulp version less than 2.9.

Children of this base class must provide a distributors attribute with the list of distributors to export a repository or repository group.

test_publish_to_dir_checksum_type()

Publish to a directory choosing the checksum type.

test_publish_to_web_checksum_type()

Publish to web choosing the checksum type.

class pulp_smash.tests.rpm.api_v2.test_export.ExportChecksumTypeTestCase(*args, **kwargs)

Publish a repository choosing the distributor checksum type.

get_export_entity()

Provide the export entity.

get_export_entity_type()

Provide the export entity type.

get_repomd_iso_publish_path(export_dir, distributor)

Provide the repomd.xml publish path within an exported ISO.

get_repomd_publish_path(export_dir, distributor)

Provide the repomd.xml publish path.

classmethod setUpClass()

Create some distributors.

Each distributor is configured with a valid checksum type.

class pulp_smash.tests.rpm.api_v2.test_export.ExportDirMixin(*args, **kwargs)

Mixin with repo export to dir utilities.

A mixin with methods for managing an export directory on a Pulp server. This mixin is designed to support the following work flow:

  1. Create a directory. (See create_export_dir().)
  2. Export a repository to the directory.
  3. Make the directory readable. (See change_export_dir_owner().)
  4. Inspect the contents of the directory.

publish_to_dir() conveniently executes steps 1–3. Consider using the other methods only if more granularity is needed.

A class attribute named cfg must be present. It should be a pulp_smash.config.PulpSmashConfig.

change_export_dir_owner(export_dir)

Change the owner to the running Pulp Smash user.

Update the remote path dir owner to the user running Pulp Smash.

create_export_dir()

Create a directory, and ensure Pulp can export to it.

Create a directory, and set its owner and group to apache. If Pulp issue 616 affects the current Pulp system, disable SELinux, and schedule a clean-up command that re-enables SELinux.

Warning

Only call this method from a unittest test* method. If called from elsewhere, SELinux may be left disabled.

Returns:The path to the created directory, as a string.
publish_to_dir(entity_href, distributor_id)

Create an export directory, publish to it, and change its owner.

For details, see ExportDirMixin.

Parameters:
  • entity_href – The path to an entity such as a repository or a repository group.
  • distributor_id – The ID of the distributor to use when exporting.
Returns:

The path to the export directory.

sudo()

Return either '' or 'sudo '.

Return the former if root, and the latter if not.

class pulp_smash.tests.rpm.api_v2.test_export.ExportDistributorTestCase(*args, **kwargs)

Establish we can publish a repository using an export distributor.

setUp()

Optionally create an export distributor.

Create an export distributor only if one is not already present. (See setUpClass().)

classmethod setUpClass()

Create and sync a repository. Optionally create a distributor.

Skip creating the distributor if we are testing Pulp 2.9 and it is affected by Pulp #1928.

test_publish_to_dir()

Publish the repository to a directory on the Pulp server.

gerify that pulp_smash.constants.RPM is present and has a correct checksum.

This test is skipped if selinux is installed and enabled on the target system an Pulp issue 616 is open.

test_publish_to_web()

Publish the repository to the web, and fetch the ISO file.

The ISO file should be available over both HTTP and HTTPS. Fetch it from both locations, and assert that the fetch was successful.

class pulp_smash.tests.rpm.api_v2.test_export.RepoGroupExportChecksumTypeTestCase(*args, **kwargs)

Publish a repository group choosing the distributor checksum type.

get_export_entity()

Provide the export entity.

get_export_entity_type()

Provide the export entity type.

get_repomd_iso_publish_path(export_dir, distributor)

Provide the repomd.xml publish path within an exported ISO.

get_repomd_publish_path(export_dir, distributor)

Provide the repomd.xml publish path.

classmethod setUpClass()

Create required entities for publishing a repository group.

Do the following:

  1. Create a repository group and add the repository created by super call.
  2. Creates some distributors. Each distributor is configured with a valid checksum type.
pulp_smash.tests.rpm.api_v2.test_export.setUpModule()

Possibly skip the tests in this module.

Skip tests if Pulp #2277 affects us.

pulp_smash.tests.rpm.api_v2.test_force_full

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.api_v2.test_force_full

Tests for publishing with the force_full parameter set.

When a repository is published, Pulp checks to see if certain steps can be skipped. For example, if one publishes a repository twice in a row, the second publish is a no-op, as nothing needs to be done. As of Pulp 2.9, clients can tell Pulp to perform a “full” publish. When this is done, Pulp executes all publication steps, even steps that normally would be skipped.

This module tests Pulp’s handling of “full” publishes.

class pulp_smash.tests.rpm.api_v2.test_force_full.ForceFullTestCase(methodName='runTest')

Test the force_full option.

Repeatedly publish a repository. Set the force_full option to various values, and try omitting it too.

get_step(steps, step_type)

Return the task step with the given step_type.

Parameters:
  • steps – A list of dicts, as can be accessed by call_report_task['result']['details'].
  • step_type – The step_type of a particular step, such as save_tar.
Returns:

The matching step.

Raises:

An assertion error if exactly one match is not found.

classmethod setUpClass()

Create and sync a repository.

test_01_force_full_false()

Publish the repository and set force_full to false.

A full publish should occur.

test_02_force_full_omit()

Publish the repository and omit force_full.

A fast-forward publish should occur. This test targets Pulp #1966.

test_03_force_full_true()

Publish the repository and set force_full to true.

A full publish should occur. The “force” publish feature was introduced in Pulp 2.9, and as such, this test will skip when run against an older version of Pulp. See Pulp #1938.

pulp_smash.tests.rpm.api_v2.test_iso_crud

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.api_v2.test_iso_crud

Test CRUD for ISO RPM repositories.

class pulp_smash.tests.rpm.api_v2.test_iso_crud.AddImporterDistributorTestCase(methodName='runTest')

Add an importer and a distributor to an existing untyped repository.

See:

classmethod setUpClass()

Create a repository and add an importer and distributor to it.

Do the following:

  1. Create a repository.
  2. Read the repository’s importers and distributors.
  3. Add an importer and distributor to the repo.
  4. Re-read the repository’s importers and distributors.
test_add_distributor()

Check the HTTP status code for adding a distributor.

test_add_importer()

Check the HTTP status code for adding an importer.

test_after()

Verify the repository ends up with one importer and distributor.

test_before()

Verify the repository has no importer or distributors initially.

class pulp_smash.tests.rpm.api_v2.test_iso_crud.CreateTestCase(methodName='runTest')

Create an ISO RPM repo with an importer and distributor.

classmethod setUpClass()

Create an ISO RPM repo with an importer and distributor.

test_attributes()

Assert the created repository has the requested attributes.

test_headers_location()

Assert the response’s Location header is correct.

The Location may be either an absolute or relative URL. See pulp_smash.tests.platform.api_v2.test_repository.CreateSuccessTestCase.test_location_header().

test_status_code()

Assert the response has an HTTP 201 status code.

class pulp_smash.tests.rpm.api_v2.test_iso_crud.PulpManifestTestCase(methodName='runTest')

Ensure ISO repo properly handles PULP_MANIFEST information.

static parse_pulp_manifest(feed_url)

Parse PULP_MANIFEST information from feed_url/PULP_MANIFEST.

Parameters:feed_url – The URL for the file feed. It will be joined with /PULP_MANIFEST in order to find the PULP_MANIFEST file.
Returns:A list of dicts mapping each PULP_MANIFEST row. The dict contains the keys name, checksum and size which represent the PULP_MANIFEST data.
test_invalid_file_feed()

Create and sync a ISO repo from an invalid file feed.

Assert that the sync fails with the information that some units were not available.

test_valid_file_feed()

Create and sync a ISO repo from a file feed.

Assert that the number of units synced is the same as PULP_MANIFEST lists.

class pulp_smash.tests.rpm.api_v2.test_iso_crud.ReadUpdateDeleteTestCase(methodName='runTest')

Establish that we can interact with typed repositories as expected.

classmethod setUpClass()

Create three repositories and read, update and delete them.

test_read()

Assert that the “read” call returns correct attributes.

test_read_distributors()

Assert each read w/distributors contains info about distributors.

test_read_importers()

Assert each read with importers contains info about importers.

test_status_code()

Assert each response has a correct HTTP status code.

pulp_smash.tests.rpm.api_v2.test_iso_sync_publish

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.api_v2.test_iso_sync_publish

Tests that sync and publish ISO repositories.

class pulp_smash.tests.rpm.api_v2.test_iso_sync_publish.ServeHttpsFalseTestCase(methodName='runTest')

Publish w/an rsync distributor when serve_https is false.

More precisely, do the following:

  1. Create an ISO RPM repository. Ensure the repository has distributors of type iso_distributor and iso_rsync_distributor, and ensure the former distributor’s publish_https attribute is false.
  2. Populate the repository with some content.
  3. Publish the repository with both distributors. Assert that the ISO rsync distributor successfully places files on the target system.

This test targets Pulp #2657. According to this issue, the ISO rsync distributor will fail to publish files if the the ISO distributor has not published files via HTTPS.

setUp()

Set the pulp_manage_rsync boolean.

tearDown()

Reset the pulp_manage_rsync boolean.

test_all()

Publish w/an rsync distributor when serve_https is false.

class pulp_smash.tests.rpm.api_v2.test_iso_sync_publish.UploadIsoTestCase(methodName='runTest')

Upload an ISO file into an ISO repository.

test_all()

Upload an ISO file into an ISO repository.

Specifically, do the following:

  1. Create an ISO repository.
  2. Upload pulp_smash.constants.FILE_URL to the repository.

Note

A nice future addition would be to publish the repository, download the published ISO file, and assert that it’s identical to the ISO file uploaded earlier.

pulp_smash.tests.rpm.api_v2.test_mirrorlist

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.api_v2.test_mirrorlist

Tests that exercise Pulp’s support for mirrorlist feeds.

The tests in this module target:

  • Pulp #175: “As a user, I can specify mirrorlists for rpm repository feeds.”
  • Pulp #2224: “Cannot sync from mirrorlists.”

The test cases in this module reference “good,” “mixed” and “bad” mirrorlist files. A “good” file contains only valid references, a “mixed” file contains both valid and invalid references, and a “bad” file contains only invalid references.

class pulp_smash.tests.rpm.api_v2.test_mirrorlist.BadMirrorlistTestCase(methodName='runTest')

Create a repository that references a “bad” mirrorlist file.

Do the following:

  1. Create a repository. Make its importer feed option reference a “bad” mirrorlist file.
  2. Sync the repository. Expect a failure.
test_all()

Execute the test case business logic.

class pulp_smash.tests.rpm.api_v2.test_mirrorlist.BadRelativeUrlTestCase(methodName='runTest')

Like BadMirrorlistTestCase, but pass relative_url too.

test_all()

Execute the test case business logic.

class pulp_smash.tests.rpm.api_v2.test_mirrorlist.GoodMirrorlistTestCase(methodName='runTest')

Create a repository that references a “good” mirrorlist file.

Do the following:

  1. Create a repository. Make its importer feed option reference a “good” mirrorlist file.
  2. Sync and publish the repository.
  3. Download and verify a file from the published repository.
test_all()

Execute the test case business logic.

class pulp_smash.tests.rpm.api_v2.test_mirrorlist.GoodRelativeUrlTestCase(methodName='runTest')

Like GoodMirrorlistTestCase, but pass relative_url too.

test_all()

Execute the test case business logic.

class pulp_smash.tests.rpm.api_v2.test_mirrorlist.MixedMirrorlistTestCase(methodName='runTest')

Create a repository that references a “mixed” mirrorlist file.

  1. Create a repository. Make its importer feed option reference a “mixed” mirrorlist file.
  2. Sync and publish the repository.
  3. Download and verify a file from the published repository.
test_all()

Execute the test case business logic.

class pulp_smash.tests.rpm.api_v2.test_mirrorlist.MixedRelativeUrlTestCase(methodName='runTest')

Like MixedMirrorlistTestCase, but pass relative_url too.

test_all()

Execute the test case business logic.

class pulp_smash.tests.rpm.api_v2.test_mirrorlist.UtilsMixin

A mixin providing methods to the test cases in this module.

Any class inheriting from this mixin must also inherit from unittest.TestCase or a compatible clone.

check_issue_2277(cfg)

Skip the current test method if Pulp issue #2277 affects us.

check_issue_2321(cfg)

Skip the current test method if Pulp issue #2321 affects us.

check_issue_2326(cfg)

Skip the current test method if Pulp issue #2326 affects us.

check_issue_2363(cfg)

Skip the current test method if Pulp issue #2363 affects us.

create_repo(cfg, feed, relative_url=None)

Create an RPM repository with a yum importer and distributor.

In addition, schedule the repository for deletion with addCleanup.

Parameters:
  • cfg (pulp_smash.config.PulpSmashConfig) – The Pulp deployment on which to create a repository.
  • feed – A value for the yum importer’s feed option.
  • relative_url – A value for the yum distributor’s relative_url option. If None, this option is not passed to Pulp.
Returns:

A detailed dict of information about the repository.

pulp_smash.tests.rpm.api_v2.test_mirrorlist.tearDownModule()

Delete orphan content units.

pulp_smash.tests.rpm.api_v2.test_no_op_publish

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.api_v2.test_no_op_publish

Test Pulp’s handling of no-op publishes.

As of version 2.9, Pulp has the ability to perform no-op publishes, instead of the more typical full publish. A no-op publish is one in which no files are changed, including metadata files. No-op publishes occur when all of the components — including the repository, distributor and override config — are unchanged.

Tests for this feature include the following:

For more information, see:

class pulp_smash.tests.rpm.api_v2.test_no_op_publish.BaseTestCase(methodName='runTest')

Provide common behaviour for the test cases in this module.

classmethod setUpClass()

Create a repository with a distributor, and populate it.

In addition, create several variables for use by the test methods.

test_first_publish()

Assert the first publish is a full publish.

class pulp_smash.tests.rpm.api_v2.test_no_op_publish.ChangeRepoTestCase(methodName='runTest')

Publish a repository, change it, and publish it again.

classmethod setUpClass()

Publish a repository, change it, and publish it again.

test_second_publish_repomd()

Assert the two publishes produce identical repomd.xml files.

test_second_publish_tasks()

Assert the second publish’s last task reports a no-op publish.

class pulp_smash.tests.rpm.api_v2.test_no_op_publish.NoOpPublishMixin

Provide tests for the no-op publish test cases in this module.

test_second_publish_repomd()

Assert the two publishes produce identical repomd.xml files.

test_second_publish_tasks()

Assert the second publish’s last task reports a no-op publish.

class pulp_smash.tests.rpm.api_v2.test_no_op_publish.PubTwiceTestCase(methodName='runTest')

Publish a repository twice.

classmethod setUpClass()

Publish a repository twice.

class pulp_smash.tests.rpm.api_v2.test_no_op_publish.PubTwiceWithOverrideTestCase(methodName='runTest')

Publish a repository twice, with an override config both times.

classmethod setUpClass()

Publish a repository twice, with an override config both times.

pulp_smash.tests.rpm.api_v2.test_no_op_publish.get_repomd_xml_path(distributor_rel_url)

Construct the path to a repository’s repomd.xml file.

Parameters:distributor_rel_url – A distributor’s relative_url option.
Returns:An string path to a repomd.xml file.
pulp_smash.tests.rpm.api_v2.test_no_op_publish.setUpModule()

Possibly skip the tests in this module. Create and sync an RPM repo.

Skip this module of tests if Pulp is older than version 2.9. (See Pulp #1724.) Then create an RPM repository with a feed and sync it. Test cases may copy data from this repository but should not change it.

pulp_smash.tests.rpm.api_v2.test_no_op_publish.tearDownModule()

Delete the repository created by setUpModule().

pulp_smash.tests.rpm.api_v2.test_orphan_remove

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.api_v2.test_orphan_remove

Test Pulp’s handling of orphaned content units.

This module integrates tightly with Pulp Fixtures. Pulp Smash #134 and Pulp Smash #459 describe specific tests that should be in this module.

class pulp_smash.tests.rpm.api_v2.test_orphan_remove.OrphansTestCase(methodName='runTest')

Establish that API calls related to orphans function correctly.

At a high level, this test case does the following:

  1. Create an RPM repository and populate it with content. Delete the repository, thus leaving behind orphans.
  2. Make several orphan-related API calls, and assert that each call has the desired effect.
check_one_orphan_deleted(orphans_pre, orphans_post, orphan)

Ensure that a specific orphan is well and truly deleted.

Parameters:
Returns:

Nothing.

classmethod setUpClass()

Create orphans.

Create, sync and delete an RPM repository. Doing this creates orphans that the test methods can make use of.

test_00_orphans_available()

Assert that an expected number of orphans is present.

If the expected number of orphans is present, set a class variable indicating such. The following test methods can conditionally run or skip based on this variable. If this method fails, it may indicate that other repositories exist and have references to the same content units.

test_01_get_by_href()

Get an orphan by its href.

test_01_get_by_invalid_type()

Get orphans by content type. Specify a non-existent content type.

test_02_delete_by_href()

Delete an orphan by its href.

test_02_delete_by_type_and_id()

Delete an orphan by its ID and type.

This test exercises Pulp #1923.

test_03_delete_by_content_type()

Delete orphans by their content type.

test_04_delete_all()

Delete all orphans.

test_05_no_orphans_exist()

Assert no orphans exist.

pulp_smash.tests.rpm.api_v2.test_package_paths

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.api_v2.test_package_paths

Tests that sync repositories whose packages are in varying locations.

The packages in a repository may be in the root of a repository, like so:

repository
├── bear-4.1-1.noarch.rpm
├── camel-0.1-1.noarch.rpm
├── …
└── repodata
    ├── b83f17e552fa7a86f75811147251b4cc4f411eacfde5a187375d-primary.xml.gz
    ├── 5ec9512bc0461c579aebd3fe6d89133db5255cc1e15d529a20-other.sqlite.bz2
    └── …

However, the files in the repodata/ directory specify the paths to each file included in a repository. Consequently, other layouts are possible, like so:

repository
├── packages
│   └── keep-going
│       ├── bear-4.1-1.noarch.rpm
│       ├── camel-0.1-1.noarch.rpm
│       └── …
└── repodata
    ├── b83f17e552fa7a86f75811147251b4cc4f411eacfde5a187375d-primary.xml.gz
    ├── 5ec9512bc0461c579aebd3fe6d89133db5255cc1e15d529a20-other.sqlite.bz2
    └── …

The tests in this module verify that Pulp can correctly handle these situations.

class pulp_smash.tests.rpm.api_v2.test_package_paths.ReuseContentTestCase(methodName='runTest')

Sync two repositories with identical content but differing layouts.

If two repositories have some identical content, then Pulp should be able to re-use that content. This is true even if the content is placed in differing locations in the two repositories. Do the following:

  1. Create a pair of repositories. Give the two repositories a download policy of either on demand or background. (One of these download policies must be used to ensure that the Pulp streamer is used.) Give the two repositories differing feeds, where the feeds reference a pair of repositories with some identical content and differing layouts.
  2. Sync each of the repositories.
  3. Publish each of the repositories.
  4. Fetch an identical content unit from each of the two repositories.

This test targets Pulp #2354.

create_repo(cfg, feed, download_policy)

Create an RPM repository with the given feed and download policy.

Also, schedule the repository for deletion at the end of the current test. Return a detailed dict of information about the just-created repository.

test_all()

Sync two repositories w/identical content but differing layouts.

pulp_smash.tests.rpm.api_v2.test_remove_unit

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.api_v2.test_remove_unit

Tests for the remove_missing repository option.

class pulp_smash.tests.rpm.api_v2.test_remove_unit.RemoveMissingTestCase(methodName='runTest')

Test the remove_missing repository option.

The test procedure is as follows:

  1. Create a repository, populate it with content, and publish it.
  2. Create several more repositories whose “feed” attribute references the repository created in the previous step. Sync each of these child repositories.
  3. Remove a content unit from the parent repository and re-publish it.
  4. Re-sync each of the child repositories.

The child repositories are designed to test the following issues:

classmethod setUpClass()

Initialize class-wide variables.

classmethod tearDownClass()

Delete all resources named by resources.

test_01_create_root_repo()

Create, sync and publish a repository.

The repositories created in later steps sync from this one.

test_02_create_immediate_child()

Create a child repository with the “immediate” download policy.

Sync the child repository, and verify it has the same contents as the root repository.

test_02_create_on_demand_child()

Create a child repository with the “on_demand” download policy.

Also, let the repository’s “remove_missing” option be true. Then, sync the child repository, and verify it has the same contents as the root repository.

test_03_update_root_repo()

Remove a content unit from the root repository and republish it.

test_04_sync_immediate_child()

Sync the “immediate” repository.

Verify it has the same contents as the root repository.

test_04_sync_on_demand_child()

Sync the “on demand” repository.

Verify it has the same contents as the root repository.

pulp_smash.tests.rpm.api_v2.test_repomd

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.api_v2.test_repomd

Verify the repomd.xml file generated by a YUM distributor.

class pulp_smash.tests.rpm.api_v2.test_repomd.FastForwardIntegrityTestCase(methodName='runTest')

Ensure fast-forward publishes use files referenced by repomd.xml.

When Pulp performs an incremental fast-forward publish, it should copy the original repository’s repodata/[…]-primary.xml file to the new repository, and then modify it as needed.

According to Pulp #1088, Pulp does something different: it searches for all files named repodata/[0-9a-zA-Z]*-primary.xml.*, sorts them by mtime, copies the newest one to the new repository and modifies it. This behaviour typically works, because Pulp only creates one […]-primary.xml file in a given repository. However, this behaviour is fragile, and it’s especially likely to fail when third-party tools are used to supplement Pulp’s functionality. What Pulp should do is to consult the old repository’s repomd.xml file to find the […]-primary.xml file.

Do the following:

  1. Create a repository with a yum distributor, sync in some content, and publish it. Verify that […]-primary.xml contains a certain phrase.
  2. Create a second […]-primary.xml file in the published repository, and replace the known phrase with a new phrase. Trigger a full publish, and verify that the known phrase is present, not the new phrase.
  3. Create a second […]-primary.xml file in the published repository, and replace the known phrase with a new phrase. Trigger an incremental publish, and verify that the known phrase is present, not the new phrase.
test_all()

Ensure fast-forward publishes use files referenced by repomd.xml.

class pulp_smash.tests.rpm.api_v2.test_repomd.RepoMDTestCase(methodName='runTest')

Tests to ensure repomd.xml can be created and is valid.

classmethod setUpClass()

Generate, fetch and parse a repomd.xml file.

Do the following:

  1. Create an RPM repository with a YUM distributor and publish it.
  2. Fetch the repomd.xml file from the distributor, and parse it.
test_data()

Assert the tree’s “data” elements have correct “type” attributes.

test_tag()

Assert the XML tree’s root element has the correct tag.

pulp_smash.tests.rpm.api_v2.test_repository_layout

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.api_v2.test_repository_layout

Tests for the published repository layout.

Starting with Pulp 2.12, YUM distributor must publish repositories using the layout where the packages are published to into Packages/<first_letter> where <first_letter> is the first letter of a given RPM package. For example, the bear.rpm package will be published into Packages/b/bear.rpm. For more information, see Pulp issue #1976.

Old versions of Pulp uses the old layout where all repository’s packages were published on the root of the repository directory not inside the Packages/<first_letter> subdirectory.

class pulp_smash.tests.rpm.api_v2.test_repository_layout.RepositoryLayoutTestCase(methodName='runTest')

Test the YUM distributor publishing repository layout.

test_all()

Do not use the packages_directory option.

Create a distributor with default options, and use it to publish the repository. Verify packages end up in the current directory, relative to the published repository’s root. (This same directory contains the repodata directory, and it may be changed by setting the distributor’s relative_url.)

pulp_smash.tests.rpm.api_v2.test_repository_layout.get_file_hrefs(repomd_xml)

Return the href of each file in a repomd.xml file.

Parameters:repomd_xml – An xml.etree.ElementTree object representing the root of a repomd.xml document.
Returns:An iterable of hrefs, with each href as a string.
pulp_smash.tests.rpm.api_v2.test_repository_layout.get_package_hrefs(primary_xml)

Return the href of each package in a primary.xml file.

Parameters:primary_xml – An xml.etree.ElementTree object representing the root of a primary.xml document.
Returns:An iterable of hrefs, with each href as a string.
pulp_smash.tests.rpm.api_v2.test_repository_layout.get_parse_repodata_primary_xml(cfg, distributor)

Fetch, decompress, parse and return a repodata/…primary.xml.gz file.

Parameters:
  • cfg (pulp_smash.config.PulpSmashConfig) – Information about the Pulp deployment being targeted.
  • distributor – Information about a distributor. It should be a dict containing at least {'config': {'relative_url': …}}.
Returns:

An xml.etree.ElementTree object.

pulp_smash.tests.rpm.api_v2.test_repository_layout.get_parse_repodata_xml(server_config, distributor, file_path)

Fetch, parse and return an XML file from a repodata directory.

Parameters:
  • server_config (pulp_smash.config.PulpSmashConfig) – Information about the Pulp deployment being targeted.
  • distributor – Information about a distributor. It should be a dict containing at least {'config': {'relative_url': …}}.
  • file_path – The path to an XML file, relative to the distributor’s relative URL. For example: repodata/repomd.xml.
Returns:

The XML document, parsed as an xml.etree.ElementTree object.

pulp_smash.tests.rpm.api_v2.test_repoview

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.api_v2.test_repoview

Tests that exercise Pulp’s repoview feature.

For more information, see:

class pulp_smash.tests.rpm.api_v2.test_repoview.RepoviewTestCase(methodName='runTest')

Publish a repository with the repoview feature on and off.

Do the following:

  1. Create an RPM repository, and add some content to it.
  2. Publish the repository. Get /pulp/repos/{rel_url}/, and verify that no redirects occur.
  3. Publish the repository with the repoview and generate_sqlite options set to true. Get /pulp/repos/{rel_url}/, and verify that a redirect to /pulp/repos/{rel_url}/repoview/index.html occurs.
  4. Repeat step 2.
test_all()

Publish a repository with the repoview feature on and off.

pulp_smash.tests.rpm.api_v2.test_republish

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.api_v2.test_republish

Test re-publish repository after unassociating content.

Following steps are executed in order to test correct functionality of repository created with valid feed.

  1. Create repository foo with valid feed, run sync, add distributor to it and publish over http and https.
  2. Pick a unit X and and assert it is accessible.
  3. Remove unit X from repository foo and re-publish.
  4. Assert unit X is not accessible.
class pulp_smash.tests.rpm.api_v2.test_republish.RepublishTestCase(methodName='runTest')

Test re-publish repository after unassociating content.

test_all()

Create one repository with feed, unassociate unit and re-publish.

Following steps are executed:

  1. Create, sync and publish a repository.
  2. Pick a content unit from the repository and verify it can be downloaded.
  3. Remove the content unit from the repository, re-publish, and verify it can’t be downloaded.

pulp_smash.tests.rpm.api_v2.test_retain_old_count

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.api_v2.test_retain_old_count

Test the functionality in RPM repos when retain_old_count is specified.

Following steps are executed in order to test correct functionality of repository created with valid feed and retain_old_count option set.

  1. Create repository foo with valid feed, run sync, add distributor to it and publish over http and https.
  2. Create second repository bar, with feed pointing to first repository, set retain_old_count=0 and run sync.
  3. Assert that repositories do not contain same set of units.
  4. Assert that number or RPMs in repo bar is less then in foo repo.
class pulp_smash.tests.rpm.api_v2.test_retain_old_count.RetainOldCountTestCase(methodName='runTest')

Test functionality of –retain-old-count option specified.

classmethod setUpClass()

Create two repositories, first is feed of second one.

Provides server config and set of iterable to delete. Following steps are executed:

  1. Create repository foo with feed, sync and publish it.
  2. Create repository bar with foo as a feed with retain_old_count=0.
  3. Run sync of repo foo.
  4. Get information on both repositories.
test_retain_old_count_works()

Test that content_unit_counts in repositories differ.

Most of the RPMs in the first repository are unique. However, there are two different versions of the “walrus” RPM. When we copy its contents to the second repository with retain_old_count=0, zero old versions of the “walrus” RPM will be copied.

test_status_code()

Verify the HTTP status code of each server response.

pulp_smash.tests.rpm.api_v2.test_rsync_distributor

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.api_v2.test_rsync_distributor

Test the functionality of the RPM rsync distributor.

The RPM rsync distributor lets one publish content units to a directory via rsync+ssh. A typical usage of the RPM rsync distributor is as follows:

  1. Create RPM repository with yum and RPM rsync distributors.
  2. Upload some content units to the repository.
  3. Publish the repository with the yum distributor.
  4. Publish the repository with the RPM rsync distributor.

The RPM rsync distributor may not be used by itself. One cannot create an RPM repository with just an RPM rsync distributor; and one cannot publish a repository with the RPM rsync distributor without first publishing with a yum distributor.

For more information on the RPM rsync distributor, see Pulp #1759. As a quick reference, consider a repository with the following abbreviated distributor definitions:

[
    {
        'distributor_type_id': 'rpm_rsync_distributor',
        'config': {
            'remote': {'host': '192.168.100.32', 'root': '/home/myuser'},
            'remote_units_path': 'foo/bar/biz'  # default: 'content/units'
        }
    },
    {
        'distributor_type_id': 'yum_distributor',
        'config': {'relative_url': 'rel-url/'}
    }
]

Following a publish with the yum and rpm rsync distributors, respectively, files will be laid out as follows:

/home/myuser
├── foo
│   └── bar
│       └── biz
│           └── rpm
│               ├── 06
│               │   └── …
│               │       └── dog-4.23-1.noarch.rpm
│               ├── 09
│               │   └── …
│               ┆       └── crow-0.8-1.noarch.rpm
└── rel-url
    ├── bear-4.1-1.noarch.rpm -> ../foo/bar/biz/rpm/a9/…/bear-4.1-1.noarch…
    ├── camel-0.1-1.noarch.rpm -> ../foo/bar/biz/rpm/92/…/camel-0.1-1.noar…
    ┆
class pulp_smash.tests.rpm.api_v2.test_rsync_distributor.AddUnitTestCase(methodName='runTest')

Add a content unit to a repo in the middle of several publishes.

When executed, this test case does the following:

  1. Create a yum repository with a yum and rsync distributor.
  2. Add some content to the repository.
  3. Publish the repository with its yum distributor.
  4. Add additional content to the repository.
  5. Publish the repository with its rsync distributor. This publish shouldn’t distribute the new content unit, as the new content unit wasn’t included in the most recent publish with the yum distributor.
  6. Publish the repository with its yum distributor.
  7. Publish the repository with its rsync distributor. This publish should distribute the new content unit, as the new content unit was included in the most recent publish with the yum distributor.

This test case targets:

test_all()

Add a content unit to a repo in the middle of several publishes.

class pulp_smash.tests.rpm.api_v2.test_rsync_distributor.DeleteTestCase(methodName='runTest')

Use the delete RPM rsync distributor option.

Do the following:

  1. Create a repository with a yum distributor and RPM rsync distributor. Add content units to the repository.
  2. Publish with the yum distributor.
  3. Publish with the RPM rsync distributor. Verify that the correct files are in the target directory.
  4. Remove all files from the repository, and publish with the yum distributor.
  5. Publish with the RPM rsync distributor, with delete set to true. Verify that all files are removed from the target directory.

This test targets Pulp #2221.

test_all()

Use the delete RPM rsync distributor option.

class pulp_smash.tests.rpm.api_v2.test_rsync_distributor.ForceFullTestCase(methodName='runTest')

Use the force_full RPM rsync distributor option.

Do the following:

  1. Create a repository with a yum distributor and RPM rsync distributor. Add content units to the repository.
  2. Publish with the yum distributor.
  3. Publish with the RPM rsync distributor. Verify that the correct files are in the target directory.
  4. Remove all files from the target directory. Publish again, and verify that:
    • The task for publishing has a result of “skipped.”
    • No files are placed in the target directory. (This tests Pulp’s fast-forward logic.)
  5. Publish with the RPM rsync distributor, with force_full set to true. Verify that files are placed in the target directory. Skip this step if Pulp #2202 is not yet fixed.

Additionally, SELinux is temporarily set to “permissive” mode on the target system if Pulp #2199 is not yet fixed.

test_all()

Use the force_full RPM rsync distributor option.

class pulp_smash.tests.rpm.api_v2.test_rsync_distributor.PublishBeforeYumDistTestCase(methodName='runTest')

Publish a repo with the rsync distributor before the yum distributor.

Do the following:

  1. Create a repository with a yum distributor and rsync distributor.
  2. Publish with the rpm rsync distributor. Verify that:
    • The publish has a result of “skipped.”
    • No files are placed on the remote system.
  3. Publish with the rpm rsync distributor again. Perform the same verification steps.

This test targets:

test_all()

Publish the rpm rsync distributor before the yum distributor.

class pulp_smash.tests.rpm.api_v2.test_rsync_distributor.PublishTwiceTestCase(methodName='runTest')

Publish with a yum and rsync distributor twice.

Do the following when executed:

  1. Create a yum repository with a yum and rsync distributor.
  2. Add some content to the repository.
  3. Publish with the yum and rsync distributor.
  4. Publish with the yum and rsync distributor again.

The second publish with the rsync distributor should be a fast-forward publish, as no new units were added to the repository between the first and second publishes. Verify that the first rsync publish is not a fast-foward publish and that the second one is.

This test case targets Pulp #2666.

static get_num_processed(publish_task)

Return num_processed for unit query step in publish_task.

test_all()

Publish with a yum and rsync distributor twice.

class pulp_smash.tests.rpm.api_v2.test_rsync_distributor.RemoteUnitsPathTestCase(methodName='runTest')

Exercise the remote_units_path option.

Do the following:

  1. Create a repository with a yum distributor and RPM rsync distributor, and ensure that the latter distributor’s remote_units_path option is set to a non-default value (not content/units). Add content units to the repository.
  2. Publish with the yum distributor.
  3. Publish with the RPM rsync distributor. Verify that files are placed in the correct directory.
  4. Publish with the RPM rsync distributor, with remote_units_path passed as publish option. Verify that files are placed in this directory.
test_all()

Exercise the remote_units_path option.

class pulp_smash.tests.rpm.api_v2.test_rsync_distributor.VerifyOptionsTestCase(methodName='runTest')

Test Pulp’s verification of RPM rsync distributor configuration options.

Do the following:

  • Repeatedly attempt to create an RPM repository with an importer and pair of distributors. Each time, pass an invalid option, or omit a required option.
  • Create an RPM repository with an importer and pair of distributors. Pass valid configuration options. This demonstrates that creation failures are due to Pulp’s validation logic, not some other factor.
classmethod setUpClass()

Create a value for the rsync distrib’s remote config section.

Using the same config for each of the test methods allows the test methods to behave more similarly.

tearDown()

Verify that the remote config section hasn’t changed.

test_predistributor_id()

Pass a bogus ID as the predistributor_id config option.

test_remote_units_path()

Pass an absolute path to the remote_units_path config option.

test_required_options()

Omit each of the required RPM rsync distributor config options.

test_root()

Pass a relative path to the root configuration option.

test_success()

Successfully create an RPM repo with importers and distributors.

pulp_smash.tests.rpm.api_v2.test_rsync_distributor.setUpModule()

Conditionally skip the tests in this module.

Skip the tests in this module if:

  • The RPM plugin is not installed on the target Pulp server.
  • Pulp #1759 is not implemented on the target Pulp server.
pulp_smash.tests.rpm.api_v2.test_rsync_distributor.tearDownModule()

Delete orphan content units.

pulp_smash.tests.rpm.api_v2.test_schedule_publish

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.api_v2.test_schedule_publish

Test the API’s schedule functionality for repository publication.

This module assumes that the tests in pulp_smash.tests.platform.api_v2.test_repository and pulp_smash.tests.rpm.api_v2.test_sync_publish hold true.

class pulp_smash.tests.rpm.api_v2.test_schedule_publish.CreateFailureTestCase(methodName='runTest')

Establish that schedules are not created in documented scenarios.

classmethod setUpClass()

Create several schedules.

Each schedule is created to test a different failure scenario.

test_status_code()

Assert that each response has the expected HTTP status code.

class pulp_smash.tests.rpm.api_v2.test_schedule_publish.CreateSuccessTestCase(methodName='runTest')

Establish that we can create a schedule to publish the repository.

classmethod setUpClass()

Create a schedule to publish the repository.

Do the following:

  1. Create a repository with a valid feed
  2. Sync it
  3. Schedule publish to run every 30 seconds
test_is_enabled()

Check if sync is enabled.

test_status_code()

Assert the response has an HTTP 201 status code.

test_total_run_count()

Check that total_run_count is sane.

class pulp_smash.tests.rpm.api_v2.test_schedule_publish.ReadUpdateDeleteTestCase(methodName='runTest')

Establish that we can read, update and delete schedules.

This test case assumes the assertions in CreateSuccessTestCase hold true.

classmethod setUpClass()

Create three schedules and read, update and delete them.

test_read_many()

Assert the “read_many” response body contains all schedules.

test_read_one()

Assert the “read_one” response contains the correct attributes.

test_status_code()

Assert each response has a correct HTTP status code.

test_update()

Assert the “update” response body has the correct attributes.

class pulp_smash.tests.rpm.api_v2.test_schedule_publish.ScheduledPublishTestCase(methodName='runTest')

Establish that publish runs according to the specified schedule.

This test case assumes the assertions in CreateSuccessTestCase and ReadUpdateDeleteTestCase hold true.

classmethod setUpClass()

Create a schedule to publish a repo, verify the total_run_count.

Do the following:

  1. Create a repository with a valid feed
  2. Sync it
  3. Schedule publish to run every 2 minutes
  4. Wait for 130 seconds and read the schedule to get the number of “publish” runs
test_no_failure()

Make sure any failure ever happened.

test_total_run_count()

Check for the expected total run count.

pulp_smash.tests.rpm.api_v2.test_schedule_sync

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.api_v2.test_schedule_sync

Test the API’s schedule functionality for repository syncronization.

This module assumes that the tests in pulp_smash.tests.platform.api_v2.test_repository hold true.

class pulp_smash.tests.rpm.api_v2.test_schedule_sync.CreateFailureTestCase(methodName='runTest')

Establish that schedules are not created in documented scenarios.

classmethod setUpClass()

Intentionally fail at creating several sync schedules for a repo.

Each schedule tests a different failure scenario.

test_status_code()

Assert that each response has the expected HTTP status code.

class pulp_smash.tests.rpm.api_v2.test_schedule_sync.CreateRepoMixin

Provide a method for creating a repository.

classmethod create_repo()

Create a semi-random RPM repository with a valid RPM feed URL.

Add this repository’s href to cls.resources. Return a two-tuple of (href, importer_type_id). This method requires a server config, cls.cfg, and a set, cls.resources.

class pulp_smash.tests.rpm.api_v2.test_schedule_sync.CreateSuccessTestCase(methodName='runTest')

Establish that we can create a schedule to sync the repository.

classmethod setUpClass()

Create an RPM repo with a valid feed, create a schedule to sync it.

Do the following:

  1. Create a repository with a valid feed
  2. Schedule sync to run every 30 seconds
test_enabled()

Verify the enabled attribute in the response.

test_status_code()

Assert the response has an HTTP 201 status code.

test_total_run_count()

Verify the total_run_count attribute in the response.

class pulp_smash.tests.rpm.api_v2.test_schedule_sync.ReadUpdateDeleteTestCase(methodName='runTest')

Establish that we can read, update and delete schedules.

This test case assumes the assertions in CreateSuccessTestCase hold true.

classmethod setUpClass()

Create three schedules and read, update and delete them.

test_delete()

Assert the “delete” response body is null.

test_read_many()

Assert the “read_many” response body contains all schedule hrefs.

test_read_one()

Assert the “read_one” response contains the correct attributes.

test_status_code()

Assert each response has a correct HTTP status code.

test_update()

Assert the “update” response body has the correct attributes.

class pulp_smash.tests.rpm.api_v2.test_schedule_sync.ScheduledSyncTestCase(methodName='runTest')

Establish that sync runs according to the specified schedule.

This test case assumes the assertions in CreateSuccessTestCase and ReadUpdateDeleteTestCase hold true.

classmethod setUpClass()

Create a schedule to sync the repo, verify the total_run_count.

Do the following:

  1. Create a repository with a valid feed
  2. Schedule sync to run every 30 seconds
  3. Wait for 40 seconds and read the schedule to get the number of “sync” runs.
test_consecutive_failures()

Assert the sync encountered no consecutive failures.

pulp_smash.tests.rpm.api_v2.test_signatures_checked_for_copies

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.api_v2.test_signatures_checked_for_copies

Tests for repository signature checks when copying packages.

This module mimics pulp_smash.tests.rpm.api_v2.test_signatures_checked_for_uploads, except that packages are primarily copied into repositories, instead of being uploaded.

Note

Pulp’s signature checking logic is subtle. Please read pulp_smash.tests.rpm.api_v2.test_signatures_checked_for_uploads.

class pulp_smash.tests.rpm.api_v2.test_signatures_checked_for_copies.AllowAnyKeyTestCase(methodName='runTest')

Use an importer that allows unsigned packages and has no key IDs.

The importer should have the following pseudocode configuration:

{"require_signature": false, "allowed_keys": []}
test_signed_packages()

Copy signed packages into a repository.

Assert packages are copied in.

test_unsigned_packages()

Copy unsigned packages into a repository.

Assert packages are copied in.

class pulp_smash.tests.rpm.api_v2.test_signatures_checked_for_copies.AllowInvalidKeyTestCase(methodName='runTest')

Use an importer that allows unsigned packages and has an invalid key ID.

The importer should have the following pseudocode configuration:

{"require_signature": false, "allowed_keys": ["invalid key id"]}
test_signed_packages()

Copy signed packages into a repository.

Assert no packages are copied in.

test_unsigned_packages()

Copy unsigned packages into a repository.

Assert packages are copied in.

class pulp_smash.tests.rpm.api_v2.test_signatures_checked_for_copies.AllowValidKeyTestCase(methodName='runTest')

Use an importer that allows unsigned packages and has a valid key ID.

The importer should have the following pseudocode configuration:

{"require_signature": false, "allowed_keys": ["valid key id"]}

Note

Pulp’s signature checking logic is subtle. Please read pulp_smash.tests.rpm.api_v2.test_signatures_checked_for_uploads.

test_signed_packages()

Copy signed packages into a repository.

Assert packages are copied in.

test_unsigned_packages()

Copy unsigned packages into a repository.

Assert packages are copied in.

class pulp_smash.tests.rpm.api_v2.test_signatures_checked_for_copies.RequireAnyKeyTestCase(methodName='runTest')

Use an importer that requires signatures and has no key IDs.

The importer should have the following pseudocode configuration:

{"require_signature": true, "allowed_keys": []}
test_signed_packages()

Copy signed packages into a repository.

Assert packages are copied in.

test_unsigned_packages()

Copy unsigned packages into a repository.

Assert no packages are copied in.

class pulp_smash.tests.rpm.api_v2.test_signatures_checked_for_copies.RequireInvalidKeyTestCase(methodName='runTest')

Use an importer that requires signatures and has an invalid key ID.

The importer should have the following pseudocode configuration:

{"require_signature": true, "allowed_keys": ["invalid key id"]}
test_signed_packages()

Copy signed packages into a repository.

Assert no packages are copied in.

test_unsigned_packages()

Copy unsigned packages into a repository.

Assert no packages are copied in.

class pulp_smash.tests.rpm.api_v2.test_signatures_checked_for_copies.RequireValidKeyTestCase(methodName='runTest')

Use an importer that requires signatures and has a valid key ID.

The importer should have the following pseudocode configuration:

{"require_signature": true, "allowed_keys": ["valid key id"]}
test_signed_packages()

Copy signed packages into a repository.

Assert packages are copied in.

test_unsigned_packages()

Copy unsigned packages into a repository.

Assert no packages are copied in.

pulp_smash.tests.rpm.api_v2.test_signatures_checked_for_copies.setUpModule()

Conditionally skip tests. Create repositories with fixture data.

pulp_smash.tests.rpm.api_v2.test_signatures_checked_for_copies.tearDownModule()

Delete repositories with fixture data.

pulp_smash.tests.rpm.api_v2.test_signatures_checked_for_syncs

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.api_v2.test_signatures_checked_for_syncs

Tests for repository signature checks when syncing packages.

This module mimics pulp_smash.tests.rpm.api_v2.test_signatures_checked_for_uploads, except that packages are synced in to Pulp instead of being uploaded.

Note

Pulp’s signature checking logic is subtle. Please read pulp_smash.tests.rpm.api_v2.test_signatures_checked_for_uploads.

class pulp_smash.tests.rpm.api_v2.test_signatures_checked_for_syncs.AllowAnyKeyTestCase(methodName='runTest')

Use an importer that allows unsigned packages and has no key IDs.

The importer should have the following pseudocode configuration:

{"require_signature": false, "allowed_keys": []}
test_signed_drpm()

Sync signed DRPMs into the repository.

Assert packages are synced in.

test_signed_rpm()

Sync signed RPMs into the repository.

Assert packages are synced in.

test_signed_srpm()

Sync signed SRPMs into the repository.

Assert packages are synced in.

test_unsigned_drpms()

Import unsigned DRPMs into a repository.

Verify packages are synced.

test_unsigned_rpms()

Import unsigned RPMs into a repository.

Verify packages are synced.

test_unsigned_srpms()

Import unsigned SRPMs into a repository.

Verify packages are synced.

class pulp_smash.tests.rpm.api_v2.test_signatures_checked_for_syncs.AllowInvalidKeyTestCase(methodName='runTest')

Use an importer that allows unsigned packages and has an invalid key ID.

The importer should have the following pseudocode configuration:

{"require_signature": false, "allowed_keys": ["invalid key id"]}
test_signed_packages()

Import signed RPMs, DRPMs and SRPMs into repositories.

Assert no packages are synced.

test_unsigned_drpms()

Import unsigned DRPMs into a repository.

Assert packages are synced.

test_unsigned_rpms()

Import unsigned RPMs into a repository.

Assert packages are synced.

test_unsigned_srpms()

Import unsigned SRPMs into a repository.

Assert packages are synced.

class pulp_smash.tests.rpm.api_v2.test_signatures_checked_for_syncs.AllowValidKeyTestCase(methodName='runTest')

Use an importer that allows unsigned packages and has a valid key ID.

The importer should have the following pseudocode configuration:

{"require_signature": false, "allowed_keys": ["valid key id"]}

Note

Pulp’s signature checking logic is subtle. Please read pulp_smash.tests.rpm.api_v2.test_signatures_checked_for_uploads.

test_signed_drpm()

Sync signed DRPMs into the repository.

Assert packages are synced in.

test_signed_rpm()

Sync signed RPMs into the repository.

Assert packages are synced in.

test_signed_srpm()

Sync signed SRPMs into the repository.

Assert packages are synced in.

test_unsigned_drpms()

Import unsigned DRPMs into a repository.

Assert packages are synced.

test_unsigned_rpms()

Import unsigned RPMs into a repository.

Assert packages are synced.

test_unsigned_srpms()

Import unsigned SRPMs into a repository.

Assert packages are synced.

class pulp_smash.tests.rpm.api_v2.test_signatures_checked_for_syncs.RequireAnyKeyTestCase(methodName='runTest')

Use an importer that requires signatures and has no key IDs.

The importer should have the following pseudocode configuration:

{"require_signature": true, "allowed_keys": []}
test_signed_drpm()

Sync signed DRPMs into the repository.

Assert packages are synced in.

test_signed_rpm()

Sync signed RPMs into the repository.

Assert packages are synced in.

test_signed_srpm()

Sync signed SRPMs into the repository.

Assert packages are synced in.

test_unsigned_packages()

Sync unsigned RPMs, DRPMs and SRPMS into repositories.

Assert no packages are synced in.

class pulp_smash.tests.rpm.api_v2.test_signatures_checked_for_syncs.RequireInvalidKeyTestCase(methodName='runTest')

Use an importer that requires signatures and has an invalid key ID.

The importer should have the following pseudocode configuration:

{"require_signature": true, "allowed_keys": ["invalid key id"]}
test_packages()

Sync signed and unsigned RPMs, DRPMs and SRPMs into repositories.

Assert no packages are synced in.

class pulp_smash.tests.rpm.api_v2.test_signatures_checked_for_syncs.RequireValidKeyTestCase(methodName='runTest')

Use an importer that requires signatures and has a valid key ID.

The importer should have the following pseudocode configuration:

{"require_signature": true, "allowed_keys": ["valid key id"]}
test_signed_drpm()

Sync signed DRPMs into the repository.

Assert packages are synced in.

test_signed_rpm()

Sync signed RPMs into the repository.

Assert packages are synced in.

test_signed_srpm()

Sync signed SRPMs into the repository.

Assert packages are synced in.

test_unsigned_packages()

Sync unsigned RPMs, DRPMs and SRPMS into repositories.

Assert no packages are synced in.

pulp_smash.tests.rpm.api_v2.test_signatures_checked_for_syncs.setUpModule()

Conditionally skip tests.

pulp_smash.tests.rpm.api_v2.test_signatures_checked_for_syncs.tearDownModule()

Delete orphan content units.

pulp_smash.tests.rpm.api_v2.test_signatures_checked_for_uploads

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.api_v2.test_signatures_checked_for_uploads

Tests for repository importer signature checks.

As of Pulp 2.10, it’s possible to configure an RPM repository importer to perform checks on all synced-in and uploaded packages. Two new importer options are available:

require_signature
A boolean. If true, imported packages must be signed with a key listed in allowed_keys.
allowed_keys
A list of 32-bit key IDs, as hex characters. (e.g. ["deadbeef"]) An empty list is treated as the list of all possible key IDs.

Beware that if a package has a signature, its signature must be listed in allowed_keys, even when require_signature is false. The only importer configuration that allows all packages is {'require_signature': False, 'allowed_keys': []}.

To test this feature, importers with at least the following options should be created:

{'require_signature': False, 'allowed_keys': ['invalid key id']}
{'require_signature': False, 'allowed_keys': ['valid key id']}
{'require_signature': False, 'allowed_keys': []}
{'require_signature': True, 'allowed_keys': ['invalid key id']}
{'require_signature': True, 'allowed_keys': ['valid key id']}
{'require_signature': True, 'allowed_keys': []}

In addition, at least the following types of packages should be imported:

* Signed DRPMs
* Signed RPMs
* Signed SRPMs
* Unsigned DRPMs
* Unsigned RPMs
* Unsigned SRPMs

Finally, importer options may be changed in some circumstances, and Pulp should gracefully handle those changes.

For more information, see Pulp #1991 and Pulp Smash #347.

class pulp_smash.tests.rpm.api_v2.test_signatures_checked_for_uploads.AllowAnyKeyTestCase(methodName='runTest')

Use an importer that allows unsigned packages and has no key IDs.

The importer should have the following pseudocode configuration:

{"require_signature": false, "allowed_keys": []}
classmethod setUpClass()

Create a repository with an importer.

test_all_packages()

Import signed and unsigned DRPM, RPM & SRPM packages into the repo.

Verify that each import succeeds.

class pulp_smash.tests.rpm.api_v2.test_signatures_checked_for_uploads.AllowInvalidKeyTestCase(methodName='runTest')

Use an importer that allows unsigned packages and has an invalid key ID.

The importer should have the following pseudocode configuration:

{"require_signature": false, "allowed_keys": ["invalid key id"]}
classmethod setUpClass()

Create a repository with an importer.

test_signed_packages()

Import signed DRPM, RPM and SRPM packages into the repository.

Verify that each import fails.

test_unsigned_packages()

Import unsigned DRPM, RPM and SRPM packages into the repository.

Verify that each import succeeds.

class pulp_smash.tests.rpm.api_v2.test_signatures_checked_for_uploads.AllowValidKeyTestCase(methodName='runTest')

Use an importer that allows unsigned packages and has a valid key ID.

The importer should have the following pseudocode configuration:

{"require_signature": false, "allowed_keys": ["valid key id"]}
classmethod setUpClass()

Create a repository with an importer.

test_all_packages()

Import signed and unsigned DRPM, RPM & SRPM packages into the repo.

Verify that each import succeeds.

class pulp_smash.tests.rpm.api_v2.test_signatures_checked_for_uploads.KeyLengthTestCase(methodName='runTest')

Verify pulp rejects key IDs that are not 32-bits long.

An OpenPGP-compatible key ID (key fingerprint) is traditionally a 32-bit value. Newer OpenPGP key handling software allows for longer key IDs, and this is recommended, as it’s extremely easy to find colliding key IDs. [1] However, Pulp allows only the short key IDs.

[1]https://evil32.com/
test_key_ids()

Create importers with key IDs shorter and longer than 32 bits.

Pulp should prevent the importers from being created.

class pulp_smash.tests.rpm.api_v2.test_signatures_checked_for_uploads.RequireAnyKeyTestCase(methodName='runTest')

Use an importer that requires signatures and has no key IDs.

The importer should have the following pseudocode configuration:

{"require_signature": true, "allowed_keys": []}
classmethod setUpClass()

Create a repository with an importer.

test_signed_packages()

Import signed DRPM, RPM and SRPM packages into the repo.

Verify that each import succeeds.

test_unsigned_packages()

Import unsigned DRPM, RPM and SRPM packages into the repo.

Verify that each import fails.

class pulp_smash.tests.rpm.api_v2.test_signatures_checked_for_uploads.RequireInvalidKeyTestCase(methodName='runTest')

Use an importer that requires signatures and has an invalid key ID.

The importer should have the following pseudocode configuration:

{"require_signature": true, "allowed_keys": ["invalid key id"]}
classmethod setUpClass()

Create a repository with an importer.

test_all_packages()

Import signed and unsigned DRPM, RPM & SRPM packages into the repo.

Verify that each import fails.

class pulp_smash.tests.rpm.api_v2.test_signatures_checked_for_uploads.RequireValidKeyTestCase(methodName='runTest')

Use an importer that requires signatures and has a valid key ID.

The importer should have the following pseudocode configuration:

{"require_signature": true, "allowed_keys": ["valid key id"]}
classmethod setUpClass()

Create a repository with an importer.

test_signed_packages()

Import signed DRPM, RPM and SRPM packages into the repository.

Verify that each import succeeds.

test_unsigned_packages()

Import unsigned DRPM, RPM and SRPM packages into the repository.

Verify that each import fails.

pulp_smash.tests.rpm.api_v2.test_signatures_checked_for_uploads.setUpModule()

Conditionally skip tests. Cache packages to be uploaded to repos.

Skip the tests in this module if:

  • The RPM plugin is unsupported.
  • Pulp #1991 is untestable for the version of Pulp under test.
pulp_smash.tests.rpm.api_v2.test_signatures_checked_for_uploads.tearDownModule()

Delete the cached set of packages to be uploaded to repos.

pulp_smash.tests.rpm.api_v2.test_signatures_saved_for_packages

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.api_v2.test_signatures_saved_for_packages

Tests for how well Pulp can deal with package signatures.

When a package is added to an RPM repository, its signature should be stored by Pulp. This is true regardless of whether the package is an RPM, DRPM or SRPM.

Tests for this feature include the following:

For more information, see:

class pulp_smash.tests.rpm.api_v2.test_signatures_saved_for_packages.SyncPackageTestCase(methodName='runTest')

Test if Pulp saves signatures from synced-in packages.

test_signed_drpm()

Assert signature is stored for signed drpm during sync.

test_signed_rpm()

Assert signature is stored for signed rpm during sync.

test_signed_srpm()

Assert signature is stored for signed srpm during sync.

test_unsigned_drpm()

Assert no signature is stored for unsigned drpm during sync.

test_unsigned_rpm()

Assert no signature is stored for unsigned rpm during sync.

test_unsigned_srpm()

Assert no signature is stored for unsigned srpm during sync.

class pulp_smash.tests.rpm.api_v2.test_signatures_saved_for_packages.UploadPackageTestCase(methodName='runTest')

Test if Pulp saves signatures from uploaded packages.

test_signed_drpm()

Import a signed DRPM into Pulp. Verify its signature.

test_signed_rpm()

Import a signed RPM into Pulp. Verify its signature.

test_signed_srpm()

Import a signed SRPM into Pulp. Verify its signature.

test_unsigned_drpm()

Import an unsigned DRPM into Pulp. Verify it has no signature.

test_unsigned_rpm()

Import an unsigned RPM into Pulp. Veriy it has no signature.

test_unsigned_srpm()

Import an unsigned SRPM into Pulp. Verify it has no signature.

pulp_smash.tests.rpm.api_v2.test_sync_publish

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.api_v2.test_sync_publish

Tests that sync and publish RPM repositories.

For information on repository sync and publish operations, see Synchronization and Publication.

class pulp_smash.tests.rpm.api_v2.test_sync_publish.ChangeFeedTestCase(methodName='runTest')

Sync a repository, change its feed, and sync it again.

Specifically, the test case procedure is as follows:

  1. Create three repositories — call them A, B and C.
  2. Populate repository A and B with identical content, and publish them.
  3. Set C’s feed to repository A. Sync and publish repository C.
  4. Set C’s feed to repository B. Sync and publish repository C.
  5. Download an RPM from repository C.

The entire procedure should succeed. This test case targets Pulp #1922.

create_sync_publish_repo(body)

Create, sync and publish a repository.

Also, schedule the repository for deletion.

Parameters:body – A dict of information to use when creating the repository.
Returns:A detailed dict of information about the repository.
get_feed(repo)

Build the feed to an RPM repository’s distributor.

test_all()

Sync a repository, change its feed, and sync it again.

class pulp_smash.tests.rpm.api_v2.test_sync_publish.SyncDrpmRepoTestCase(methodName='runTest')

Test one can create and sync an RPM repository with an DRPM feed.

static get_feed_url()

Return an DRPM repository feed URL.

class pulp_smash.tests.rpm.api_v2.test_sync_publish.SyncInvalidFeedTestCase(methodName='runTest')

Create and sync an RPM repository with an invalid feed.

The sync should complete with errors reported.

classmethod setUpClass()

Create class-wide variables.

test_01_set_up()

Create and sync an RPM repository with an invalid feed.

test_02_task_error()

Assert each task’s “error” field is non-null.

Also, assert each error has a useful “description” field. For each error that is present, its “description” field should not be the (vague) string “Unsupported scheme: ”. This test targets Pulp #1376.

test_02_task_traceback()

Assert each task’s “traceback” field is non-null.

class pulp_smash.tests.rpm.api_v2.test_sync_publish.SyncInvalidMetadataTestCase(methodName='runTest')

Sync various repositories with invalid metadata.

When a repository with invalid metadata is encountered, Pulp should gracefully fail. This test case targets Pulp #1287.

do_test(feed_url)

Implement the logic described by each of the test* methods.

classmethod tearDownClass()

Delete orphan content units.

test_incomplete_filelists()

Sync a repository with an incomplete filelists.xml file.

test_incomplete_other()

Sync a repository with an incomplete other.xml file.

test_missing_filelists()

Sync a repository that’s missing its filelists.xml file.

test_missing_other()

Sync a repository that’s missing its other.xml file.

test_missing_primary()

Sync a repository that’s missing its primary.xml file.

class pulp_smash.tests.rpm.api_v2.test_sync_publish.SyncRepoBaseTestCase(methodName='runTest')

A parent class for repository syncronization test cases.

get_feed_url() should be overridden by concrete child classes. This method’s response is used when setting the repository’s importer feed URL.

static get_feed_url()

Return an RPM repository feed URL. Should be overridden.

Raises:NotImplementedError if not overridden by a child class.
classmethod setUpClass()

Create an RPM repository with a valid feed and sync it.

test_start_sync_code()

Assert the call to sync a repository returns an HTTP 202.

test_task_progress_report()

Assert no task’s progress report contains error details.

Other assertions about the final state of each task are handled by the client’s response handler. (For more information, see the source of pulp_smash.api.safe_handler().)

class pulp_smash.tests.rpm.api_v2.test_sync_publish.SyncRpmRepoTestCase(methodName='runTest')

Test one can create and sync an RPM repository with an RPM feed.

static get_feed_url()

Return an RPM repository feed URL.

test_no_change_in_second_sync()

Verify that syncing a second time has no changes.

If the repository have not changed then Pulp must state that anything was changed when doing a second sync.

test_unit_count_on_repo()

Verify that the sync added the correct number of units to the repo.

Read the repository and examine its content_unit_counts attribute. Compare these attributes to metadata from the remote repository. Expected values are currently hard-coded into this test.

class pulp_smash.tests.rpm.api_v2.test_sync_publish.SyncSrpmRepoTestCase(methodName='runTest')

Test one can create and sync an RPM repository with an SRPM feed.

static get_feed_url()

Return an SRPM repository feed URL.

pulp_smash.tests.rpm.api_v2.test_unassociate

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.api_v2.test_unassociate

Test Unassociating Content Units from a Repository for RPM.

This module assumes that the tests in pulp_smash.tests.platform.api_v2.test_repository and pulp_smash.tests.rpm.api_v2.test_sync_publish hold true.

class pulp_smash.tests.rpm.api_v2.test_unassociate.RemoveUnitsTestCase(methodName='runTest')

Remove units of various types from a synced RPM repository.

At a high level, this test case does the following:

  1. Create and sync an RPM repository.
  2. For each of several different types of content, remove a content unit of that type from the repository.
do_remove_unit(type_id)

Remove a content unit from the repository.

Do the following:

  1. Note the repository’s last_unit_removed field.
  2. Sleep for at least one second.
  3. Remove a unit of type type_id from the repository.
  4. Note the repository’s last_unit_removed field.

When the first unit is removed, assert that last_unit_removed changes from null to a non-null value. When each subsequent unit is removed, assert that last_unit_removed increments.

get_repo_last_unit_removed()

Get the repository’s last_unit_removed attribute.

classmethod setUpClass()

Create and sync a repository.

classmethod tearDownClass()

Remove the created repository and any orphans.

test_01_remove_units()

Remove several types of content units from the repository.

Each removal is wrapped in a subTest. See do_remove_unit().

test_02_remaining_units()

Assert the correct units are still in the repository.

The repository should have all the units that were originally synced into the repository, minus those that have been removed.

class pulp_smash.tests.rpm.api_v2.test_unassociate.RepublishTestCase(methodName='runTest')

Repeatedly publish a repository, with different content each time.

Specifically, do the following:

  1. Create a repository.
  2. Add a content unit to the repository. Publish the repository.
  3. Unassociate the content unit and repository. Publish the repository.

Verify that:

  • The last_unit_added, last_unit_removed and last_publish timestamps are correct.
  • The content unit in question is only available when associated with the repository.
get_repo()

Get detailed information about the repository.

classmethod setUpClass()

Create a repository.

classmethod tearDownClass()

Remove the created repository and any orphans.

test_01_add_unit()

Add a content unit to the repository. Publish the repository.

test_02_find_unit()

Search for the content unit. Assert it is available.

test_03_unassociate_unit()

Unassociate the unit from the repository. Publish the repository.

test_04_find_unit()

Search for the content unit. Assert it isn’t available.

class pulp_smash.tests.rpm.api_v2.test_unassociate.SelectiveAssociateTestCase(methodName='runTest')

Ensure Pulp only associate needed content.

Test steps:

  1. Create and sync an RPM repository.
  2. Unassociate some RPMs from the repository created on the previous step.
  3. Sync the repository again and check if only the missing units were associated.

See Pulp #2457

test_all()

Check if Pulp only associate missing repo content.

pulp_smash.tests.rpm.api_v2.test_unassociate.setUpModule()

Maybe skip this module of tests.

pulp_smash.tests.rpm.api_v2.test_updateinfo

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.api_v2.test_updateinfo

Test the updateinfo.xml files published by Pulp’s yum distributor.

The purpose of an updateinfo.xml file is to document the errata (i.e. maintenance patches) provided by a repository. For an overview of the structure and contents of such a file, see openSUSE:Standards Rpm Metadata UpdateInfo. Beware that yum and dnf do not adhere to the openSUSE standards. We link to their standard anyway because it’s easier to understand than yum or dnf’s source code. (!)

One discrepancy is in the schema for the <pkglist> element. According to the yum source code, it has the following structure:

<!ELEMENT pkglist (collection+)>
<!ELEMENT collection (name?, package+)>
    <!ATTLIST collection short CDATA #IMPLIED>
    <!ATTLIST collection name CDATA #IMPLIED>
<!ELEMENT name (#PCDATA)>

Here’s a concrete example of what that might look like:

<pkglist>
    <collection name="…" short="…">
        <name></name>
        <package></package>
        <package></package>
    </collection>
</pkglist>

yum (and, therefore, dnf) allows a <collection> element to have “name” and “short” attributes. openSUSE does not.

class pulp_smash.tests.rpm.api_v2.test_updateinfo.CleanUpTestCase(methodName='runTest')

Test whether old updateinfo.xml files are cleaned up.

Do the following:

  1. Create, populate and publish a repository. Verify that an updateinfo.xml file is present and can be downloaded.
  2. Add an additional content unit to the repository, and publish it again. Verify that the updateinfo.xml file created by the first publish is no longer available, and that a new updateinfo.xml file is available.

This procedure targets Pulp #2096. Note that the second publish must be an incremental publish.

get_updateinfo_xml_href()

Return the path to the updateinfo.xml file.

classmethod setUpClass()

Create and sync a repository.

classmethod tearDownClass()

Remove the created repository and any orphans.

test_01_first_publish()

Populate and publish the repository.

test_02_second_publish()

Add an additional content unit and publish the repository again.

class pulp_smash.tests.rpm.api_v2.test_updateinfo.PkglistsTestCase(methodName='runTest')

Sync a repository whose updateinfo file has multiple pkglist sections.

This test case targets Pulp #2227.

test_all()

Sync a repo whose updateinfo file has multiple pkglist sections.

Specifically, do the following:

  1. Create, sync and publish an RPM repository whose feed is set to pulp_smash.constants.RPM_PKGLISTS_UPDATEINFO_FEED_URL.
  2. Fetch and parse the published repository’s updateinfo.xml file.

Verify that the updateinfo.xml file has three packages whose <filename> elements have the following text:

  • penguin-0.9.1-1.noarch.rpm
  • shark-0.1-1.noarch.rpm
  • walrus-5.21-1.noarch.rpm

Note that Pulp is free to change the structure of a source repository at will. For example, the source repository has three <collection> elements, the published repository can have one, two or three <collection> elements. Assertions are not made about these details.

class pulp_smash.tests.rpm.api_v2.test_updateinfo.UpdateInfoTestCase(methodName='runTest')

Tests to ensure updateinfo.xml can be created and is valid.

classmethod setUpClass()

Create, populate and publish a repository.

More specifically, do the following:

  1. Create an RPM repository with a distributor.
  2. Populate the repository with an RPM and two errata, where one erratum references the RPM, and the other does not.
  3. Publish the repository Fetch and parse its updateinfo.xml file.
test_erratum()

Assert the erratum generated by Pulp is correct.

Walk through each top-level element of the erratum which was generated during this test case’s set-up and uploaded to Pulp. For each element, verify that the updateinfo.xml file generated by Pulp has a corresponding entry. Each of the verify_* methods on this test case implement the test logic for a single element.

test_one_task_per_import()

Assert only one task is spawned per erratum upload.

test_reboot_not_suggested()

Assert the update info tree does not suggest a spurious reboot.

The errata uploaded by this test case do not suggest that a reboot be applied. As a result, the relevant <update> element in the updateinfo.xml file should not have a <reboot_suggested> tag. Verify that this is so. See Pulp #2032.

Note

In previous versions of Pulp, if no reboot should be applied, a <reboot_suggested>False</reboot_suggested> element would be present. See Pulp #1782.

test_tasks_result()

Assert each task’s result success flag (if present) is true.

This test assumes test_one_task_per_import() passes.

test_tasks_state()

Assert each task’s state is “finished”.

This test assumes test_one_task_per_import() passes.

test_update_elements()

Assert there is one “update” element in updateinfo.xml.

test_updates_element()

Assert updateinfo.xml has a root element named updates.

verify_description(erratum, update_element)

Verify erratum and update_element have same description.

verify_id(erratum, update_element)

Verify erratum and update_element have the same id.

verify_issued(erratum, update_element)

Verify erratum and update_element have the same issued.

verify_pkglist(erratum, update_element)

Verify erratum and update_element have the same pkglist.

verify_references(erratum, update_element)

Verify erratum and update_element have same references.

verify_solution(erratum, update_element)

Verify erratum and update_element have the same solution.

verify_status(erratum, update_element)

Verify erratum and update_element have the same status.

verify_title(erratum, update_element)

Verify erratum and update_element have the same title.

verify_type(erratum, update_element)

Verify erratum and update_element have the same type.

verify_version(erratum, update_element)

Verify erratum and update_element have the same version.

class pulp_smash.tests.rpm.api_v2.test_updateinfo.UpdateRepoTestCase(methodName='runTest')

Verify updateinfo.xml changes as its repo changes.

classmethod setUpClass()

Create an RPM repository with a feed and distributor.

test_01_sync_publish()

Sync and publish the repository.

When executed, this test method will fetch updateinfo.xml and verify that:

test_02_unassociate_publish()

Unassociate a content unit and publish the repository.

Fetch updateinfo.xml. Verify that an <update> with an <id> of pulp_smash.constants.RPM_ERRATUM_ID is not present.

pulp_smash.tests.rpm.api_v2.test_updateinfo.setUpModule()

Possibly skip the tests in this module.

Skip tests if Pulp #2277 affects us.

pulp_smash.tests.rpm.api_v2.test_upload_publish

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.api_v2.test_upload_publish

Tests that upload to and publish RPM repositories.

For information on repository upload and publish operations, see Uploading Content and Publication.

class pulp_smash.tests.rpm.api_v2.test_upload_publish.UploadDrpmTestCase(methodName='runTest')

Test whether one can upload a DRPM into a repository.

This test case targets Pulp Smash #336

classmethod setUpClass()

Import a DRPM into a repository and search it for content units.

Specifically, this method does the following:

  1. Create a yum repository.
  2. Upload a DRPM into the repository.
  3. Search for all content units in the repository.
test_drpm_file_name_is_correct()

Test if DRPM extracted correct metadata for creating filename.

test_drpm_uploaded_successfully()

Test if DRPM has been uploaded successfully.

test_status_code_units()

Verify the HTTP status code for repo units response.

class pulp_smash.tests.rpm.api_v2.test_upload_publish.UploadRpmTestCase(methodName='runTest')

Test whether one can upload, associate and publish RPMs.

The test procedure is as follows:

  1. Create a pair of repositories.
  2. Upload an RPM to the first repository, and publish it.
  3. Copy the RPM to the second repository, and publish it.
classmethod setUpClass()

Create a pair of RPM repositories.

classmethod tearDownClass()

Clean up resources created during the test.

test_01_upload_publish()

Upload an RPM to the first repository, and publish it.

Execute verify_repo_search() and verify_repo_download().

test_02_copy_publish()

Copy and RPM from the first repo to the second, and publish it.

Execute verify_repo_search() and verify_repo_download().

test_03_compare_repos()

Verify the two repositories contain the same content unit.

verify_repo_download(repo)

Download pulp_smash.constants.RPM from the given repo.

Verify that it is exactly equal to the one uploaded earlier.

Search for units in the given repo.

Verify that only one content unit is in repo, and that several of its metadata attributes are correct. This test targets Pulp #2365.

class pulp_smash.tests.rpm.api_v2.test_upload_publish.UploadSrpmTestCase(methodName='runTest')

Test whether one can upload a SRPM into a repository.

This test case targets Pulp Smash #402

classmethod setUpClass()

Import a SRPM into a repository and search it for content units.

Specifically, this method does the following:

  1. Create a yum repository.
  2. Upload a SRPM into the repository.
  3. Search for all content units in the repository.
test_srpm_file_name_is_correct()

Test if SRPM extracted correct metadata for creating filename.

test_srpm_uploaded_successfully()

Test if SRPM has been uploaded successfully.

test_status_code_units()

Verify the HTTP status code for repo units response.

pulp_smash.tests.rpm.api_v2.utils

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.api_v2.utils

Utility functions for RPM API tests.

class pulp_smash.tests.rpm.api_v2.utils.DisableSELinuxMixin

A mixin providing the ability to temporarily disable SELinux.

maybe_disable_selinux(cfg, pulp_issue_id)

Disable SELinux if appropriate.

If the given Pulp issue is unresolved, and if SELinux is installed and enforcing on the target Pulp system, then disable SELinux and schedule it to be re-enabled. (Method addCleanup is used for the schedule.)

Parameters:
  • cfg (pulp_smash.config.PulpSmashConfig) – Information about the Pulp deployment being targeted.
  • pulp_issue_id – The (integer) ID of a Pulp issue. If the referenced issue is fixed in the Pulp system under test, this method immediately returns.
Returns:

Nothing.

class pulp_smash.tests.rpm.api_v2.utils.TemporaryUserMixin

A mixin providing the ability to create a temporary user.

A typical usage of this mixin is as follows:

ssh_user, priv_key = self.make_user(cfg)
ssh_identity_file = self.write_private_key(cfg, priv_key)

This mixin requires that the unittest.TestCase class from the standard library be a parent class.

static delete_user(cfg, username)

Delete a user.

The Pulp rsync distributor has a habit of leaving (idle?) SSH sessions open even after publishing a repository. When executed, this function will:

  1. Poll the process list until all processes belonging to username have died, or raise a unittest.SkipTest exception if the time limit is exceeded.
  2. Delete username.
make_user(cfg)

Create a user account with a home directory and an SSH keypair.

In addition, schedule the user for deletion with self.addCleanup.

Parameters:cfg (pulp_smash.config.PulpSmashConfig) – Information about the host being targeted.
Returns:A (username, private_key) tuple.
write_private_key(cfg, private_key)

Write the given private key to a file on disk.

Ensure that the file is owned by user “apache” and has permissions of 600. In addition, schedule the key for deletion with self.addCleanup.

Parameters:cfg (pulp_smash.config.PulpSmashConfig) – Information about the host being targeted.
Returns:The path to the private key on disk, as a string.
pulp_smash.tests.rpm.api_v2.utils.gen_distributor()

Return a semi-random dict for use in creating a YUM distributor.

pulp_smash.tests.rpm.api_v2.utils.gen_repo()

Return a semi-random dict for use in creating an RPM repository.

pulp_smash.tests.rpm.api_v2.utils.gen_repo_group()

Return a semi-random dict for use in creating a RPM repository group.

pulp_smash.tests.rpm.api_v2.utils.get_dists_by_type_id(cfg, repo)

Return the named repository’s distributors, keyed by their type IDs.

Parameters:
Returns:

A dict in the form {'type_id': {distributor_info}}.

pulp_smash.tests.rpm.api_v2.utils.get_repodata(cfg, distributor, type_, response_handler=None, repomd_xml=None)

Download a file of the given type_ from a repodata/ directory.

Parameters:
Returns:

Whatever is dictated by response_handler.

pulp_smash.tests.rpm.api_v2.utils.get_repodata_repomd_xml(cfg, distributor, response_handler=None)

Download the given repository’s repodata/repomd.xml file.

Parameters:
Returns:

Whatever is dictated by response_handler.

pulp_smash.tests.rpm.api_v2.utils.get_unit(cfg, distributor, unit_name, primary_xml=None)

Download a file from a published repository.

A typical invocation is as follows:

>>> foo_rpm = get_unit(cfg, repo['distributors'][0], 'foo.rpm')

If multiple units are being fetched, efficiency can be improved by passing in a parsed primary.xml file:

>>> distributor = repo['distributors'][0]
>>> primary_xml = get_repodata(cfg, distributor, 'primary')
>>> foo_rpm = get_unit(cfg, distributor, 'foo.rpm', primary_xml)
>>> bar_rpm = get_unit(cfg, distributor, 'bar.rpm', primary_xml)
Parameters:
  • cfg (pulp_smash.config.PulpSmashConfig) – Information about a Pulp host.
  • distributor – A dict of information about a repository distributor.
  • unit_name – The name of a content unit to be fetched. For example: “bear-4.1-1.noarch.rpm”.
  • primary_xml – A primary.xml file as an ElementTree. If not given, get_repodata() is consulted.
Returns:

A raw response. The unit is available as response.content.

pulp_smash.tests.rpm.api_v2.utils.set_pulp_manage_rsync(cfg, boolean)

Set the pulp_manage_rsync SELinux policy.

If the semanage executable is not available, return. (This is the case if SELinux isn’t installed on the system under test.) Otherwise, set the pulp_manage_rsync SELinux policy on or off, depending on the truthiness of ``boolean.

For more information on the pulp_manage_rsync SELinux policy, see ISO rsync Distributor → Configuration.

Parameters:
Returns:

Information about the executed command, or None if no command was executed.

Return type:

pulp_smash.cli.CompletedProcess

pulp_smash.tests.rpm.api_v2.utils.xml_handler(_, response)

Decode a response as if it is XML.

This API response handler is useful for fetching XML files made available by an RPM repository. When it handles a response, it will check the status code of response, decompress the response if the request URL ended in .gz, and return an xml.etree.Element instance built from the response body.

Note:

  • The entire response XML is loaded and parsed before returning, so this may be unsafe for use with large XML files.
  • The Content-Type and Content-Encoding response headers are ignored due to https://pulp.plan.io/issues/1781.

pulp_smash.tests.rpm.cli

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.cli

Tests that communicate with the server via the CLI.

pulp_smash.tests.rpm.cli.test_character_encoding

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.cli.test_character_encoding

Tests for Pulp’s character encoding handling.

RPM files have metadata embedded in their headers. This metadata should be encoded as utf-8, and Pulp should gracefully handle cases where invalid byte sequences are encountered.

class pulp_smash.tests.rpm.cli.test_character_encoding.UploadNonAsciiTestCase(methodName='runTest')

Test whether one can upload an RPM with non-ascii metadata.

Specifically, do the following:

  1. Create an RPM repository.
  2. Upload and import pulp_smash.constants.RPM_WITH_NON_ASCII_URL into the repository.
test_all()

Test whether one can upload an RPM with non-ascii metadata.

class pulp_smash.tests.rpm.cli.test_character_encoding.UploadNonUtf8TestCase(methodName='runTest')

Test whether one can upload an RPM with non-utf-8 metadata.

Specifically, do the following:

  1. Create an RPM repository.
  2. Upload and import pulp_smash.constants.RPM_WITH_NON_UTF_8_URL into the repository.

This test case targets Pulp #1903.

test_all()

Test whether one can upload an RPM with non-utf-8 metadata.

pulp_smash.tests.rpm.cli.test_character_encoding.setUpModule()

Execute pulp-admin login.

pulp_smash.tests.rpm.cli.test_copy_units

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.cli.test_copy_units

Tests that copy units from one repository to another.

class pulp_smash.tests.rpm.cli.test_copy_units.CopyLangpacksTestCase(methodName='runTest')

Copy langpacks from one repository to another.

This test case verifies that it is possible to use the pulp-admin rpm repo copy langpacks command to copy langpacks from one repository to another. See Pulp Smash #255.

test_all()

Copy langpacks from one repository to another.

Assert that:

  • pulp-admin does not produce any errors.
  • A non-zero number of langpacks are present in the target repository.
class pulp_smash.tests.rpm.cli.test_copy_units.CopyRecursiveTestCase(methodName='runTest')

Recursively copy a “chimpanzee” unit from one repository to another.

This test case verifies that it is possible to use the pulp-admin rpm repo copy command to recursively copy units from one repository to another. See Pulp Smash #107.

test_all()

Recursively copy a “chimpanzee” unit from one repository to another.

“chimpanzee” depends on “walrus,” and there are multiple versions of “walrus” in the source repository. Verify that one “walrus” unit has been copied to the target repository, and that the newer one has been copied.

class pulp_smash.tests.rpm.cli.test_copy_units.CopyTestCase(methodName='runTest')

Copy a “chimpanzee” unit from one repository to another.

This test case verifies that it is possible to use the pulp-admin rpm repo copy command to copy a single unit from one repository to another.

test_all()

Copy a “chimpanzee” unit from one repository to another.

Verify that only the “chimpanzee” unit is in the target repository.

class pulp_smash.tests.rpm.cli.test_copy_units.UpdateRpmTestCase(methodName='runTest')

Update an RPM in a repository and on a host.

Do the following:

  1. Create two repositories. Populate the first, and leave the second empty.
  2. Pick an RPM with at least two versions.
  3. Copy the older version of the RPM from the first repository to the second, and publish the second repository.
  4. Pick a host system capable of installing RPMs. (By default, this is the system hosting Pulp.) Make it add the second repository as a source of packages, and make it install the RPM.
  5. Copy the newer version of the RPM from the first repository to the second, and publish the second repository.
  6. Make the host install the newer RPM with yum update rpm_name, or a similar command.

This test case targets Pulp Smash #311.

test_all()

Update an RPM in a repository and on a host.

class pulp_smash.tests.rpm.cli.test_copy_units.UtilsMixin

A mixin providing useful tools to unittest subclasses.

Any class inheriting from this mixin must also inherit from unittest.TestCase or a compatible clone.

create_repo(cfg)

Create a repository and schedule it for deletion.

Parameters:cfg (pulp_smash.config.PulpSmashConfig) – The Pulp system on which to create a repository.
Returns:The repository’s ID.
pulp_smash.tests.rpm.cli.test_copy_units.gen_yum_config_file(cfg, repositoryid, **kwargs)

Generate a yum configuration file and write it to /etc/yum.repos.d/.

Generate a yum configuration file containing a single repository section, and write it to /etc/yum.repos.d/{repositoryid}.repo.

Parameters:
  • cfg (pulp_smash.config.PulpSmashConfig) – The system on which to create a yum configuration file.
  • repositoryid – The section’s repositoryid. Used when naming the configuration file and populating the brackets at the head of the file. For details, see yum.conf(5).
  • kwargs – Section options. Each kwarg corresponds to one option. For details, see yum.conf(5).
Returns:

The path to the yum configuration file.

pulp_smash.tests.rpm.cli.test_copy_units.setUpModule()

Possibly skip tests. Create and sync an RPM repository.

Skip tests in this module if the RPM plugin is not installed on the target Pulp server. Then create an RPM repository with a feed and sync it. Test cases may copy data from this repository but should not change it.

pulp_smash.tests.rpm.cli.test_copy_units.tearDownModule()

Delete the repository created by setUpModule.

pulp_smash.tests.rpm.cli.test_environments

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.cli.test_environments

Tests for RPM package environments.

class pulp_smash.tests.rpm.cli.test_environments.UploadPackageEnvTestCase(methodName='runTest')

Test whether Pulp can upload package environments into a repository.

This test case covers Pulp #1003 and the corresponding Pulp Smash issue Pulp Smash #319. The following test steps are based on official Pulp RPM Recipes.

  1. Create and sync a repository.
  2. Upload the environmrnt into this repo and check if there’s any error.
classmethod setUpClass()

Create and sync a repository.

classmethod tearDownClass()

Destroy the repository.

test_upload_environment()

Test if package environments can be uploaded.

pulp_smash.tests.rpm.cli.test_langpacks

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.cli.test_langpacks

Tests for Pulp’s langpack support.

class pulp_smash.tests.rpm.cli.test_langpacks.UploadAndRemoveLangpacksTestCase(methodName='runTest')

Test whether one can upload to and remove langpacks from a repository.

This test targets Pulp Smash #270. The test steps are as follows:

  1. Create a repository.
  2. Upload langpacks to the repository. Verify the correct number of langpacks are present.
  3. Remove langpacks from the repository. Verify that no langpacks are present.
classmethod setUpClass()

Create a repository.

classmethod tearDownClass()

Delete the repository created by setUpClass().

test_01_upload_langpacks()

Upload a langpack to the repository.

test_02_remove_langpacks()

Remove all langpacks from the repository.

pulp_smash.tests.rpm.cli.test_process_recycling

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.cli.test_process_recycling

Test Pulp’s ability to recycle processes.

class pulp_smash.tests.rpm.cli.test_process_recycling.MaxTasksPerChildTestCase(methodName='runTest')

Test Pulp’s handling of its PULP_MAX_TASKS_PER_CHILD setting.

The PULP_MAX_TASKS_PER_CHILD setting controls how many tasks a worker process executes before being destroyed. Setting this option to a low value, like 2, ensures that processes don’t have a chance to consume large amounts of memory.

Test this feature by doing the following:

  1. Use ps to see how Pulp worker processes were invoked. None should have the --maxtasksperchild option set.
  2. Set PULP_MAX_TASKS_PER_CHILD and restart Pulp. Use ps to see how Pulp worker processes were invoked. Each should have the --maxtasksperchild option set as appropriate.
  3. Execute a sync and publish. No errors should be reported.
  4. Reset the PULP_MAX_TASKS_PER_CHILD option and restart Pulp. ps to see how Pulp worker processes were invoked. Each should have the --maxtasksperchild option set as appropriate.

For more information, see Pulp #2172.

test_all()

Test Pulp’s handling of its PULP_MAX_TASKS_PER_CHILD setting.

pulp_smash.tests.rpm.cli.test_process_recycling.get_pulp_worker_procs(cfg)

Use ps aux to get information about each Pulp worker process.

Parameters:cfg (pulp_smash.config.PulpSmashConfig) – Information about the Pulp deployment being targeted.
Returns:An iterable of strings, one per line of matching output.
pulp_smash.tests.rpm.cli.test_process_recycling.restart_pulp(cfg)

Restart all of Pulp’s services.

Unlike pulp_smash.utils.reset_pulp(), do not reset the state of any of Pulp’s services.

Parameters:cfg (pulp_smash.config.PulpSmashConfig) – Information about the Pulp deployment being targeted.
pulp_smash.tests.rpm.cli.test_process_recycling.setUpModule()

Conditionally skip this module, and execute pulp-admin login.

pulp_smash.tests.rpm.cli.test_sync

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.cli.test_sync

Tests that sync RPM repositories.

class pulp_smash.tests.rpm.cli.test_sync.ForceSyncTestCase(methodName='runTest')

Test whether one can force Pulp to perform a full sync.

This test case targets Pulp #1982 and Pulp Smash #353. The test procedure is as follows:

  1. Create and sync a repository.
  2. Remove some number of RPMs from /var/lib/pulp/content/units/rpm/. Verify they are missing.
  3. Sync the repository. Verify the RPMs are still missing.
  4. Sync the repository with --force-full true. Verify all RPMs are present.
test_all()

Test whether one can force Pulp to perform a full sync.

class pulp_smash.tests.rpm.cli.test_sync.RemovedContentTestCase(methodName='runTest')

Test whether Pulp can re-sync content into a repository.

This test case targets Pulp #1775 and the corresponding Pulp Smash issue, Pulp Smash #243.

  1. Create and sync a repository. Select a content unit.
  2. Delete the content unit from the repository, and verify it’s absent.
  3. Sync the repository, and verify that the content unit is present.
test_all()

Test whether Pulp can re-sync content into a repository.

pulp_smash.tests.rpm.cli.test_sync.get_rpm_names(cfg, repo_id)

Get a list of names of all packages in a repository.

Parameters:
Returns:

The names of all modules in a repository, as an list.

pulp_smash.tests.rpm.cli.test_sync.setUpModule()

Execute pulp-admin login and reset Pulp.

For RemovedContentTestCase to function correctly, we require that all of the content units on Pulp’s filesystem belong to the repository created by that test case. Resetting Pulp guarantees that this is so. Ideally, all test cases would clean up after themselves so that no resets are necessary.

pulp_smash.tests.rpm.cli.test_sync.sync_repo(cfg, repo_id, force_sync=False)

Sync an RPM repository.

Parameters:
  • cfg (pulp_smash.config.PulpSmashConfig) – Information about a Pulp deployment.
  • repo_id – A RPM repository ID.
  • repo_id – A boolean flag to denote if is a force-full sync.
Returns:

A pulp_smash.cli.CompletedProcess.

pulp_smash.tests.rpm.cli.test_upload

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.cli.test_upload

Tests that upload content units into repositories.

class pulp_smash.tests.rpm.cli.test_upload.UploadDrpmTestCase(methodName='runTest')

Test whether one can upload a DRPM into a repository.

This test case targets Pulp Smash #336

test_upload()

Create a repository and upload DRPMs into it.

Specifically, do the following:

  1. Create a yum repository.
  2. Download a DRPM file.
  3. Upload the DRPM into it. Use pulp-admin to verify its presence in the repository.
  4. Upload the same DRPM into the same repository, and use the --skip-existing flag during the upload. Verify that Pulp skips the upload.
pulp_smash.tests.rpm.cli.test_upload.setUpModule()

Execute pulp-admin login on the target Pulp system.

pulp_smash.tests.rpm.cli.utils

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.cli.utils

Utility functions for RPM CLI tests.

pulp_smash.tests.rpm.cli.utils.count_langpacks(server_config, repo_id)

Tell how many langpack content units are in the given repository.

Parameters:
Returns:

The number of langpacks in the named repository, as an integer.

pulp_smash.tests.rpm.utils

Location: Pulp SmashAPI Documentationpulp_smash.tests.rpm.utils

Utilities for RPM tests.

pulp_smash.tests.rpm.utils.check_issue_2277(cfg)

Return true if Pulp #2277 affects the targeted Pulp system.

Parameters:cfg (pulp_smash.config.PulpSmashConfig) – The Pulp system under test.
pulp_smash.tests.rpm.utils.check_issue_2354(cfg)

Return true if Pulp #2354 affects the targeted Pulp system.

Parameters:cfg (pulp_smash.config.PulpSmashConfig) – The Pulp system under test.
pulp_smash.tests.rpm.utils.check_issue_2387(cfg)

Return true if Pulp #2387 affects the targeted Pulp system.

Parameters:cfg (pulp_smash.config.PulpSmashConfig) – The Pulp system under test.
pulp_smash.tests.rpm.utils.check_issue_2620(cfg)

Return true if Pulp #2620 affects the targeted Pulp system.

Parameters:cfg (pulp_smash.config.PulpSmashConfig) – The Pulp system under test.
pulp_smash.tests.rpm.utils.os_is_rhel6(cfg)

Return True if the server runs RHEL 6, or False otherwise.

Parameters:cfg (pulp_smash.config.PulpSmashConfig) – Information about the system being targeted.
Returns:True or false.
pulp_smash.tests.rpm.utils.set_up_module()

Skip tests if the RPM plugin is not installed.

See pulp_smash.tests for more information.

pulp_smash.utils

Location: Pulp SmashAPI Documentationpulp_smash.utils

Utility functions for Pulp tests.

This module may make use of pulp_smash.api and pulp_smash.cli, but the reverse should not be done.

class pulp_smash.utils.BaseAPICrudTestCase(methodName='runTest')

A parent class for API CRUD test cases.

create_body() and update_body() should be overridden by concrete child classes. The bodies of these two methods are encoded to JSON and used as the bodies of HTTP requests for creating and updating a repository, respectively. Be careful to return appropriate data when overriding these methods: the various test* methods assume the repository is fairly simple.

Relevant Pulp documentation:

Create
http://docs.pulpproject.org/en/latest/dev-guide/integration/rest-api/repo/cud.html#create-a-repository
Read
http://docs.pulpproject.org/en/latest/dev-guide/integration/rest-api/repo/retrieval.html#retrieve-a-single-repository
Update
http://docs.pulpproject.org/en/latest/dev-guide/integration/rest-api/repo/cud.html#update-a-repository
Delete
http://docs.pulpproject.org/en/latest/dev-guide/integration/rest-api/repo/cud.html#delete-a-repository
static create_body()

Return a dict for creating a repository. Should be overridden.

Raises:NotImplementedError if not implemented by a child class.
classmethod setUpClass()

Create, update, read and delete a repository.

test_create()

Assert the created repository has all requested attributes.

Walk through each of the attributes returned by create_body() and verify the attribute is present in the repository.

NOTE: Any attribute whose name starts with importer or distributor is not verified.

test_importer_config()

Validate the config attribute of each importer.

test_importer_type_id()

Validate the repo importer’s importer_type_id attribute.

test_number_importers()

Assert the repository has one importer.

test_read()

Assert the repo update response has the requested changes.

test_status_codes()

Assert each response has a correct status code.

test_update()

Assert the repo update response has the requested changes.

static update_body()

Return a dict for updating a repository. Should be overridden.

Raises:NotImplementedError if not implemented by a child class.
class pulp_smash.utils.BaseAPITestCase(methodName='runTest')

A class with behaviour that is of use in many API test cases.

This test case provides set-up and tear-down behaviour that is common to many API test cases. It is not necessary to use this class as the parent of all API test cases, but it serves well in many cases.

classmethod setUpClass()

Provide a server config and an iterable of resources to delete.

The following class attributes are created this method:

cfg
A pulp_smash.config.PulpSmashConfig object.
resources
A set object. If a child class creates some resources that should be deleted when the test is complete, the child class should add that resource’s href to this set.
classmethod tearDownClass()

Delete all resources named by resources.

class pulp_smash.utils.DuplicateUploadsMixin

A mixin that adds tests for the “duplicate upload” test cases.

Consider the following procedure:

  1. Create a new feed-less repository of any content unit type.
  2. Upload a content unit into the repository.
  3. Upload the same content unit into the same repository.

The second upload should silently fail for all Pulp releases in the 2.x series. See:

This mixin adds tests for this case. Child classes should do the following:

  • Create a repository. Content units will be uploaded into this repository.
  • Create a class or instance attribute named upload_import_unit_args. It should be an iterable whose contents match the signature of upload_import_unit().
test_01_first_upload()

Upload a content unit to a repository.

test_02_second_upload()

Upload the same content unit to the same repository.

pulp_smash.utils.get_broker(server_config)

Build an object for managing the target system’s AMQP broker.

Talk to the host named by server_config and use simple heuristics to determine which AMQP broker is installed. If Qpid or RabbitMQ appear to be installed, return the name of that service. Otherwise, raise an exception.

Parameters:server_config (pulp_smash.config.PulpSmashConfig) – Information about the system on which an AMQP broker exists.
Returns:A string such as ‘qpidd’ or ‘rabbitmq’.
Raises:pulp_smash.exceptions.NoKnownBrokerError – If unable to find any AMQP brokers on the target system.
pulp_smash.utils.get_sha256_checksum(url)

Return the sha256 checksum of the file at the given URL.

When a URL is encountered for the first time, do the following:

  1. Download the file and calculate its sha256 checksum.
  2. Cache the URL-checksum pair.
  3. Return the checksum.

On subsequent calls, return a cached checksum.

pulp_smash.utils.get_unit_type_ids(server_config)

Tell which content unit types are supported by the target Pulp server.

Each Pulp plugin adds one (or more?) content unit types to Pulp, and each content unit type has a unique identifier. For example, the Python plugin [1] adds the Python content unit type [2], and Python content units have an ID of python_package. This function queries the server and returns those unit type IDs.

Parameters:server_config (pulp_smash.config.PulpSmashConfig) – Information about the Pulp deployment being targeted.
Returns:A set of content unit type IDs. For example: {'ostree', 'python_package'}.
[1]http://docs.pulpproject.org/plugins/pulp_python/
[2]http://docs.pulpproject.org/plugins/pulp_python/reference/python-type.html
pulp_smash.utils.http_get(url, **kwargs)

Issue a HTTP request to the url and return the response content.

This is useful for downloading file contents over HTTP[S].

Parameters:
  • url – the URL where the content should be get.
  • kwargs – additional kwargs to be passed to requests.get.
Returns:

the response content of a GET request to url.

pulp_smash.utils.publish_repo(cfg, repo, json=None)

Publish a repository.

Parameters:
  • cfg (pulp_smash.config.PulpSmashConfig) – Information about the Pulp host.
  • repo – A dict of detailed information about the repository to be published.
  • json – Data to be encoded as JSON and sent as the request body. Defaults to {'id': repo['distributors'][0]['id']}.
Raises:

ValueError when json is not passed, and repo does not have exactly one distributor.

Returns:

The server’s reponse. Call .json() on the response to get a call report.

pulp_smash.utils.pulp_admin_login(server_config)

Execute pulp-admin login.

Parameters:server_config (pulp_smash.config.PulpSmashConfig) – Information about the Pulp server being targeted.
Returns:The completed process.
Return type:pulp_smash.cli.CompletedProcess
pulp_smash.utils.reset_pulp(server_config)

Stop Pulp, reset its database, remove certain files, and start it.

Parameters:server_config (pulp_smash.config.PulpSmashConfig) – Information about the Pulp server being targeted.
Returns:Nothing.
pulp_smash.utils.reset_squid(cfg)

Stop Squid, reset its cache directory, and restart it.

Parameters:cfg (pulp_smash.config.PulpSmashConfig) – Information about a Pulp host.
Returns:Nothing.
pulp_smash.utils.search_units(cfg, repo, criteria=None, response_handler=None)

Find content units in a repo.

Parameters:
Returns:

Whatever is dictated by response_handler.

pulp_smash.utils.skip_if_type_is_unsupported(unit_type_id, server_config=None)

Raise SkipTest if support for the named type is not availalble.

Parameters:
Raises:

unittest.SkipTest if support is unavailable.

Returns:

Nothing.

pulp_smash.utils.sync_repo(server_config, href)

Sync the referenced repository via the API. Return the server response.

Checks are run against the server’s response. If the sync appears to have failed, an exception is raised.

Parameters:
Returns:

The server’s response.

pulp_smash.utils.upload_import_erratum(server_config, erratum, repo_href)

Upload an erratum to a Pulp server and import it into a repository.

For most content types, use upload_import_unit().

Parameters:
  • server_config (pulp_smash.config.PulpSmashConfig) – Information about the Pulp server being targeted.
  • erratum – A dict, with keys such as “id,” “status,” “issued,” and “references.”
  • repo_href – The path to the repository into which erratum will be imported.
Returns:

The call report returned when importing the erratum.

pulp_smash.utils.upload_import_unit(cfg, unit, import_params, repo)

Upload a content unit to a Pulp server and import it into a repository.

This procedure only works for some unit types, such as rpm or python_package. Others, like package_group, require an alternate procedure. The procedure encapsulated by this function is as follows:

  1. Create an upload request.
  2. Upload the content unit to Pulp, in small chunks.
  3. Import the uploaded content unit into a repository.
  4. Delete the upload request.

The default set of parameters sent to Pulp during step 3 are:

{'unit_key': {}, 'upload_id': '…'}

The actual parameters required by Pulp depending on the circumstances, and the parameters sent to Pulp may be customized via the import_params argument. For example, if uploading a Python content unit, import_params should be the following:

{'unit_key': {'filename': '…'}, 'unit_type_id': 'python_package'}

This would result in the following upload parameters being used:

{
    'unit_key': {'filename': '…'},
    'unit_type_id': 'python_package',
    'upload_id': '…',
}
Parameters:
  • cfg (pulp_smash.config.PulpSmashConfig) – Information about a Pulp host.
  • unit – The unit to be uploaded and imported, as a binary blob.
  • import_params – A dict of parameters to be merged into the default set of import parameters during step 3.
  • repo – A dict of information about the target repository.
Returns:

The call report returned when importing the unit.

pulp_smash.utils.uuid4()

Return a random UUID, as a unicode string.

tests

Location: Pulp SmashAPI Documentationtests

Unit tests for Pulp Smash.

This package and its sub-packages contain tests for Pulp Smash. These tests verify that Pulp Smash’s internal functions and libraries function correctly.

These tests are entirely different from the tests in pulp_smash.tests.

tests.test_api

Location: Pulp SmashAPI Documentationtests.test_api

Unit tests for pulp_smash.api.

class tests.test_api.ClientTestCase(methodName='runTest')

Tests for pulp_smash.api.Client.

classmethod setUpClass()

Assert methods delegate to pulp_smash.api.Client.request().

All methods on pulp_smash.api.Client, such as pulp_smash.api.Client.delete(), should delegate to pulp_smash.api.Client.request(). Mock out request and call the other methods.

test_called_once()

Assert each method calls request exactly once.

test_http_action()

Assert each method calls request with the right HTTP action.

class tests.test_api.ClientTestCase2(methodName='runTest')

More tests for pulp_smash.api.Client.

test_json_arg()

Assert methods with a json argument pass on that argument.

test_response_handler()

Assert __init__ saves the response_handler argument.

The argument should be saved as an instance attribute.

class tests.test_api.EchoHandlerTestCase(methodName='runTest')

Tests for pulp_smash.api.echo_handler().

test_202_check_skipped()

Assert HTTP 202 responses are not treated specially.

test_raise_for_status()

Assert response.raise_for_status() is not called.

test_return()

Assert the passed-in response is returned.

class tests.test_api.JsonHandlerTestCase(methodName='runTest')

Tests for pulp_smash.api.json_handler().

test_202_check_run()

Assert HTTP 202 responses are not treated specially.

test_raise_for_status()

Assert response.raise_for_status() is called.

test_return()

Assert the JSON-decoded body of response is returned.

class tests.test_api.SafeHandlerTestCase(methodName='runTest')

Tests for pulp_smash.api.safe_handler().

test_202_check_run()

Assert HTTP 202 responses are not treated specially.

test_raise_for_status()

Assert response.raise_for_status() is called.

test_return()

Assert the passed-in response is returned.

tests.test_cli

Location: Pulp SmashAPI Documentationtests.test_cli

Unit tests for pulp_smash.cli.

class tests.test_cli.ClientTestCase(methodName='runTest')

Tests for pulp_smash.cli.Client.

test_default_response_handler()

Assert the default response handler checks return codes.

test_explicit_local_transport()

Assert it is possible to explicitly ask for a “local” transport.

test_explicit_pulp_system()

Assert it is possible to explicitly target a pulp cli PulpSystem.

test_explicit_response_handler()

Assert it is possible to explicitly set a response handler.

test_implicit_local_transport()

Assert it is possible to implicitly ask for a “local” transport.

test_implicit_pulp_system()

Assert it is possible to implicitly target a pulp cli PulpSystem.

class tests.test_cli.CodeHandlerTestCase(methodName='runTest')

Tests for pulp_smash.cli.code_handler().

classmethod setUpClass()

Call the function under test, and record inputs and outputs.

test_check_returncode()

Assert completed_proc.check_returncode() is not called.

test_input_returned()

Assert the passed-in completed_proc is returned.

class tests.test_cli.CompletedProcessTestCase(methodName='runTest')

Tests for pulp_smash.cli.CompletedProcess.

setUp()

Generate kwargs that can be used to instantiate a completed proc.

test_can_eval()

Assert __repr__() can be parsed by eval().

test_check_returncode_nonzero()

Call check_returncode when returncode is not zero.

test_check_returncode_zero()

Call check_returncode when returncode is zero.

test_init()

Assert all constructor arguments are saved as instance attrs.

class tests.test_cli.EchoHandlerTestCase(methodName='runTest')

Tests for pulp_smash.cli.echo_handler().

classmethod setUpClass()

Call the function under test, and record inputs and outputs.

test_check_returncode()

Assert completed_proc.check_returncode() is not called.

test_input_returned()

Assert the passed-in completed_proc is returned.

class tests.test_cli.GetHostnameTestCase(methodName='runTest')

Tests for pulp_smash.cli._get_hostname.

test_parsing()

Assert the function extracts hostnames as shown in its docstring.

tests.test_config

Location: Pulp SmashAPI Documentationtests.test_config

Unit tests for pulp_smash.config.

class tests.test_config.GetConfigFilePathTestCase(methodName='runTest')

Test pulp_smash.config._get_config_file_path.

test_failures()

Assert the method raises an exception when no config is found.

test_success()

Assert the method returns a path when a config file is found.

class tests.test_config.GetConfigTestCase(methodName='runTest')

Test pulp_smash.config.get_config().

test_cache_empty