Created
March 20, 2018 15:07
-
-
Save firemanxbr/a5a37b32a2d265f29be640fa3a7c7581 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from avocado_qemu import test | |
from avocado.utils import vmimage | |
from avocado.utils import git | |
from avocado.utils import process | |
class TestMinishift(test.QemuTest): | |
""" | |
:avocado: enable | |
""" | |
def setUp(self): | |
distro = self.params.get('distro', default='Fedora') | |
image = vmimage.get(distro, cache_dir='~/minishift/') | |
self.vm.add_image(image.path, cloudinit=True, snapshot=False) | |
self.vm.args.extend(['-device', 'virtio-net-pci,id=avocado_nic,netdev=device_avocado_nic']) | |
self.vm.args.extend(['-netdev', 'user,id=device_avocado_nic,hostfwd=tcp::12345-:22']) | |
self.vm.args.extend(['-m', '6400']) | |
self.vm.args.extend(['-cpu', 'host']) | |
self.vm.args.extend(['-accel', 'kvm']) | |
# Headless | |
self.vm.args.extend(['-display', 'none', '-vga', 'none']) | |
self.vm.launch() | |
console = self.vm.get_console() | |
console.close() | |
git.get_repo('https://github.com/firemanxbr/contra-env-setup.git', | |
branch='new_release_v2', | |
destination_dir=self.workdir) | |
def test(self): | |
print('WORKDIR: {0}'.format(self.workdir)) | |
ssh_args = ['-o UserKnownHostsFile=/dev/null', | |
'-o StrictHostKeyChecking=no', | |
'-p 12345'] | |
cmd = ('ansible localhost -i "localhost," --become ' | |
'-m raw -a "dnf install -y python; dnf update -y nettle" --user %s ' | |
'--ssh-common-args="%s"' % | |
(self.vm.username, ' '.join(ssh_args))) | |
process.run(cmd) | |
cmd = ('ANSIBLE_CONFIG=ansible.cfg ansible-playbook -i "localhost,"' | |
' playbooks/setup.yml ' | |
'-e remote_user=%s --ssh-common-args="%s"' % | |
(self.vm.username, ' '.join(ssh_args))) | |
process.run(cmd) | |
self.vm.shutdown() | |
self.vm.launch() | |
console = self.vm.get_console() | |
console.close() | |
cmd = ('ANSIBLE_CONFIG=ansible.cfg ansible-playbook -i "localhost,"' | |
' playbooks/setup.yml ' | |
'-e remote_user=%s --ssh-common-args="%s" -e skip_clean=true' % | |
(self.vm.username, ' '.join(ssh_args))) | |
process.run(cmd) | |
def tearDown(self): | |
self.vm.shutdown() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment