From e542a1591445e5247acba53f73f0fb8d308ddab5 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 21 Apr 2015 16:11:57 +0800 Subject: [PATCH] Wei updated code based on Liz's feedback --- .../BVT-IS-ROOT-PASSWORD-DELETED.py | 40 +++++-------------- remote-scripts/BVT-SWAP-CHECK.py | 34 ++++++++++++---- .../BVT-VERIFY-VHD-PREREQUISITES.ps1 | 2 +- .../BVT-VERIFY-VHD-PREREQUISITES.py | 13 +++--- remote-scripts/ignorable-boot-errors.xml | 2 + 5 files changed, 46 insertions(+), 45 deletions(-) diff --git a/remote-scripts/BVT-IS-ROOT-PASSWORD-DELETED.py b/remote-scripts/BVT-IS-ROOT-PASSWORD-DELETED.py index bba57eb..d8013b4 100644 --- a/remote-scripts/BVT-IS-ROOT-PASSWORD-DELETED.py +++ b/remote-scripts/BVT-IS-ROOT-PASSWORD-DELETED.py @@ -5,37 +5,15 @@ from azuremodules import * def RunTest(): UpdateState("TestRunning") RunLog.info("Checking if root password is deleted or not...") - + passwd_output = Run("cat /etc/shadow | grep root") - root_passwd = passwd_output.split(":")[1] - if (IsUbuntu()): - if ('*' in root_passwd or '!' in root_passwd): - RunLog.info('root password is deleted in /etc/shadow in Ubuntu.') - ResultLog.info('PASS') - else: - RunLog.info('root password is not deleted in /etc/shadow in Ubuntu.') - ResultLog.info('FAIL') + root_passwd = passwd_output.split(":")[1] + if ('*' in root_passwd or '!' in root_passwd): + RunLog.info('root password is deleted in /etc/shadow.') + ResultLog.info('PASS') else: - RunLog.info("Read Provisioning.DeleteRootPassword from /etc/waagent.conf..") - outputlist=open("/etc/waagent.conf") - for line in outputlist: - if(line.find("Provisioning.DeleteRootPassword")!=-1): - break + RunLog.error('root password not deleted.%s', passwd_output) + ResultLog.error('FAIL') + UpdateState("TestCompleted") - RunLog.info("Value ResourceDisk.DeleteRootPassword in /etc/waagent.conf.." + line.strip()[-1]) - - if (('*' in root_passwd or '!' in root_passwd) and (line.strip()[-1] == "y")): - RunLog.info('root password is deleted in /etc/shadow.') - ResultLog.info('PASS') - elif(not('*' in root_passwd or '!' in root_passwd) and (line.strip()[-1] == "n")): - RunLog.info('root password is not deleted in /etc/shadow.') - ResultLog.info('PASS') - if (('*' in root_passwd or '!' in root_passwd) and (line.strip()[-1] == "n")): - RunLog.error('root password is deleted. Expected not deleted %s', passwd_output) - ResultLog.error('FAIL') - elif(not('*' in root_passwd or '!' in root_passwd) and (line.strip()[-1] == "y")): - RunLog.error('root password not deleted. Expected deleted %s', passwd_output) - ResultLog.error('FAIL') - UpdateState("TestCompleted") - -RunTest() +RunTest() diff --git a/remote-scripts/BVT-SWAP-CHECK.py b/remote-scripts/BVT-SWAP-CHECK.py index a1641de..fec65e1 100644 --- a/remote-scripts/BVT-SWAP-CHECK.py +++ b/remote-scripts/BVT-SWAP-CHECK.py @@ -1,6 +1,7 @@ #!/usr/bin/python from azuremodules import * +import os.path def RunTest(command): UpdateState("TestRunning") @@ -8,14 +9,20 @@ def RunTest(command): RunLog.info("Executing swapon -s..") temp = Run(command) output = temp - - RunLog.info("Read ResourceDisk.EnableSwap from /etc/waagent.conf..") - outputlist=open("/etc/waagent.conf") + + if os.path.exists("/etc/lsb-release") and int(Run("cat /etc/lsb-release | grep -i coreos | wc -l")) > 0: + waagent_conf_file = "/usr/share/oem/waagent.conf" + else: + waagent_conf_file = "/etc/waagent.conf" + + RunLog.info("Read ResourceDisk.EnableSwap from " + waagent_conf_file + "..") + outputlist=open(waagent_conf_file) + for line in outputlist: if(line.find("ResourceDisk.EnableSwap")!=-1): break - RunLog.info("Value ResourceDisk.EnableSwap in /etc/waagent.conf.." + line.strip()[-1]) + RunLog.info("Value ResourceDisk.EnableSwap in " + waagent_conf_file + ": " + line.strip()[-1]) if (("swap" in output) and (line.strip()[-1] == "n")): RunLog.error('Swap is enabled. Swap should not be enabled.') RunLog.error('%s', output) @@ -24,15 +31,26 @@ def RunTest(command): elif ((output.find("swap")==-1) and (line.strip()[-1] == "y")): RunLog.error('Swap is disabled. Swap should be enabled.') RunLog.error('%s', output) + RunLog.info("Pleae check value of setting ResourceDisk.SwapSizeMB") ResultLog.error('FAIL') elif(("swap" in output) and (line.strip()[-1] == "y")): RunLog.info('swap is enabled.') - ResultLog.info('PASS') - - elif ((output.find("swap")==-1) and (line.strip()[-1] == "n")): + if(IsUbuntu()) : + mntresource = "/mnt" + else: + mntresource = "/mnt/resource" + swapfile = mntresource + "/swapfile" + if(swapfile in output): + RunLog.info("swap is enabled on resource disk") + ResultLog.info('PASS') + else: + RunLog.info("swap is not enabled on resource disk") + ResultLog.info('FAIL') + elif((output.find("swap")==-1) and (line.strip()[-1] == "n")): RunLog.info('swap is disabled.') ResultLog.info('PASS') - UpdateState("TestCompleted") + RunTest("swapon -s") + diff --git a/remote-scripts/BVT-VERIFY-VHD-PREREQUISITES.ps1 b/remote-scripts/BVT-VERIFY-VHD-PREREQUISITES.ps1 index c905c71..51516fe 100644 --- a/remote-scripts/BVT-VERIFY-VHD-PREREQUISITES.ps1 +++ b/remote-scripts/BVT-VERIFY-VHD-PREREQUISITES.ps1 @@ -52,7 +52,7 @@ if ($isDeployed) } if ($detectedDistro -imatch "COREOS") { - $matchstrings = @("_TEST_GRUB_VERIFICATION_SUCCESS","_TEST_UDEV_RULES_SUCCESS") + $matchstrings = @("_TEST_UDEV_RULES_SUCCESS") } RemoteCopy -uploadTo $hs1VIP -port $hs1vm1sshport -files $currentTestData.files -username $user -password $password -upload diff --git a/remote-scripts/BVT-VERIFY-VHD-PREREQUISITES.py b/remote-scripts/BVT-VERIFY-VHD-PREREQUISITES.py index a8ccf57..963ce86 100644 --- a/remote-scripts/BVT-VERIFY-VHD-PREREQUISITES.py +++ b/remote-scripts/BVT-VERIFY-VHD-PREREQUISITES.py @@ -35,11 +35,14 @@ def verify_grub(distro): if distro == "UBUNTU": grub_out = Run("cat /etc/default/grub") if distro == "SUSE": - suse_ver = Run("cat /etc/SuSE-release | grep -i version | awk -F ' ' '{print $3}' | tr -d '\n'") - if suse_ver == "13.2": + if os.path.exists("/boot/grub2/grub.cfg"): grub_out = Run("cat /boot/grub2/grub.cfg") - if suse_ver == "13.1": + elif os.path.exists("/boot/grub/grub.conf"): grub_out = Run("cat /boot/grub/grub.conf") + else: + RunLog.error("Unable to locate grub file") + print(distro+"_TEST_GRUB_VERIFICATION_FAIL") + return False if distro == "CENTOS" or distro == "ORACLELINUX" or distro == "REDHAT" or distro == "SLES" or distro == "FEDORA": if os.path.isfile("/boot/grub2/grub.cfg"): RunLog.info("Getting Contents of /boot/grub2/grub.cfg") @@ -55,7 +58,7 @@ def verify_grub(distro): #in core os we don't have access to boot partition grub_out = Run("dmesg") if "console=ttyS0" in grub_out and "rootdelay=300" in grub_out and "libata.atapi_enabled=0" not in grub_out and "reserve=0x1f0,0x8" not in grub_out: - if distro == "CENTOS" or distro == "ORACLELINUX": + if distro == "CENTOS" or distro == "ORACLELINUX" or distro == "REDHAT": # check numa=off in grub for CentOS 6.x and Oracle Linux 6.x version_release = Run("cat /etc/system-release | grep -o [0-9].[0-9] | head -1 | tr -d '\n'") if float(version_release) < 7.0: @@ -328,6 +331,6 @@ if distro == "SLES": RunLog.info("DHCLIENT_SET_HOSTNAME='no' not present in /etc/sysconfig/network/dhcp, it's not strict.") if distro == "COREOS": - #"rootdelay=300" has issues with CoreOS which causes extra long boot time + #"rootdelay=300" has issues with CoreOS which causes extra long boot time #result = verify_grub(distro) result = verify_udev_rules(distro) diff --git a/remote-scripts/ignorable-boot-errors.xml b/remote-scripts/ignorable-boot-errors.xml index 3aab436..e37ce39 100644 --- a/remote-scripts/ignorable-boot-errors.xml +++ b/remote-scripts/ignorable-boot-errors.xml @@ -5,6 +5,8 @@ Fast TSC calibration acpi PNP0A03:00 systemd-journald-audit.socket + Failed to set file attributes: Inappropriate ioctl for device + Failed to create new system journal: No such file or directory