From 45f534e4a37cdc58a83b55773a89e86074cee7f5 Mon Sep 17 00:00:00 2001 From: Federico Ressi Date: Thu, 10 Oct 2019 10:55:43 +0200 Subject: [PATCH] Create scenario test case for cloud nodes Change-Id: I4d71137662d4fcafb51da7a73aa69b18e24306a2 --- tobiko/tests/scenario/cloud/__init__.py | 0 tobiko/tests/scenario/cloud/test_nodes.py | 47 +++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 tobiko/tests/scenario/cloud/__init__.py create mode 100644 tobiko/tests/scenario/cloud/test_nodes.py diff --git a/tobiko/tests/scenario/cloud/__init__.py b/tobiko/tests/scenario/cloud/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tobiko/tests/scenario/cloud/test_nodes.py b/tobiko/tests/scenario/cloud/test_nodes.py new file mode 100644 index 000000000..f2244c66e --- /dev/null +++ b/tobiko/tests/scenario/cloud/test_nodes.py @@ -0,0 +1,47 @@ +# Copyright (c) 2019 Red Hat +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +from __future__ import absolute_import + +import testtools + +import tobiko +from tobiko.shell import ping +from tobiko.shell import sh +from tobiko.openstack import topology + + +class OpenstackNodesTest(testtools.TestCase): + + topology = tobiko.required_setup_fixture( + topology.get_default_openstack_topology_class()) + + def test_public_ips(self): + ips = dict() + for node in self.topology.nodes: + ping.ping(node.public_ip).assert_replied() + other = ips.setdefault(node.public_ip, node) + if node is not other: + tobiko.fail("Nodes {!r} and {!r} have the same IP: {!s}", + node.name, other.name, node.public_ip) + + def test_hostnames(self): + hostnames = dict() + for node in self.topology.nodes: + hostname = sh.get_hostname(ssh_client=node.ssh_client) + self.assertTrue(hostname.startswith(node.name)) + other = hostnames.setdefault(hostname, node) + if node is not other: + tobiko.fail("Nodes {!r} and {!r} have the same hostname: {!r}", + node.name, other.name, hostname)