Change the default plugin behavior in perf tests
[csit.git] / resources / libraries / python / ContainerUtils.py
index b56fb0d..da3d705 100644 (file)
@@ -166,18 +166,23 @@ class ContainerManager(object):
         dut_cnt = len(Counter([self.containers[container].node['host']
                                for container in self.containers]))
         container_cnt = len(self.containers)
-        mod = dut_cnt/container_cnt
+        mod = container_cnt/dut_cnt
 
         for i, container in enumerate(self.containers):
+            mid1 = i % mod + 1
+            mid2 = i % mod + 1
+            sid1 = i % mod * 2 + 1
+            sid2 = i % mod * 2 + 2
             self.engine.container = self.containers[container]
             self.engine.create_vpp_startup_config()
-            self.engine.create_vpp_exec_config(vat_template_file,
-                                               memif_id1=i % mod * 2 + 1,
-                                               memif_id2=i % mod * 2 + 2,
-                                               socket1='memif-{c.name}-1'
-                                               .format(c=self.engine.container),
-                                               socket2='memif-{c.name}-2'
-                                               .format(c=self.engine.container))
+            self.engine.create_vpp_exec_config(vat_template_file, mid1=mid1,
+                                               mid2=mid2, sid1=sid1, sid2=sid2,
+                                               socket1='memif-{c.name}-{sid}'
+                                               .format(c=self.engine.container,
+                                                       sid=sid1),
+                                               socket2='memif-{c.name}-{sid}'
+                                               .format(c=self.engine.container,
+                                                       sid=sid2))
 
     def stop_all_containers(self):
         """Stop all containers."""
@@ -286,6 +291,7 @@ class ContainerEngine(object):
                          'do dpkg -i --force-all {0}/install_dir/$i; done'
                          .format(self.container.guest_dir))
         self.execute('apt-get -f install -y')
+        self.execute('apt-get install -y ca-certificates')
         self.execute('echo "{0}" >> {1}'
                      .format(
                          '[program:vpp]\n'
@@ -321,7 +327,8 @@ class ContainerEngine(object):
         if cpuset_cpus:
             corelist_workers = ','.join(str(cpu) for cpu in cpuset_cpus)
             vpp_config.add_cpu_corelist_workers(corelist_workers)
-        vpp_config.add_plugin_disable('dpdk_plugin.so')
+        vpp_config.add_plugin('disable', 'default')
+        vpp_config.add_plugin('enable', 'memif_plugin.so')
 
         self.execute('mkdir -p /etc/vpp/')
         self.execute('echo "{c}" | tee {f}'
@@ -357,10 +364,27 @@ class ContainerEngine(object):
     def _configure_cgroup(self, name):
         """Configure the control group associated with a container.
 
+        By default the cpuset cgroup is using exclusive CPU/MEM. When Docker
+        container is initialized a new cgroup /docker or /lxc is created under
+        cpuset parent tree. This newly created cgroup is inheriting parent
+        setting for cpu/mem exclusive parameter and thus cannot be overriden
+        within /docker or /lxc cgroup. This patch is supposed to set cpu/mem
+        exclusive parameter for both parent and subgroup.
+
         :param name: Name of cgroup.
         :type name: str
         :raises RuntimeError: If applying cgroup settings via cgset failed.
         """
+        ret, _, _ = self.container.ssh.exec_command_sudo(
+            'cgset -r cpuset.cpu_exclusive=0 /')
+        if int(ret) != 0:
+            raise RuntimeError('Failed to apply cgroup settings.')
+
+        ret, _, _ = self.container.ssh.exec_command_sudo(
+            'cgset -r cpuset.mem_exclusive=0 /')
+        if int(ret) != 0:
+            raise RuntimeError('Failed to apply cgroup settings.')
+
         ret, _, _ = self.container.ssh.exec_command_sudo(
             'cgcreate -g cpuset:/{name}'.format(name=name))
         if int(ret) != 0: