class TestDownloadDeploy(StdoutTestCase): # pylint: disable=too-many-public-methods def setUp(self): super().setUp() self.factory = Factory() self.job = self.factory.create_job('db410c-01.jinja2', 'sample_jobs/download.yaml') def test_deploy_job(self): self.assertEqual(self.job.pipeline.job, self.job) self.assertIsInstance(self.job.device['device_info'], list) for action in self.job.pipeline.actions: if isinstance(action, DeployAction): self.assertEqual(action.job, self.job) def test_pipeline(self): description_ref = self.pipeline_reference('download.yaml') self.assertEqual(description_ref, self.job.pipeline.describe(False)) @unittest.skipIf( infrastructure_error_multi_paths(['lxc-info', 'img2simg', 'simg2img']), "lxc or img2simg or simg2img not installed") def test_validate(self): try: self.job.pipeline.validate_actions() except JobError as exc: self.fail(exc) for action in self.job.pipeline.actions: self.assertEqual([], action.errors) def test_directories(self): job = self.factory.create_job('bbb-01.jinja2', 'sample_jobs/download_dir.yaml') with self.assertRaises(JobError): job.validate()
def setUp(self): super().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/qemu-reboot.yaml", check_job=True) 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.skipped_shell = [ action for action in test_retry.internal_pipeline.actions if action.name == 'lava-test-shell' ][0] print(self.skipped_shell.parameters['timeout']) self.skipped_shell.logger = DummyLogger() test_retry = [ action for action in self.job.pipeline.actions if action.name == 'lava-test-retry' ][1] self.fatal_shell = [ action for action in test_retry.internal_pipeline.actions if action.name == 'lava-test-shell' ][0]
def test_basic_actions(self): factory = Factory() job = factory.create_fake_qemu_job() if not job: return unittest.skip("not all deployments have been implemented") self.assertIsInstance(job, Job) self.assertIsInstance(job.pipeline, Pipeline)
def test_device_environment_validity(self): # pylint: disable=invalid-name """ Use non-YAML syntax a bit like existing device config syntax. Ensure this syntax is picked up as invalid. """ data = """ # YAML syntax. overrides: DEBEMAIL = "*****@*****.**" DEBFULLNAME: "Neil Williams" """ factory = Factory() job_parser = JobParser() (rendered, _) = factory.create_device('bbb-01.jinja2') device = NewDevice(yaml.load(rendered)) sample_job_file = os.path.join(os.path.dirname(__file__), 'sample_jobs/uboot-ramdisk.yaml') with open(sample_job_file) as sample_job_data: job = job_parser.parse(sample_job_data, device, 4212, None, "", env_dut=data) job.logger = DummyLogger() self.assertEqual(job.parameters['env_dut'], data) with self.assertRaises(JobError): job.validate()
def test_device_environment(self): data = """ # YAML syntax. overrides: DEBEMAIL: "*****@*****.**" DEBFULLNAME: "Neil Williams" """ factory = Factory() job_parser = JobParser() (rendered, _) = factory.create_device('bbb-01.jinja2') device = NewDevice(yaml.safe_load(rendered)) sample_job_file = os.path.join(os.path.dirname(__file__), 'sample_jobs/uboot-ramdisk.yaml') with open(sample_job_file) as sample_job_data: job = job_parser.parse( sample_job_data, device, 4212, None, "", env_dut=data) job.logger = DummyLogger() self.assertEqual( job.parameters['env_dut'], data ) job.validate() boot_actions = [ action.internal_pipeline.actions for action in job.pipeline.actions if action.name == 'uboot-action'][0] retry = [action for action in boot_actions if action.name == 'uboot-retry'][0] boot_env = [action for action in retry.internal_pipeline.actions if action.name == 'export-device-env'][0] found = False for line in boot_env.env: if 'DEBFULLNAME' in line: found = True # assert that the string containing a space still contains that space and is quoted self.assertIn('\\\'Neil Williams\\\'', line) self.assertTrue(found)
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)
def test_device_constants(self): factory = Factory() (rendered, _) = factory.create_device('bbb-01.jinja2') device = NewDevice(yaml.safe_load(rendered)) self.assertIn('constants', device) self.assertEqual(device.get_constant('kernel-start-message'), "Linux version [0-9]") self.assertRaises(ConfigurationError, device.get_constant, ('non-existing-const'))
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 test_device_power(self): factory = Factory() (rendered, _) = factory.create_device('bbb-01.jinja2') device = yaml.load(rendered) self.assertNotEqual(device['commands'].get('hard_reset', ''), '') (rendered, _) = factory.create_device('kvm01.jinja2') device = yaml.load(rendered) self.assertNotIn('commands', device)
def setUp(self): super().setUp() self.factory = Factory() self.job = self.factory.create_job('qemu01.jinja2', '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 setUp(self): super().setUp() self.filename = os.path.join(os.path.dirname(__file__), 'sample_jobs/bbb-group-vland-alpha.yaml') self.beta_filename = os.path.join( os.path.dirname(__file__), 'sample_jobs/bbb-group-vland-beta.yaml') self.factory = Factory() (rendered, _) = self.factory.create_device('bbb-01.jinja2') self.device = NewDevice(yaml.safe_load(rendered)) self.job_id = "100"
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): """ 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 test_device_parser(self): job_parser = JobParser() factory = Factory() job = factory.create_job('bbb-01.jinja2', 'sample_jobs/uboot-ramdisk.yaml') uboot_action = None device = job.device for action in job.pipeline.actions: if isinstance(action, DeployAction): self.assertIn('ramdisk', action.parameters) if isinstance(action, BootAction): self.assertIn('method', action.parameters) self.assertEqual('u-boot', action.parameters['method']) methods = device['actions']['boot']['methods'] self.assertIn('ramdisk', methods['u-boot']) self.assertIn('bootloader_prompt', methods['u-boot']['parameters']) self.assertIsNotNone(methods[action.parameters['method']][ action.parameters['commands']]['commands']) for line in methods[action.parameters['method']][ action.parameters['commands']]['commands']: self.assertIsNotNone(line) self.assertIsInstance(action, UBootAction) uboot_action = action self.assertIsNotNone(uboot_action) uboot_action.validate() self.assertTrue(uboot_action.valid) for action in uboot_action.internal_pipeline.actions: if isinstance(action, BootloaderInterruptAction): self.assertIn('power-on', action.job.device['commands']) self.assertIn('hard_reset', action.job.device['commands']) self.assertIn('connect', action.job.device['commands']) self.assertEqual( action.job.device['commands']['connect'].split(' ')[0], 'telnet') self.assertTrue(action.interrupt_newline) if isinstance(action, UBootAction): self.assertIn('method', action.parameters) self.assertIn('commands', action.parameters) self.assertIn('ramdisk', action.parameters['u-boot']) self.assertIn(action.parameters['commands'], action.parameters[action.parameters['method']]) self.assertIn( 'commands', action.parameters[action.parameters['method']][ action.parameters['commands']]) self.assertIsNotNone(action.parameters['u-boot']['ramdisk']) self.assertIsInstance( action.parameters['u-boot']['ramdisk']['commands'], list) self.assertTrue( len(action.parameters['u-boot']['ramdisk']['commands']) > 2 )
def test_empty_device_environment(self): factory = Factory() data = None job_parser = JobParser() (rendered, _) = factory.create_device('bbb-01.jinja2') device = NewDevice(yaml.safe_load(rendered)) sample_job_file = os.path.join(os.path.dirname(__file__), 'sample_jobs/uboot-ramdisk.yaml') with open(sample_job_file) as sample_job_data: job = job_parser.parse( sample_job_data, device, 4212, None, "", env_dut=data) self.assertEqual( job.parameters['env_dut'], None )
def test_iot_lxc(self): self.factory = Factory() job = self.factory.create_job('frdm-k64f-01.jinja2', 'sample_jobs/frdm-k64f-lxc.yaml') job.validate() self.assertIsNotNone([ action for action in job.pipeline.actions if action.name == 'lxc-deploy' ]) self.assertIsNotNone([ action for action in job.pipeline.actions if action.name == 'lxc-boot' ]) description_ref = self.pipeline_reference('frdm-k64f-lxc.yaml', job=job) self.assertEqual(description_ref, job.pipeline.describe(False))
def test_new_device(self): factory = Factory() (rendered, _) = factory.create_device('kvm01.jinja2') kvm01 = yaml.load(rendered) try: self.assertIsNotNone(kvm01['actions']) except Exception: self.fail("missing actions block for device") try: self.assertIsNotNone(kvm01['actions']['boot']) except Exception: self.fail("missing boot block for device") try: self.assertIsNotNone(kvm01['actions']['deploy']) except Exception: self.fail("missing boot block for device") self.assertTrue('qemu' in kvm01['actions']['boot']['methods']) self.assertTrue('image' in kvm01['actions']['deploy']['methods'])
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 test_adb_nuc_job(self): self.factory = LxcFactory() job = self.factory.create_adb_nuc_job('sample_jobs/adb-nuc.yaml') description_ref = self.pipeline_reference('adb-nuc.yaml', job=job) self.assertEqual(description_ref, job.pipeline.describe(False))
def setUp(self): super().setUp() self.factory = LxcFactory() self.job = self.factory.create_bbb_lxc_job('sample_jobs/bbb-lxc.yaml')
def setUp(self): super(TestKVMDownloadLocalDeploy, 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(TestKvmGuest, self).setUp() factory = Factory() self.job = factory.create_kvm_job('sample_jobs/kvm-local.yaml')
def setUp(self): super().setUp() self.factory = Factory() self.job = self.factory.create_job("juno-r2-01.jinja2", "sample_jobs/juno-uefi-nfs.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(TestMonitor, self).setUp() factory = Factory() self.job = factory.create_kvm_job('sample_jobs/qemu-monitor.yaml')
def test_autologin_normal_kvm(self): factory = Factory() job = factory.create_kvm_job('sample_jobs/kvm.yaml') job.validate() self.assertTrue(find_autologin(job))
class TestBootloaderAction(StdoutTestCase): # pylint: disable=too-many-public-methods def setUp(self): super().setUp() self.factory = Factory() def test_simulated_action(self): job = self.factory.create_job('x86-01.jinja2', 'sample_jobs/ipxe-ramdisk.yaml') self.assertIsNotNone(job) description_ref = self.pipeline_reference('ipxe.yaml', job=job) self.assertEqual(description_ref, job.pipeline.describe(False)) self.assertIsNone(job.validate()) def test_tftp_pipeline(self): job = self.factory.create_job('x86-01.jinja2', 'sample_jobs/ipxe-ramdisk.yaml') self.assertEqual([action.name for action in job.pipeline.actions], [ 'tftp-deploy', 'bootloader-action', 'lava-test-retry', 'finalize' ]) tftp = [ action for action in job.pipeline.actions if action.name == 'tftp-deploy' ][0] self.assertTrue( tftp.get_namespace_data(action=tftp.name, label='tftp', key='ramdisk')) self.assertIsNotNone(tftp.internal_pipeline) self.assertEqual( [action.name for action in tftp.internal_pipeline.actions], [ 'download-retry', 'download-retry', 'download-retry', 'prepare-tftp-overlay', 'lxc-create-udev-rule-action', 'deploy-device-env' ]) self.assertIn('ramdisk', [ action.key for action in tftp.internal_pipeline.actions if hasattr(action, 'key') ]) self.assertIn('kernel', [ action.key for action in tftp.internal_pipeline.actions if hasattr(action, 'key') ]) def test_device_x86(self): job = self.factory.create_job('x86-02.jinja2', 'sample_jobs/ipxe-ramdisk.yaml') self.assertEqual( job.device['commands']['connections']['uart0']['connect'], 'telnet bumblebee 8003') self.assertEqual(job.device['commands'].get('interrupt', ' '), ' ') methods = job.device['actions']['boot']['methods'] self.assertIn('ipxe', methods) self.assertEqual( methods['ipxe']['parameters'].get('bootloader_prompt'), 'iPXE>') def test_bootloader_action(self): job = self.factory.create_job('x86-01.jinja2', 'sample_jobs/ipxe-ramdisk.yaml') job.validate() self.assertEqual(job.pipeline.errors, []) self.assertIn('ipxe', job.device['actions']['boot']['methods']) params = job.device['actions']['boot']['methods']['ipxe']['parameters'] boot_message = params.get( 'boot_message', job.device.get_constant('kernel-start-message')) self.assertIsNotNone(boot_message) bootloader_action = [ action for action in job.pipeline.actions if action.name == 'bootloader-action' ][0] bootloader_retry = [ action for action in bootloader_action.internal_pipeline.actions if action.name == 'bootloader-retry' ][0] commands = [ action for action in bootloader_retry.internal_pipeline.actions if action.name == 'bootloader-commands' ][0] self.assertEqual(commands.character_delay, 500) for action in job.pipeline.actions: action.validate() if isinstance(action, BootloaderAction): self.assertIn('method', action.parameters) self.assertEqual('ipxe', action.parameters['method']) self.assertEqual( 'reboot: Restarting system', action.parameters.get('parameters', {}).get( 'shutdown-message', job.device.get_constant('shutdown-message'))) if isinstance(action, TftpAction): self.assertIn('ramdisk', action.parameters) self.assertIn('kernel', action.parameters) self.assertIn('to', action.parameters) self.assertEqual('tftp', action.parameters['to']) self.assertTrue(action.valid) def test_overlay_action(self): # pylint: disable=too-many-locals parameters = { 'device_type': 'x86', 'job_name': 'ipxe-pipeline', 'job_timeout': '15m', 'action_timeout': '5m', 'priority': 'medium', 'actions': { 'boot': { 'method': 'ipxe', 'commands': 'ramdisk', 'prompts': ['linaro-test', 'root@debian:~#'] }, 'deploy': { 'ramdisk': 'initrd.gz', 'kernel': 'zImage', } } } (rendered, _) = self.factory.create_device('x86-01.jinja2') device = NewDevice(yaml.safe_load(rendered)) job = Job(4212, parameters, None) job.device = device pipeline = Pipeline(job=job, parameters=parameters['actions']['boot']) job.pipeline = pipeline overlay = BootloaderCommandOverlay() pipeline.add_action(overlay) ip_addr = dispatcher_ip(None) kernel = parameters['actions']['deploy']['kernel'] ramdisk = parameters['actions']['deploy']['ramdisk'] substitution_dictionary = { '{SERVER_IP}': ip_addr, '{RAMDISK}': ramdisk, '{KERNEL}': kernel, '{LAVA_MAC}': "00:00:00:00:00:00" } params = device['actions']['boot']['methods'] params['ipxe']['ramdisk']['commands'] = substitute( params['ipxe']['ramdisk']['commands'], substitution_dictionary) commands = params['ipxe']['ramdisk']['commands'] self.assertIs(type(commands), list) self.assertIn("dhcp net0", commands) self.assertIn( "set console console=ttyS0,115200n8 lava_mac=00:00:00:00:00:00", commands) self.assertIn("set extraargs ip=dhcp", commands) self.assertNotIn( "kernel tftp://{SERVER_IP}/{KERNEL} ${extraargs} ${console}", commands) self.assertNotIn("initrd tftp://{SERVER_IP}/{RAMDISK}", commands) self.assertIn("boot", commands) def test_download_action(self): job = self.factory.create_job('x86-01.jinja2', 'sample_jobs/ipxe.yaml') for action in job.pipeline.actions: action.validate() self.assertTrue(action.valid) job.validate() self.assertEqual(job.pipeline.errors, []) deploy = None overlay = None extract = None for action in job.pipeline.actions: if action.name == 'tftp-deploy': deploy = action if deploy: for action in deploy.internal_pipeline.actions: if action.name == 'prepare-tftp-overlay': overlay = action if overlay: for action in overlay.internal_pipeline.actions: if action.name == 'extract-nfsrootfs': extract = action test_dir = overlay.get_namespace_data(action='test', label='results', key='lava_test_results_dir') self.assertIsNotNone(test_dir) self.assertIn('/lava-', test_dir) self.assertIsNotNone(extract) self.assertEqual(extract.timeout.duration, 120) def test_reset_actions(self): job = self.factory.create_job('x86-01.jinja2', 'sample_jobs/ipxe.yaml') bootloader_action = None bootloader_retry = None reset_action = None for action in job.pipeline.actions: action.validate() self.assertTrue(action.valid) if action.name == 'bootloader-action': bootloader_action = action names = [ r_action.name for r_action in bootloader_action.internal_pipeline.actions ] self.assertIn('connect-device', names) self.assertIn('bootloader-retry', names) for action in bootloader_action.internal_pipeline.actions: if action.name == 'bootloader-retry': bootloader_retry = action names = [ r_action.name for r_action in bootloader_retry.internal_pipeline.actions ] self.assertIn('reset-device', names) self.assertIn('bootloader-interrupt', names) self.assertIn('expect-shell-connection', names) self.assertIn('bootloader-commands', names) for action in bootloader_retry.internal_pipeline.actions: if action.name == 'reset-device': reset_action = action names = [ r_action.name for r_action in reset_action.internal_pipeline.actions ] self.assertIn('pdu-reboot', names) @unittest.skipIf(infrastructure_error('telnet'), "telnet not installed") def test_prompt_from_job(self): # pylint: disable=too-many-locals """ Support setting the prompt after login via the job Loads a known YAML, adds a prompt to the dict and re-parses the job. Checks that the prompt is available in the expect_shell_connection action. """ job = self.factory.create_job('x86-01.jinja2', 'sample_jobs/ipxe-ramdisk.yaml') job.validate() bootloader = [ action for action in job.pipeline.actions if action.name == 'bootloader-action' ][0] retry = [ action for action in bootloader.internal_pipeline.actions if action.name == 'bootloader-retry' ][0] expect = [ action for action in retry.internal_pipeline.actions if action.name == 'expect-shell-connection' ][0] check = expect.parameters (rendered, _) = self.factory.create_device('x86-01.jinja2') device = NewDevice(yaml.safe_load(rendered)) extra_yaml = os.path.join(os.path.dirname(__file__), 'sample_jobs/ipxe.yaml') with open(extra_yaml) as data: sample_job_string = data.read() parser = JobParser() sample_job_data = yaml.safe_load(sample_job_string) boot = [ item['boot'] for item in sample_job_data['actions'] if 'boot' in item ][0] self.assertIsNotNone(boot) sample_job_string = yaml.dump(sample_job_data) job = parser.parse(sample_job_string, device, 4212, None, "") job.logger = DummyLogger() job.validate() bootloader = [ action for action in job.pipeline.actions if action.name == 'bootloader-action' ][0] retry = [ action for action in bootloader.internal_pipeline.actions if action.name == 'bootloader-retry' ][0] expect = [ action for action in retry.internal_pipeline.actions if action.name == 'expect-shell-connection' ][0] def test_xz_nfs(self): job = self.factory.create_job('x86-01.jinja2', 'sample_jobs/ipxe-nfs.yaml') # this job won't validate as the .xz nfsrootfs URL is a fiction self.assertRaises(JobError, job.validate) tftp_deploy = [ action for action in job.pipeline.actions if action.name == 'tftp-deploy' ][0] prepare = [ action for action in tftp_deploy.internal_pipeline.actions if action.name == 'prepare-tftp-overlay' ][0] nfs = [ action for action in prepare.internal_pipeline.actions if action.name == 'extract-nfsrootfs' ][0] self.assertIn('compression', nfs.parameters['nfsrootfs']) self.assertEqual(nfs.parameters['nfsrootfs']['compression'], 'xz') def test_ipxe_with_monitor(self): job = self.factory.create_job('x86-01.jinja2', 'sample_jobs/ipxe-monitor.yaml') job.validate() description_ref = self.pipeline_reference('ipxe-monitor.yaml', job=job) self.assertEqual(description_ref, job.pipeline.describe(False))
def setUp(self): super(TestKVMQcow2Deploy, self).setUp() factory = Factory() self.job = factory.create_kvm_job('sample_jobs/kvm-qcow2.yaml')
class TestUefiShell(StdoutTestCase): def setUp(self): super().setUp() self.factory = Factory() self.job = self.factory.create_job("juno-r2-01.jinja2", "sample_jobs/juno-uefi-nfs.yaml") def test_shell_reference(self): self.job.validate() self.assertEqual([], self.job.pipeline.errors) description_ref = self.pipeline_reference('juno-uefi-nfs.yaml') self.assertEqual(description_ref, self.job.pipeline.describe(False)) def test_device_juno_uefi(self): job = self.job self.assertIsNotNone(job) self.assertIsNone(job.validate()) def test_shell_prompts(self): self.job.validate() params = self.job.device['actions']['boot']['methods']['uefi']['parameters'] self.assertIn('shell_interrupt_prompt', params) self.assertIn('shell_menu', params) self.assertIn('bootloader_prompt', params) # Nfs Deploy checks deploy = [action for action in self.job.pipeline.actions if action.name == 'nfs-deploy'][0] overlay = [action for action in deploy.internal_pipeline.actions if action.name == 'lava-overlay'][0] self.assertIsNotNone(overlay) # Boot checks boot = [action for action in self.job.pipeline.actions if action.name == 'uefi-shell-main-action'][0] commands = [action for action in boot.internal_pipeline.actions if action.name == 'bootloader-overlay'][0] menu_connect = [action for action in boot.internal_pipeline.actions if action.name == 'menu-connect'][0] menu_interrupt = [action for action in boot.internal_pipeline.actions if action.name == 'uefi-shell-menu-interrupt'][0] menu_selector = [action for action in boot.internal_pipeline.actions if action.name == 'uefi-shell-menu-selector'][0] shell_interrupt = [action for action in boot.internal_pipeline.actions if action.name == 'uefi-shell-menu-interrupt'][0] boot_commands = [action for action in boot.internal_pipeline.actions if action.name == 'bootloader-commands'][0] self.assertEqual('uefi', commands.method) self.assertFalse(commands.use_bootscript) self.assertIsNone(commands.lava_mac) self.assertIsNotNone(menu_connect) self.assertIn('bootloader_prompt', menu_interrupt.params) self.assertIn('interrupt_prompt', menu_interrupt.params) self.assertIn('boot_message', menu_interrupt.params) # First, menu drops to shell... self.assertEqual('UEFI Interactive Shell', menu_selector.boot_message) # ...then, shell commands boot to linux. self.assertEqual('Linux version', boot_commands.params['boot_message']) self.assertIsNotNone(shell_interrupt) def test_no_menu_reference(self): job = self.factory.create_job("juno-r2-01.jinja2", "sample_jobs/juno-uefi-nfs-no-menu.yaml") self.assertEqual([], job.pipeline.errors) description_ref = self.pipeline_reference('juno-uefi-nfs-no-menu.yaml', job=job) self.assertEqual(description_ref, job.pipeline.describe(False)) def test_no_menu(self): """ Tests that if shell_menu=='' that the menu is skipped """ job = self.factory.create_job("juno-r2-01.jinja2", "sample_jobs/juno-uefi-nfs-no-menu.yaml") job.validate() params = job.device['actions']['boot']['methods']['uefi']['parameters'] self.assertIn('shell_interrupt_prompt', params) self.assertIn('shell_menu', params) self.assertIn('bootloader_prompt', params) # Nfs Deploy checks deploy = [action for action in job.pipeline.actions if action.name == 'nfs-deploy'][0] overlay = [action for action in deploy.internal_pipeline.actions if action.name == 'lava-overlay'][0] self.assertIsNotNone(overlay) # Boot checks boot = [action for action in job.pipeline.actions if action.name == 'uefi-shell-main-action'][0] commands = [action for action in boot.internal_pipeline.actions if action.name == 'bootloader-overlay'][0] boot_commands = [action for action in boot.internal_pipeline.actions if action.name == 'bootloader-commands'][0] self.assertIsNotNone([action for action in boot.internal_pipeline.actions if action.name == 'uefi-shell-interrupt']) self.assertEqual(0, len([action for action in boot.internal_pipeline.actions if action.name == 'uefi-shell-menu-interrupt'])) self.assertEqual(0, len([action for action in boot.internal_pipeline.actions if action.name == 'uefi-shell-menu-selector'])) self.assertEqual('uefi', commands.method) self.assertFalse(commands.use_bootscript) self.assertIsNone(commands.lava_mac) # Shell commands boot to linux. self.assertEqual('Linux version', boot_commands.params['boot_message'])
def setUp(self): super(TestCommand, self).setUp() factory = Factory() self.job = factory.create_kvm_job('sample_jobs/kvm-command.yaml')
def setUp(self): super(TestKvmUefi, self).setUp() factory = Factory() self.job = factory.create_kvm_job('sample_jobs/kvm-uefi.yaml')
class TestPowerAction(StdoutTestCase): # pylint: disable=too-many-public-methods def setUp(self): super().setUp() self.factory = Factory() def test_reset_nopower(self): job = self.factory.create_job('cubie1.jinja2', 'sample_jobs/uboot-ramdisk.yaml') uboot_action = None names = [r_action.name for r_action in job.pipeline.actions] self.assertIn('uboot-action', names) uboot_action = [ action for action in job.pipeline.actions if action.name == 'uboot-action' ][0] names = [ r_action.name for r_action in uboot_action.internal_pipeline.actions ] self.assertIn('uboot-retry', names) uboot_retry = [ action for action in uboot_action.pipeline.actions if action.name == 'uboot-retry' ][0] names = [ r_action.name for r_action in uboot_retry.internal_pipeline.actions ] self.assertIn('reset-device', names) reset_device = [ action for action in uboot_retry.pipeline.actions if action.name == 'reset-device' ][0] names = [ r_action.name for r_action in reset_device.internal_pipeline.actions ] self.assertEqual(['send-reboot-commands'], names) def test_reset_power(self): job = self.factory.create_job('bbb-01.jinja2', 'sample_jobs/uboot-ramdisk.yaml') uboot_action = None names = [r_action.name for r_action in job.pipeline.actions] self.assertIn('uboot-action', names) uboot_action = [ action for action in job.pipeline.actions if action.name == 'uboot-action' ][0] names = [ r_action.name for r_action in uboot_action.internal_pipeline.actions ] self.assertIn('uboot-retry', names) uboot_retry = [ action for action in uboot_action.pipeline.actions if action.name == 'uboot-retry' ][0] names = [ r_action.name for r_action in uboot_retry.internal_pipeline.actions ] self.assertIn('reset-device', names) reset_device = [ action for action in uboot_retry.pipeline.actions if action.name == 'reset-device' ][0] names = [ r_action.name for r_action in reset_device.internal_pipeline.actions ] self.assertEqual(['pdu-reboot'], names)
def setUp(self): super().setUp() factory = Factory() self.job = factory.create_kvm_job('sample_jobs/compression.yaml') self.job.validate()
class TestRemovable(StdoutTestCase): # pylint: disable=too-many-public-methods def setUp(self): super().setUp() self.factory = Factory() def test_device_parameters(self): """ Test that the correct parameters have been set for the device """ (rendered, _) = self.factory.create_device('cubie2.jinja2') cubie = NewDevice(yaml.safe_load(rendered)) self.assertIsNotNone(cubie['parameters']['media'].get('usb')) self.assertIsNotNone(cubie.get('commands')) self.assertIsNotNone(cubie.get('actions')) self.assertIsNotNone(cubie['actions'].get('deploy')) self.assertIsNotNone(cubie['actions']['deploy'].get('methods')) self.assertIn('usb', cubie['actions']['deploy']['methods']) self.assertIsNotNone(cubie['actions'].get('boot')) self.assertIsNotNone(cubie['actions']['boot'].get('methods')) self.assertIn('u-boot', cubie['actions']['boot']['methods']) u_boot_params = cubie['actions']['boot']['methods']['u-boot'] self.assertIn('usb', u_boot_params) self.assertIn('commands', u_boot_params['usb']) self.assertIn('parameters', u_boot_params) self.assertIn('bootloader_prompt', u_boot_params['parameters']) def _check_valid_job(self, device, test_file): self.maxDiff = None # pylint: disable=invalid-name job_parser = JobParser() sample_job_file = os.path.join(os.path.dirname(__file__), 'sample_jobs/{}'.format(test_file)) with open(sample_job_file) as sample_job_data: job = job_parser.parse(sample_job_data, device, 4212, None, "") job.logger = DummyLogger() try: job.validate() except JobError: self.fail(job.pipeline.errors) description_ref = self.pipeline_reference(test_file, job=job) self.assertEqual(description_ref, job.pipeline.describe(False)) return job def _check_job_parameters(self, device, job, agent_key): mass_storage = None # deploy for action in job.pipeline.actions: if isinstance(action, DeployAction): if isinstance(action, MassStorage): self.assertTrue(action.valid) agent = action.parameters[agent_key]['tool'] self.assertTrue(agent.startswith('/')) # needs to be a full path but on the device, so avoid os.path self.assertIn(action.parameters['device'], job.device['parameters']['media']['usb']) mass_storage = action self.assertIsNotNone(mass_storage) self.assertIn('device', mass_storage.parameters) self.assertIn(mass_storage.parameters['device'], device['parameters']['media']['usb']) self.assertIsNotNone(mass_storage.get_namespace_data(action='storage-deploy', label='u-boot', key='device')) u_boot_params = device['actions']['boot']['methods']['u-boot'] self.assertEqual(mass_storage.get_namespace_data(action='uboot-retry', label='bootloader_prompt', key='prompt'), u_boot_params['parameters']['bootloader_prompt']) def test_job_parameters(self): """ Test that the job parameters match expected structure """ (rendered, _) = self.factory.create_device('cubie1.jinja2') cubie = NewDevice(yaml.safe_load(rendered)) job = self._check_valid_job(cubie, 'cubietruck-removable.yaml') self._check_job_parameters(cubie, job, 'download') def test_writer_job_parameters(self): """ Test that the job parameters with a writer tool match expected structure """ (rendered, _) = self.factory.create_device('cubie1.jinja2') cubie = NewDevice(yaml.safe_load(rendered)) job = self._check_valid_job(cubie, 'cubietruck-removable-with-writer.yaml') self._check_job_parameters(cubie, job, 'writer') def _check_deployment(self, device, test_file): job_parser = JobParser() job = self._check_valid_job(device, test_file) self.assertIn('usb', device['parameters']['media'].keys()) deploy_params = [methods for methods in job.parameters['actions'] if 'deploy' in methods.keys()][1]['deploy'] self.assertIn('device', deploy_params) self.assertIn(deploy_params['device'], device['parameters']['media']['usb']) self.assertIn('uuid', device['parameters']['media']['usb'][deploy_params['device']]) self.assertIn('device_id', device['parameters']['media']['usb'][deploy_params['device']]) self.assertNotIn('boot_part', device['parameters']['media']['usb'][deploy_params['device']]) deploy_action = [action for action in job.pipeline.actions if action.name == 'storage-deploy'][0] tftp_deploy_action = [action for action in job.pipeline.actions if action.name == 'tftp-deploy'][0] self.assertIsNotNone(deploy_action) test_dir = deploy_action.get_namespace_data(action='test', label='results', key='lava_test_results_dir', parameters=tftp_deploy_action.parameters) self.assertIsNotNone(test_dir) self.assertIn('/lava-', test_dir) self.assertIsInstance(deploy_action, MassStorage) img_params = deploy_action.parameters.get('images', deploy_action.parameters) self.assertIn('image', img_params) dd_action = [action for action in deploy_action.internal_pipeline.actions if action.name == 'dd-image'][0] self.assertEqual( dd_action.boot_params[dd_action.parameters['device']]['uuid'], 'usb-SanDisk_Ultra_20060775320F43006019-0:0') self.assertIsNotNone(dd_action.get_namespace_data(action=dd_action.name, label='u-boot', key='boot_part')) self.assertIsNotNone(dd_action.get_namespace_data(action='uboot-from-media', label='uuid', key='boot_part')) self.assertEqual('0', '%s' % dd_action.get_namespace_data(action=dd_action.name, label='u-boot', key='boot_part')) self.assertIsInstance(dd_action.get_namespace_data(action='uboot-from-media', label='uuid', key='boot_part'), str) self.assertEqual('0:1', dd_action.get_namespace_data(action='uboot-from-media', label='uuid', key='boot_part')) self.assertIsNotNone(dd_action.get_namespace_data( action='uboot-prepare-kernel', label='bootcommand', key='bootcommand')) def test_deployment(self): (rendered, _) = self.factory.create_device('cubie1.jinja2') cubie = NewDevice(yaml.safe_load(rendered)) self._check_deployment(cubie, 'cubietruck-removable.yaml') def test_writer_deployment(self): (rendered, _) = self.factory.create_device('cubie1.jinja2') cubie = NewDevice(yaml.safe_load(rendered)) self._check_deployment(cubie, 'cubietruck-removable-with-writer.yaml') def test_juno_deployment(self): factory = RemovableFactory() job = factory.create_job('sample_jobs/juno-uboot-removable.yaml', '../devices/juno-uboot.yaml') job.logger = DummyLogger() job.validate() self.assertEqual(job.pipeline.errors, []) self.assertIn('usb', job.device['parameters']['media'].keys()) deploy_params = [methods for methods in job.parameters['actions'] if 'deploy' in methods.keys()][1]['deploy'] self.assertIn('device', deploy_params) self.assertIn(deploy_params['device'], job.device['parameters']['media']['usb']) self.assertIn('uuid', job.device['parameters']['media']['usb'][deploy_params['device']]) self.assertIn('device_id', job.device['parameters']['media']['usb'][deploy_params['device']]) self.assertNotIn('boot_part', job.device['parameters']['media']['usb'][deploy_params['device']]) tftp_deploys = [action for action in job.pipeline.actions if action.name == 'tftp-deploy'] self.assertEqual(len(tftp_deploys), 2) first_deploy = tftp_deploys[0] second_deploy = tftp_deploys[1] self.assertIsNotNone(first_deploy) self.assertIsNotNone(second_deploy) self.assertEqual('openembedded', first_deploy.parameters['namespace']) self.assertEqual('android', second_deploy.parameters['namespace']) self.assertNotIn('deployment_data', first_deploy.parameters) self.assertNotIn('deployment_data', second_deploy.parameters) storage_deploy_action = [action for action in job.pipeline.actions if action.name == 'storage-deploy'][0] download_action = [ action for action in storage_deploy_action.internal_pipeline.actions if action.name == 'download-retry'][0] self.assertIsNotNone(download_action) self.assertEqual('android', storage_deploy_action.parameters['namespace']) def test_mustang_deployment(self): factory = RemovableFactory() job = factory.create_job('sample_jobs/mustang-secondary-media.yaml', '../devices/mustang-media.yaml') job.validate() description_ref = self.pipeline_reference('mustang-media.yaml', job=job) self.assertEqual(description_ref, job.pipeline.describe(False)) self.assertIn('sata', job.device['parameters']['media'].keys()) deploy_params = [methods for methods in job.parameters['actions'] if 'deploy' in methods.keys()][1]['deploy'] self.assertIn('device', deploy_params) self.assertIn(deploy_params['device'], job.device['parameters']['media']['sata']) self.assertIn('uuid', job.device['parameters']['media']['sata'][deploy_params['device']]) self.assertIn('device_id', job.device['parameters']['media']['sata'][deploy_params['device']]) self.assertEqual('hd0', job.device['parameters']['media']['sata'][deploy_params['device']]['grub_interface']) grub_deploys = [action for action in job.pipeline.actions if action.name == 'grub-main-action'] self.assertEqual(len(grub_deploys), 2) first_deploy = grub_deploys[0] second_deploy = grub_deploys[1] self.assertEqual('nfsdeploy', first_deploy.parameters['namespace']) self.assertEqual('satadeploy', second_deploy.parameters['namespace']) def test_secondary_media(self): factory = RemovableFactory() job = factory.create_job('sample_jobs/mustang-secondary-media.yaml', '../devices/mustang-media.yaml') job.validate() grub_nfs = [action for action in job.pipeline.actions if action.name == 'grub-main-action' and action.parameters['namespace'] == 'nfsdeploy'][0] media_action = [action for action in grub_nfs.internal_pipeline.actions if action.name == 'bootloader-from-media'][0] self.assertEqual(None, media_action.get_namespace_data(action='download-action', label='file', key='kernel')) self.assertEqual(None, media_action.get_namespace_data(action='compress-ramdisk', label='file', key='ramdisk')) self.assertEqual(None, media_action.get_namespace_data(action='download-action', label='file', key='dtb')) self.assertEqual(None, media_action.get_namespace_data(action=media_action.name, label='file', key='root')) grub_main = [action for action in job.pipeline.actions if action.name == 'grub-main-action' and action.parameters['namespace'] == 'satadeploy'][0] media_action = [action for action in grub_main.internal_pipeline.actions if action.name == 'bootloader-from-media'][0] self.assertIsInstance(media_action, BootloaderSecondaryMedia) self.assertIsNotNone(media_action.get_namespace_data(action='download-action', label='file', key='kernel')) self.assertIsNotNone(media_action.get_namespace_data(action='compress-ramdisk', label='file', key='ramdisk')) self.assertIsNotNone(media_action.get_namespace_data(action='download-action', label='file', key='ramdisk')) self.assertEqual('', media_action.get_namespace_data(action='download-action', label='file', key='dtb')) self.assertIsNotNone(media_action.get_namespace_data(action=media_action.name, label='uuid', key='root')) self.assertIsNotNone(media_action.get_namespace_data(action=media_action.name, label='uuid', key='boot_part')) @unittest.skipIf(infrastructure_error('mkimage'), "u-boot-tools not installed") def test_primary_media(self): """ Test that definitions of secondary media do not block submissions using primary media """ job_parser = JobParser() (rendered, _) = self.factory.create_device('bbb-01.jinja2') bbb = NewDevice(yaml.safe_load(rendered)) sample_job_file = os.path.join(os.path.dirname(__file__), 'sample_jobs/uboot-ramdisk.yaml') with open(sample_job_file) as sample_job_data: job = job_parser.parse(sample_job_data, bbb, 4212, None, "") job.logger = DummyLogger() job.validate() self.assertEqual(job.pipeline.errors, []) self.assertIn('usb', bbb['parameters']['media'].keys()) def test_substitutions(self): """ Test substitution of secondary media values into u-boot commands Unlike most u-boot calls, removable knows in advance all the values it needs to substitute into the boot commands for the secondary deployment as these are fixed by the device config and the image details from the job submission. """ job_parser = JobParser() (rendered, _) = self.factory.create_device('cubie1.jinja2') cubie = NewDevice(yaml.safe_load(rendered)) sample_job_file = os.path.join(os.path.dirname(__file__), 'sample_jobs/cubietruck-removable.yaml') with open(sample_job_file) as sample_job_data: job = job_parser.parse(sample_job_data, cubie, 4212, None, "") job.logger = DummyLogger() job.validate() boot_params = [ methods for methods in job.parameters['actions'] if 'boot' in methods.keys()][1]['boot'] self.assertIn('ramdisk', boot_params) self.assertIn('kernel', boot_params) self.assertIn('dtb', boot_params) self.assertIn('root_uuid', boot_params) self.assertIn('boot_part', boot_params) self.assertNotIn('type', boot_params) self.assertGreater(len(job.pipeline.actions), 1) self.assertIsNotNone(job.pipeline.actions[1].internal_pipeline) u_boot_action = [action for action in job.pipeline.actions if action.name == 'uboot-action'][1] overlay = [action for action in u_boot_action.internal_pipeline.actions if action.name == 'bootloader-overlay'][0] self.assertIsNotNone(overlay.get_namespace_data(action='storage-deploy', label='u-boot', key='device')) methods = cubie['actions']['boot']['methods'] self.assertIn('u-boot', methods) self.assertIn('usb', methods['u-boot']) self.assertIn('commands', methods['u-boot']['usb']) commands_list = methods['u-boot']['usb']['commands'] device_id = u_boot_action.get_namespace_data(action='storage-deploy', label='u-boot', key='device') self.assertIsNotNone(device_id) kernel_type = u_boot_action.parameters['kernel_type'] bootcommand = map_kernel_uboot(kernel_type, device_params=cubie.get('parameters')) substitutions = { '{BOOTX}': "%s %s %s %s" % ( bootcommand, cubie['parameters'][bootcommand]['kernel'], cubie['parameters'][bootcommand]['ramdisk'], cubie['parameters'][bootcommand]['dtb'],), '{RAMDISK}': boot_params['ramdisk'], '{KERNEL}': boot_params['kernel'], '{DTB}': boot_params['dtb'], '{ROOT}': boot_params['root_uuid'], '{ROOT_PART}': "%s:%s" % ( cubie['parameters']['media']['usb'][device_id]['device_id'], u_boot_action.parameters['boot_part'] ) } self.assertEqual('bootz 0x42000000 0x43300000 0x43000000', substitutions['{BOOTX}']) self.assertEqual('/boot/initrd.img-3.16.0-4-armmp-lpae.u-boot', substitutions['{RAMDISK}']) commands = substitute(commands_list, substitutions) print(commands) self.assertEqual( commands, [ 'usb start', 'setenv autoload no', 'load usb 0:0:1 {KERNEL_ADDR} /boot/vmlinuz-3.16.0-4-armmp-lpae', 'load usb 0:0:1 {RAMDISK_ADDR} /boot/initrd.img-3.16.0-4-armmp-lpae.u-boot', 'setenv initrd_size ${filesize}', 'load usb 0:0:1 {DTB_ADDR} /boot/dtb-3.16.0-4-armmp-lpae', 'console=ttyS0,115200n8 root=UUID=159d17cc-697c-4125-95a0-a3775e1deabe ip=dhcp', 'bootz 0x42000000 0x43300000 0x43000000' ] )
def setUp(self): super(TestDefinitionHandlers, self).setUp() factory = Factory() self.job = factory.create_kvm_job('sample_jobs/kvm.yaml')
class TestLxcWithDevices(StdoutTestCase): def setUp(self): super().setUp() self.factory = LxcFactory() self.job = self.factory.create_bbb_lxc_job('sample_jobs/bbb-lxc.yaml') def test_lxc_feedback(self): # pylint: disable=too-many-locals self.assertIsNotNone(self.job) # validate with two test actions, lxc and device self.job.validate() drone_test = [ action for action in self.job.pipeline.actions if action.name == 'lava-test-retry' ][0] self.assertNotEqual(10, drone_test.connection_timeout.duration) drone_shell = [ action for action in drone_test.internal_pipeline.actions if action.name == 'lava-test-shell' ][0] self.assertEqual(10, drone_shell.connection_timeout.duration) def test_lxc_with_device(self): # pylint: disable=too-many-locals self.assertIsNotNone(self.job) # validate with two test actions, lxc and device self.job.validate() lxc_yaml = os.path.join(os.path.dirname(__file__), 'sample_jobs/bbb-lxc.yaml') with open(lxc_yaml) as sample_job_data: data = yaml.safe_load(sample_job_data) lxc_deploy = [ action for action in self.job.pipeline.actions if action.name == 'lxc-deploy' ][0] overlay = [ action for action in lxc_deploy.internal_pipeline.actions if action.name == 'lava-overlay' ][0] test_def = [ action for action in overlay.internal_pipeline.actions if action.name == 'test-definition' ][0] self.assertIsNotNone(test_def.level, test_def.test_list) runner = [ action for action in test_def.internal_pipeline.actions if action.name == 'test-runscript-overlay' ][0] self.assertIsNotNone(runner.testdef_levels) tftp_deploy = [ action for action in self.job.pipeline.actions if action.name == 'tftp-deploy' ][0] prepare = [ action for action in tftp_deploy.internal_pipeline.actions if action.name == 'prepare-tftp-overlay' ][0] overlay = [ action for action in prepare.internal_pipeline.actions if action.name == 'lava-overlay' ][0] test_def = [ action for action in overlay.internal_pipeline.actions if action.name == 'test-definition' ][0] namespace = test_def.parameters.get('namespace') self.assertIsNotNone(namespace) test_actions = [ action for action in self.job.parameters['actions'] if 'test' in action ] for action in test_actions: if 'namespace' in action['test']: if action['test']['namespace'] == namespace: self.assertEqual(action['test']['definitions'][0]['name'], 'smoke-tests-bbb') namespace_tests = [ action['test']['definitions'] for action in test_actions if 'namespace' in action['test'] and action['test']['namespace'] == namespace ] self.assertEqual(len(namespace_tests), 1) self.assertEqual(len(test_actions), 2) self.assertEqual('smoke-tests-bbb', namespace_tests[0][0]['name']) self.assertEqual('smoke-tests-bbb', test_def.test_list[0][0]['name']) self.assertIsNotNone(test_def.level, test_def.test_list) runner = [ action for action in test_def.internal_pipeline.actions if action.name == 'test-runscript-overlay' ][0] self.assertIsNotNone(runner.testdef_levels) # remove the second test action data['actions'].pop() test_actions = [ action for action in data['actions'] if 'test' in action ] self.assertEqual(len(test_actions), 1) self.assertEqual(test_actions[0]['test']['namespace'], 'probe') parser = JobParser() (rendered, _) = self.factory.create_device('bbb-01.jinja2') device = NewDevice(yaml.safe_load(rendered)) job = parser.parse(yaml.dump(data), device, 4577, None, "") job.logger = DummyLogger() job.validate() lxc_deploy = [ action for action in self.job.pipeline.actions if action.name == 'lxc-deploy' ][0] overlay = [ action for action in lxc_deploy.internal_pipeline.actions if action.name == 'lava-overlay' ][0] test_def = [ action for action in overlay.internal_pipeline.actions if action.name == 'test-definition' ][0] self.assertIsNotNone(test_def.level, test_def.test_list) runner = [ action for action in test_def.internal_pipeline.actions if action.name == 'test-runscript-overlay' ][0] self.assertIsNotNone(runner.testdef_levels) def test_lxc_with_static_device(self): # pylint: disable=too-many-locals self.job = self.factory.create_hikey_aep_job( 'sample_jobs/hi6220-hikey.yaml') self.job.validate() lxc_boot = [ action for action in self.job.pipeline.actions if action.name == 'lxc-boot' ][0] lxc_static = [ action for action in lxc_boot.internal_pipeline.actions if action.name == 'lxc-add-static' ][0] self.assertIsNotNone(lxc_static) self.assertIsInstance(self.job.device.get('static_info'), list) self.assertEqual(len(self.job.device.get('static_info')), 1) for board in self.job.device.get('static_info'): self.assertIsInstance(board, dict) self.assertIn('board_id', board) self.assertEqual(board['board_id'], 'S/NO62200001') description_ref = self.pipeline_reference('hi6220-hikey.yaml', job=self.job) self.assertEqual(description_ref, self.job.pipeline.describe(False)) def test_lxc_without_lxctest(self): # pylint: disable=too-many-locals lxc_yaml = os.path.join(os.path.dirname(__file__), 'sample_jobs/bbb-lxc-notest.yaml') with open(lxc_yaml) as sample_job_data: data = yaml.safe_load(sample_job_data) parser = JobParser() (rendered, _) = self.factory.create_device('bbb-01.jinja2') device = NewDevice(yaml.safe_load(rendered)) job = parser.parse(yaml.dump(data), device, 4577, None, "") job.logger = DummyLogger() job.validate() lxc_deploy = [ action for action in job.pipeline.actions if action.name == 'lxc-deploy' ][0] names = [ action.name for action in lxc_deploy.internal_pipeline.actions ] self.assertNotIn('prepare-tftp-overlay', names) namespace1 = lxc_deploy.parameters.get('namespace') tftp_deploy = [ action for action in job.pipeline.actions if action.name == 'tftp-deploy' ][0] prepare = [ action for action in tftp_deploy.internal_pipeline.actions if action.name == 'prepare-tftp-overlay' ][0] overlay = [ action for action in prepare.internal_pipeline.actions if action.name == 'lava-overlay' ][0] test_def = [ action for action in overlay.internal_pipeline.actions if action.name == 'test-definition' ][0] namespace = test_def.parameters.get('namespace') self.assertIsNotNone(namespace) self.assertIsNotNone(namespace1) self.assertNotEqual(namespace, namespace1) self.assertNotEqual(self.job.pipeline.describe(False), job.pipeline.describe(False)) test_actions = [ action for action in job.parameters['actions'] if 'test' in action ] for action in test_actions: if 'namespace' in action['test']: if action['test']['namespace'] == namespace: self.assertEqual(action['test']['definitions'][0]['name'], 'smoke-tests-bbb') else: self.fail("Found a test action not from the tftp boot") namespace_tests = [ action['test']['definitions'] for action in test_actions if 'namespace' in action['test'] and action['test']['namespace'] == namespace ] self.assertEqual(len(namespace_tests), 1) self.assertEqual(len(test_actions), 1) description_ref = self.pipeline_reference('bbb-lxc-notest.yaml', job=job) self.assertEqual(description_ref, job.pipeline.describe(False)) def test_adb_nuc_job(self): self.factory = LxcFactory() job = self.factory.create_adb_nuc_job('sample_jobs/adb-nuc.yaml') description_ref = self.pipeline_reference('adb-nuc.yaml', job=job) self.assertEqual(description_ref, job.pipeline.describe(False)) def test_iot_lxc(self): self.factory = Factory() job = self.factory.create_job('frdm-k64f-01.jinja2', 'sample_jobs/frdm-k64f-lxc.yaml') job.validate() self.assertIsNotNone([ action for action in job.pipeline.actions if action.name == 'lxc-deploy' ]) self.assertIsNotNone([ action for action in job.pipeline.actions if action.name == 'lxc-boot' ]) description_ref = self.pipeline_reference('frdm-k64f-lxc.yaml', job=job) self.assertEqual(description_ref, job.pipeline.describe(False))
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(TestKVMInlineTestDeploy, self).setUp() factory = Factory() self.job = factory.create_kvm_job('sample_jobs/kvm-inline.yaml')
def setUp(self): super().setUp() self.factory = Factory()
def setUp(self): super(TestRepeatBootTest, self).setUp() factory = Factory() self.job = factory.create_kvm_job('sample_jobs/kvm-repeat.yaml')