Skip to content

Commit

Permalink
Test works fine
Browse files Browse the repository at this point in the history
  • Loading branch information
macartur committed Nov 29, 2017
1 parent d8ba75d commit f7427d0
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions tests/test_system/test_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
CONTAINER = 'kytos_tests'
IMAGE = 'kytos/systests'
PROMPT = 'root@.*:/usr/local/src/kytos# '
WITH_SUDO = True

WITH_SUDO = True if (os.geteuid() == 0) else False
PROJECTS = ['python-openflow', 'kytos-utils', 'kytos']
NAPPS = ['kytos/of_core', 'kytos/of_lldp']

class TestStruct(TestCase):
"""Test the alpine container."""
Expand Down Expand Up @@ -42,6 +43,11 @@ def setUpClass(cls):
# Start the container to run the tests
cmd = f'docker run --rm -it --name {CONTAINER} {IMAGE}'
cls._kytos = cls.execute(cmd, PROMPT, with_sudo=WITH_SUDO)
cmd = f'docker exec -it --privileged {CONTAINER} /bin/bash'
cls._mininet = cls.execute(cmd, PROMPT, with_sudo=WITH_SUDO)

cls._kytos.sendline("pip install ruamel.yaml")
cls._kytos.expect("Successfully installed ruamel.yaml")

def test000_uname_a(self):
"""Test expected 'uname -a' command using the container."""
Expand All @@ -56,6 +62,35 @@ def test00_update_repositories(self):
self._kytos.expect(['Fast-forward', 'up-to-date'])
self._kytos.expect(PROMPT)

def test01_install_projects(self):
"""Install Kytos projects from cloned repository in safe order."""
pip = 'pip install --no-index --find-links $KYTOSDEPSDIR .'

for project in PROJECTS:
self._kytos.sendline(f'cd $KYTOSDIR/{project}; {pip}; cd -')
self._kytos.expect(f'Successfully installed .*{project}',
timeout=60)
self._kytos.expect(PROMPT)

def test02_launch_kytosd(self):
"""kytos-utils requires kytosd to be running."""
self._kytos.sendline('kytosd -f')
# Regex is for color codes
self._kytos.expect(r'kytos \$> ')

def test03_install_napps(self):
"""Install NApps for the ping to work.
As self._kytos is blocked in kytosd shell, we use mininet terminal.
"""
for napp in NAPPS:
self._mininet.sendline(f'kytos napps install {napp}')
self._mininet.expect('INFO Enabled.')
napp_name = napp.split('/')[0]
self._kytos.expect(napp_name +'.+Running NApp')
self._mininet.expect(PROMPT)

@classmethod
def tearDownClass(cls):
"""Stop container."""
Expand Down

0 comments on commit f7427d0

Please sign in to comment.