Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ robot --argumentfile prioritized.robot --metadata changes:"$(YOUR_GIT_COMMAND_LI

robot --argumentfile remnant.robot --metadata changes:"$(YOUR_GIT_COMMAND_LISTING_RELEVANT_CHANGES)" --metadata commit:$(git rev-parse HEAD) tests/
```
For more details about the data expected by the prioritization API see [prioritization_api.md](prioritization_api.md).

## Swagger docs

Expand Down
23 changes: 23 additions & 0 deletions prioritization_api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#Querying tests from sinle repository

The body looks similar as in the [feeding.api](feeding_api.md), because API is also using the `changes` and the
`context` keys in identical manner. But because API is querying test, we do not the `tests` contains only the
`repository` and `subtype` keys.

```
{
"context": "the execution context (e.g. from which pipeline to not mix results from parallel tests. Supports LIKE operator from SQL engine, example %)" ,
"tests": {
"repository": "Repository ",
"subtype": "type of test (optional, for separating test cases and for filtering subsets when prioritising",
},
"changes": [
{
"name": "string representing the changed item, for example file path",
"repository": "repository (optional, for separating between changed items with identical names)",
"item_type": "(optional, for separating items and for filtering subsets when prioritising)",
"subtype": "(optional, for separating items for filtering subsets when prioritising"
}
]
}
```
4 changes: 2 additions & 2 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,11 @@ def post(self):
data = json.loads(self.request.body)
tests = data['tests']
changes = data['changes']
context = data['context'] if 'context' in data else 'default'
context = data.get('context', 'default')
changed_item_ids = self.item_ids(changes)
if type(tests) == dict:
repository = tests['repository']
subtype = tests['subtype'] if 'subtype' in tests else 'default'
subtype = tests.get('subtype', 'default')
prioritized = yield self.async_query(self.async_db.prioritize, context, repository, subtype,
changed_item_ids)
elif type(tests) == list:
Expand Down
7 changes: 5 additions & 2 deletions sql_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
SET status=%(status)s, fingerprint=%(fingerprint)s, last_updated='now', execution_id=%(execution_id)s
"""


def update_links(alpha, strength, effected_item, changed_items):
VALUES_ROW = "({effected_item}, {strength}, {changed_item}, %(context)s, 'now')"
value_rows = []
Expand All @@ -48,6 +49,7 @@ def update_links(alpha, strength, effected_item, changed_items):
alpha=float(alpha),
strength=float(strength))


TEST_ID_SUBQUERY = """
SELECT id
FROM item
Expand All @@ -56,15 +58,16 @@ def update_links(alpha, strength, effected_item, changed_items):
AND subtype=%(subtype)s
"""


def prioritize(use_test_list=True):
return """
SELECT item.id, item.name, repository, item_type, subtype,
status, sum(strength) as strength
FROM item
LEFT OUTER JOIN previous_status ON previous_status.test=item.id
AND previous_status.context=%(context)s
AND previous_status.context LIKE %(context)s
LEFT OUTER JOIN link ON link.effected_item=item.id
AND link.context=%(context)s
AND link.context LIKE %(context)s
AND link.changed_item IN %(changed_item_ids)s
WHERE item.id IN {test_ids}
GROUP BY item.id, item.name, repository, item_type, subtype, status
Expand Down