Skip to content

Commit

Permalink
improvement(logcollector): collect schema info
Browse files Browse the repository at this point in the history
Collect schema and system_schema.tables info and save it on the
runner. Add the new logs to the node logs archive

(cherry picked from commit d8c275f)

# Conflicts:
#	sdcm/logcollector.py
#	sdcm/tester.py
  • Loading branch information
juliayakovlev committed Dec 8, 2024
1 parent a151912 commit cbe1cd2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
6 changes: 6 additions & 0 deletions sdcm/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,12 @@ def __init__(self, name, parent_cluster, ssh_login_info=None, base_logdir=None,
self._datacenter_name = None
self._node_rack = None

def save_cqlsh_output_in_file(self, cmd: str, log_file: str):
self.log.info("Save command '%s' output in the file. Node %s", cmd, self.name)
result_tables = self.run_cqlsh(cmd, split=True)
for line in result_tables:
self.remoter.run(f"echo '{line}' >> {log_file}")

def _is_node_ready_run_scylla_commands(self) -> bool:
"""
When node is just created and started to configure, during first node initializing, it is impossible to connect to the node yet and
Expand Down
6 changes: 5 additions & 1 deletion sdcm/logcollector.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,11 @@ class ScyllaLogCollector(LogCollector):
CommandLog(name='scylla-manager-agent.yaml',
command=f'cat {SCYLLA_MANAGER_AGENT_YAML_PATH}'),
CommandLog(name='setup_scripts_errors.log',
command='for i in /var/tmp/scylla/*.log;do echo [$i]; cat $i;done')
command='for i in /var/tmp/scylla/*.log;do echo [$i]; cat $i;done'),
CommandLog(name='schema.log',
command='cat schema.log'),
CommandLog(name='system_schema_tables.log',
command='cat system_schema_tables.log'),
]
cluster_log_type = "db-cluster"
cluster_dir_prefix = "db-cluster"
Expand Down
11 changes: 11 additions & 0 deletions sdcm/tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -2781,10 +2781,21 @@ def clean_resources(self):

self.destroy_credentials()

def save_nodes_schema(self):
if self.db_cluster is None:
self.log.info("No nodes found in the Scylla cluster")

self.log.info("Save nodes user schema in the files")
for node in self.db_cluster.nodes:
node.save_cqlsh_output_in_file(cmd="desc schema", log_file="schema.log")
node.save_cqlsh_output_in_file(cmd="select JSON * from system_schema.tables",
log_file="system_schema_tables.log")

def tearDown(self):
self.teardown_started = True
with silence(parent=self, name='Sending test end event'):
InfoEvent(message="TEST_END").publish()
self.save_nodes_schema()
self.log.info('TearDown is starting...')
self.stop_timeout_thread()
self.stop_event_analyzer()
Expand Down
3 changes: 3 additions & 0 deletions unit_tests/test_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ def stop_event_device(self):
time.sleep(0.5)
super().stop_event_device()

def save_nodes_schema(self):
pass


class SubtestAndTeardownFailsTest(ClusterTesterForTests):
def test(self):
Expand Down

0 comments on commit cbe1cd2

Please sign in to comment.