Testsuite: add basic configuration/operation mode testcase

This commit is contained in:
Christian Poessinger 2019-12-27 20:14:35 +02:00
parent e62250029e
commit 237f8a05ff

View File

@ -32,7 +32,6 @@
# [--silent] only print on errors # [--silent] only print on errors
# [--debug] print all communication with the device # [--debug] print all communication with the device
import pexpect import pexpect
import sys import sys
import os import os
@ -49,7 +48,6 @@ from datetime import datetime
EXCEPTION = 0 EXCEPTION = 0
now = datetime.now() now = datetime.now()
parser = argparse.ArgumentParser(description='Install and start a test VyOS vm.') parser = argparse.ArgumentParser(description='Install and start a test VyOS vm.')
parser.add_argument('iso', help='ISO file to install') parser.add_argument('iso', help='ISO file to install')
parser.add_argument('disk', help='name of disk image file', parser.add_argument('disk', help='name of disk image file',
@ -102,7 +100,7 @@ log = logging.getLogger()
log.setLevel(logging.DEBUG) log.setLevel(logging.DEBUG)
stl = StreamToLogger(log) stl = StreamToLogger(log)
formatter = logging.Formatter('- %(levelname)5s - %(message)s') formatter = logging.Formatter('%(levelname)5s - %(message)s')
handler = logging.StreamHandler(sys.stdout) handler = logging.StreamHandler(sys.stdout)
if args.silent: if args.silent:
@ -115,15 +113,12 @@ else:
handler.setFormatter(formatter) handler.setFormatter(formatter)
log.addHandler(handler) log.addHandler(handler)
if args.logfile: if args.logfile:
filehandler = logging.FileHandler(args.logfile) filehandler = logging.FileHandler(args.logfile)
filehandler.setLevel(logging.DEBUG) filehandler.setLevel(logging.DEBUG)
filehandler.setFormatter(formatter) filehandler.setFormatter(formatter)
log.addHandler(filehandler) log.addHandler(filehandler)
if args.silent: if args.silent:
output = BytesIO() output = BytesIO()
else: else:
@ -143,7 +138,6 @@ else:
kvm=True kvm=True
# Creating diskimage!! # Creating diskimage!!
if not os.path.isfile(args.disk): if not os.path.isfile(args.disk):
log.info("Creating Disk image {}".format(args.disk)) log.info("Creating Disk image {}".format(args.disk))
c = subprocess.check_output(["qemu-img", "create", args.disk, "2G"]) c = subprocess.check_output(["qemu-img", "create", args.disk, "2G"])
@ -151,8 +145,6 @@ if not os.path.isfile(args.disk):
else: else:
log.info("Diskimage already exists, using the existing one") log.info("Diskimage already exists, using the existing one")
try: try:
################################################# #################################################
# Installing image to disk # Installing image to disk
@ -192,7 +184,6 @@ try:
c.expect(r'vyos@vyos:~\$') c.expect(r'vyos@vyos:~\$')
log.info('Logged in!') log.info('Logged in!')
################################################# #################################################
# Installing into VyOS system # Installing into VyOS system
################################################# #################################################
@ -242,7 +233,6 @@ try:
log.error("VM Did not shut down after 300sec, killing") log.error("VM Did not shut down after 300sec, killing")
c.close() c.close()
################################################# #################################################
# Booting installed system # Booting installed system
################################################# #################################################
@ -281,7 +271,15 @@ try:
c.expect(r'vyos@vyos:~\$') c.expect(r'vyos@vyos:~\$')
log.info('Logged in!') log.info('Logged in!')
#################################################
# Basic Configmode/Opmode switch
#################################################
log.info("Basic CLI configuration mode test")
c.sendline('configure')
c.expect(r'vyos@vyos#')
c.sendline('run show version')
c.sendline('exit')
c.expect(r'vyos@vyos:~\$')
################################################# #################################################
# Executing test-suite # Executing test-suite
@ -342,8 +340,6 @@ except Exception:
traceback.print_exc() traceback.print_exc()
EXCEPTION = 1 EXCEPTION = 1
################################################# #################################################
# Cleaning up # Cleaning up
################################################# #################################################