mirror of
https://github.com/vyos/vyos-build.git
synced 2025-10-01 20:28:40 +02:00
Testsuite: add new "make testraid" target for RAID-1 installation testing
This commit is contained in:
parent
2aa0166d87
commit
462c5f80e0
5
Makefile
5
Makefile
@ -116,6 +116,11 @@ testd: checkiso
|
||||
testc: checkiso
|
||||
scripts/check-qemu-install --debug --configd --configtest build/live-image-amd64.hybrid.iso
|
||||
|
||||
.PHONY: testraid
|
||||
.ONESHELL:
|
||||
testraid: checkiso
|
||||
scripts/check-qemu-install --debug --configd --raid --configtest build/live-image-amd64.hybrid.iso
|
||||
|
||||
.PHONY: clean
|
||||
.ONESHELL:
|
||||
clean:
|
||||
|
||||
@ -66,6 +66,7 @@ parser.add_argument('--debug', help='Send all debug output to stdout',
|
||||
action='store_true', default=False)
|
||||
parser.add_argument('--logfile', help='Log to file')
|
||||
parser.add_argument('--uefi', help='Boot using UEFI', action='store_true', default=False)
|
||||
parser.add_argument('--raid', help='Perform a RAID-1 install', action='store_true', default=False)
|
||||
parser.add_argument('--no-kvm', help='Disable use of kvm', action='store_true', default=False)
|
||||
parser.add_argument('--configd', help='Execute testsuite with config daemon', action='store_true',
|
||||
default=False)
|
||||
@ -110,7 +111,7 @@ def get_half_cpus():
|
||||
cpu /= 2
|
||||
return int(cpu)
|
||||
|
||||
def get_qemu_cmd(name, enable_kvm, enable_uefi, disk_img, iso_img=None):
|
||||
def get_qemu_cmd(name, enable_kvm, enable_uefi, disk_img, raid=None, iso_img=None):
|
||||
kvm = "-enable-kvm"
|
||||
cpu = "-cpu host"
|
||||
if not enable_kvm:
|
||||
@ -150,6 +151,9 @@ def get_qemu_cmd(name, enable_kvm, enable_uefi, disk_img, iso_img=None):
|
||||
-nographic {cpu} {cdrom} {kvm} \
|
||||
-drive format=raw,file={disk_img}'
|
||||
|
||||
if raid:
|
||||
cmd += f' -drive format=raw,file={raid}'
|
||||
|
||||
return cmd
|
||||
|
||||
|
||||
@ -196,12 +200,24 @@ else:
|
||||
kvm=True
|
||||
|
||||
# Creating diskimage!!
|
||||
if not os.path.isfile(args.disk):
|
||||
log.info(f'Creating Disk image {args.disk}')
|
||||
c = subprocess.check_output(['qemu-img', 'create', args.disk, '2G'])
|
||||
diskname_raid = None
|
||||
def gen_disk(name):
|
||||
if not os.path.isfile(name):
|
||||
log.info(f'Creating Disk image {name}')
|
||||
c = subprocess.check_output(['qemu-img', 'create', name, '2G'])
|
||||
log.debug(c.decode())
|
||||
else:
|
||||
log.info('Diskimage already exists, using the existing one')
|
||||
else:
|
||||
log.info(f'Diskimage "{name}" already exists, using the existing one.')
|
||||
|
||||
if args.raid:
|
||||
filename, ext = os.path.splitext(args.disk)
|
||||
diskname_raid = f'{filename}_disk1{ext}'
|
||||
# change primary diskname, too
|
||||
args.disk = f'{filename}_disk0{ext}'
|
||||
gen_disk(diskname_raid)
|
||||
|
||||
# must be called after the raid disk as args.disk name is altered in the RAID path
|
||||
gen_disk(args.disk)
|
||||
|
||||
test_timeout = 3 *3600 # 3 hours (in seconds)
|
||||
try:
|
||||
@ -209,7 +225,7 @@ try:
|
||||
# Installing image to disk
|
||||
#################################################
|
||||
log.info('Installing system')
|
||||
cmd = get_qemu_cmd('TESTVM', kvm, args.uefi, args.disk, args.iso)
|
||||
cmd = get_qemu_cmd('TESTVM', kvm, args.uefi, args.disk, diskname_raid, args.iso)
|
||||
log.debug(f'Executing command: {cmd}')
|
||||
c = pexpect.spawn(cmd, logfile=stl)
|
||||
|
||||
@ -242,6 +258,14 @@ try:
|
||||
c.sendline('install image')
|
||||
c.expect('\nWould you like to continue?.*:')
|
||||
c.sendline('yes')
|
||||
|
||||
if args.raid:
|
||||
c.expect('\nWould you like to configure RAID-1 mirroring on them?.*:')
|
||||
c.sendline('yes')
|
||||
# Erase all data on disks
|
||||
c.expect('\nAre you sure you want to do this?.*:')
|
||||
c.sendline('yes')
|
||||
else:
|
||||
log.info('Partitioning disk')
|
||||
c.expect('\nPartition.*:')
|
||||
c.sendline('')
|
||||
@ -251,8 +275,9 @@ try:
|
||||
c.sendline('Yes')
|
||||
c.expect('\nHow big of a root partition should I create?.*:')
|
||||
c.sendline('')
|
||||
log.info('Disk partitioned, installing')
|
||||
c.expect('\nWhat would you like to name this image?.*:')
|
||||
|
||||
log.info('Disk(s) partitioned, installing...')
|
||||
c.expect('\nWhat would you like to name this image?.*:', timeout=300)
|
||||
c.sendline('')
|
||||
log.info('Copying files')
|
||||
c.expect('\nWhich one should I copy to.*:', timeout=300)
|
||||
@ -262,9 +287,12 @@ try:
|
||||
c.sendline(default_user)
|
||||
c.expect('\nRetype password for user.*:')
|
||||
c.sendline(default_password)
|
||||
|
||||
if not args.raid:
|
||||
c.expect('\nWhich drive should GRUB modify the boot partition on.*:')
|
||||
c.sendline('')
|
||||
c.expect(op_mode_prompt)
|
||||
|
||||
log.info('system installed, shutting down')
|
||||
|
||||
#################################################
|
||||
@ -288,7 +316,7 @@ try:
|
||||
# Booting installed system
|
||||
#################################################
|
||||
log.info('Booting installed system')
|
||||
cmd = get_qemu_cmd('TESTVM', kvm, args.uefi, args.disk)
|
||||
cmd = get_qemu_cmd('TESTVM', kvm, args.uefi, args.disk, diskname_raid)
|
||||
log.debug(f'Executing command: {cmd}')
|
||||
c = pexpect.spawn(cmd, logfile=stl)
|
||||
|
||||
@ -345,12 +373,16 @@ try:
|
||||
c.sendline('show interfaces')
|
||||
c.expect(op_mode_prompt)
|
||||
|
||||
if args.raid:
|
||||
c.sendline('cat /proc/mdstat')
|
||||
c.expect(op_mode_prompt)
|
||||
|
||||
#################################################
|
||||
# Executing test-suite
|
||||
#################################################
|
||||
|
||||
# run default smoketest suite
|
||||
if not args.configtest:
|
||||
if not args.raid and not args.configtest:
|
||||
if args.no_interfaces:
|
||||
# remove interface tests as they consume a lot of time
|
||||
c.sendline('sudo rm -f /usr/libexec/vyos/tests/smoke/cli/test_interfaces_*')
|
||||
@ -380,7 +412,7 @@ try:
|
||||
raise Exception("Smoketest-failed, please look into debug output")
|
||||
|
||||
# else, run configtest suite
|
||||
else:
|
||||
elif not args.raid:
|
||||
log.info('Adding a legacy WireGuard default keypair for migrations')
|
||||
c.sendline('sudo mkdir -p /config/auth/wireguard/default')
|
||||
c.expect(op_mode_prompt)
|
||||
@ -486,6 +518,8 @@ if not args.keep:
|
||||
log.info(f'Removing disk file: {args.disk}')
|
||||
try:
|
||||
os.remove(args.disk)
|
||||
if diskname_raid:
|
||||
os.remove(diskname_raid)
|
||||
except Exception:
|
||||
log.error('Exception while removing diskimage!')
|
||||
log.error(traceback.format_exc())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user