Create scenario test case for cloud nodes

Change-Id: I4d71137662d4fcafb51da7a73aa69b18e24306a2
This commit is contained in:
Federico Ressi 2019-10-10 10:55:43 +02:00
parent 9afc448f94
commit 45f534e4a3
2 changed files with 47 additions and 0 deletions

View File

View File

@ -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)