Skip to contentSkip to conversation

Test case for cpupools

PATCH Superseded Dario Faggioli 3 participants 6 messages Feb 4, 2015 – Mar 11, 2015

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Test case for cpupools

We aren't doing any cpupools smoke testing as of now. So, do some. :-)

As suggested by Juergen, I adjusted things such that we are now generating test jobs for ARM too. In fact, here is the list of jobs, and for each jobs the runvars, being introduced by this series:

dariof@hoopak:~/osstest.git$ diff -Nru runvars.orig runvars.patched 
--- runvars.orig        2015-02-04 15:15:35.214928000 +0000
+++ runvars.patched     2015-02-04 15:11:30.529748000 +0000
@@ -0,0 +1,18 @@
+test-amd64-amd64-xl-cpupools              all_hostflags               arch-amd64,arch-xen-amd64,suite-wheezy,purpose-test                             
+test-amd64-amd64-xl-cpupools              arch                        amd64                                                                           
+test-amd64-amd64-xl-cpupools              buildjob                    build-amd64                                                                     
+test-amd64-amd64-xl-cpupools              debian_arch                 amd64                                                                           
+test-amd64-amd64-xl-cpupools              debian_kernkind             pvops                                                                           
+test-amd64-amd64-xl-cpupools              kernbuildjob                build-amd64-pvops                                                               
+test-amd64-amd64-xl-cpupools              kernkind                    pvops                                                                           
+test-amd64-amd64-xl-cpupools              toolstack                   xl                                                                              
+test-amd64-amd64-xl-cpupools              xenbuildjob                 build-amd64                                                                     
+test-armhf-armhf-xl-cpupools              all_hostflags               arch-armhf,arch-xen-armhf,suite-wheezy,purpose-test                             
+test-armhf-armhf-xl-cpupools              arch                        armhf                                                                           
+test-armhf-armhf-xl-cpupools              buildjob                    build-armhf                                                                     
+test-armhf-armhf-xl-cpupools              debian_arch                 armhf                                                                           
+test-armhf-armhf-xl-cpupools              debian_kernkind             pvops                                                                           
+test-armhf-armhf-xl-cpupools              kernbuildjob                build-armhf-pvops                                                               
+test-armhf-armhf-xl-cpupools              kernkind                    pvops                                                                           
+test-armhf-armhf-xl-cpupools              toolstack                   xl                                                                              
+test-armhf-armhf-xl-cpupools              xenbuildjob                 build-armhf 

Regards,
Dario
---
Dario Faggioli (2):
ts-cpupools: new test script
Testing cpupools: recipe for it and job definition

 make-flight |   12 ++++++
 sg-run-job  |    7 +++
 ts-cpupools |  124 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 143 insertions(+)
 create mode 100755 ts-cpupools

--
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

#1 lore raw

PATCH v2 1/2 ts-cpupools: new test script

for smoke testing cpupools a bit. It tries to partition a live host in two cpupools, trying out the following 3 schedulers for the new cpupool (one after the other):
credit, credit2 and RTDS.

It also tries to migrating a domain to the new cpupool and then back to Pool-0.

---
 ts-cpupools |  124 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 124 insertions(+)
 create mode 100755 ts-cpupools
ts-cpupools new file +124 -0
new file mode 100755
index 0000000..fe612e1
@@ -0,0 +1,124 @@
+#!/usr/bin/perl -w
+# This is part of "osstest", an automated testing framework for Xen.
+# Copyright (C) 2009-2014 Citrix Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+use strict qw(vars);
+use DBI;
+use Osstest;
+use Osstest::TestSupport;
+
+tsreadconfig();
+
+our ($whhost,$gn)= @ARGV;
+$whhost ||= 'host';
+$gn ||= 'debian';
+
+our ($ho,$gho) = ts_get_host_guest($whhost,$gn);
+#our $ho= selecthost(@ARGV);
+
+our $default_cpupool= "Pool-0";
+our @schedulers= ("credit","credit2","rtds");
+our @cpulist;
+our $nr_cpus;
+
+sub check () {
+  my $out;
+
+  # Figure out the number of pCPUs of the host. We need to know
+  # that in order to decide with what pCPUs we want to create
+  # cpupools
+  my $xlinfo= target_cmd_output_root($ho, "xl info");
+  $xlinfo =~ /nr_cpus\s*:\s([0-9]*)/;
+  $nr_cpus= $1;
+  logm("Found $nr_cpus pCPUs");
+  die "Too few pCPUs to test cpupools: $nr_cpus" if $nr_cpus < 2;
+
+  # We want only 1 cpupool to exist
+  my $cppinfo= target_cmd_output_root($ho, "xl cpupool-list");
+  my $nr_cpupools= $cppinfo =~ tr/\n//;
+  logm("Found $nr_cpupools cpupools");
+  die "There already is more than one cpu pool!" if $nr_cpupools > 1;
+  die "Non-default cpupool configuration detected" if $cppinfo =~ /^$default_cpupool\b/;
+
+  $out= target_cmd_output_root($ho, "xl cpupool-list"); logm("$out");
+  $out= target_cmd_output_root($ho, "xl cpupool-list -c"); logm("$out");
+}
+
+# List of the odd pCPUs
+sub prep_cpulist () {
+  if (! defined @cpulist) {
+    foreach my $cpu (0..$nr_cpus) {
+      next unless $cpu % 2;
+      push @cpulist, $cpu;
+    }
+  }
+}
+
+sub prep ($) {
+  my ($sched)= @_;
+
+  # Remove the pCPUs from in $cpulist from the default cpupool
+  my $cpustr= "[";
+  foreach my $cpu (@cpulist) {
+    target_cmd_root($ho,"xl cpupool-cpu-remove $default_cpupool $cpu");
+    $cpustr.= "\"$cpu\", ";
+  }
+  $cpustr.= "]";
+
+  logm("Creating config file for cpupool-osstest-$sched with cpus=$cpustr");
+  target_putfilecontents_stash($ho,100,<<"END","/etc/xen/cpupool-osstest-$sched");
+name = "cpupool-osstest-$sched"
+sched=\"$sched\"
+cpus=$cpustr
+END
+}
+
+check();
+prep_cpulist();
+foreach my $sched (@schedulers) {
+  my $out;
+
+  prep("$sched");
+
+  # For each cpupool:
+  #  * create it
+  #  * rename it
+  #  * move a domain in it
+  #  * move back a domain out of it
+  #  * add back the pcpus from it to the default pool
+  #  * destroy it
+  target_cmd_root($ho, "xl cpupool-create /etc/xen/cpupool-osstest-$sched");
+  target_cmd_output_root($ho, "xl cpupool-rename cpupool-osstest-$sched cpupool-test");
+  $out= target_cmd_output_root($ho, "xl cpupool-list -c"); logm("$out");
+  $out= target_cmd_output_root($ho, "xl cpupool-list"); logm("$out");
+
+  target_cmd_root($ho, "xl cpupool-migrate $gho->{Name} cpupool-test");
+  $out= target_cmd_output_root($ho, "xl cpupool-list"); logm("$out");
+  $out= target_cmd_output_root($ho, "xl vcpu-list"); logm("$out");
+
+  target_cmd_root($ho, "xl cpupool-migrate $gho->{Name} Pool-0");
+  $out= target_cmd_output_root($ho, "xl cpupool-list"); logm("$out");
+
+  foreach my $cpu (@cpulist) {
+    target_cmd_root($ho,"xl cpupool-cpu-remove cpupool-test $cpu");
+    target_cmd_root($ho,"xl cpupool-cpu-add $default_cpupool $cpu");
+  }
+  $out= target_cmd_output_root($ho, "xl cpupool-list -c"); logm("$out");
+
+  target_cmd_root($ho, "xl cpupool-destroy cpupool-test");
+  $out= target_cmd_output_root($ho, "xl cpupool-list"); logm("$out");
+}
+
#3 lore raw

PATCH v2 2/2 Testing cpupools: recipe for it and job definition

In reply to Dario Faggioli

---
Changes from v1:
* added invocation to ts-guest-stop in the recipe to kill leak-check complaints (which went unnoticed during v1 testing, sorry)
* moved the test before the "ARM cutoff", and remove the per-arch filtering, so that the test can run on ARM hardware too

---
 make-flight |   12 ++++++++++++
 sg-run-job  |    7 +++++++
 2 files changed, 19 insertions(+)
make-flight +12 -0
index 63b14f5..4d2e4bf 100755
@@ -283,6 +283,16 @@ do_multivcpu_tests () {
                     $debian_runvars all_hostflags=$most_hostflags
 }
 
+do_cpupools_tests () {
+  if [ $xenarch != $dom0arch ]; then
+    return
+  fi
+
+  job_create_test test-$xenarch$kern-$dom0arch-xl-cpupools            \
+                    test-cpupools xl $xenarch $dom0arch               \
+                    $debian_runvars all_hostflags=$most_hostflags
+}
+
 do_passthrough_tests () {
   if [ $xenarch != amd64 -o $dom0arch != amd64 -o "$kern" != "" ]; then
     return
@@ -318,6 +328,8 @@ test_matrix_do_one () {
   do_sedf_tests
   do_credit2_tests
 
+  do_cpupools_tests
+
   # No further arm tests at the moment
   if [ $dom0arch = armhf ]; then
       return
sg-run-job +7 -0
index 2cf810a..fae5af0 100755
@@ -272,6 +272,13 @@ proc run-job/test-debianhvm {} {
     test-guest debianhvm
 }
 
+proc need-hosts/test-cpupools {} { return host }
+proc run-job/test-cpupools {} {
+    install-guest-debian
+    run-ts . = ts-cpupools
+    run-ts . = ts-guest-stop + host debian
+}
+
 proc need-hosts/test-pair {} { return {src_host dst_host} }
 proc run-job/test-pair {} {
     run-ts . =              ts-debian-install      dst_host
#5 lore raw
In reply to Dario Faggioli
Quoted 6 lines · Dario Faggioli

---
Dario Faggioli (2):
ts-cpupools: new test script
Testing cpupools: recipe for it and job definition

Quoted 6 lines
 make-flight |   12 ++++++
 sg-run-job  |    7 +++
 ts-cpupools |  124 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 143 insertions(+)
 create mode 100755 ts-cpupools

Ping...

Regards,
Dario

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#2 lore raw

Re: [OSSTest PATCH v2 1/2] ts-cpupools: new test script

In reply to Dario Faggioli

ts-cpupools line 44

Quoted 2 lines · Dario Faggioli
ts-cpupools new file +2 -0
+  my $xlinfo= target_cmd_output_root($ho, "xl info");
+  $xlinfo =~ /nr_cpus\s*:\s([0-9]*)/;

I thought Perl needed a modifier to work in multiline mode?

ts-cpupools line 47

Quoted 3 lines
ts-cpupools new file +3 -0
+  $nr_cpus= $1;
+  logm("Found $nr_cpus pCPUs");
+  die "Too few pCPUs to test cpupools: $nr_cpus" if $nr_cpus < 2;

This will cause a sticky test failure if this ever gets run on a single cpu host (which might just about be plausible on ARM).

The proper fix would be a property in the hostdb which was used to constrain which hosts the jobs containing this test could run on. (e.g. we have pcipassthrough-nic).

Maybe this way is OK until we find we are commissioning a machine with a single CPU, at which point this failure will seem pretty obvious. Ian?

ts-cpupools line 54

Quoted 7 lines
ts-cpupools new file +7 -0
+
+  # We want only 1 cpupool to exist
+  my $cppinfo= target_cmd_output_root($ho, "xl cpupool-list");
+  my $nr_cpupools= $cppinfo =~ tr/\n//;
+  logm("Found $nr_cpupools cpupools");
+  die "There already is more than one cpu pool!" if $nr_cpupools > 1;
+  die "Non-default cpupool configuration detected" if $cppinfo =~ /^$default_cpupool\b/;

Shouldn't the condition on the last one be inverted, i.e. die unless Pool-0 is present?

Also: long lines?

ts-cpupools line 57

Quoted 3 lines
ts-cpupools new file +3 -0
+
+  $out= target_cmd_output_root($ho, "xl cpupool-list"); logm("$out");
+  $out= target_cmd_output_root($ho, "xl cpupool-list -c"); logm("$out");

Is this just for logging? target_cmd_root will just do that for you I think.

You may want to include one or more of these in ts-logs-capture too, which allow us to have some chance of noticing pooling oddities on other jobs.

ts-cpupools line 67

Quoted 10 lines
ts-cpupools new file +10 -0
+}
+
+# List of the odd pCPUs
+sub prep_cpulist () {
+  if (! defined @cpulist) {
+    foreach my $cpu (0..$nr_cpus) {
+      next unless $cpu % 2;
+      push @cpulist, $cpu;
+    }
+  }

Seems like this ought to be doable as a one or two liner with grep or map.

ts-cpupools line 79

Quoted 12 lines
ts-cpupools new file +12 -0
+}
+
+sub prep ($) {
+  my ($sched)= @_;
+
+  # Remove the pCPUs from in $cpulist from the default cpupool
+  my $cpustr= "[";
+  foreach my $cpu (@cpulist) {
+    target_cmd_root($ho,"xl cpupool-cpu-remove $default_cpupool $cpu");
+    $cpustr.= "\"$cpu\", ";
+  }
+  $cpustr.= "]";

I think you should accumulate $cpu in @cpus and then join it at the end and add the []s (or leave them inline in the here doc.

ts-cpupools line 84

Quoted 5 lines
ts-cpupools new file +5 -0
+
+  logm("Creating config file for cpupool-osstest-$sched with cpus=$cpustr");
+  target_putfilecontents_stash($ho,100,<<"END","/etc/xen/cpupool-osstest-$sched");
+name = "cpupool-osstest-$sched"
+sched=\"$sched\"

One of these two quoting styles must be wrong I think?

Quoted 10 lines
ts-cpupools new file +10 -0
+cpus=$cpustr
+END
+}
+
+check();
+prep_cpulist();
+foreach my $sched (@schedulers) {
+  my $out;
+
+  prep("$sched");

ts-cpupools line 104

Quoted 10 lines
ts-cpupools new file +10 -0
+
+  # For each cpupool:
+  #  * create it
+  #  * rename it
+  #  * move a domain in it
+  #  * move back a domain out of it
+  #  * add back the pcpus from it to the default pool
+  #  * destroy it
+  target_cmd_root($ho, "xl cpupool-create /etc/xen/cpupool-osstest-$sched");
+  target_cmd_output_root($ho, "xl cpupool-rename cpupool-osstest-$sched cpupool-test");

Doesn't this throw away the output? I think you want to drop _output here.

Quoted 1 line

+ $out= target_cmd_output_root($ho, "xl cpupool-list -c"); logm("$out");

What about libvirt? This either needs to use the toolstack()/Osstest::Toolstack abstraction or it needs to error for toolstacks which aren't xl.

Quoted 20 lines
ts-cpupools new file +19 -0
+  $out= target_cmd_output_root($ho, "xl cpupool-list"); logm("$out");
+
+  target_cmd_root($ho, "xl cpupool-migrate $gho->{Name} cpupool-test");
+  $out= target_cmd_output_root($ho, "xl cpupool-list"); logm("$out");
+  $out= target_cmd_output_root($ho, "xl vcpu-list"); logm("$out");
+
+  target_cmd_root($ho, "xl cpupool-migrate $gho->{Name} Pool-0");
+  $out= target_cmd_output_root($ho, "xl cpupool-list"); logm("$out");
+
+  foreach my $cpu (@cpulist) {
+    target_cmd_root($ho,"xl cpupool-cpu-remove cpupool-test $cpu");
+    target_cmd_root($ho,"xl cpupool-cpu-add $default_cpupool $cpu");
+  }
+  $out= target_cmd_output_root($ho, "xl cpupool-list -c"); logm("$out");
+
+  target_cmd_root($ho, "xl cpupool-destroy cpupool-test");
+  $out= target_cmd_output_root($ho, "xl cpupool-list"); logm("$out");
+}
+