4 # Copyright (C) 2007 Google Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 """OS related QA tests.
29 from ganeti import utils
30 from ganeti import constants
35 from qa_utils import AssertEqual, StartSSH
38 _TEMP_OS_NAME = "TEMP-Ganeti-QA-OS"
39 _TEMP_OS_PATH = os.path.join(constants.OS_SEARCH_PATH[0], _TEMP_OS_NAME)
44 master = qa_config.GetMasterNode()
46 cmd = ['gnt-os', 'list']
47 AssertEqual(StartSSH(master['primary'],
48 utils.ShellQuoteArgs(cmd)).wait(), 0)
53 master = qa_config.GetMasterNode()
55 cmd = ['gnt-os', 'diagnose']
56 AssertEqual(StartSSH(master['primary'],
57 utils.ShellQuoteArgs(cmd)).wait(), 0)
60 def _SetupTempOs(node, dir, valid):
61 """Creates a temporary OS definition on the given node.
64 sq = utils.ShellQuoteArgs
65 parts = [sq(["rm", "-rf", dir]),
66 sq(["mkdir", "-p", dir]),
68 sq(["ln", "-fs", "/bin/true", "export"]),
69 sq(["ln", "-fs", "/bin/true", "import"]),
70 sq(["ln", "-fs", "/bin/true", "rename"])]
73 parts.append(sq(["ln", "-fs", "/bin/true", "create"]))
75 parts.append(sq(["echo", str(constants.OS_API_VERSION)]) +
76 " >ganeti_api_version")
78 cmd = ' && '.join(parts)
80 print qa_utils.FormatInfo("Setting up %s with %s OS definition" %
82 ["an invalid", "a valid"][int(valid)]))
84 AssertEqual(StartSSH(node['primary'], cmd).wait(), 0)
87 def _RemoveTempOs(node, dir):
88 """Removes a temporary OS definition.
91 cmd = ['rm', '-rf', dir]
92 AssertEqual(StartSSH(node['primary'],
93 utils.ShellQuoteArgs(cmd)).wait(), 0)
97 """Generic function for OS definition testing
100 master = qa_config.GetMasterNode()
106 for node in qa_config.get('nodes'):
114 _SetupTempOs(node, dir, valid)
117 cmd = ['gnt-os', 'diagnose']
118 result = StartSSH(master['primary'],
119 utils.ShellQuoteArgs(cmd)).wait()
121 AssertEqual(result, 0)
123 AssertEqual(result, 1)
126 _RemoveTempOs(node, dir)
130 """Testing valid OS definition"""
135 """Testing invalid OS definition"""
139 def TestOsPartiallyValid():
140 """Testing partially valid OS definition"""