glare.tests.functional package

Submodules

glare.tests.functional.base module

class glare.tests.functional.base.TestArtifact(*args, **kwargs)[source]

Bases: glare.tests.functional.FunctionalTest

admin_action(artifact_id, body, status=200, type_name='sample_artifact')[source]
create_artifact(data=None, status=201, type_name='sample_artifact')[source]
delete(url, status=204, headers=None)[source]
enabled_types = (u'sample_artifact', u'images', u'heat_templates', u'heat_environments', u'tosca_templates', u'murano_packages', u'all')
get(url, status=200, headers=None)[source]
make_active = [{'path': '/status', 'value': 'active', 'op': 'replace'}]
make_deactivated = [{'path': '/status', 'value': 'deactivated', 'op': 'replace'}]
make_public = [{'path': '/visibility', 'value': 'public', 'op': 'replace'}]
patch(url, data, status=200, headers=None)[source]

Monkey-patch ‘obj.attribute’ to ‘value’ while the test is running.

If ‘obj’ has no attribute, then the monkey-patch will still go ahead, and the attribute will be deleted instead of restored to its original value.

Parameters:
  • obj – The object to patch. Can be anything.
  • attribute – The attribute on ‘obj’ to patch.
  • value – The value to set ‘obj.attribute’ to.
post(url, data=None, status=201, headers=None)[source]
put(url, data=None, status=200, headers=None)[source]
setUp()[source]

Hook method for setting up the test fixture before exercising it.

set_user(username)[source]
tearDown()[source]

Hook method for deconstructing the test fixture after testing it.

users = {'admin': {'id': '213a6080-e30e-435e-8b24-941e0574280f', 'role': 'admin', 'tenant_id': '3bdfee97-ab73-478a-8b82-142ef0aa62c6', 'token': 'bf274109-3e27-4692-935e-e87deccebff0'}, 'anonymous': {'id': None, 'role': None, 'tenant_id': None, 'token': None}, 'user1': {'id': '1e397885-21f2-4e3f-927d-8c408b156df3', 'role': 'member', 'tenant_id': 'ade66340-d079-4e39-8a21-e3d114d0c2e9', 'token': 'cc78154a-c92a-45dd-80dc-6073c0024704'}, 'user2': {'id': '9abfc6af-0b61-4678-8a45-791b12ed683b', 'role': 'member', 'tenant_id': 'a2b1f01a-bcc1-4455-9acf-5ea744a9230e', 'token': 'e0c78346-0452-4b34-8ff2-beb007d4a73e'}}
glare.tests.functional.base.sort_results(lst, target='name')[source]

glare.tests.functional.test_all module

class glare.tests.functional.test_all.TestAll(*args, **kwargs)[source]

Bases: glare.tests.functional.base.TestArtifact

test_all()[source]
test_all_readonlyness()[source]
test_format_all()[source]

glare.tests.functional.test_database_store module

class glare.tests.functional.test_database_store.TestMultiStore(*args, **kwargs)[source]

Bases: glare.tests.functional.base.TestArtifact

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_blob_dicts()[source]
test_blob_download()[source]
test_blob_upload()[source]

glare.tests.functional.test_quotas module

class glare.tests.functional.test_quotas.TestDynamicQuotas(*args, **kwargs)[source]

Bases: glare.tests.functional.base.TestArtifact

Test dynamic quota limits.

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_calculate_uploaded_data()[source]
test_count_artifact_number()[source]
class glare.tests.functional.test_quotas.TestQuotasAPI(*args, **kwargs)[source]

Bases: glare.tests.functional.base.TestArtifact

Test quotas REST API.

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_quota_api()[source]
test_quota_api_wrong()[source]
class glare.tests.functional.test_quotas.TestStaticQuotas(*args, **kwargs)[source]

Bases: glare.tests.functional.base.TestArtifact

Test static quota limits.

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_calculate_uploaded_data()[source]
test_count_artifact_number()[source]

glare.tests.functional.test_sample_artifact module

class glare.tests.functional.test_sample_artifact.TestArtifactOps(*args, **kwargs)[source]

Bases: glare.tests.functional.base.TestArtifact

test_activate()[source]
test_create()[source]

All tests related to artifact creation

test_deactivate()[source]
test_delete()[source]
test_publish()[source]
test_reactivate()[source]
class glare.tests.functional.test_sample_artifact.TestBlobs(*args, **kwargs)[source]

Bases: glare.tests.functional.base.TestArtifact

test_blob_add_custom_location()[source]
test_blob_dicts()[source]
test_blob_download()[source]
test_blob_upload()[source]
test_delete_external_blob()[source]
test_delete_external_blob_dict()[source]
test_internal_location()[source]

Bases: glare.tests.functional.base.TestArtifact

class glare.tests.functional.test_sample_artifact.TestList(*args, **kwargs)[source]

Bases: glare.tests.functional.base.TestArtifact

test_artifact_list_dict_filters()[source]
test_list_artifact_with_filter_query_combiner()[source]
test_list_base_filters()[source]
test_list_dict_prop_filters()[source]
test_list_display_type_name_attribute()[source]
test_list_latest_filter()[source]
test_list_marker_and_limit()[source]
test_list_response_attributes()[source]
test_list_sorted()[source]
test_list_support_unicode_filters()[source]
test_list_versions()[source]
class glare.tests.functional.test_sample_artifact.TestTags(*args, **kwargs)[source]

Bases: glare.tests.functional.base.TestArtifact

test_tags()[source]
class glare.tests.functional.test_sample_artifact.TestUpdate(*args, **kwargs)[source]

Bases: glare.tests.functional.base.TestArtifact

test_update_after_activate_and_publish()[source]
test_update_artifact_before_activate()[source]

Test updates for artifact before activation

test_update_base_fields()[source]
test_update_field_dict()[source]
test_update_field_list()[source]
test_update_invalid_activation()[source]
test_update_malformed_json_patch()[source]
test_update_remove_properties()[source]
test_update_with_validators()[source]
glare.tests.functional.test_sample_artifact.sort_results(lst, target='name')[source]

glare.tests.functional.test_schemas module

class glare.tests.functional.test_schemas.TestSchemas(*args, **kwargs)[source]

Bases: glare.tests.functional.base.TestArtifact

test_schemas()[source]
glare.tests.functional.test_schemas.generate_type_props(props)[source]

glare.tests.functional.test_scrubber module

class glare.tests.functional.test_scrubber.TestScrubber(*args, **kwargs)[source]

Bases: glare.tests.functional.base.TestArtifact

Test that delayed_delete works and the scrubber deletes

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_scrubber_app()[source]

Test that the scrubber script runs successfully when not in daemon mode.

test_scrubber_delayed_delete()[source]

Test that artifacts don’t get deleted immediately and that the scrubber scrubs them.

wait_for_scrub(url)[source]

The build servers sometimes take longer than 15 seconds to scrub. Give it up to 5 min, checking every 5 seconds. When/if it flips to deleted, bail immediately.

glare.tests.functional.test_visibility module

class glare.tests.functional.test_visibility.TestVisibility(*args, **kwargs)[source]

Bases: glare.tests.functional.base.TestArtifact

Test Glare artifact visibility for various users.

test_visibility_all()[source]
test_visibility_artifact_types()[source]
test_visibility_basic()[source]
test_visibility_name_version()[source]

Module contents

Base test class for running non-stubbed tests (functional tests)

The FunctionalTest class contains helper methods for starting Glare server, grabbing the logs of each, cleaning up pidfiles, and spinning down the server.

class glare.tests.functional.FunctionalTest(*args, **kwargs)[source]

Bases: glare.tests.utils.BaseTestCase

Base test class for any test that wants to test the actual servers and clients and not just the stubbed out interfaces

add_log_details(servers=None)[source]
cleanup()[source]

Makes sure anything we created or started up in the tests are destroyed or spun down

copy_data_file(file_name, dst_dir)[source]
disabled = False
inited = False
launched_servers = []
ping_server(port)[source]

Simple ping on the port. If responsive, return True, else return False.

:note We use raw sockets, not ping here, since ping uses ICMP and has no concept of ports…

run_sql_cmd(sql)[source]

Provides a crude mechanism to run manual SQL commands for backend DB verification within the functional tests. The raw result set is returned.

setUp()[source]

Hook method for setting up the test fixture before exercising it.

set_policy_rules(rules)[source]
start_server(server, expect_launch, expect_exit=True, expected_exitcode=0, **kwargs)[source]

Starts a server on an unused port.

Any kwargs passed to this method will override the configuration value in the conf file used in starting the server.

Parameters:
  • server – the server to launch
  • expect_launch – true iff the server is expected to successfully start
  • expect_exit – true iff the launched process is expected to exit in a timely fashion
  • expected_exitcode – expected exitcode from the launcher
start_servers(**kwargs)[source]

Starts the Glare server on unused port.

Any kwargs passed to this method will override the configuration value in the conf file used in starting the servers.

start_with_retry(server, port_name, max_retries, expect_launch=True, **kwargs)[source]

Starts a server, with retries if the server launches but fails to start listening on the expected port.

Parameters:
  • server – the server to launch
  • port_name – the name of the port attribute
  • max_retries – the maximum number of attempts
  • expect_launch – true iff the server is expected to successfully start
  • expect_exit – true iff the launched process is expected to exit in a timely fashion
stop_server(server)[source]

Called to stop a single server in a normal fashion.

Parameters:server – the server to stop
stop_servers()[source]
tearDown()[source]

Hook method for deconstructing the test fixture after testing it.

wait_for_servers(servers, expect_launch=True, timeout=30)[source]

Tight loop, waiting for the given server port(s) to be available. Returns when all are pingable. There is a timeout on waiting for the servers to come up.

Parameters:
  • servers – Glare server ports to ping
  • expect_launch – Optional, true iff the server(s) are expected to successfully start
  • timeout – Optional, defaults to 30 seconds
Returns:

None if launch expectation is met, otherwise an assertion message

class glare.tests.functional.GlareServer(test_dir, port, policy_file, delayed_delete=False, pid_file=None, sock=None, **kwargs)[source]

Bases: glare.tests.functional.Server

Server object that starts/stops/manages Glare server

class glare.tests.functional.ScrubberDaemon(test_dir, policy_file, daemon=False, **kwargs)[source]

Bases: glare.tests.functional.Server

Server object that starts/stops/manages the Scrubber server

start(expect_exit=True, expected_exitcode=0, **kwargs)[source]

Starts the server.

Any kwargs passed to this method will override the configuration value in the conf file used in starting the servers.

class glare.tests.functional.Server(test_dir, port, sock=None)[source]

Bases: object

Class used to easily manage starting and stopping a server during functional test runs.

create_database()[source]

Create database if required for this server

dump_log(name)[source]
reload(expect_exit=True, expected_exitcode=0, **kwargs)[source]

Start and stop the service to reload

Any kwargs passed to this method will override the configuration value in the conf file used in starting the servers.

start(expect_exit=True, expected_exitcode=0, **kwargs)[source]

Starts the server.

Any kwargs passed to this method will override the configuration value in the conf file used in starting the servers.

stop()[source]

Spin down the server.

write_conf(**kwargs)[source]

Writes the configuration file for the server to its intended destination. Returns the name of the configuration file and the over-ridden config content (may be useful for populating error messages).

class glare.tests.functional.TestRouter(mapper)[source]

Bases: glare.api.v1.router.API