def test_ha_cluster_vlan(self): logging.info("Testing ha vlan installation.") self._revert_nodes() cluster_name = 'ha_vlan' nodes = { 'controller': ['slave1', 'slave2', 'slave3'], 'compute': ['slave4', 'slave5'] } self._create_cluster(name=cluster_name, net_manager="VlanManager") cluster_id = self._basic_provisioning(cluster_name, nodes, 90 * 60) slave = ci.environment.node['slave1'] node = self._get_slave_node_by_devops_node(slave) wait(lambda: self._check_cluster_status(node['ip'], 13, 8), timeout=300) logging.info("Verifying networks for ha vlan installation.") vlans = self._get_cluster_vlans(cluster_id) slave2 = ci.environment.node['slave2'] slave3 = ci.environment.node['slave3'] slave4 = ci.environment.node['slave4'] slave5 = ci.environment.node['slave5'] for vlan in vlans: for n in (slave, slave2, slave3, slave4, slave5): self._restore_vlan_in_ebtables(n.interfaces[0].target_dev, vlan, False) task = self._run_network_verify(cluster_id) self._task_wait(task, 'Verify network ha vlan', 60 * 2)
def test_ha_cluster_vlan(self): logging.info("Testing ha vlan installation.") self._revert_nodes() cluster_name = 'ha_vlan' nodes = { 'controller': ['slave1', 'slave2', 'slave3'], 'compute': ['slave4', 'slave5'] } self._create_cluster(name=cluster_name, net_manager="VlanManager") cluster_id = self._basic_provisioning(cluster_name, nodes, 90 * 60) slave = ci.environment.node['slave1'] node = self._get_slave_node_by_devops_node(slave) wait( lambda: self._check_cluster_status(node['ip'], 13, 8), timeout=300 ) logging.info("Verifying networks for ha vlan installation.") vlans = self._get_cluster_vlans(cluster_id) slave2 = ci.environment.node['slave2'] slave3 = ci.environment.node['slave3'] slave4 = ci.environment.node['slave4'] slave5 = ci.environment.node['slave5'] for vlan in vlans: for n in (slave, slave2, slave3, slave4, slave5): self._restore_vlan_in_ebtables( n.interfaces[0].target_dev, vlan, False ) task = self._run_network_verify(cluster_id) self._task_wait(task, 'Verify network ha vlan', 60 * 2)
def test_puppetmaster_alive(self): wait( lambda: tcp_ping(self.ip, 8140), timeout=5 ) self.remote.connect_ssh(self.ip, 'root', 'r00tme') ps_output = self.remote.execute('ps ax')['stdout'] pm_processes = filter( lambda x: '/usr/sbin/puppetmasterd' in x, ps_output ) logging.debug("Found puppet master processes: %s" % pm_processes) self.assertEquals(len(pm_processes), 4)
def test_ip_address_detection(self): node = self.env.nodes[0] network = self.env.networks[0] node.start() # Wait for ISOLINUX to boot time.sleep(10) # Trigger ISOLINUX menu selection node.send_keys('<Enter>') try: wait(lambda: len(node.ip_addresses) > 0, timeout=60) except TimeoutError: self.fail("Node didn't get ip_address in specified amount of time") self.assertEqual(node.ip_address, node.ip_addresses[0]) self.assertTrue(node.ip_address in network.ip_addresses)
def test_simple_cluster_flat(self): logging.info("Testing simple flat installation.") self._revert_nodes() cluster_name = 'simple_flat' nodes = {'controller': ['slave1'], 'compute': ['slave2']} cluster_id = self._basic_provisioning(cluster_name, nodes) slave = ci.environment.node['slave1'] node = self._get_slave_node_by_devops_node(slave) wait(lambda: self._check_cluster_status(node['ip'], 5), timeout=300) logging.info("Verifying networks for simple flat installation.") vlans = self._get_cluster_vlans(cluster_id) slave2 = ci.environment.node['slave2'] for vlan in vlans: for n in (slave, slave2): self._restore_vlan_in_ebtables(n.interfaces[0].target_dev, vlan, False) task = self._run_network_verify(cluster_id) self._task_wait(task, 'Verify network simple flat', 60 * 2)
def test_simple_cluster_flat(self): logging.info("Testing simple flat installation.") self._revert_nodes() cluster_name = 'simple_flat' nodes = {'controller': ['slave1'], 'compute': ['slave2']} cluster_id = self._basic_provisioning(cluster_name, nodes) slave = ci.environment.node['slave1'] node = self._get_slave_node_by_devops_node(slave) wait(lambda: self._check_cluster_status(node['ip'], 5), timeout=300) logging.info("Verifying networks for simple flat installation.") vlans = self._get_cluster_vlans(cluster_id) slave2 = ci.environment.node['slave2'] for vlan in vlans: for n in (slave, slave2): self._restore_vlan_in_ebtables( n.interfaces[0].target_dev, vlan, False ) task = self._run_network_verify(cluster_id) self._task_wait(task, 'Verify network simple flat', 60 * 2)
def main(): parser = OptionParser() (options, args) = parser.parse_args() if len(args) != 1: print("Usage: python install_admin.py <admin_disk_path>") sys.exit(1) admin_disk_path = args[0] download_iso() environment = Environment('admin') network = Network('default') environment.networks.append(network) admin_node = Node('admin') admin_node.vnc = True admin_node.cdrom = Cdrom(isopath=ADMIN_ISO_PATH) admin_node.disks.append(Disk(size=8 * 1024 ** 3)) admin_node.interfaces.append(Interface(network)) admin_node.boot += ['disk', 'cdrom'] environment.nodes.append(admin_node) log("Creating environment") controller = Controller(Libvirt()) controller.build_environment(environment) log("Starting node") try: admin_node.start() log("Node started. VNC is available at port %d" % admin_node.vnc_port) log("Waiting node to boot") time.sleep(10) ip = network.ip_addresses log("Sending user input") admin_node.send_keys("""<Esc><Enter> <Wait> /install/vmlinuz initrd=/install/initrd.gz priority=critical locale=en_US file=/cdrom/preseed/manual.seed vga=788 netcfg/get_ipaddress=%(ipaddress)s netcfg/get_netmask=%(netmask)s netcfg/get_gateway=%(gateway)s netcfg/get_nameservers=%(gateway)s netcfg/confirm_static=true <Enter>""" % {'ipaddress': ip[2], 'netmask': ip.netmask, 'gateway': ip[1]}) log("Waiting for node to install") wait(lambda: tcp_ping(ip[2], 22)) log("Stopping node") admin_node.stop() log("Copying node's disk image") shutil.copy(admin_node.disks[0].path, admin_disk_path) print( "Admin image creation completed. Image is stored at %s" % admin_disk_path) log("Destroying environment") controller.destroy_environment(environment) except: log("Error occurred, leaving environment for inspection") raise
def main(): logging.basicConfig(level=logging.WARN) logger = logging.getLogger('test.integration') logger.setLevel(logging.INFO) environment = devops.load(MASTER_AND_SLAVE_CONFIG) logger.info("Building environment") devops.build(environment) logger.info("Environment ready") try: external_network = environment.network['external'] master_node = environment.node['master'] slave_node = environment.node['slave'] logger.info("Starting master node") master_node.start() logger.info("VNC to master is available on %d" % master_node.vnc_port) logger.info("Waiting master node to boot") time.sleep(15) logger.info("Sending user input") ip = external_network.ip_addresses host_ip = ip[1] master_ip = ip[2] netmask = ip.netmask master_node.send_keys("""<Esc><Enter> <Wait> /install/vmlinuz initrd=/install/initrd.gz priority=critical locale=en_US file=/cdrom/preseed/manual.seed vga=788 netcfg/get_ipaddress=%s netcfg/get_netmask=%s netcfg/get_gateway=%s netcfg/get_nameservers=%s netcfg/confirm_static=true <Enter>""" % (master_ip, netmask, host_ip, host_ip)) logger.info("Finished sending user input") logger.info("Waiting master node to install") wait(lambda: tcp_ping(master_ip, 22)) logger.info("Starting slave node") slave_node.start() logger.info("VNC to slave node at port %d" % slave_node.vnc_port) logger.info("Waiting slave node to configure network") wait(lambda: len(slave_node.ip_addresses) > 0, timeout=120) logger.info("Slave node has IP address %s" % slave_node.ip_addresses[0]) except: devops.save(environment) logger.warn("Environment has been saved as %s" % environment.id) raise
def main(): parser = OptionParser() (options, args) = parser.parse_args() if len(args) != 1: print("Usage: python install_admin.py <admin_disk_path>") sys.exit(1) admin_disk_path = args[0] download_iso() environment = Environment('admin') network = Network('default') environment.networks.append(network) admin_node = Node('admin') admin_node.vnc = True admin_node.cdrom = Cdrom(isopath=ADMIN_ISO_PATH) admin_node.disks.append(Disk(size=8 * 1024**3)) admin_node.interfaces.append(Interface(network)) admin_node.boot += ['disk', 'cdrom'] environment.nodes.append(admin_node) log("Creating environment") controller = Controller(Libvirt()) controller.build_environment(environment) log("Starting node") try: admin_node.start() log("Node started. VNC is available at port %d" % admin_node.vnc_port) log("Waiting node to boot") time.sleep(10) ip = network.ip_addresses log("Sending user input") admin_node.send_keys("""<Esc><Enter> <Wait> /install/vmlinuz initrd=/install/initrd.gz priority=critical locale=en_US file=/cdrom/preseed/manual.seed vga=788 netcfg/get_ipaddress=%(ipaddress)s netcfg/get_netmask=%(netmask)s netcfg/get_gateway=%(gateway)s netcfg/get_nameservers=%(gateway)s netcfg/confirm_static=true <Enter>""" % { 'ipaddress': ip[2], 'netmask': ip.netmask, 'gateway': ip[1] }) log("Waiting for node to install") wait(lambda: tcp_ping(ip[2], 22)) log("Stopping node") admin_node.stop() log("Copying node's disk image") shutil.copy(admin_node.disks[0].path, admin_disk_path) print("Admin image creation completed. Image is stored at %s" % admin_disk_path) log("Destroying environment") controller.destroy_environment(environment) except: log("Error occurred, leaving environment for inspection") raise
} keys = """<Esc><Enter> <Wait> vmlinuz initrd=initrd.img ks=cdrom:/ks.cfg ip=%(ip)s netmask=%(mask)s gw=%(gw)s dns1=%(gw)s hostname=%(hostname)s <Enter> """ % params node.send_keys(keys) logger.info( "Waiting for completion of admin node software installation") wait(lambda: tcp_ping(node.ip_address, 22), timeout=self.installation_timeout) logger.info("Got SSH access to admin node, " "waiting for ports 80 and 8000 to open") wait(lambda: tcp_ping(node.ip_address, 80) and tcp_ping( node.ip_address, 8000), timeout=self.deployment_timeout) logging.info("Waiting while bootstrapping is in progress") ssh = SSHClient() logpath = "/var/log/puppet/bootstrap_admin_node.log" str_success = "Finished catalog run" ssh.connect_ssh(str(self.environment.node['admin'].ip_address), "root", "r00tme") wait(lambda: not ssh.execute("grep '%s' '%s'" %
def main(): logging.basicConfig(level=logging.WARN) logger = logging.getLogger('test.integration') logger.setLevel(logging.INFO) environment = devops.load(MASTER_AND_SLAVE_CONFIG) logger.info("Building environment") devops.build(environment) logger.info("Environment ready") try: external_network = environment.network['external'] master_node = environment.node['master'] slave_node = environment.node['slave'] logger.info("Starting master node") master_node.start() logger.info("VNC to master is available on %d" % master_node.vnc_port) logger.info("Waiting master node to boot") time.sleep(15) logger.info("Sending user input") ip = external_network.ip_addresses host_ip = ip[1] master_ip = ip[2] netmask = ip.netmask master_node.send_keys("""<Esc><Enter> <Wait> /install/vmlinuz initrd=/install/initrd.gz priority=critical locale=en_US file=/cdrom/preseed/manual.seed vga=788 netcfg/get_ipaddress=%s netcfg/get_netmask=%s netcfg/get_gateway=%s netcfg/get_nameservers=%s netcfg/confirm_static=true <Enter>""" % (master_ip, netmask, host_ip, host_ip)) logger.info("Finished sending user input") logger.info("Waiting master node to install") wait(lambda: tcp_ping(master_ip, 22)) logger.info("Starting slave node") slave_node.start() logger.info("VNC to slave node at port %d" % slave_node.vnc_port) logger.info("Waiting slave node to configure network") wait(lambda: len(slave_node.ip_addresses) > 0, timeout=120) logger.info( "Slave node has IP address %s" % slave_node.ip_addresses[0]) except: devops.save(environment) logger.warn("Environment has been saved as %s" % environment.id) raise
<Wait> vmlinuz initrd=initrd.img ks=cdrom:/ks.cfg ip=%(ip)s netmask=%(mask)s gw=%(gw)s dns1=%(gw)s hostname=%(hostname)s <Enter> """ % params node.send_keys(keys) logger.info( "Waiting for completion of admin node software installation" ) wait( lambda: tcp_ping(node.ip_address, 22), timeout=self.installation_timeout ) logger.info( "Got SSH access to admin node, " "waiting for ports 80 and 8000 to open" ) wait( lambda: tcp_ping(node.ip_address, 80) and tcp_ping(node.ip_address, 8000), timeout=self.deployment_timeout ) logging.info("Waiting while bootstrapping is in progress") ssh = SSHClient() logpath = "/var/log/puppet/bootstrap_admin_node.log"
def test_cobbler_alive(self): wait(lambda: http(host=self.ip, url='/cobbler_api', waited_code=502), timeout=60) server = xmlrpclib.Server('http://%s/cobbler_api' % self.ip) # raises an error if something isn't right token = server.login('cobbler', 'cobbler')