add_run_metadata
(meta_dict, run_id, session=None)[source]Add a metadata key value pairs for a specific run.
This method will take a dictionary and store key value pair metadata in the DB associated with the specified run.
Parameters: |
|
---|---|
Return list: | The list of created metadata objects |
Return type: | subunit2sql.models.RunMeta |
add_test_metadata
(meta_dict, test_id, session=None)[source]Add a metadata key value pairs for a specific test.
This method will take a dictionary and store key value pair metadata in the DB associated with the specified run.
Parameters: |
|
---|---|
Return list: | The list of created metadata objects |
Return type: | subunit2sql.models.TestMeta |
add_test_run_attachments
(attach_dict, test_run_id, session=None)[source]Add attachments a specific test run.
This method will take a dictionary and store key blob pair attachments in the DB associated with the specified test_run.
Parameters: |
|
---|---|
Return list: | The list of created attachment objects |
Return type: | subunit2sql.models.Attachments |
add_test_run_metadata
(meta_dict, test_run_id, session=None)[source]Add a metadata key value pairs for a specific run.
This method will take a dictionary and store key value pair metadata in the DB associated with the specified run.
Parameters: |
|
---|---|
Return list: | The list of created metadata objects |
Return type: | subunit2sql.models.TestRunMeta |
create_run
(skips=0, fails=0, passes=0, run_time=0, artifacts=None, id=None, session=None, run_at=None)[source]Create a new run record in the database
Parameters: |
|
---|---|
Returns: | The run object stored in the DB |
Return type: | subunit2sql.models.Run |
create_test
(test_id, run_count=0, success=0, failure=0, run_time=0.0, session=None)[source]Create a new test record in the database.
This method is used to add a new test in the database. Tests are used to track the run history of a unique test over all runs.
Parameters: |
|
---|---|
Returns: | The test object stored in the DB |
Return type: | subunit2sql.models.Test |
Raises: | InvalidRunCount – If the run_count doesn’t equal the sum of the successes and failures. |
create_test_run
(test_id, run_id, status, start_time=None, end_time=None, session=None)[source]Create a new test run record in the database
This method creates a new record in the database
Parameters: |
|
---|---|
Returns: | The test_run object stored in the DB |
Return type: | subunit2sql.models.TestRun |
delete_old_runs
(expire_age=186, session=None)[source]Delete all runs and associated metadata older than the provided age
Parameters: |
|
---|
delete_old_test_runs
(expire_age=186, session=None)[source]Delete all test runs and associated metadata older than the provided age
Parameters: |
|
---|
delete_run_by_uuid
(run_uuid, session=None)[source]Delete a single test run based on its uuid.
Parameters: |
|
---|
delete_test_runs_by_run_uuid
(run_uuid, session=None)[source]Delete all test runs included in a given run
Parameters: |
|
---|
get_all_run_metadata_keys
(session=None)[source]Get a list of all the keys used in the run_metadata table
Parameters: | session – Optional session object if one isn’t provided a new session will be acquired for the duration of this operation |
---|---|
Return keys: | A list of all keys used in the run_metadata table |
Return type: | list |
get_all_runs
(session=None)[source]Return all runs from the DB.
Parameters: | session – Optional session object if one isn’t provided a new session will be acquired for the duration of this operation |
---|---|
Return list: | The list of run objects |
Return type: | subunit2sql.models.Run |
get_all_runs_by_date
(start_date=None, stop_date=None, session=None)[source]Return all runs from the DB.
Parameters: |
|
---|---|
Return list: | The list of run objects |
Return type: | subunit2sql.models.Run |
get_all_runs_time_series_by_key
(key, start_date=None, stop_date=None, session=None)[source]Get a time series of run summaries grouped by a key
This method will get a time series dictionary of run summary views which are grouped by the values of the specified key
Parameters: |
|
---|---|
Return runs: | A time series dictionary of runs grouped by values of the specified key |
Return type: | dict |
get_all_test_metadata_keys
(session=None)[source]Get a list of all the keys used in the test_metadata table
Parameters: | session – Optional session object if one isn’t provided a new session will be acquired for the duration of this operation |
---|---|
Return keys: | A list of all keys used in the test_metadata table |
Return type: | list |
get_all_test_run_metadata_keys
(session=None)[source]Get a list of all the keys used in the test_run_metadata table
Parameters: | session – Optional session object if one isn’t provided a new session will be acquired for the duration of this operation |
---|---|
Return keys: | A list of all keys used in the test_run_metadata table |
Return type: | list |
get_all_test_runs
(session=None)[source]Return all test runs from the DB.
Parameters: | session – Optional session object if one isn’t provided a new session will be acquired for the duration of this operation |
---|---|
Return list: | The list of test run objects |
Return type: | subunit2sql.models.TestRun |
get_all_tests
(session=None)[source]Return all tests from the DB.
Parameters: | session – Optional session object if one isn’t provided a new session will be acquired for the duration of this operation |
---|---|
Return list: | The list of test objects |
Return type: | subunit2sql.models.Test |
get_engine
(use_slave=False)[source]Get a new sqlalchemy engine instance
Parameters: | use_slave (bool) – If possible, use ‘slave’ database for this engine |
---|---|
Returns: | The engine object for the database connection |
Return type: | sqlalchemy.engine.Engine |
get_failing_from_run
(run_id, session=None)[source]Return the set of failing test runs for a give run.
This method will return all the test run objects that failed during the specified run.
Parameters: |
|
---|---|
Return list: | The list of failing test runs for the given run |
Return type: | subunit2sql.models.TestRun |
get_failing_test_ids_from_runs_by_key_value
(key, value, session=None)[source]Get a list of failing test_ids from runs with run_metadata.
This method gets a distinct list of test_ids (the test_id column not the id column) from all runs that match a run metadata key value pair.
Parameters: |
|
---|---|
Returns: | A list of test_ids that failed from runs that match the provided key value run_metadata pair |
Return type: | list |
get_id_from_test_id
(test_id, session=None)[source]Return the id (uuid primary key) for a test given it’s test_id value
Parameters: |
|
---|---|
Returns: | The id for the specified test |
Return type: | str |
get_ids_for_all_tests
(session=None)[source]Return an iterator of ids (uuid primary key) for all tests in the database
Parameters: | session – Optional session object if one isn’t provided a new session will be acquired for the duration of this operation |
---|---|
Returns: | The iterator of all ids for tests in the tests table |
Return type: | iterator |
get_latest_run
(session=None)[source]Return the most recently created run from the DB.
Parameters: | session – Optional session object if one isn’t provided a new session will be acquired for the duration of this operation |
---|---|
Returns: | The latest run object |
Return type: | subunit2sql.models.Run |
get_recent_failed_runs
(num_runs=10, session=None, start_date=None)[source]Return a list of run uuid strings for the most recent failed runs
Parameters: |
|
---|---|
Return list: | A list of run uuid strings (the id column in the runs table) for the most recent runs. |
get_recent_failed_runs_by_run_metadata
(key, value, num_runs=10, start_date=None, session=None)[source]Get a list of recent failed runs for a given run metadata pair
Parameters: |
|
---|---|
Return list: | The list of recent failed Run objects |
Return type: | subunit2sql.models.Run |
get_recent_runs_by_key_value_metadata
(key, value, num_runs=10, session=None, start_date=None)[source]Get a list of runs for recent runs with a key value metadata pair
Parameters: |
|
---|---|
Return list: | A list of run objects for the most recent runs. |
Return type: | subunit2sql.db.models.Run |
get_recent_successful_runs
(num_runs=10, session=None, start_date=None)[source]Return a list of run uuid strings for the most recent successful runs
Parameters: |
|
---|---|
Return list: | A list of run uuid strings (the id column in the runs table) for the most recent runs. |
get_recent_successful_runs_by_run_metadata
(key, value, num_runs=10, start_date=None, session=None)[source]Get a list of recent successful runs for a given run metadata pair
Parameters: |
|
---|---|
Return list: | The list of recent failed Run objects |
Return type: | subunit2sql.models.Run |
get_run_by_id
(id, session=None)[source]Get an individual run by it’s id.
Parameters: |
|
---|---|
Returns: | The specified run object |
Return type: | subunit2sql.models.Run |
get_run_failure_rate_by_key_value_metadata
(key, value, start_date=None, stop_date=None, session=None)[source]Return the failure percentage of runs with a set of run metadata
Parameters: |
|
---|---|
Return failure_rate: | |
The percentage of runs that failed, will be None if no runs are found |
|
Return type: | float |
get_run_id_from_uuid
(uuid, session=None)[source]Get the id for a run by it’s uuid
Parameters: |
|
---|---|
Returns: | The id for the run with the provided uuid |
Return type: | int |
get_run_metadata
(run_id, session=None)[source]Return all run metadata objects associated with a given run.
Parameters: |
|
---|---|
Return list: | The list of metadata objects |
Return type: | subunit2sql.models.RunMetadata |
get_run_times_all_test_runs
(tests=None, start_date=None, stop_date=None, session=None)[source]Return the all the individual duration times for each test_run
This function will return a dictionary where each key is a test_id and the value is a list of all the durations for each run of that test
Parameters: |
|
---|---|
Return run_times: | |
all the durations for test_runs grouped by test_id |
|
Return type: | dict |
get_run_times_grouped_by_run_metadata_key
(key, start_date=None, stop_date=None, session=None, match_key=None, match_value=None)[source]Return the aggregate run times for all runs grouped by a metadata key
The results of the output can be limited to runs with a different matching key value run_metadata pair using the match_key and match_value parameters.
Parameters: |
|
---|---|
Returns: | A dictionary where keys are the value of the provided metadata key and the values are a list of run_times for successful runs with that metadata value |
Return type: | dict |
get_run_times_time_series_grouped_by_run_metadata_key
(key, start_date=None, stop_date=None, session=None, match_key=None, match_value=None)[source]Get a times series dict of aggregate run times grouped by a metadata key
The results of the output can be limited to runs with a different matching key value run_metadata pair using the match_key and match_value parameters.
Parameters: |
|
---|---|
Returns: | A dictionary where keys are the time stamp and the value is a dict with the key being the value of the provided metadata key and the values are run times for the successful runs |
Return type: | dict |
get_runs_by_ids
(ids, session=None)[source]Get a list of runs by their ids.
Parameters: |
|
---|---|
Returns: | The list of the specified run objects |
Return type: | list |
get_runs_by_key_value
(key, value, session=None)[source]Return all run objects associated with a certain key/value metadata pair
Parameters: |
|
---|---|
Return list: | The list of runs |
Return type: | subunit2sql.models.Run |
get_runs_by_status_grouped_by_run_metadata
(key, start_date=None, stop_date=None, session=None)[source]get_runs_count
(session=None)[source]Get the number of runs currently in the database
Return count: | The number of runs in the DB |
---|---|
Return type: | int |
get_runs_counts_by_run_metadata
(key, value, start_date=None, session=None)[source]Check runs for a given run metadata pair
Parameters: |
|
---|---|
Return count: | A count for a given run metadata key-value pair |
Return type: | int |
get_session
(autocommit=True, expire_on_commit=False)[source]Get a new sqlalchemy Session instance
Parameters: |
|
---|
get_test_by_id
(id, session=None)[source]Get an individual test by it’s uuid.
Parameters: |
|
---|---|
Returns: | The specified test object |
Return type: | subunit2sql.models.Test |
get_test_by_test_id
(test_id, session=None)[source]Get an individual test by it’s test_id.
Parameters: |
|
---|---|
Returns: | The specified test object |
Return type: | subunit2sql.models.Test |
get_test_counts_in_date_range
(test_id, start_date=None, stop_date=None, session=None)[source]Return the number of successes, failures, and skips for a single test.
Optionally you can provide a date to filter the results to be within a certain date range
Parameters: |
|
---|---|
Returns: | A dict containing the number of successes, failures, and skips |
Return type: | dict |
get_test_metadata
(test_id, session=None)[source]Return all test metadata objects for associated with a given test.
Parameters: |
|
---|---|
Return list: | The list of created metadata objects |
Return type: | subunit2sql.models.TestMetadata |
get_test_prefixes
(session=None)[source]Returns all test prefixes from the DB.
This returns a list of unique test_id prefixes from the database, defined as the first dot-separated token in the test id. Prefixes wrapped in function syntax, such as ‘setUpClass (a’, will have this extra syntax stripped out of the returned value, up to and including the ‘(‘ character.
As an example, given an input test with an ID ‘prefix.test.Clazz.a_method’, the derived prefix would be ‘prefix’. Given a second test with an ID ‘setUpClass (prefix.test.Clazz)’, the derived prefix would also be ‘prefix’. If this function were called on a database containing only these tests, a list with only one entry, ‘prefix’, would be returned.
Note that this implementation assumes that tests ids are semantically separated by a period. If this is not the case (and no period characters occur at any position within test ids), the full test id will be considered the prefix, and the result of this function will be all unique test ids in the database.
Parameters: | session – Optional session object if one isn’t provided a new session will be acquired for the duration of this operation |
---|---|
Return list: | A list of all unique prefix strings, with any extraneous details removed, e.g. ‘setUpClass (‘. |
Return type: | str |
get_test_run_by_id
(test_run_id, session=None)[source]Get an individual test run by it’s id.
Parameters: |
|
---|---|
Returns: | The specified test run object |
Return type: | subunit2sql.models.TestRun |
get_test_run_dict_by_run_meta_key_value
(key, value, start_date=None, stop_date=None, session=None)[source]Get a list of test run dicts from runs with a run metadata key value pair
Parameters: |
|
---|---|
Return test_runs: | |
The dictionary of all the tests run on any run that had metadata matching the provided key value pair. |
|
Return type: | dict |
get_test_run_duration
(test_run_id, session=None)[source]Get the run duration for a specific test_run.
Parameters: |
|
---|---|
Returns: | The duration of the test run in secs |
Return type: | float |
get_test_run_metadata
(test_run_id, session=None)[source]Return all run metadata objects for associated with a given run.
Parameters: |
|
---|---|
Return list: | The list of created metadata objects |
Return type: | subunit2sql.models.RunMeta |
get_test_run_series
(start_date=None, stop_date=None, session=None, key='build_queue', value='gate')[source]Returns a time series dict of total daily run counts
Parameters: |
|
---|---|
Return dict: | A dictionary with the dates as the keys and the values being the total run count for that day. (The sum of success and failures from all runs that started that day) |
get_test_run_time_series
(test_id, session=None)[source]Returns a time series dict of run_times for successes of a single test
Parameters: |
|
---|---|
Return dict: | A dictionary with the start times as the keys and the values being the duration of the test that started at that time in sec. |
get_test_runs_by_run_id
(run_id, session=None)[source]Get all test runs for a specific run.
Parameters: |
|
---|---|
Return list: | The list of test run objects for the specified test |
Return type: | subunit2sql.models.TestRun |
get_test_runs_by_status_for_run_ids
(status, run_ids, key=None, session=None, include_run_id=False)[source]Get a list of test run dicts by status for all the specified runs
Parameters: |
|
---|---|
Return test_runs: | |
A list of dicts for the test_runs and associated data |
|
Return type: | list |
get_test_runs_by_test_id
(test_id, session=None)[source]Get all test runs for a specific test.
Parameters: |
|
---|---|
Return list: | The list of test run objects for the specified test |
Return type: | subunit2sql.models.TestRun |
get_test_runs_by_test_test_id
(test_id, start_date=None, stop_date=None, session=None, key=None, value=None, most_recent_first=False)[source]Get all test runs for a specific test by the test’stest_id column
Parameters: |
|
---|---|
Return list: | The list of test run objects for the specified test |
Return type: | subunit2sql.models.TestRun |
get_test_status_time_series
(test_id, session=None)[source]Returns a time series dict of test_run statuses of a single test
Parameters: |
|
---|---|
Return dict: | A dictionary with the start times as the keys and the values being the status of that test run. |
get_tests_by_prefix
(prefix, session=None, limit=100, offset=0)[source]Returns all tests with the given prefix in the DB.
A test prefix is the first segment of a test_id when split using a period (‘.’). This function will return a list of tests whose first period-separated token ends with the specified prefix. As a side-effect, given an input ‘a’, this will return tests with prefixes ‘a’, but also prefixes wrapped in function syntax, such as ‘setUpClass (a’.
Note that this implementation assumes that tests ids are semantically separated by a period. If no period character exists in a test id, its prefix will be considered the full test id, and this method may return unexpected results.
Parameters: |
|
---|---|
Return list: | The list of matching test objects, ordered by their test id |
Return type: | subunit2sql.models.Test |
get_tests_by_test_ids
(test_ids, session=None)[source]Get tests that match input test_ids
Parameters: |
|
---|---|
Returns: | A list of the specified test objects |
Return type: | list |
get_tests_from_run_id
(run_id, session=None)[source]Return the all tests for a specific run.
This method returns a list of all the Test objects that were executed as part of a specified run.
Parameters: |
|
---|---|
Return list: | The list of test objects for the specified test |
Return type: | subunit2sql.models.Test |
get_tests_run_dicts_from_run_id
(run_id, session=None)[source]Returns all the stored data about test runs for a specific run.
This method returns a dictionary containing all the information stored in the database regarding the test_runs. This includes the test_id from the tests table, all the stored key value pair metadata from the test_run_metadata table, and from the test_runs table the status, start_time, and stop_time.
Parameters: |
|
---|---|
Return dict: | A dictionary with the test_id from the tests for keys that contains all the stored information about the test_runs. |
get_time_series_runs_by_key_value
(key, value, start_date=None, stop_date=None, session=None)[source]Get a time series of runs with meta for all runs with a key value pai
Parameters: |
|
---|---|
Return runs: | A time series dictionary (where the top level key is a timestamp) that contains all the runs which |
Return type: | dict |
update_run
(values, run_id, session=None)[source]Update an individual run with new data.
This method will take a dictionary of fields to update for a specific run. If a field is omitted it will not be changed in the DB.
Parameters: |
|
---|---|
Returns: | The updated run object stored in the DB |
Return type: | subunit2sql.models.Run |
update_test
(values, test_id, session=None)[source]Update an individual test with new data.
This method will take a dictionary of fields to update for a specific test. If a field is omitted it will not be changed in the DB.
Parameters: |
|
---|---|
Returns: | The updated test object stored in the DB |
Return type: | subunit2sql.models.Test |
update_test_run
(values, test_run_id, session=None)[source]Update an individual test_run with new data.
This method will take a dictionary of fields to update for a specific test_run. If a field is omitted it will not be changed in the DB.
Parameters: |
|
---|---|
Returns: | The updated test_run object stored in the DB |
Return type: | subunit2sql.models.TestRun |
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.