def test_basic_actions(self): factory = Factory() job = factory.create_kvm_job('sample_jobs/basics.yaml') if not job: return unittest.skip("not all deployments have been implemented") self.assertIsInstance(job, Job) self.assertIsInstance(job.pipeline, Pipeline) return None
def setUp(self): super(TestDefinitionHandlers, self).setUp() factory = Factory() self.job = factory.create_kvm_job('sample_jobs/kvm.yaml') with open( os.path.join(os.path.dirname(__file__), 'testdefs', 'params.yaml'), 'r') as params: self.testdef = yaml.safe_load(params)
class TestDefinitionHandlers(StdoutTestCase): # pylint: disable=too-many-public-methods def setUp(self): super().setUp() self.factory = Factory() self.job = self.factory.create_kvm_job('sample_jobs/kvm.yaml') def test_testshell(self): testshell = None for action in self.job.pipeline.actions: self.assertIsNotNone(action.name) if isinstance(action, TestShellRetry): testshell = action.pipeline.actions[0] break self.assertIsInstance(testshell, TestShellAction) self.assertTrue(testshell.valid) if 'timeout' in testshell.parameters: time_int = Timeout.parse(testshell.parameters['timeout']) else: time_int = Timeout.default_duration() self.assertEqual( datetime.timedelta(seconds=time_int).total_seconds(), testshell.timeout.duration) def test_missing_handler(self): (rendered, _) = self.factory.create_device('kvm01.jinja2') device = NewDevice(yaml.load(rendered)) kvm_yaml = os.path.join(os.path.dirname(__file__), 'sample_jobs/kvm.yaml') parser = JobParser() with open(kvm_yaml) as sample_job_data: data = yaml.load(sample_job_data) data['actions'][2]['test']['definitions'][0][ 'from'] = 'unusable-handler' try: job = parser.parse(yaml.dump(data), device, 4212, None, "") job.logger = DummyLogger() except JobError: pass except Exception as exc: # pylint: disable=broad-except self.fail(exc) else: self.fail('JobError not raised') def test_eventpatterns(self): testshell = None for action in self.job.pipeline.actions: self.assertIsNotNone(action.name) if isinstance(action, TestShellRetry): testshell = action.pipeline.actions[0] break self.assertTrue(testshell.valid) self.assertFalse(testshell.check_patterns('exit', None, '')) self.assertRaises(InfrastructureError, testshell.check_patterns, 'eof', None, '') self.assertTrue(testshell.check_patterns('timeout', None, ''))
def test_qemu_monitor_zephyr_job(self): factory = Factory() job = factory.create_kvm_job('sample_jobs/zephyr-qemu-test-task.yaml') job.validate() self.assertIsNotNone(job) self.assertIsNotNone(job.pipeline) self.assertIsNotNone(job.pipeline.actions) for action in job.pipeline.actions: action.validate() self.assertTrue(action.valid) self.assertFalse(find_autologin(job))
def test_qemu_notest(self): factory = Factory() job = factory.create_kvm_job('sample_jobs/kvm-notest.yaml') job.validate() self.assertIsNotNone(job) self.assertIsNotNone(job.pipeline) self.assertIsNotNone(job.pipeline.actions) for action in job.pipeline.actions: action.validate() self.assertTrue(action.valid) self.assertTrue(find_autologin(job))
def setUp(self): """ Attempt to setup a valid group with clients and test the protocol """ super().setUp() factory = Factory() self.client_job = factory.create_kvm_job('sample_jobs/kvm-multinode-client.yaml') self.server_job = factory.create_kvm_job('sample_jobs/kvm-multinode-server.yaml') self.client_job.logger = DummyLogger() self.server_job.logger = DummyLogger() self.job_id = "100" self.coord = TestCoordinator()
def setUp(self): super(TestPatterns, self).setUp() self.testdef = os.path.join(os.path.dirname(__file__), 'testdefs', 'params.yaml') self.res_data = os.path.join(os.path.dirname(__file__), 'testdefs', 'result-data.txt') factory = Factory() self.job = factory.create_kvm_job("sample_jobs/kvm.yaml") self.job.logger = DummyLogger() self.job.validate() self.ret = False test_retry = [action for action in self.job.pipeline.actions if action.name == 'lava-test-retry'][0] self.test_shell = [action for action in test_retry.internal_pipeline.actions if action.name == 'lava-test-shell'][0] self.test_shell.logger = DummyLogger()
def setUp(self): """ Attempt to setup a valid group with clients and test the protocol """ super(TestMultinode, self).setUp() factory = Factory() self.client_job = factory.create_kvm_job('sample_jobs/kvm-multinode-client.yaml') self.server_job = factory.create_kvm_job('sample_jobs/kvm-multinode-server.yaml') self.client_job.logger = DummyLogger() self.server_job.logger = DummyLogger() self.job_id = "100" self.coord = TestCoordinator()
def setUp(self): super(TestPatterns, self).setUp() self.testdef = os.path.join(os.path.dirname(__file__), 'testdefs', 'params.yaml') self.res_data = os.path.join(os.path.dirname(__file__), 'testdefs', 'result-data.txt') factory = Factory() self.job = factory.create_kvm_job("sample_jobs/kvm.yaml") self.job.logger = DummyLogger() self.job.validate() self.ret = False test_retry = [ action for action in self.job.pipeline.actions if action.name == 'lava-test-retry' ][0] self.test_shell = [ action for action in test_retry.internal_pipeline.actions if action.name == 'lava-test-shell' ][0] self.test_shell.logger = DummyLogger()
def setUp(self): super(TestDefinitionHandlers, self).setUp() factory = Factory() self.job = factory.create_kvm_job('sample_jobs/kvm.yaml')
def setUp(self): super(TestChecksum, self).setUp() factory = Factory() self.job = factory.create_kvm_job('sample_jobs/kvm-inline.yaml')
def setUp(self): super(TestCommand, self).setUp() factory = Factory() self.job = factory.create_kvm_job('sample_jobs/kvm-command.yaml')
def setUp(self): super(TestRepeatBootTest, self).setUp() factory = Factory() self.job = factory.create_kvm_job('sample_jobs/kvm-repeat.yaml')
def setUp(self): super(TestDefinitionRepeat, self).setUp() factory = Factory() self.job = factory.create_kvm_job("sample_jobs/kvm-multi.yaml")
def setUp(self): super(TestKVMInlineTestDeploy, self).setUp() factory = Factory() self.job = factory.create_kvm_job('sample_jobs/kvm-inline.yaml')
def setUp(self): super(TestMonitor, self).setUp() factory = Factory() self.job = factory.create_kvm_job('sample_jobs/qemu-monitor.yaml')
def setUp(self): super(TestKvmUefi, self).setUp() factory = Factory() self.job = factory.create_kvm_job('sample_jobs/kvm-uefi.yaml')
def setUp(self): super(TestKvmGuest, self).setUp() factory = Factory() self.job = factory.create_kvm_job('sample_jobs/kvm-local.yaml')
def test_kvm_simulation(self): # pylint: disable=too-many-statements """ Build a pipeline which simulates a KVM LAVA job without using the formal objects (to avoid validating data known to be broken). The details are entirely arbitrary. """ factory = Factory() job = factory.create_kvm_job('sample_jobs/kvm.yaml') pipe = Pipeline() action = Action() action.name = "deploy_linaro_image" action.description = "deploy action using preset subactions in an internal pipe" action.summary = "deploy_linaro_image" action.job = job # deliberately unlikely location # a successful validation would need to use the cwd action.parameters = {"image": "file:///none/images/bad-kvm-debian-wheezy.img"} pipe.add_action(action) self.assertEqual(action.level, "1") deploy_pipe = Pipeline(action) action = Action() action.name = "downloader" action.description = "download image wrapper, including an internal retry pipe" action.summary = "downloader" action.job = job deploy_pipe.add_action(action) self.assertEqual(action.level, "1.1") # a formal RetryAction would contain a pre-built pipeline which can be inserted directly retry_pipe = Pipeline(action) action = Action() action.name = "wget" action.description = "do the download with retries" action.summary = "wget" action.job = job retry_pipe.add_action(action) self.assertEqual(action.level, "1.1.1") action = Action() action.name = "checksum" action.description = "checksum the downloaded file" action.summary = "md5sum" action.job = job deploy_pipe.add_action(action) self.assertEqual(action.level, "1.2") action = Action() action.name = "overlay" action.description = "apply lava overlay" action.summary = "overlay" action.job = job deploy_pipe.add_action(action) self.assertEqual(action.level, "1.3") action = Action() action.name = "boot" action.description = "boot image" action.summary = "qemu" action.job = job # cmd_line built from device configuration action.parameters = { 'cmd_line': [ 'qemu-system-x86_64', '-machine accel=kvm:tcg', '-hda' '%s' % "tbd", '-nographic', '-net', 'nic,model=virtio' '-net user' ] } pipe.add_action(action) self.assertEqual(action.level, "2") action = Action() action.name = "simulated" action.description = "lava test shell" action.summary = "simulated" action.job = job # a formal lava test shell action would include an internal pipe # which would handle the run.sh pipe.add_action(action) self.assertEqual(action.level, "3") # just a fake action action = Action() action.name = "fake" action.description = "faking results" action.summary = "fake action" action.job = job pipe.add_action(action) self.assertEqual(action.level, "4") self.assertEqual(len(pipe.describe()), 4)
def setUp(self): super(TestDefinitionSimple, self).setUp() factory = Factory() self.job = factory.create_kvm_job('sample_jobs/kvm-notest.yaml')
class TestDefinitionParams(StdoutTestCase): # pylint: disable=too-many-public-methods def setUp(self): super(TestDefinitionParams, self).setUp() self.factory = Factory() self.job = self.factory.create_kvm_job('sample_jobs/kvm-params.yaml') def test_job_without_tests(self): boot = finalize = None allow_missing_path(self.job.pipeline.validate_actions, self, 'qemu-system-x86_64') deploy = [ action for action in self.job.pipeline.actions if action.name == 'deployimages' ][0] overlay = [ action for action in deploy.internal_pipeline.actions if action.name == 'lava-overlay' ][0] testdef = [ action for action in overlay.internal_pipeline.actions if action.name == 'test-definition' ][0] for action in self.job.pipeline.actions: self.assertNotIsInstance(action, TestDefinitionAction) self.assertNotIsInstance(action, OverlayAction) boot = self.job.pipeline.actions[1] finalize = self.job.pipeline.actions[3] self.assertIsInstance(overlay, OverlayAction) self.assertIsInstance(testdef, TestDefinitionAction) test = testdef.internal_pipeline.actions[1] install = testdef.internal_pipeline.actions[2] runsh = testdef.internal_pipeline.actions[3] self.assertIsInstance(deploy, DeployImagesAction) self.assertIsInstance(boot, BootAction) self.assertIsInstance(finalize, FinalizeAction) self.assertEqual(len(self.job.pipeline.actions), 4) # deploy, boot, test, finalize self.assertNotIn('test_params', testdef.parameters) self.assertIsInstance(install, TestInstallAction) self.assertIsInstance(runsh, TestRunnerAction) self.assertIsNot(list(install.parameters.items()), []) testdef = { 'params': { 'VARIABLE_NAME_1': 'value_1', 'VARIABLE_NAME_2': 'value_2' } } content = test.handle_parameters(testdef) self.assertEqual( set(content), { '###default parameters from test definition###\n', "VARIABLE_NAME_1='value_1'\n", "VARIABLE_NAME_2='value_2'\n", '######\n', '###test parameters from job submission###\n', "VARIABLE_NAME_1='eth2'\n", "VARIABLE_NAME_2='wlan0'\n", '######\n' }) testdef = { 'parameters': { 'VARIABLE_NAME_1': 'value_1', 'VARIABLE_NAME_2': 'value_2' } } content = test.handle_parameters(testdef) self.assertEqual( set(content), { '###default parameters from test definition###\n', "VARIABLE_NAME_1='value_1'\n", "VARIABLE_NAME_2='value_2'\n", '######\n', '###test parameters from job submission###\n', "VARIABLE_NAME_1='eth2'\n", "VARIABLE_NAME_2='wlan0'\n", '######\n' }) @unittest.skipIf(infrastructure_error('git'), 'git not installed') def test_install_repos(self): job = self.factory.create_kvm_job('sample_jobs/kvm-install.yaml') allow_missing_path(self.job.pipeline.validate_actions, self, 'qemu-system-x86_64') deploy = [ action for action in job.pipeline.actions if action.name == 'deployimages' ][0] overlay = [ action for action in deploy.internal_pipeline.actions if action.name == 'lava-overlay' ][0] testdef = [ action for action in overlay.internal_pipeline.actions if action.name == 'test-definition' ][0] test_install = [ action for action in testdef.internal_pipeline.actions if action.name == 'test-install-overlay' ][0] self.assertIsNotNone(test_install) yaml_file = os.path.join(os.path.dirname(__file__), './testdefs/install.yaml') self.assertTrue(os.path.exists(yaml_file)) with open(yaml_file, 'r') as test_file: testdef = yaml.safe_load(test_file) repos = testdef['install'].get('git-repos', []) self.assertIsNotNone(repos) self.assertIsInstance(repos, list) for repo in repos: self.assertIsNotNone(repo) runner_path = tempfile.mkdtemp() test_install.install_git_repos(testdef, runner_path) shutil.rmtree(runner_path)
def setUp(self): super(TestKVMQcow2Deploy, self).setUp() factory = Factory() self.job = factory.create_kvm_job('sample_jobs/kvm-qcow2.yaml')
class TestKVMInlineTestDeploy(StdoutTestCase): # pylint: disable=too-many-public-methods def setUp(self): super().setUp() self.factory = Factory() self.job = self.factory.create_kvm_job('sample_jobs/kvm-inline.yaml') def test_deploy_job(self): self.assertEqual(self.job.pipeline.job, self.job) for action in self.job.pipeline.actions: if isinstance(action, DeployAction): self.assertEqual(action.job, self.job) def test_validate(self): try: self.job.pipeline.validate_actions() except JobError as exc: self.fail(exc) except InfrastructureError: pass for action in self.job.pipeline.actions: self.assertEqual([], action.errors) def test_extra_options(self): (rendered, _) = self.factory.create_device('kvm01.jinja2') device = NewDevice(yaml.safe_load(rendered)) kvm_yaml = os.path.join(os.path.dirname(__file__), 'sample_jobs/kvm-inline.yaml') with open(kvm_yaml) as sample_job_data: job_data = yaml.safe_load(sample_job_data) device['actions']['boot']['methods']['qemu']['parameters'][ 'extra'] = yaml.safe_load(""" - -smp - 1 - -global - virtio-blk-device.scsi=off - -device virtio-scsi-device,id=scsi - --append "console=ttyAMA0 root=/dev/vda rw" """) self.assertIsInstance( device['actions']['boot']['methods']['qemu']['parameters']['extra'] [1], int) parser = JobParser() job = parser.parse(yaml.dump(job_data), device, 4212, None, "") job.logger = DummyLogger() job.validate() boot_image = [ action for action in job.pipeline.actions if action.name == 'boot-image-retry' ][0] boot_qemu = [ action for action in boot_image.internal_pipeline.actions if action.name == 'boot-qemu-image' ][0] qemu = [ action for action in boot_qemu.internal_pipeline.actions if action.name == 'execute-qemu' ][0] self.assertIsInstance(qemu.sub_command, list) [self.assertIsInstance(item, str) for item in qemu.sub_command] # pylint: disable=expression-not-assigned self.assertIn('virtio-blk-device.scsi=off', qemu.sub_command) self.assertIn('1', qemu.sub_command) self.assertNotIn(1, qemu.sub_command) def test_pipeline(self): description_ref = self.pipeline_reference('kvm-inline.yaml') self.assertEqual(description_ref, self.job.pipeline.describe(False)) self.assertEqual(len(self.job.pipeline.describe()), 4) inline_repo = None for action in self.job.pipeline.actions: if isinstance(action, DeployAction): self.assertIsNotNone(action.internal_pipeline.actions[1]) overlay = action.pipeline.actions[1] self.assertIsNotNone(overlay.internal_pipeline.actions[1]) testdef = overlay.internal_pipeline.actions[2] self.assertIsNotNone(testdef.internal_pipeline.actions[0]) inline_repo = testdef.internal_pipeline.actions[0] break # Test the InlineRepoAction directly self.assertIsNotNone(inline_repo) location = mkdtemp() # other actions have not been run, so fake up inline_repo.set_namespace_data(action='test', label='results', key='lava_test_results_dir', value=location) inline_repo.set_namespace_data(action='test', label='test-definition', key='overlay_dir', value=location) inline_repo.set_namespace_data(action='test', label='shared', key='location', value=location) inline_repo.set_namespace_data(action='test', label='test-definiton', key='overlay_dir', value=location) inline_repo.run(None, None) yaml_file = os.path.join( location, '0/tests/0_smoke-tests-inline/inline/smoke-tests-basic.yaml') self.assertTrue(os.path.exists(yaml_file)) with open(yaml_file, 'r') as f_in: testdef = yaml.safe_load(f_in) expected_testdef = { 'metadata': { 'description': 'Basic system test command for Linaro Ubuntu images', 'devices': [ 'panda', 'panda-es', 'arndale', 'vexpress-a9', 'vexpress-tc2' ], 'format': 'Lava-Test Test Definition 1.0', 'name': 'smoke-tests-basic', 'os': ['ubuntu'], 'scope': ['functional'], 'yaml_line': 39 }, 'run': { 'steps': [ 'lava-test-case linux-INLINE-pwd --shell pwd', 'lava-test-case linux-INLINE-uname --shell uname -a', 'lava-test-case linux-INLINE-vmstat --shell vmstat', 'lava-test-case linux-INLINE-ifconfig --shell ifconfig -a', 'lava-test-case linux-INLINE-lscpu --shell lscpu', 'lava-test-case linux-INLINE-lsusb --shell lsusb', 'lava-test-case linux-INLINE-lsb_release --shell lsb_release -a' ], 'yaml_line': 53 }, 'yaml_line': 38 } self.assertEqual(set(testdef), set(expected_testdef))
def test_autologin_normal_kvm(self): factory = Factory() job = factory.create_kvm_job('sample_jobs/kvm.yaml') job.validate() self.assertTrue(find_autologin(job))
def setUp(self): super(TestKVMDownloadLocalDeploy, self).setUp() factory = Factory() self.job = factory.create_kvm_job('sample_jobs/kvm-local.yaml')
class TestChecksum(StdoutTestCase): def setUp(self): super().setUp() self.factory = Factory() self.job = self.factory.create_kvm_job('sample_jobs/kvm-inline.yaml') def test_download_checksum_match_success(self): self.assertEqual(len(self.job.pipeline.describe()), 4) deployimagesaction = [ action for action in self.job.pipeline.actions if action.name == 'deployimages' ][0] downloadretryaction = [ action for action in deployimagesaction.internal_pipeline.actions if action.name == 'download-retry' ][0] httpdownloadaction = [ action for action in downloadretryaction.internal_pipeline.actions if action.name == 'http-download' ][0] # Just a small image httpdownloadaction.url = 'http://images.validation.linaro.org/unit-tests/rootfs.gz' httpdownloadaction.parameters.update({ 'images': { 'rootfs': { 'url': httpdownloadaction.url, 'md5sum': '6ea432ac3c23210c816551782346ed1c', 'sha256sum': '1a76b17701b9fdf6346b88eb49b0143a9c6912701b742a6e5826d6856edccd21' } } }) httpdownloadaction.validate() httpdownloadaction.run(None, None) def test_download_checksum_match_fail(self): self.assertEqual(len(self.job.pipeline.describe()), 4) deployimagesaction = [ action for action in self.job.pipeline.actions if action.name == 'deployimages' ][0] downloadretryaction = [ action for action in deployimagesaction.internal_pipeline.actions if action.name == 'download-retry' ][0] httpdownloadaction = [ action for action in downloadretryaction.internal_pipeline.actions if action.name == 'http-download' ][0] # Just a small image httpdownloadaction.url = 'http://images.validation.linaro.org/unit-tests/rootfs.gz' httpdownloadaction.parameters.update({ 'images': { 'rootfs': { 'url': httpdownloadaction.url, 'md5sum': 'df1bd1598699e7a89d2e111111111111', 'sha256sum': '92d6ff900d0c3656ab3f214ce6efd708f898fc5e259111111111111111111111' } } }) httpdownloadaction.validate() self.assertRaises(JobError, httpdownloadaction.run, None, None) def test_download_no_images_no_checksum(self): self.assertEqual(len(self.job.pipeline.describe()), 4) deployimagesaction = [ action for action in self.job.pipeline.actions if action.name == 'deployimages' ][0] downloadretryaction = [ action for action in deployimagesaction.internal_pipeline.actions if action.name == 'download-retry' ][0] httpdownloadaction = [ action for action in downloadretryaction.internal_pipeline.actions if action.name == 'http-download' ][0] # Just a small image httpdownloadaction.url = 'http://images.validation.linaro.org/unit-tests/rootfs.gz' del httpdownloadaction.parameters['images'] httpdownloadaction.parameters.update( {'rootfs': { 'url': httpdownloadaction.url }}) httpdownloadaction.validate() httpdownloadaction.run(None, None) def test_download_no_images_match_success(self): self.assertEqual(len(self.job.pipeline.describe()), 4) deployimagesaction = [ action for action in self.job.pipeline.actions if action.name == 'deployimages' ][0] downloadretryaction = [ action for action in deployimagesaction.internal_pipeline.actions if action.name == 'download-retry' ][0] httpdownloadaction = [ action for action in downloadretryaction.internal_pipeline.actions if action.name == 'http-download' ][0] # Just a small image httpdownloadaction.url = 'http://images.validation.linaro.org/unit-tests/rootfs.gz' del httpdownloadaction.parameters['images'] httpdownloadaction.parameters.update({ 'rootfs': { 'url': httpdownloadaction.url, 'md5sum': '6ea432ac3c23210c816551782346ed1c', 'sha256sum': '1a76b17701b9fdf6346b88eb49b0143a9c6912701b742a6e5826d6856edccd21' } }) httpdownloadaction.validate() httpdownloadaction.run(None, None) def test_download_no_images_match_fail(self): self.assertEqual(len(self.job.pipeline.describe()), 4) deployimagesaction = [ action for action in self.job.pipeline.actions if action.name == 'deployimages' ][0] downloadretryaction = [ action for action in deployimagesaction.internal_pipeline.actions if action.name == 'download-retry' ][0] httpdownloadaction = [ action for action in downloadretryaction.internal_pipeline.actions if action.name == 'http-download' ][0] # Just a small image httpdownloadaction.url = 'http://images.validation.linaro.org/unit-tests/rootfs.gz' del httpdownloadaction.parameters['images'] httpdownloadaction.parameters.update({ 'rootfs': { 'url': httpdownloadaction.url, 'md5sum': '6ea432ac3c232122222221782346ed1c', 'sha256sum': '1a76b17701b9fdf63444444444444444446912701b742a6e5826d6856edccd21' } }) httpdownloadaction.validate() self.assertRaises(JobError, httpdownloadaction.run, None, None) def test_no_test_action_validate(self): self.assertEqual(len(self.job.pipeline.describe()), 4) del self.job.pipeline.actions[2] try: self.job.pipeline.validate_actions() except JobError as exc: self.fail(exc) except InfrastructureError as exc: check_missing_path(self, exc, 'qemu-system-x86_64') for action in self.job.pipeline.actions: self.assertEqual([], action.errors) def test_uboot_checksum(self): (rendered, _) = self.factory.create_device('bbb-01.jinja2') device = NewDevice(yaml.safe_load(rendered)) bbb_yaml = os.path.join(os.path.dirname(__file__), 'sample_jobs/bbb-ramdisk-nfs.yaml') with open(bbb_yaml) as sample_job_data: parser = JobParser() job = parser.parse(sample_job_data, device, 4212, None, "") deploy = [ action for action in job.pipeline.actions if action.name == 'tftp-deploy' ][0] download = [ action for action in deploy.internal_pipeline.actions if action.name == 'download-retry' ][0] helper = [ action for action in download.internal_pipeline.actions if action.name == 'file-download' ][0] remote = helper.parameters[helper.key] md5sum = remote.get('md5sum') self.assertIsNone(md5sum) sha256sum = remote.get('sha256sum') self.assertIsNotNone(sha256sum)
def setUp(self): super(TestAutoLogin, self).setUp() factory = Factory() self.job = factory.create_kvm_job('sample_jobs/kvm-inline.yaml') self.job.logger = DummyLogger() self.max_end_time = time.time() + 30
def setUp(self): super().setUp() factory = Factory() self.job = factory.create_kvm_job('sample_jobs/qemu-monitor.yaml')
def setUp(self): super().setUp() factory = Factory() self.job = factory.create_kvm_job("sample_jobs/kvm-multi.yaml")
def setUp(self): super().setUp() factory = Factory() self.job = factory.create_kvm_job('sample_jobs/kvm-inline.yaml') self.job.logger = DummyLogger() self.max_end_time = time.time() + 30
def test_kvm_simulation(self): # pylint: disable=too-many-statements """ Build a pipeline which simulates a KVM LAVA job without using the formal objects (to avoid validating data known to be broken). The details are entirely arbitrary. """ factory = Factory() job = factory.create_kvm_job('sample_jobs/kvm.yaml') pipe = Pipeline() action = Action() action.name = "deploy_linaro_image" action.description = "deploy action using preset subactions in an internal pipe" action.summary = "deploy_linaro_image" action.job = job # deliberately unlikely location # a successful validation would need to use the cwd action.parameters = { "image": "file:///none/images/bad-kvm-debian-wheezy.img" } pipe.add_action(action) self.assertEqual(action.level, "1") deploy_pipe = Pipeline(action) action = Action() action.name = "downloader" action.description = "download image wrapper, including an internal retry pipe" action.summary = "downloader" action.job = job deploy_pipe.add_action(action) self.assertEqual(action.level, "1.1") # a formal RetryAction would contain a pre-built pipeline which can be inserted directly retry_pipe = Pipeline(action) action = Action() action.name = "wget" action.description = "do the download with retries" action.summary = "wget" action.job = job retry_pipe.add_action(action) self.assertEqual(action.level, "1.1.1") action = Action() action.name = "checksum" action.description = "checksum the downloaded file" action.summary = "md5sum" action.job = job deploy_pipe.add_action(action) self.assertEqual(action.level, "1.2") action = Action() action.name = "overlay" action.description = "apply lava overlay" action.summary = "overlay" action.job = job deploy_pipe.add_action(action) self.assertEqual(action.level, "1.3") action = Action() action.name = "boot" action.description = "boot image" action.summary = "qemu" action.job = job # cmd_line built from device configuration action.parameters = { 'cmd_line': [ 'qemu-system-x86_64', '-machine accel=kvm:tcg', '-hda' '%s' % "tbd", '-nographic', '-net', 'nic,model=virtio' '-net user' ] } pipe.add_action(action) self.assertEqual(action.level, "2") action = Action() action.name = "simulated" action.description = "lava test shell" action.summary = "simulated" action.job = job # a formal lava test shell action would include an internal pipe # which would handle the run.sh pipe.add_action(action) self.assertEqual(action.level, "3") # just a fake action action = Action() action.name = "fake" action.description = "faking results" action.summary = "fake action" action.job = job pipe.add_action(action) self.assertEqual(action.level, "4") self.assertEqual(len(pipe.describe()), 4)
def setUp(self): super().setUp() factory = Factory() self.job = factory.create_kvm_job('sample_jobs/kvm-uefi.yaml')
def setUp(self): super().setUp() factory = Factory() self.job = factory.create_kvm_job('sample_jobs/compression.yaml') self.job.validate()