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.