test: fix test failure on ubuntu 24.04: "top: unknown option 'n'" (#9262)

This commit is contained in:
Wei Zhou 2024-06-21 07:16:06 +02:00 committed by GitHub
parent 5ab23cd9c9
commit ded7b4dbe5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -1043,7 +1043,7 @@ class TestCpuCapServiceOfferings(cloudstackTestCase):
#Get host CPU usage from top command before and after VM consuming 100% CPU
find_pid_cmd = "ps -ax | grep '%s' | head -1 | awk '{print $1}'" % self.vm.id
pid = ssh_host.execute(find_pid_cmd)[0]
cpu_usage_cmd = "top -b n 1 p %s | tail -1 | awk '{print $9}'" % pid
cpu_usage_cmd = "top -b -n 1 -p %s | tail -1 | awk '{print $9}'" % pid
host_cpu_usage_before_str = ssh_host.execute(cpu_usage_cmd)[0]
host_cpu_usage_before = round(float(host_cpu_usage_before_str))