Skip to content

Commit 9bb682a

Browse files
kavehshahediMatthewKhouzam
authored andcommitted
Add tests for get-virtual-table-columns and get-virtual-table-lines
1 parent 9861732 commit 9bb682a

File tree

1 file changed

+97
-8
lines changed

1 file changed

+97
-8
lines changed

test_tsp.py

Lines changed: 97 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@
3737
"org.eclipse.tracecompass.analysis.timing.core.segmentstore.SegmentStoreStatisticsDataProvider:"
3838
"org.eclipse.linuxtools.lttng2.ust.analysis.callstack"
3939
)
40+
TABLE_DP_ID = (
41+
"org.eclipse.tracecompass.analysis.timing.core.segmentstore.SegmentStoreTableDataProvider:"
42+
"org.eclipse.linuxtools.lttng2.ust.analysis.callstack"
43+
)
44+
4045
REQUESTED_TIME_START = 1332170682440133097
4146
REQUESTED_TIME_END = 1332170692664579801
4247
REQUESTED_TIME_LENGTH = 10
@@ -47,6 +52,8 @@
4752
CONFIG_SOURCE_TYPE = 'org.eclipse.tracecompass.tmf.core.config.xmlsourcetype'
4853

4954
# pylint: disable=too-many-public-methods
55+
56+
5057
class TestTspClient:
5158
"""TspClient test methods.
5259
@@ -81,34 +88,34 @@ def _delete_traces(self):
8188
@pytest.fixture(scope='module')
8289
def extension(self):
8390
"""Absolute xml analysis file path."""
84-
return (f'{os.getcwd()}/org.eclipse.tracecompass.incubator/tracetypes/'
85-
f'org.eclipse.tracecompass.incubator.ftrace.core/xml_analyses/{self.name}')
91+
return os.path.join(os.getcwd(), 'org.eclipse.tracecompass.incubator', 'tracetypes',
92+
'org.eclipse.tracecompass.incubator.ftrace.core', 'xml_analyses', self.name)
8693

8794
@staticmethod
8895
@pytest.fixture(scope='module')
8996
def kernel():
9097
"""Absolute kernel test trace path."""
91-
return f'{os.getcwd()}/tracecompass-test-traces/ctf/src/main/resources/kernel'
98+
return os.path.join(os.getcwd(), 'tracecompass-test-traces', 'ctf', 'src', 'main', 'resources', 'kernel')
9299

93100
@staticmethod
94101
@pytest.fixture(scope='module')
95102
def other():
96103
"""Absolute kernel-vm test trace path."""
97-
return f'{os.getcwd()}/tracecompass-test-traces/ctf/src/main/resources/kernel_vm'
104+
return os.path.join(os.getcwd(), 'tracecompass-test-traces', 'ctf', 'src', 'main', 'resources', 'kernel_vm')
98105

99106
@staticmethod
100107
@pytest.fixture(scope='module')
101108
def switches():
102109
"""Absolute switches test trace path."""
103-
return (f'{os.getcwd()}/tracecompass-test-traces/ctf/src/main/resources/context-switches/'
104-
f'context-switches-kernel')
110+
return os.path.join(os.getcwd(), 'tracecompass-test-traces', 'ctf', 'src', 'main', 'resources', 'context-switches',
111+
'context-switches-kernel')
105112

106113
@staticmethod
107114
@pytest.fixture(scope='module')
108115
def ust():
109116
"""Absolute ust test trace path."""
110-
return (f'{os.getcwd()}/tracecompass-test-traces/ctf/src/main/resources/context-switches/'
111-
f'context-switches-ust')
117+
return os.path.join(os.getcwd(), 'tracecompass-test-traces', 'ctf', 'src', 'main', 'resources', 'context-switches',
118+
'context-switches-ust')
112119

113120
@pytest.fixture(scope="module", autouse=True)
114121
def test_fetch_traces(self):
@@ -415,6 +422,88 @@ def test_fetch_timegraph_tree_complete(self, kernel):
415422
self._delete_experiments()
416423
self._delete_traces()
417424

425+
def test_fetch_virtual_table_columns(self, ust):
426+
"""Expect virtual table columns out of opened trace experiment."""
427+
traces = []
428+
response = self.tsp_client.open_trace(os.path.basename(ust), ust)
429+
traces.append(response.model.UUID)
430+
response = self.tsp_client.open_experiment(
431+
os.path.basename(ust), traces)
432+
assert response.status_code == 200
433+
experiment_uuid = response.model.UUID
434+
435+
status = ResponseStatus.RUNNING.name
436+
while status == ResponseStatus.RUNNING.name:
437+
time.sleep(1)
438+
response = self.tsp_client.fetch_virtual_table_columns(
439+
exp_uuid=experiment_uuid, output_id=TABLE_DP_ID)
440+
assert response.model is not None
441+
status = response.model.status.upper()
442+
443+
output_id = TABLE_DP_ID
444+
response = self.tsp_client.fetch_virtual_table_columns(exp_uuid=experiment_uuid, output_id=output_id)
445+
assert response.status_code == 200
446+
assert response.model.model_type == response.model.model_type.VIRTUAL_TABLE_HEADER
447+
assert len(response.model.model.columns) > 0
448+
for column in response.model.model.columns:
449+
assert column.id is not None
450+
assert column.name is not None
451+
452+
self._delete_experiments()
453+
self._delete_traces()
454+
455+
def test_fetch_virtual_table_lines(self, ust):
456+
"""Expect virtual table out of opened trace experiment."""
457+
traces = []
458+
response = self.tsp_client.open_trace(os.path.basename(ust), ust)
459+
traces.append(response.model.UUID)
460+
response = self.tsp_client.open_experiment(
461+
os.path.basename(ust), traces)
462+
assert response.status_code == 200
463+
experiment_uuid = response.model.UUID
464+
465+
status = ResponseStatus.RUNNING.name
466+
while status == ResponseStatus.RUNNING.name:
467+
time.sleep(1)
468+
response = self.tsp_client.fetch_virtual_table_columns(
469+
exp_uuid=experiment_uuid, output_id=TABLE_DP_ID)
470+
assert response.model is not None
471+
status = response.model.status.upper()
472+
473+
output_id = TABLE_DP_ID
474+
response = self.tsp_client.fetch_virtual_table_columns(exp_uuid=experiment_uuid, output_id=output_id)
475+
assert response.status_code == 200
476+
assert response.model.model_type == response.model.model_type.VIRTUAL_TABLE_HEADER
477+
assert len(response.model.model.columns) > 0
478+
for column in response.model.model.columns:
479+
assert column.id is not None
480+
assert column.name is not None
481+
482+
LOW_INDEX = 0
483+
LINE_COUNT = 10
484+
485+
params = {
486+
TspClient.PARAMETERS_KEY: {
487+
TspClient.REQUESTED_TABLE_LINE_INDEX_KEY: LOW_INDEX,
488+
TspClient.REQUESTED_TABLE_LINE_COUNT_KEY: LINE_COUNT
489+
}
490+
}
491+
response = self.tsp_client.fetch_virtual_table_lines(exp_uuid=experiment_uuid, output_id=output_id, parameters=params)
492+
assert response.status_code == 200
493+
assert response.model.model_type == response.model.model_type.VIRTUAL_TABLE
494+
assert len(response.model.model.lines) == 10
495+
for i, line in enumerate(response.model.model.lines):
496+
assert line.index is not None
497+
if i == 0:
498+
assert line.index == LOW_INDEX
499+
500+
assert len(line.cells) > 0
501+
for cell in line.cells:
502+
assert cell.content is not None
503+
504+
self._delete_experiments()
505+
self._delete_traces()
506+
418507
def test_fetch_configuration_sources(self):
419508
"""Expect at least configuration source ."""
420509
response = self.tsp_client.fetch_configuration_sources()

0 commit comments

Comments
 (0)