Revision dffa96d6 test/ganeti.tools.prepare_node_join_unittest.py
b/test/ganeti.tools.prepare_node_join_unittest.py | ||
---|---|---|
130 | 130 |
self.assertRaises(_JoinError, prepare_node_join.VerifyClusterName, |
131 | 131 |
{}, _verify_fn=NotImplemented) |
132 | 132 |
|
133 |
def testMissingFile(self): |
|
134 |
tmpfile = utils.PathJoin(self.tmpdir, "does-not-exist") |
|
135 |
prepare_node_join._VerifyClusterName(NotImplemented, |
|
136 |
_ss_cluster_name_file=tmpfile) |
|
137 |
|
|
138 |
def testMatchingName(self): |
|
139 |
tmpfile = utils.PathJoin(self.tmpdir, "cluster_name") |
|
140 |
|
|
141 |
for content in ["cluster.example.com", "cluster.example.com\n\n"]: |
|
142 |
utils.WriteFile(tmpfile, data=content) |
|
143 |
prepare_node_join._VerifyClusterName("cluster.example.com", |
|
144 |
_ss_cluster_name_file=tmpfile) |
|
133 |
@staticmethod |
|
134 |
def _FailingVerify(name): |
|
135 |
assert name == "cluster.example.com" |
|
136 |
raise errors.GenericError() |
|
145 | 137 |
|
146 |
def testNameMismatch(self): |
|
147 |
tmpfile = utils.PathJoin(self.tmpdir, "cluster_name") |
|
138 |
def testFailingVerification(self): |
|
139 |
data = { |
|
140 |
constants.SSHS_CLUSTER_NAME: "cluster.example.com", |
|
141 |
} |
|
148 | 142 |
|
149 |
for content in ["something.example.com", "foobar\n\ncluster.example.com"]: |
|
150 |
utils.WriteFile(tmpfile, data=content) |
|
151 |
self.assertRaises(_JoinError, prepare_node_join._VerifyClusterName, |
|
152 |
"cluster.example.com", _ss_cluster_name_file=tmpfile) |
|
143 |
self.assertRaises(errors.GenericError, prepare_node_join.VerifyClusterName, |
|
144 |
data, _verify_fn=self._FailingVerify) |
|
153 | 145 |
|
154 | 146 |
|
155 | 147 |
class TestUpdateSshDaemon(unittest.TestCase): |
Also available in: Unified diff