Skip to content

Commit

Permalink
Allow passing in marks to wait_for_any_log
Browse files Browse the repository at this point in the history
  • Loading branch information
ptnapoleon committed Apr 25, 2018
1 parent 1db7384 commit 0a8179e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions ccmlib/cluster.py
Expand Up @@ -700,5 +700,5 @@ def timed_grep_nodes_for_patterns(self, versions_to_patterns, timeout_seconds, f
return ret(node=node, matchings=matchings)
time.sleep(1)

def wait_for_any_log(self, pattern, timeout, filename='system.log'):
return common.wait_for_any_log(self.nodelist(), pattern, timeout, filename=filename)
def wait_for_any_log(self, pattern, timeout, filename='system.log', marks=None):
return common.wait_for_any_log(self.nodelist(), pattern, timeout, filename=filename, marks=marks)
7 changes: 5 additions & 2 deletions ccmlib/common.py
Expand Up @@ -764,7 +764,7 @@ def is_intlike(obj):
raise RuntimeError('Reached end of {}; should not be possible'.format(is_intlike.__name__))


def wait_for_any_log(nodes, pattern, timeout, filename='system.log'):
def wait_for_any_log(nodes, pattern, timeout, filename='system.log', marks=None):
"""
Look for a pattern in the system.log of any in a given list
of nodes.
Expand All @@ -775,11 +775,14 @@ def wait_for_any_log(nodes, pattern, timeout, filename='system.log'):
but a maximum number of attempts. This implies that
the all the grepping takes no time at all, so it is
somewhat inaccurate, but probably close enough.
@param marks A dict of nodes to marks in the file. Keys must match the first param list.
@return The first node in whose log the pattern was found
"""
if marks is None:
marks = {}
for _ in range(timeout):
for node in nodes:
found = node.grep_log(pattern, filename=filename)
found = node.grep_log(pattern, filename=filename, from_mark=marks.get(node, None))
if found:
return node
time.sleep(1)
Expand Down
5 changes: 4 additions & 1 deletion ccmlib/dse_cluster.py
Expand Up @@ -72,10 +72,13 @@ def create_node(self, name, auto_bootstrap, thrift_interface, storage_interface,
def start(self, no_wait=False, verbose=False, wait_for_binary_proto=False, wait_other_notice=True, jvm_args=None, profile_options=None, quiet_start=False, allow_root=False):
if jvm_args is None:
jvm_args = []
marks = {}
for node in self.nodelist():
marks[node] = node.mark_log()
started = super(DseCluster, self).start(no_wait, verbose, wait_for_binary_proto, wait_other_notice, jvm_args, profile_options, quiet_start=quiet_start, allow_root=allow_root, timeout=180)
self.start_opscenter()
if self._misc_config_options.get('enable_aoss', False):
self.wait_for_any_log('AlwaysOn SQL started', 600)
self.wait_for_any_log('AlwaysOn SQL started', 600, marks=marks)
return started

def stop(self, wait=True, signal_event=signal.SIGTERM, **kwargs):
Expand Down

0 comments on commit 0a8179e

Please sign in to comment.