How to use fetch_asset method in avocado

Best Python code snippet using avocado_python

boot_linux_console.py

Source:boot_linux_console.py Github

copy

Full Screen

...66 """67 kernel_url = ('https://download.fedoraproject.org/pub/fedora/linux/'68 'releases/29/Everything/x86_64/os/images/pxeboot/vmlinuz')69 kernel_hash = '23bebd2680757891cf7adedb033532163a792495'70 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)71 self.vm.set_machine('pc')72 self.vm.set_console()73 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'74 self.vm.add_args('-kernel', kernel_path,75 '-append', kernel_command_line)76 self.vm.launch()77 console_pattern = 'Kernel command line: %s' % kernel_command_line78 self.wait_for_console_pattern(console_pattern)79 def test_mips_malta(self):80 """81 :avocado: tags=arch:mips82 :avocado: tags=machine:malta83 :avocado: tags=endian:big84 """85 deb_url = ('http://snapshot.debian.org/archive/debian/'86 '20130217T032700Z/pool/main/l/linux-2.6/'87 'linux-image-2.6.32-5-4kc-malta_2.6.32-48_mips.deb')88 deb_hash = 'a8cfc28ad8f45f54811fc6cf74fc43ffcfe0ba04'89 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)90 kernel_path = self.extract_from_deb(deb_path,91 '/boot/vmlinux-2.6.32-5-4kc-malta')92 self.vm.set_machine('malta')93 self.vm.set_console()94 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'95 self.vm.add_args('-kernel', kernel_path,96 '-append', kernel_command_line)97 self.vm.launch()98 console_pattern = 'Kernel command line: %s' % kernel_command_line99 self.wait_for_console_pattern(console_pattern)100 def test_mips64el_malta(self):101 """102 This test requires the ar tool to extract "data.tar.gz" from103 the Debian package.104 The kernel can be rebuilt using this Debian kernel source [1] and105 following the instructions on [2].106 [1] http://snapshot.debian.org/package/linux-2.6/2.6.32-48/107 #linux-source-2.6.32_2.6.32-48108 [2] https://kernel-team.pages.debian.net/kernel-handbook/109 ch-common-tasks.html#s-common-official110 :avocado: tags=arch:mips64el111 :avocado: tags=machine:malta112 """113 deb_url = ('http://snapshot.debian.org/archive/debian/'114 '20130217T032700Z/pool/main/l/linux-2.6/'115 'linux-image-2.6.32-5-5kc-malta_2.6.32-48_mipsel.deb')116 deb_hash = '1aaec92083bf22fda31e0d27fa8d9a388e5fc3d5'117 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)118 kernel_path = self.extract_from_deb(deb_path,119 '/boot/vmlinux-2.6.32-5-5kc-malta')120 self.vm.set_machine('malta')121 self.vm.set_console()122 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'123 self.vm.add_args('-kernel', kernel_path,124 '-append', kernel_command_line)125 self.vm.launch()126 console_pattern = 'Kernel command line: %s' % kernel_command_line127 self.wait_for_console_pattern(console_pattern)128 def test_mips_malta_cpio(self):129 """130 :avocado: tags=arch:mips131 :avocado: tags=machine:malta132 :avocado: tags=endian:big133 """134 deb_url = ('http://snapshot.debian.org/archive/debian/'135 '20160601T041800Z/pool/main/l/linux/'136 'linux-image-4.5.0-2-4kc-malta_4.5.5-1_mips.deb')137 deb_hash = 'a3c84f3e88b54e06107d65a410d1d1e8e0f340f8'138 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)139 kernel_path = self.extract_from_deb(deb_path,140 '/boot/vmlinux-4.5.0-2-4kc-malta')141 initrd_url = ('https://github.com/groeck/linux-build-test/raw/'142 '8584a59ed9e5eb5ee7ca91f6d74bbb06619205b8/rootfs/'143 'mips/rootfs.cpio.gz')144 initrd_hash = 'bf806e17009360a866bf537f6de66590de349a99'145 initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)146 initrd_path = self.workdir + "rootfs.cpio"147 with gzip.open(initrd_path_gz, 'rb') as f_in:148 with open(initrd_path, 'wb') as f_out:149 shutil.copyfileobj(f_in, f_out)150 self.vm.set_machine('malta')151 self.vm.set_console()152 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE153 + 'console=ttyS0 console=tty '154 + 'rdinit=/sbin/init noreboot')155 self.vm.add_args('-kernel', kernel_path,156 '-initrd', initrd_path,157 '-append', kernel_command_line,158 '-no-reboot')159 self.vm.launch()160 self.wait_for_console_pattern('Boot successful.')161 self.exec_command_and_wait_for_pattern('cat /proc/cpuinfo',162 'BogoMIPS')163 self.exec_command_and_wait_for_pattern('uname -a',164 'Debian')165 self.exec_command_and_wait_for_pattern('reboot',166 'reboot: Restarting system')167 def do_test_mips_malta32el_nanomips(self, kernel_url, kernel_hash):168 kernel_path_xz = self.fetch_asset(kernel_url, asset_hash=kernel_hash)169 kernel_path = self.workdir + "kernel"170 with lzma.open(kernel_path_xz, 'rb') as f_in:171 with open(kernel_path, 'wb') as f_out:172 shutil.copyfileobj(f_in, f_out)173 self.vm.set_machine('malta')174 self.vm.set_console()175 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE176 + 'mem=256m@@0x0 '177 + 'console=ttyS0')178 self.vm.add_args('-no-reboot',179 '-cpu', 'I7200',180 '-kernel', kernel_path,181 '-append', kernel_command_line)182 self.vm.launch()183 console_pattern = 'Kernel command line: %s' % kernel_command_line184 self.wait_for_console_pattern(console_pattern)185 def test_mips_malta32el_nanomips_4k(self):186 """187 :avocado: tags=arch:mipsel188 :avocado: tags=machine:malta189 :avocado: tags=endian:little190 """191 kernel_url = ('https://mipsdistros.mips.com/LinuxDistro/nanomips/'192 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'193 'generic_nano32r6el_page4k.xz')194 kernel_hash = '477456aafd2a0f1ddc9482727f20fe9575565dd6'195 self.do_test_mips_malta32el_nanomips(kernel_url, kernel_hash)196 def test_mips_malta32el_nanomips_16k_up(self):197 """198 :avocado: tags=arch:mipsel199 :avocado: tags=machine:malta200 :avocado: tags=endian:little201 """202 kernel_url = ('https://mipsdistros.mips.com/LinuxDistro/nanomips/'203 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'204 'generic_nano32r6el_page16k_up.xz')205 kernel_hash = 'e882868f944c71c816e832e2303b7874d044a7bc'206 self.do_test_mips_malta32el_nanomips(kernel_url, kernel_hash)207 def test_mips_malta32el_nanomips_64k_dbg(self):208 """209 :avocado: tags=arch:mipsel210 :avocado: tags=machine:malta211 :avocado: tags=endian:little212 """213 kernel_url = ('https://mipsdistros.mips.com/LinuxDistro/nanomips/'214 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'215 'generic_nano32r6el_page64k_dbg.xz')216 kernel_hash = '18d1c68f2e23429e266ca39ba5349ccd0aeb7180'217 self.do_test_mips_malta32el_nanomips(kernel_url, kernel_hash)218 def test_aarch64_virt(self):219 """220 :avocado: tags=arch:aarch64221 :avocado: tags=machine:virt222 """223 kernel_url = ('https://download.fedoraproject.org/pub/fedora/linux/'224 'releases/29/Everything/aarch64/os/images/pxeboot/vmlinuz')225 kernel_hash = '8c73e469fc6ea06a58dc83a628fc695b693b8493'226 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)227 self.vm.set_machine('virt')228 self.vm.set_console()229 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +230 'console=ttyAMA0')231 self.vm.add_args('-cpu', 'cortex-a53',232 '-kernel', kernel_path,233 '-append', kernel_command_line)234 self.vm.launch()235 console_pattern = 'Kernel command line: %s' % kernel_command_line236 self.wait_for_console_pattern(console_pattern)237 def test_arm_virt(self):238 """239 :avocado: tags=arch:arm240 :avocado: tags=machine:virt241 """242 kernel_url = ('https://download.fedoraproject.org/pub/fedora/linux/'243 'releases/29/Everything/armhfp/os/images/pxeboot/vmlinuz')244 kernel_hash = 'e9826d741b4fb04cadba8d4824d1ed3b7fb8b4d4'245 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)246 self.vm.set_machine('virt')247 self.vm.set_console()248 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +249 'console=ttyAMA0')250 self.vm.add_args('-kernel', kernel_path,251 '-append', kernel_command_line)252 self.vm.launch()253 console_pattern = 'Kernel command line: %s' % kernel_command_line254 self.wait_for_console_pattern(console_pattern)255 def test_arm_emcraft_sf2(self):256 """257 :avocado: tags=arch:arm258 :avocado: tags=machine:emcraft_sf2259 :avocado: tags=endian:little260 """261 uboot_url = ('https://raw.githubusercontent.com/'262 'Subbaraya-Sundeep/qemu-test-binaries/'263 'fa030bd77a014a0b8e360d3b7011df89283a2f0b/u-boot')264 uboot_hash = 'abba5d9c24cdd2d49cdc2a8aa92976cf20737eff'265 uboot_path = self.fetch_asset(uboot_url, asset_hash=uboot_hash)266 spi_url = ('https://raw.githubusercontent.com/'267 'Subbaraya-Sundeep/qemu-test-binaries/'268 'fa030bd77a014a0b8e360d3b7011df89283a2f0b/spi.bin')269 spi_hash = '85f698329d38de63aea6e884a86fbde70890a78a'270 spi_path = self.fetch_asset(spi_url, asset_hash=spi_hash)271 self.vm.set_machine('emcraft-sf2')272 self.vm.set_console()273 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE274 self.vm.add_args('-kernel', uboot_path,275 '-append', kernel_command_line,276 '-drive', 'file=' + spi_path + ',if=mtd,format=raw',277 '-no-reboot')278 self.vm.launch()279 self.wait_for_console_pattern('init started: BusyBox')280 def test_s390x_s390_ccw_virtio(self):281 """282 :avocado: tags=arch:s390x283 :avocado: tags=machine:s390_ccw_virtio284 """285 kernel_url = ('https://download.fedoraproject.org/pub/fedora-secondary/'286 'releases/29/Everything/s390x/os/images/kernel.img')287 kernel_hash = 'e8e8439103ef8053418ef062644ffd46a7919313'288 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)289 self.vm.set_machine('s390-ccw-virtio')290 self.vm.set_console()291 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=sclp0'292 self.vm.add_args('-nodefaults',293 '-kernel', kernel_path,294 '-append', kernel_command_line)295 self.vm.launch()296 console_pattern = 'Kernel command line: %s' % kernel_command_line297 self.wait_for_console_pattern(console_pattern)298 def test_alpha_clipper(self):299 """300 :avocado: tags=arch:alpha301 :avocado: tags=machine:clipper302 """303 kernel_url = ('http://archive.debian.org/debian/dists/lenny/main/'304 'installer-alpha/current/images/cdrom/vmlinuz')305 kernel_hash = '3a943149335529e2ed3e74d0d787b85fb5671ba3'306 kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)307 uncompressed_kernel = archive.uncompress(kernel_path, self.workdir)308 self.vm.set_machine('clipper')309 self.vm.set_console()310 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'311 self.vm.add_args('-vga', 'std',312 '-kernel', uncompressed_kernel,313 '-append', kernel_command_line)314 self.vm.launch()315 console_pattern = 'Kernel command line: %s' % kernel_command_line...

Full Screen

Full Screen

test_workbenches.py

Source:test_workbenches.py Github

copy

Full Screen

1import os2import pytest3from tenable_io.api.models import AssetActivity, AssetActivityList, AssetsAsset,AssetsAssetList, AssetList, AssetInfo, \4 Vulnerability, VulnerabilityList, VulnerabilityOutputList5from tenable_io.api.workbenches import WorkbenchesApi6from tests.integration.api.utils.utils import wait_until7@pytest.mark.vcr()8def test_workbenches_assets(client):9 assets_list = client.workbenches_api.assets()10 assert isinstance(assets_list, AssetsAssetList), u'The `assets` method did not return type `AssetsAssetList`.'11 for asset in assets_list.assets:12 assert isinstance(asset, AssetsAsset), u'Expected a list of type `AssetsAsset`.'13@pytest.mark.vcr()14def test_workbenches_assets_vulnerabilities(client):15 assets_list = client.workbenches_api.assets_vulnerabilities()16 assert isinstance(assets_list, AssetList), u'The `assets_vulnerabilities` method did not return type `AssetList`.'17@pytest.mark.vcr()18def test_workbenches_asset_activity(client, fetch_asset):19 asset_activity = client.workbenches_api.asset_activity(fetch_asset.id)20 assert isinstance(asset_activity, AssetActivityList), \21 u'The `asset_activity` method did not return type `AssetActivityList`.'22 for activity in asset_activity.activity:23 assert isinstance(activity, AssetActivity), u'Expected a list of type `AssetActivity`.'24@pytest.mark.vcr()25def test_workbenches_asset_info(client, fetch_asset):26 asset_info = client.workbenches_api.asset_info(fetch_asset.id)27 assert isinstance(asset_info, AssetInfo), u'The `asset_info` method did not return type `AssetInfo`.'28@pytest.mark.vcr()29def test_workbenches_asset_vulnerabilities(client, fetch_asset):30 asset_vulns = client.workbenches_api.asset_vulnerabilities(fetch_asset.id)31 assert isinstance(asset_vulns, VulnerabilityList), \32 u'The `asset_vulnerabilities` method did not return type `VulnerabilityList`.'33@pytest.mark.vcr()34def test_workbenches_asset_vulnerabilities(client, fetch_asset):35 asset_vulns = client.workbenches_api.asset_vulnerabilities(fetch_asset.id)36 assert isinstance(asset_vulns, VulnerabilityList), \37 u'The `asset_vulnerabilities` method did not return type `VulnerabilityList`.'38@pytest.mark.vcr()39def test_workbenches_vulnerabilities(client):40 vulnerabilities_list = client.workbenches_api.vulnerabilities()41 assert isinstance(vulnerabilities_list, VulnerabilityList), \42 u'The `vulnerabilities` method did not return type `VulnerabilityList`.'43 for vulnerability in vulnerabilities_list.vulnerabilities:44 assert isinstance(vulnerability, Vulnerability), u'Expected a list of type `Vulnerability`.'45@pytest.mark.vcr()46def test_workbenches_vulnerability_output(client, fetch_vulnerability):47 vulnerability_output = client.workbenches_api.vulnerability_output(fetch_vulnerability.plugin_id)48 assert isinstance(vulnerability_output, VulnerabilityOutputList), \49 u'The `vulnerability_output` method did not return type `VulnerabilityOutputList`.'50@pytest.mark.vcr()51def test_workbenches_export(client):52 file_id = client.workbenches_api.export_request(53 WorkbenchesApi.FORMAT_NESSUS,54 WorkbenchesApi.REPORT_VULNERABILITIES,55 WorkbenchesApi.CHAPTER_VULN_BY_ASSET,56 )57 assert file_id, u'The `export_request` method did not return a valid file ID.'58 export_status = wait_until(lambda: client.workbenches_api.export_status(file_id),59 lambda status: status == WorkbenchesApi.STATUS_EXPORT_READY)60 assert export_status == WorkbenchesApi.STATUS_EXPORT_READY, u'Workbench export is not ready.'61 iter_content = client.workbenches_api.export_download(file_id, False)62 download_path = 'test_workbench_export'63 assert not os.path.isfile(download_path), u'Workbench report does not exist.'64 with open(download_path, 'wb') as fd:65 for chunk in iter_content:66 fd.write(chunk)67 assert os.path.isfile(download_path), u'Workbench report was not downloaded.'68 assert os.path.getsize(download_path) > 0, u'Workbench report is empty.'...

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

...20 }21 22 store = LocalStore(self.tempdir.name)23 experiment = run(store, 'tracked-testing-fake-1', fake, 100, num_trees=4)24 model = experiment.fetch_asset('model')25 config = experiment.fetch_asset('config')26 self.assertEqual(model, 'test')27 self.assertEqual(config['iterations'], 100)28 self.assertEqual(config['num_trees'], 4)29 self.assertEqual(experiment.evaluation['accuracy'], 0.99)30 def test_run_with_no_args_and_no_kwargs(self):31 def fake():32 return {33 'model': 'test'34 }, {35 'accuracy': 0.9936 }37 38 store = LocalStore(self.tempdir.name)39 experiment = run(store, 'tracked-testing-fake-1', fake)40 model = experiment.fetch_asset('model')41 self.assertEqual(model, 'test')42 self.assertEqual(experiment.evaluation['accuracy'], 0.99)43 def test_run_with_args_only(self):44 def fake(num_trees):45 return {46 'model': 'test',47 'config': {48 'num_trees': num_trees49 }50 }, {51 'accuracy': 0.9952 }53 54 store = LocalStore(self.tempdir.name)55 experiment = run(store, 'tracked-testing-fake-1', fake, 4)56 model = experiment.fetch_asset('model')57 config = experiment.fetch_asset('config')58 self.assertEqual(model, 'test')59 self.assertEqual(config['num_trees'], 4)60 self.assertEqual(experiment.evaluation['accuracy'], 0.99)61 def test_run_with_kwargs_only(self):62 def fake(num_trees=3):63 return {64 'model': 'test',65 'config': {66 'num_trees': num_trees67 }68 }, {69 'accuracy': 0.9970 }71 72 store = LocalStore(self.tempdir.name)73 experiment = run(store, 'tracked-testing-fake-1', fake, num_trees=4)74 model = experiment.fetch_asset('model')75 config = experiment.fetch_asset('config')76 self.assertEqual(model, 'test')77 self.assertEqual(config['num_trees'], 4)...

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 avocado 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