How to use is_swap_enabled method in lisa

Best Python code snippet using lisa_python

tools.py

Source:tools.py Github

copy

Full Screen

...71 return int(waagent_configuration["OS.RootDeviceScsiTimeout"])72 def get_resource_disk_mount_point(self) -> str:73 waagent_configuration = self.get_configuration()74 return waagent_configuration["ResourceDisk.MountPoint"]75 def is_swap_enabled(self) -> bool:76 waagent_configuration = self.get_configuration()77 is_swap_enabled = waagent_configuration["ResourceDisk.EnableSwap"]78 if is_swap_enabled == "y":79 return True80 elif is_swap_enabled == "n":81 return False82 else:83 raise LisaException(84 f"Unknown value for ResourceDisk.EnableSwap : {is_swap_enabled}"85 )86 def is_rdma_enabled(self) -> bool:87 waagent_configuration = self.get_configuration()88 is_rdma_enabled = waagent_configuration["OS.EnableRDMA"]89 if is_rdma_enabled == "y":...

Full Screen

Full Screen

test_cgroups_allocations.py

Source:test_cgroups_allocations.py Github

copy

Full Screen

...76@pytest.mark.parametrize("raw_meminfo_output,expected", [77 ("SwapCached: 3000kB \nSwapTotal: 123000kB\nSwapFree: 20000kB", True),78 ("SwapCached: 0kB \nSwapTotal: 0kB\nSwapFree: 0 kB", False),79])80def test_is_swap_enabled(raw_meminfo_output, expected):81 with patch('wca.platforms.read_proc_meminfo',82 return_value=raw_meminfo_output):83 got = is_swap_enabled()84 assert got == expected85@patch('wca.platforms.read_proc_meminfo',86 return_value='SwapCached: 3000kB \nSwapTotal: 123000kB\nSwapFree: 20000kB')87@patch('wca.cgroups.Cgroup')88def test_migrate_pages_raise_exception_when_swap_is_enabled(*mocks):89 rdt_information = RDTInformation(True, True, True, True, '0', '0', 0, 0, 0)90 platform_mock = Mock(91 spec=Platform,92 cpus=10,93 sockets=1,94 rdt_information=rdt_information,95 node_cpus={0: [0, 1], 1: [2, 3]},96 numa_nodes=2,97 swap_enabled=is_swap_enabled(),98 )99 foo_container = Container(100 '/somepath', platform=platform_mock)101 foo_container._cgroup.platform = platform_mock102 migrate_pages = MigratePagesAllocationValue(0, foo_container, dict(foo='bar'))103 with pytest.raises(104 InvalidAllocations,105 match="Swap should be disabled due to possibility of OOM killer occurrence!"):106 migrate_pages.validate()107def test_cpuset_for_container_set():108 rdt_information = RDTInformation(True, True, True, True, '0', '0', 0, 0, 0)109 platform_mock = Mock(110 spec=Platform,111 cpus=10,...

Full Screen

Full Screen

memory.py

Source:memory.py Github

copy

Full Screen

...8 self.setPropertyControlCallback(1212)9 self.setPropertyControlCallback(1213)10 def load(self):11 self.setPropertyControlValue(1211, self.sys.get_gpu_memorysplit())12 self.setPropertyControlValue(1212, self.sys.is_swap_enabled())13 self.setPropertyControlEnable(1213, self.sys.is_swap_enabled())14 self.setPropertyControlValue(1213, self.sys.get_swap_size())15 def onClick_1211(self):16 value = self.getPropertyControlValue(1211)17 if value is not None and value != '':18 self._lock()19 self.trace("Applying [%s] value for [%s] configuration property within %s file" % (str(value), self.sys.PROP_BOOT_GPU_MEM, self.sys.FILE_BOOT))20 self.sys.set_gpu_memorysplit(value)21 self.mark4reboot()22 self._unlock()23 def onClick_1212(self):24 value = self.any2bool(self.getPropertyControlValue(1212))25 if value is not None and value != '':26 self._lock()27 self.trace("Applying [%s] value for [%s] configuration property within %s file" %(str(value), self.sys.PROP_SWAP_ENABLED, self.sys.FILE_SWAP))28 self.sys.set_swap_enabled(value)29 self.setPropertyControlEnable(1213, self.sys.is_swap_enabled())30 self.mark4reboot()31 self._unlock()32 def onClick_1213(self):33 value = self.getPropertyControlValue(1213)34 if value is not None and value != '':35 self._lock()36 self.trace("Applying [%s] value for [%s] configuration property within %s file" %(str(value), self.sys.PROP_SWAP_SIZE, self.sys.FILE_SWAP))37 self.sys.set_swap_size(value)38 self.mark4reboot()...

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:

YouTube

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

Run lisa 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?

Helpful

NotHelpful