Skip to content

Commit

Permalink
Merge pull request #12 from cgalibern/fix-om-mon-stack-after-daemon-s…
Browse files Browse the repository at this point in the history
…tartup

Fix 'om mon' stack, when called just after daemon startup
  • Loading branch information
cvaroqui committed Dec 18, 2020
2 parents f2cb0df + f121a83 commit a512083
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
27 changes: 27 additions & 0 deletions opensvc/tests/render/test_cluster.py
@@ -0,0 +1,27 @@
import pytest

from env import Env
from utilities.render.cluster import format_cluster


@pytest.mark.ci
class TestFormatCluster(object):
@staticmethod
def test_show_monitor_state_undef_when_monitor_has_not_yet_state(mocker):
mocker.patch.object(Env, "nodename", "node1")
output = format_cluster(node=[Env.nodename],
data={"monitor": {"nodes": {}, "services": {}}})
assert output == """Threads node1
daemon running |
monitor undef
Nodes node1
score |
load 15m |
mem | -
swap | -
compat warn |
state |
*/svc/* node1
"""
2 changes: 2 additions & 0 deletions opensvc/utilities/render/cluster/__init__.py
Expand Up @@ -518,6 +518,8 @@ def load_hb(key, _data):
out.append(line)

def load_monitor(key, _data):
if "state" not in _data:
_data["state"] = "undef"
if _data["state"] == "running":
state = colorize(_data["state"], color.GREEN)
else:
Expand Down

0 comments on commit a512083

Please sign in to comment.