Module: check_mk
Branch: master
Commit: 8bb741bd68d8c70292a6ea1e704a3ccbcbf7e5ac
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8bb741bd68d8c7…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Sat Nov 18 14:14:54 2017 +0100
Added some basic tests for the omd command
Change-Id: I4297f11956b1f3f7446d089033852a1a47333009
---
tests/omd/test_omd.py | 91 +++++++++++++++++++++++++++++++++++++++++++++++
tests/testlib/__init__.py | 4 +++
2 files changed, 95 insertions(+)
diff --git a/tests/omd/test_omd.py b/tests/omd/test_omd.py
new file mode 100644
index 0000000..064f34c
--- /dev/null
+++ b/tests/omd/test_omd.py
@@ -0,0 +1,91 @@
+import pytest
+import subprocess
+
+def test_run_omd(site):
+ p = site.execute(["omd"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = p.communicate()
+ assert p.wait() == 1
+ assert stderr == ""
+ assert "Usage" in stdout
+ assert "omd COMMAND -h" in stdout
+
+
+def test_run_omd_help(site):
+ p = site.execute(["omd", "help"], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
+ stdout, stderr = p.communicate()
+ assert p.wait() == 0
+ assert stderr == ""
+ assert "Usage" in stdout
+ assert "omd COMMAND -h" in stdout
+
+
+def test_run_omd_version(site):
+ p = site.execute(["omd", "version"], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
+ stdout, stderr = p.communicate()
+ assert p.wait() == 0
+ assert stderr == ""
+ assert stdout.endswith("%s\n" % site.version.omd_version())
+
+
+def test_run_omd_version_bare(site):
+ p = site.execute(["omd", "version", "-b"],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = p.communicate()
+ assert p.wait() == 0
+ assert stderr == ""
+ assert stdout.rstrip("\n") == site.version.omd_version()
+
+
+def test_run_omd_versions(site):
+ p = site.execute(["omd", "versions"], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
+ stdout, stderr = p.communicate()
+ assert p.wait() == 0
+ assert stderr == ""
+ versions = [ v.split(" ", 1)[0] for v in stdout.split("\n") ]
+ assert len(versions) >= 1
+ assert site.version.omd_version() in versions
+
+
+def test_run_omd_versions_bare(site):
+ p = site.execute(["omd", "versions", "-b"],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = p.communicate()
+ assert p.wait() == 0
+ assert stderr == ""
+ versions = stdout.split("\n")
+ assert len(versions) >= 1
+ assert site.version.omd_version() in versions
+
+
+def test_run_omd_sites(site):
+ p = site.execute(["omd", "sites"], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
+ stdout, stderr = p.communicate()
+ assert p.wait() == 0
+ assert stderr == ""
+ assert site.id in stdout
+
+
+def test_run_omd_sites_bare(site):
+ p = site.execute(["omd", "sites", "-b"],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = p.communicate()
+ assert p.wait() == 0
+ assert stderr == ""
+ sites = stdout.split("\n")
+ assert len(sites) >= 1
+ assert site.id in sites
+
+
+# TODO: Add tests for these modes (also check -h of each mode)
+# omd update Update site to other version of OMD
+# omd start [SERVICE] Start services of one or all sites
+# omd stop [SERVICE] Stop services of site(s)
+# omd restart [SERVICE] Restart services of site(s)
+# omd reload [SERVICE] Reload services of site(s)
+# omd status [SERVICE] Show status of services of site(s)
+# omd config ... Show and set site configuration parameters
+# omd diff ([RELBASE]) Shows differences compared to the original version
files
+# omd umount Umount ramdisk volumes of site(s)
+# omd backup [SITE] [-|ARCHIVE_PATH] Create a backup tarball of a site, writing it to
a file or stdout
+# omd restore [SITE] [-|ARCHIVE_PATH] Restores the backup of a site to an existing
site or creates a new site
+#
+#General Options:
+# -V <version> set specific version, useful in combination with
update/create
+# omd COMMAND -h, --help show available options of COMMAND
diff --git a/tests/testlib/__init__.py b/tests/testlib/__init__.py
index 88de0dc..2acf502 100644
--- a/tests/testlib/__init__.py
+++ b/tests/testlib/__init__.py
@@ -152,6 +152,10 @@ class CMKVersion(object):
def version_directory(self):
+ return self.omd_version()
+
+
+ def omd_version(self):
return "%s.%s" % (self.version, self.edition_short)