-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add state and arrow requests #69
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,7 @@ | |
"org.eclipse.tracecompass.analysis.timing.core.segmentstore.SegmentStoreTableDataProvider:" | ||
"org.eclipse.linuxtools.lttng2.ust.analysis.callstack" | ||
) | ||
TIMEGRAPH_DP_ID = "org.eclipse.tracecompass.internal.analysis.os.linux.core.threadstatus.ThreadStatusDataProvider" | ||
|
||
REQUESTED_TIME_START = 1332170682440133097 | ||
REQUESTED_TIME_END = 1332170692664579801 | ||
|
@@ -501,6 +502,87 @@ def test_fetch_virtual_table_lines(self, ust): | |
for cell in line.cells: | ||
assert cell.content is not None | ||
|
||
def test_fetch_timegraph_states(self, kernel): | ||
"""Expect having states after tree is complete""" | ||
traces = [] | ||
response = self.tsp_client.open_trace(os.path.basename(kernel), kernel) | ||
traces.append(response.model.UUID) | ||
response = self.tsp_client.open_experiment( | ||
os.path.basename(kernel), traces) | ||
assert response.status_code == 200 | ||
experiment_uuid = response.model.UUID | ||
|
||
response = self.tsp_client.fetch_experiment_outputs(experiment_uuid) | ||
output_id = TIMEGRAPH_DP_ID | ||
status = ResponseStatus.RUNNING.name | ||
while status == ResponseStatus.RUNNING.name: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. replace |
||
time.sleep(1) | ||
response = self.tsp_client.fetch_timegraph_tree( | ||
experiment_uuid, output_id) | ||
assert response.model is not None | ||
status = response.model.status.upper() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. replace it with:
|
||
entries = [entry.id for entry in response.model.model.entries if entry.has_row_model] | ||
params = { | ||
TspClient.REQUESTED_TIME_RANGE_KEY: { | ||
TspClient.REQUESTED_TIME_RANGE_NUM_TIMES_KEY: 100, | ||
TspClient.REQUESTED_TIME_RANGE_START_KEY: REQUESTED_TIME_START, | ||
TspClient.REQUESTED_TIME_RANGE_END_KEY: REQUESTED_TIME_END | ||
}, | ||
TspClient.REQUESTED_ITEM_KEY: entries | ||
} | ||
response = self.tsp_client.fetch_timegraph_states( | ||
experiment_uuid, output_id, { TspClient.PARAMETERS_KEY: params }) | ||
assert response.status_code == 200 | ||
assert len(response.model.model.rows) > 0 | ||
assert len(response.model.model.rows[0].states) != 0 | ||
row = response.model.model.rows[0].states[0] | ||
assert row.start_time is not None | ||
assert row.end_time is not None | ||
self._delete_experiments() | ||
self._delete_traces() | ||
|
||
def test_fetch_timegraph_arrows(self, kernel): | ||
"""Expect having arrows after tree is complete""" | ||
traces = [] | ||
response = self.tsp_client.open_trace(os.path.basename(kernel), kernel) | ||
traces.append(response.model.UUID) | ||
response = self.tsp_client.open_experiment( | ||
os.path.basename(kernel), traces) | ||
assert response.status_code == 200 | ||
experiment_uuid = response.model.UUID | ||
|
||
response = self.tsp_client.fetch_experiment_outputs(experiment_uuid) | ||
output_id = TIMEGRAPH_DP_ID | ||
status = ResponseStatus.RUNNING.name | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. replace |
||
while status == ResponseStatus.RUNNING.name: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. replace |
||
time.sleep(1) | ||
response = self.tsp_client.fetch_timegraph_tree( | ||
experiment_uuid, output_id) | ||
assert response.model is not None | ||
status = response.model.status.upper() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. replace it with:
|
||
|
||
entries = [entry.id for entry in response.model.model.entries if entry.has_row_model] | ||
params = { | ||
TspClient.REQUESTED_TIME_RANGE_KEY: { | ||
TspClient.REQUESTED_TIME_RANGE_NUM_TIMES_KEY: 5000, | ||
TspClient.REQUESTED_TIME_RANGE_START_KEY: REQUESTED_TIME_START, | ||
TspClient.REQUESTED_TIME_RANGE_END_KEY: REQUESTED_TIME_END | ||
}, | ||
TspClient.REQUESTED_ITEM_KEY: entries | ||
} | ||
response = self.tsp_client.fetch_timegraph_arrows( | ||
experiment_uuid, output_id, { TspClient.PARAMETERS_KEY: params }) | ||
assert response.status_code == 200 | ||
assert len(response.model.model) != 0 | ||
arrow = response.model.model[0] | ||
assert arrow.source_id is not None | ||
assert arrow.target_id is not None | ||
if arrow.start is None or arrow.end is None: | ||
assert arrow.duration | ||
else: | ||
assert arrow.start is not None | ||
assert arrow.end is not None | ||
assert arrow.style is not None | ||
self._delete_experiments() | ||
self._delete_traces() | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,9 @@ | |
'Accept': APPLICATION_JSON} | ||
|
||
GET_TREE_FAILED = "failed to get tree: {0}" | ||
GET_STATES_FAILED = "failed to get states: {0}" | ||
GET_ARROWS_FAILED = "failed to get arrows: {0}" | ||
|
||
|
||
# pylint: disable=consider-using-f-string,missing-timeout | ||
|
||
|
@@ -346,12 +349,13 @@ def fetch_timegraph_tree(self, exp_uuid, output_id, parameters=None): | |
:returns: :class: `TspClientResponse <GenericResponse>` object Timegraph entries response | ||
:rtype: TspClientResponse | ||
''' | ||
api_url = '{0}experiments/{1}/outputs/timeGraph/{2}/tree'.format( | ||
self.base_url, exp_uuid, output_id) | ||
api_url = f'{self.base_url}experiments/{exp_uuid}/outputs/timeGraph/{output_id}/tree' | ||
|
||
params = parameters | ||
if parameters is None: | ||
params = {} | ||
params = { | ||
"parameters": { } | ||
} | ||
|
||
response = requests.post(api_url, json=params, headers=headers) | ||
|
||
|
@@ -363,6 +367,62 @@ def fetch_timegraph_tree(self, exp_uuid, output_id, parameters=None): | |
print(GET_TREE_FAILED.format(response.status_code)) | ||
return TspClientResponse(None, response.status_code, response.text) | ||
|
||
|
||
def fetch_timegraph_states(self, exp_uuid, output_id, parameters=None): | ||
''' | ||
Fetch Time Graph States | ||
:param exp_uuid: Experiment UUID | ||
:param output_id: Output ID | ||
:param parameters: Query object | ||
:returns: :class: `TspClientResponse <GenericResponse>` object Timegraph Model response | ||
:rtype: TspClientResponse | ||
''' | ||
api_url = f'{self.base_url}experiments/{exp_uuid}/outputs/timeGraph/{output_id}/states' | ||
|
||
params = parameters | ||
if parameters is None: | ||
params = { | ||
"parameters": { } | ||
} | ||
|
||
response = requests.post(api_url, json=params, headers=headers) | ||
|
||
if response.status_code == 200: | ||
return TspClientResponse(GenericResponse(json.loads(response.content.decode('utf-8')), | ||
ModelType.TIME_GRAPH_STATE), | ||
response.status_code) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This fails here. Replace it by: return TspClientResponse(GenericResponse(json.loads(response.content.decode('utf-8')),
ModelType.TIME_GRAPH_STATE),
response.status_code, response.text) |
||
else: # pragma: no cover | ||
print(GET_STATES_FAILED.format(response.status_code)) | ||
return TspClientResponse(None, response.status_code, response.text) | ||
|
||
|
||
def fetch_timegraph_arrows(self, exp_uuid, output_id, parameters=None): | ||
''' | ||
Fetch Time Graph Arrows | ||
:param exp_uuid: Experiment UUID | ||
:param output_id: Output ID | ||
:param parameters: Query object | ||
:returns: :class: `TspClientResponse <GenericResponse>` list of object Timegraph arrows response | ||
:rtype: TspClientResponse | ||
''' | ||
api_url = f'{self.base_url}experiments/{exp_uuid}/outputs/timeGraph/{output_id}/arrows' | ||
|
||
params = parameters | ||
if parameters is None: | ||
params = { | ||
"parameters": { } | ||
} | ||
|
||
response = requests.post(api_url, json=params, headers=headers) | ||
|
||
if response.status_code == 200: | ||
return TspClientResponse(GenericResponse(json.loads(response.content.decode('utf-8')), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here too: return TspClientResponse(GenericResponse(json.loads(response.content.decode('utf-8')),
ModelType.TIME_GRAPH_ARROW),
response.status_code, response.text) |
||
ModelType.TIME_GRAPH_ARROW), | ||
response.status_code) | ||
else: # pragma: no cover | ||
print(GET_ARROWS_FAILED.format(response.status_code)) | ||
return TspClientResponse(None, response.status_code, response.text) | ||
|
||
def fetch_xy_tree(self, exp_uuid, output_id, parameters=None): | ||
''' | ||
Fetch XY tree, Model extends Entry | ||
|
@@ -377,7 +437,9 @@ def fetch_xy_tree(self, exp_uuid, output_id, parameters=None): | |
|
||
params = parameters | ||
if parameters is None: | ||
params = {} | ||
params = { | ||
"parameters": { } | ||
} | ||
|
||
response = requests.post(api_url, json=params, headers=headers) | ||
|
||
|
@@ -401,7 +463,12 @@ def fetch_xy(self, exp_uuid, output_id, parameters): | |
api_url = '{0}experiments/{1}/outputs/XY/{2}/xy'.format( | ||
self.base_url, exp_uuid, output_id) | ||
|
||
response = requests.post(api_url, json=parameters, headers=headers) | ||
params = parameters | ||
if parameters is None: | ||
params = { | ||
"parameters": { } | ||
} | ||
response = requests.post(api_url, json=params, headers=headers) | ||
|
||
if response.status_code == 200: | ||
return TspClientResponse(GenericResponse(json.loads(response.content.decode('utf-8')), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace
ResponseStatus.RUNNING.name
withResponseStatus.RUNNING