How to use get_vm method in lisa

Best Python code snippet using lisa_python

datasets.py

Source:datasets.py Github

copy

Full Screen

...45 def get_dataset(self, dataset: str) -> Tuple[VariabilityModel, TestingStrategy]:46 ds = self.sets.get(dataset)47 if ds is None:48 raise Exception('Unknown dataset' + dataset)49 return ds.get_vm(), ds.get_testing_start()50 def generate_testsuite(self, ds: List[str]) -> Iterator[Tuple[str, VariabilityModel, TestingStrategy]]:51 return [(name, self.get_dataset(name)[0], self.get_dataset(name)[1]) for name in ds]52class Dataset:53 @abstractmethod54 def get_vm(self):55 pass56 @abstractmethod57 def get_testing_start(self):58 pass59class SynDataset(Dataset):60 def __init__(self, params, mutexes, constrains, influential, interactions):61 self.builder = SyntheticDataBuilder(62 parameters=params,63 influential_parameters=influential,64 mutex_groups=np.random.randint(2, 3 + mutexes, mutexes) if mutexes > 0 else [],65 mutex_required=[True] * mutexes,66 constrains=constrains,67 interactions=interactions68 )69 def get_vm(self):70 return self.builder.get_vm()71 def get_testing_start(self):72 return self.builder.get_testing_strategy()73 def overview(self):74 self.builder.print_overview()75class Syn10IntPreDataset(Dataset):76 def get_vm(self):77 return dimacs_model_reader.read_file(dir_path + "/../resources/syn-10-int.dimacs")78 def get_testing_start(self):79 return SyntheticTestingStrategy.from_file(dir_path + "/../resources/syn-10-int-test.json")80class Syn10Int2PreDataset(Dataset):81 def get_vm(self):82 return dimacs_model_reader.read_file(dir_path + "/../resources/syn-10-2-int.dimacs")83 def get_testing_start(self):84 return SyntheticTestingStrategy.from_file(dir_path + "/../resources/syn-10-2-int-test.json")85class Syn50IntPreDataset(Dataset):86 def get_vm(self):87 return dimacs_model_reader.read_file(dir_path + "/../resources/syn-50-int.dimacs")88 def get_testing_start(self):89 return SyntheticTestingStrategy.from_file(dir_path + "/../resources/syn-50-int-test.json")90class Syn50Int2PreDataset(Dataset):91 def get_vm(self):92 return dimacs_model_reader.read_file(dir_path + "/../resources/syn-50-2-int.dimacs")93 def get_testing_start(self):94 return SyntheticTestingStrategy.from_file(dir_path + "/../resources/syn-50-2-int-test.json")95class Syn50PreDataset(Dataset):96 def get_vm(self):97 return dimacs_model_reader.read_file(dir_path + "/../resources/syn-50.dimacs")98 def get_testing_start(self):99 return SyntheticTestingStrategy.from_file(dir_path + "/../resources/syn-50-test.json")100class Syn100PreDataset(Dataset):101 def get_vm(self):102 return dimacs_model_reader.read_file(dir_path + "/../resources/syn-100.dimacs")103 def get_testing_start(self):104 return SyntheticTestingStrategy.from_file(dir_path + "/../resources/syn-100-test.json")105class Syn500PreDataset(Dataset):106 def get_vm(self):107 return dimacs_model_reader.read_file(dir_path + "/../resources/syn-500.dimacs")108 def get_testing_start(self):109 return SyntheticTestingStrategy.from_file(dir_path + "/../resources/syn-500-test.json")110class Syn500PreSimpleDataset(Dataset):111 def get_vm(self):112 return dimacs_model_reader.read_file(dir_path + "/../resources/syn-500-simple.dimacs")113 def get_testing_start(self):114 return SyntheticTestingStrategy.from_file(dir_path + "/../resources/syn-500-simple-test.json")115class Syn1000PreDataset(Dataset):116 def get_vm(self):117 return dimacs_model_reader.read_file(dir_path + "/../resources/syn-1000.dimacs")118 def get_testing_start(self):119 return SyntheticTestingStrategy.from_file(dir_path + "/../resources/syn-1000-test.json")120class Syn1000PreSimpleDataset(Dataset):121 def get_vm(self):122 return dimacs_model_reader.read_file(dir_path + "/../resources/syn-1000-simple.dimacs")123 def get_testing_start(self):124 return SyntheticTestingStrategy.from_file(dir_path + "/../resources/syn-1000-simple-test.json")125class PostgreSQLDataset(Dataset):126 def get_vm(self):127 return dimacs_model_reader.read_file(dir_path + "/../resources/PostgreSQL_pervolution_bin.dimacs")128 def get_testing_start(self):129 return CsvTestingStrategy(dir_path + "/../resources/PostgreSQL_pervolution_bin_measurements.csv",130 result_key='performance', result_keys={'revision', 'performance', 'cpu'})131class BerkleyDBDataset(Dataset):132 def get_vm(self):133 return dimacs_model_reader.read_file(dir_path + "/../resources/berkely.dimacs")134 def get_testing_start(self):135 return XmlTestingStrategy(dir_path + "/../resources/berkley_measurements.xml")136class ApacheDataset(Dataset):137 def get_vm(self):138 return dimacs_model_reader.read_file(dir_path + "/../resources/apache_pervolution_energy_bin.dimacs")139 def get_testing_start(self):140 return CsvTestingStrategy(dir_path + "/../resources/apache_pervolution_energy_bin_measurements.csv",141 result_key='performance',142 result_keys={'performance', 'cpu', 'benchmark-energy', 'fixed-energy', 'revision'})143class JavaGCDataset(Dataset):144 def get_vm(self):145 return dimacs_model_reader.read_file(dir_path + "/../resources/javagc.dimacs")146 def get_testing_start(self):147 return CsvTestingStrategy(dir_path + "/../resources/javagc_measurements.csv", result_key="performance",...

Full Screen

Full Screen

test_hooks.py

Source:test_hooks.py Github

copy

Full Screen

1"""Unit tests for hooks.py."""2import argparse3import pytest4from unittest.mock import patch5import orekitfactory.hooks6def raiseme(*args, **kwargs):7 raise RuntimeError()8def test_pre_init_nullargs():9 """Unit testin verifying default argument parse."""10 orekitfactory.hooks.pre_init(None)11def test_pre_init_noargs():12 """Unit testin verifying default argument parse."""13 parser = argparse.ArgumentParser()14 orekitfactory.hooks.pre_init(parser)15 args = parser.parse_args([])16 assert (17 "https://gitlab.orekit.org/orekit/orekit-data/-/archive/master/orekit-data-master.zip" # noqa: E50118 == args.orekit_data19 )20def test_pre_init_disabled():21 """Unit test verifying argument parsing."""22 try:23 orekitfactory.hooks.ENABLED = False24 parser = argparse.ArgumentParser()25 orekitfactory.hooks.pre_init(parser)26 args = parser.parse_args([])27 assert "orekit_data" not in args28 finally:29 orekitfactory.hooks.ENABLED = True30def test_pre_init_fileargs():31 """Unit test verifying argument parsing."""32 parser = argparse.ArgumentParser()33 orekitfactory.hooks.pre_init(parser)34 args = parser.parse_args(["--orekit-data", __file__])35 assert __file__ == args.orekit_data36def test_pre_init_urlargs():37 """Unit test verifying argument parsing."""38 parser = argparse.ArgumentParser()39 orekitfactory.hooks.pre_init(parser)40 args = parser.parse_args(41 ["--orekit-data", "https://data.pirates.org/yellowbeard.zip"]42 )43 assert "https://data.pirates.org/yellowbeard.zip" == args.orekit_data44@patch("orekitfactory.hooks.get_orekit_vm")45@patch("orekitfactory.hooks.init_orekit")46def test_post_init_noargs(init_orekit, get_vm):47 orekitfactory.hooks.post_init(argparse.Namespace())48 init_orekit.assert_not_called()49 get_vm.assert_called_once()50@patch("orekitfactory.hooks.get_orekit_vm")51@patch("orekitfactory.hooks.init_orekit")52def test_post_init_args(init_orekit, get_vm):53 orekitfactory.hooks.post_init(54 argparse.Namespace(orekit_data="https://pirates.data/yellowbeard.zip")55 )56 init_orekit.assert_called_with(source="https://pirates.data/yellowbeard.zip")57 get_vm.assert_called_once()58@patch("orekitfactory.hooks.get_orekit_vm")59def test_post_init_badvm(get_vm):60 """Unit testin verifying default argument parse."""61 get_vm.side_effect = raiseme62 with pytest.raises(RuntimeError):63 orekitfactory.hooks.post_init(argparse.Namespace())64 get_vm.assert_called_once()65@patch("orekitfactory.hooks.get_orekit_vm")66@patch("orekitfactory.hooks.init_orekit")67def test_post_init_disabled(init_orekit, get_vm):68 try:69 orekitfactory.hooks.ENABLED = False70 orekitfactory.hooks.post_init(71 argparse.Namespace(orekit_data="https://pirates.data/yellowbeard.zip")72 )73 init_orekit.assert_not_called()74 get_vm.assert_not_called()75 finally:...

Full Screen

Full Screen

test.py

Source:test.py Github

copy

Full Screen

1"""2This file contains the list of P1 test cases3"""4import requests5def test_checkout():6 """7 Test Steps8 1. Call the checkout method9 2. Validate the status code10 :return:11 """12 try:13 get_vm = requests.get("/checkout", params={"username": "myname"})14 assert get_vm.status_code == 20015 get_vm = get_vm.json()16 assert len(get_vm) == 417 except Exception as e:18 print(e.__doc__)19def test_checkin():20 """21 Test Steps22 1. Call the checkin method23 2. Validate the status code24 :return:25 """26 try:27 get_vm = requests.post("/checkin", data={"username": "myname"})28 assert get_vm.status_code == 20029 except Exception as e:30 print(e.__doc__)31def test__multiple_checkout():32 """33 Test Steps34 1. Call the checkout method, reserve an vm35 2. Validate the status code36 3. Retry step 137 :return:38 """39 try:40 get_vm = requests.get("/checkout", params={"username": "myname"})41 assert get_vm.status_code == 20042 get_vm = get_vm.json()43 assert len(get_vm) == 444 # Retry getting an vm again45 get_vm = requests.get("/checkout", params={"username": "myname"})46 assert get_vm.status_code == 20147 get_vm = get_vm.json()48 assert "already" in get_vm49 except Exception as e:50 print(e.__doc__)51def test_pool_fool():52 """53 Test Steps54 1. using any tool , reserve all the vm's55 2. try to reserve a machine56 3. Retry step 157 :return:58 """59 try:60 get_vm = requests.get("/checkout", params={"username": "myname"})61 assert get_vm.status_code == 20162 get_vm = get_vm.json()63 assert "full" in get_vm64 except Exception as e:65 print(e.__doc__)66def test_server_down():67 """68 Test Steps69 1. Bring down the server70 2. call checkout method71 :return:72 """73 try:74 # Call the stop server method or run flask stop command via function75 get_vm = requests.get("/checkout", params={"username": "myname"})76 assert get_vm.status_code == 50077 get_vm = get_vm.json()78 assert "full" in get_vm79 except TimeoutError as e:...

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