How to use create_container_via_memcg method in autotest

Best Python code snippet using autotest_python Github


Full Screen

...349 utils.write_one_line(cpus_path(name), ','.join(map(str, cpus)))350 logging.debug('container %s has %d cpus and %d nodes totalling %s bytes',351 name, len(cpus), len(get_mem_nodes(name)),352 utils.human_format(container_bytes(name)) )353def create_container_via_memcg(name, parent, bytes, cpus):354 # create container via direct memcg cgroup writes355 os.mkdir(full_path(name))356 nodes = utils.read_one_line(mems_path(parent))357 utils.write_one_line(mems_path(name), nodes) # inherit parent's nodes358 utils.write_one_line(memory_path(name)+'.limit_in_bytes', str(bytes))359 utils.write_one_line(cpus_path(name), ','.join(map(str, cpus)))360 logging.debug('Created container %s directly via memcg,'361 ' has %d cpus and %s bytes',362 name, len(cpus), utils.human_format(container_bytes(name)))363def _create_fake_numa_container_directly(name, parent, mbytes, cpus):364 need_fake_numa()365 lockfile = my_lock('inner') # serialize race between parallel tests366 try:367 # Pick specific mem nodes for new cpuset's exclusive use368 # For now, arbitrarily pick highest available node numbers369 needed_kbytes = mbytes * 1024370 nodes = sorted(list(available_exclusive_mem_nodes(parent)))371 kbytes = 0372 nodecnt = 0373 while kbytes < needed_kbytes and nodecnt < len(nodes):374 nodecnt += 1375 kbytes += node_avail_kbytes(nodes[-nodecnt])376 if kbytes < needed_kbytes:377 parent_mbytes = container_mbytes(parent)378 if mbytes > parent_mbytes:379 raise error.AutotestError(380 "New container's %d Mbytes exceeds "381 "parent container's %d Mbyte size"382 % (mbytes, parent_mbytes) )383 else:384 raise error.AutotestError(385 "Existing sibling containers hold "386 "%d Mbytes needed by new container"387 % ((needed_kbytes - kbytes)//1024) )388 mems = nodes[-nodecnt:]389 create_container_with_specific_mems_cpus(name, mems, cpus)390 finally:391 my_unlock(lockfile)392def create_container_directly(name, mbytes, cpus):393 parent = os.path.dirname(name)394 if fake_numa_containers:395 _create_fake_numa_container_directly(name, parent, mbytes, cpus)396 else:397 create_container_via_memcg(name, parent, mbytes<<20, cpus)398def create_container_with_mbytes_and_specific_cpus(name, mbytes,399 cpus=None, root=SUPER_ROOT, io={}, move_in=True, timeout=0):400 """\401 Create a cpuset container and move job's current pid into it402 Allocate the list "cpus" of cpus to that container403 name = arbitrary string tag404 mbytes = reqested memory for job in megabytes405 cpus = list of cpu indicies to associate with the cpuset406 defaults to all cpus avail with given root407 root = the parent cpuset to nest this new set within408 '': unnested top-level container409 io = arguments for proportional IO containers410 move_in = True: Move current process into the new container now.411 timeout = must be 0: persist until explicitly deleted....

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:


You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?