How to use sahara method in tempest

Best Python code snippet using tempest_python

test_utils.py

Source:test_utils.py Github

copy

Full Screen

1# Copyright 2014: Mirantis Inc.2# All Rights Reserved.3#4# Licensed under the Apache License, Version 2.0 (the "License"); you may5# not use this file except in compliance with the License. You may obtain6# a copy of the License at7#8# http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing, software11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the13# License for the specific language governing permissions and limitations14# under the License.15import mock16from oslo_config import cfg17from oslo_utils import uuidutils18from saharaclient.api import base as sahara_base19from rally import consts20from rally import exceptions21from rally.plugins.openstack.scenarios.sahara import utils22from tests.unit import test23CONF = cfg.CONF24SAHARA_UTILS = "rally.plugins.openstack.scenarios.sahara.utils"25class SaharaScenarioTestCase(test.ScenarioTestCase):26 # NOTE(stpierre): the Sahara utils generally do funny stuff with27 # wait_for() calls -- frequently the the is_ready and28 # update_resource arguments are functions defined in the Sahara29 # utils themselves instead of the more standard resource_is() and30 # get_from_manager() calls. As a result, the tests below do more31 # integrated/functional testing of wait_for() calls, and we can't32 # just mock out wait_for and friends the way we usually do.33 patch_benchmark_utils = False34 def setUp(self):35 super(SaharaScenarioTestCase, self).setUp()36 CONF.set_override("sahara_cluster_check_interval", 0, "benchmark",37 enforce_type=True)38 CONF.set_override("sahara_job_check_interval", 0, "benchmark",39 enforce_type=True)40 def test_list_node_group_templates(self):41 ngts = []42 self.clients("sahara").node_group_templates.list.return_value = ngts43 scenario = utils.SaharaScenario(self.context)44 return_ngts_list = scenario._list_node_group_templates()45 self.assertEqual(ngts, return_ngts_list)46 self._test_atomic_action_timer(scenario.atomic_actions(),47 "sahara.list_node_group_templates")48 @mock.patch(SAHARA_UTILS + ".SaharaScenario.generate_random_name",49 return_value="random_name")50 @mock.patch(SAHARA_UTILS + ".sahara_consts")51 def test_create_node_group_templates(52 self, mock_sahara_consts,53 mock_generate_random_name):54 scenario = utils.SaharaScenario(self.context)55 mock_processes = {56 "test_plugin": {57 "test_version": {58 "master": ["p1"],59 "worker": ["p2"]60 }61 }62 }63 mock_sahara_consts.NODE_PROCESSES = mock_processes64 scenario._create_master_node_group_template(65 flavor_id="test_flavor",66 plugin_name="test_plugin",67 hadoop_version="test_version"68 )69 scenario._create_worker_node_group_template(70 flavor_id="test_flavor",71 plugin_name="test_plugin",72 hadoop_version="test_version"73 )74 create_calls = [75 mock.call(76 name="random_name",77 plugin_name="test_plugin",78 hadoop_version="test_version",79 flavor_id="test_flavor",80 node_processes=["p1"]),81 mock.call(82 name="random_name",83 plugin_name="test_plugin",84 hadoop_version="test_version",85 flavor_id="test_flavor",86 node_processes=["p2"]87 )]88 self.clients("sahara").node_group_templates.create.assert_has_calls(89 create_calls)90 self._test_atomic_action_timer(91 scenario.atomic_actions(),92 "sahara.create_master_node_group_template")93 self._test_atomic_action_timer(94 scenario.atomic_actions(),95 "sahara.create_worker_node_group_template")96 def test_delete_node_group_templates(self):97 scenario = utils.SaharaScenario(self.context)98 ng = mock.MagicMock(id=42)99 scenario._delete_node_group_template(ng)100 delete_mock = self.clients("sahara").node_group_templates.delete101 delete_mock.assert_called_once_with(42)102 self._test_atomic_action_timer(scenario.atomic_actions(),103 "sahara.delete_node_group_template")104 @mock.patch(SAHARA_UTILS + ".SaharaScenario.generate_random_name",105 return_value="random_name")106 @mock.patch(SAHARA_UTILS + ".sahara_consts")107 def test_launch_cluster(self, mock_sahara_consts,108 mock_generate_random_name):109 self.context.update({110 "tenant": {111 "networks": [112 {113 "id": "test_neutron_id",114 "router_id": "test_router_id"115 }116 ]117 }118 })119 self.clients("services").values.return_value = [120 consts.Service.NEUTRON121 ]122 scenario = utils.SaharaScenario(context=self.context)123 mock_processes = {124 "test_plugin": {125 "test_version": {126 "master": ["p1"],127 "worker": ["p2"]128 }129 }130 }131 mock_configs = {132 "test_plugin": {133 "test_version": {134 "target": "HDFS",135 "config_name": "dfs.replication"136 }137 }138 }139 floating_ip_pool_uuid = uuidutils.generate_uuid()140 node_groups = [141 {142 "name": "master-ng",143 "flavor_id": "test_flavor",144 "node_processes": ["p1"],145 "floating_ip_pool": floating_ip_pool_uuid,146 "count": 1,147 "auto_security_group": True,148 "security_groups": ["g1", "g2"],149 "node_configs": {"HDFS": {"local_config": "local_value"}},150 }, {151 "name": "worker-ng",152 "flavor_id": "test_flavor",153 "node_processes": ["p2"],154 "floating_ip_pool": floating_ip_pool_uuid,155 "volumes_per_node": 5,156 "volumes_size": 10,157 "count": 42,158 "auto_security_group": True,159 "security_groups": ["g1", "g2"],160 "node_configs": {"HDFS": {"local_config": "local_value"}},161 }162 ]163 mock_sahara_consts.NODE_PROCESSES = mock_processes164 mock_sahara_consts.REPLICATION_CONFIGS = mock_configs165 self.clients("sahara").clusters.create.return_value.id = (166 "test_cluster_id")167 self.clients("sahara").clusters.get.return_value.status = (168 "active")169 scenario._launch_cluster(170 plugin_name="test_plugin",171 hadoop_version="test_version",172 flavor_id="test_flavor",173 image_id="test_image",174 floating_ip_pool=floating_ip_pool_uuid,175 volumes_per_node=5,176 volumes_size=10,177 auto_security_group=True,178 security_groups=["g1", "g2"],179 workers_count=42,180 node_configs={"HDFS": {"local_config": "local_value"}}181 )182 self.clients("sahara").clusters.create.assert_called_once_with(183 name="random_name",184 plugin_name="test_plugin",185 hadoop_version="test_version",186 node_groups=node_groups,187 default_image_id="test_image",188 cluster_configs={"HDFS": {"dfs.replication": 3}},189 net_id="test_neutron_id",190 anti_affinity=None191 )192 self._test_atomic_action_timer(scenario.atomic_actions(),193 "sahara.launch_cluster")194 @mock.patch(SAHARA_UTILS + ".SaharaScenario.generate_random_name",195 return_value="random_name")196 @mock.patch(SAHARA_UTILS + ".sahara_consts")197 def test_launch_cluster_with_proxy(self, mock_sahara_consts,198 mock_generate_random_name):199 context = {200 "tenant": {201 "networks": [202 {203 "id": "test_neutron_id",204 "router_id": "test_router_id"205 }206 ]207 }208 }209 self.clients("services").values.return_value = [210 consts.Service.NEUTRON211 ]212 scenario = utils.SaharaScenario(context=context)213 mock_processes = {214 "test_plugin": {215 "test_version": {216 "master": ["p1"],217 "worker": ["p2"]218 }219 }220 }221 mock_configs = {222 "test_plugin": {223 "test_version": {224 "target": "HDFS",225 "config_name": "dfs.replication"226 }227 }228 }229 floating_ip_pool_uuid = uuidutils.generate_uuid()230 node_groups = [231 {232 "name": "master-ng",233 "flavor_id": "test_flavor",234 "node_processes": ["p1"],235 "floating_ip_pool": floating_ip_pool_uuid,236 "count": 1,237 "auto_security_group": True,238 "security_groups": ["g1", "g2"],239 "node_configs": {"HDFS": {"local_config": "local_value"}},240 "is_proxy_gateway": True241 }, {242 "name": "worker-ng",243 "flavor_id": "test_flavor",244 "node_processes": ["p2"],245 "volumes_per_node": 5,246 "volumes_size": 10,247 "count": 40,248 "auto_security_group": True,249 "security_groups": ["g1", "g2"],250 "node_configs": {"HDFS": {"local_config": "local_value"}},251 }, {252 "name": "proxy-ng",253 "flavor_id": "test_flavor",254 "node_processes": ["p2"],255 "floating_ip_pool": floating_ip_pool_uuid,256 "volumes_per_node": 5,257 "volumes_size": 10,258 "count": 2,259 "auto_security_group": True,260 "security_groups": ["g1", "g2"],261 "node_configs": {"HDFS": {"local_config": "local_value"}},262 "is_proxy_gateway": True263 }264 ]265 mock_sahara_consts.NODE_PROCESSES = mock_processes266 mock_sahara_consts.REPLICATION_CONFIGS = mock_configs267 self.clients("sahara").clusters.create.return_value = mock.MagicMock(268 id="test_cluster_id")269 self.clients("sahara").clusters.get.return_value = mock.MagicMock(270 status="active")271 scenario._launch_cluster(272 plugin_name="test_plugin",273 hadoop_version="test_version",274 flavor_id="test_flavor",275 image_id="test_image",276 floating_ip_pool=floating_ip_pool_uuid,277 volumes_per_node=5,278 volumes_size=10,279 auto_security_group=True,280 security_groups=["g1", "g2"],281 workers_count=42,282 node_configs={"HDFS": {"local_config": "local_value"}},283 enable_proxy=True284 )285 self.clients("sahara").clusters.create.assert_called_once_with(286 name="random_name",287 plugin_name="test_plugin",288 hadoop_version="test_version",289 node_groups=node_groups,290 default_image_id="test_image",291 cluster_configs={"HDFS": {"dfs.replication": 3}},292 net_id="test_neutron_id",293 anti_affinity=None294 )295 self._test_atomic_action_timer(scenario.atomic_actions(),296 "sahara.launch_cluster")297 @mock.patch(SAHARA_UTILS + ".SaharaScenario.generate_random_name",298 return_value="random_name")299 @mock.patch(SAHARA_UTILS + ".sahara_consts")300 def test_launch_cluster_error(self, mock_sahara_consts,301 mock_generate_random_name):302 scenario = utils.SaharaScenario(self.context)303 mock_processes = {304 "test_plugin": {305 "test_version": {306 "master": ["p1"],307 "worker": ["p2"]308 }309 }310 }311 mock_configs = {312 "test_plugin": {313 "test_version": {314 "target": "HDFS",315 "config_name": "dfs.replication"316 }317 }318 }319 mock_sahara_consts.NODE_PROCESSES = mock_processes320 mock_sahara_consts.REPLICATION_CONFIGS = mock_configs321 self.clients("sahara").clusters.create.return_value = mock.MagicMock(322 id="test_cluster_id")323 self.clients("sahara").clusters.get.return_value = mock.MagicMock(324 status="error")325 self.assertRaises(exceptions.GetResourceErrorStatus,326 scenario._launch_cluster,327 plugin_name="test_plugin",328 hadoop_version="test_version",329 flavor_id="test_flavor",330 image_id="test_image",331 floating_ip_pool="test_pool",332 volumes_per_node=5,333 volumes_size=10,334 workers_count=42,335 node_configs={"HDFS": {"local_config":336 "local_value"}})337 def test_scale_cluster(self):338 scenario = utils.SaharaScenario(self.context)339 cluster = mock.MagicMock(id=42, node_groups=[{340 "name": "random_master",341 "count": 1342 }, {343 "name": "random_worker",344 "count": 41345 }])346 self.clients("sahara").clusters.get.return_value = mock.MagicMock(347 id=42,348 status="active")349 expected_scale_object = {350 "resize_node_groups": [{351 "name": "random_worker",352 "count": 42353 }]354 }355 scenario._scale_cluster(cluster, 1)356 self.clients("sahara").clusters.scale.assert_called_once_with(357 42, expected_scale_object)358 def test_delete_cluster(self):359 scenario = utils.SaharaScenario(self.context)360 cluster = mock.MagicMock(id=42)361 self.clients("sahara").clusters.get.side_effect = [362 cluster, sahara_base.APIException()363 ]364 scenario._delete_cluster(cluster)365 delete_mock = self.clients("sahara").clusters.delete366 delete_mock.assert_called_once_with(42)367 cl_get_expected = mock.call(42)368 self.clients("sahara").clusters.get.assert_has_calls([cl_get_expected,369 cl_get_expected])370 self._test_atomic_action_timer(scenario.atomic_actions(),371 "sahara.delete_cluster")372 @mock.patch(SAHARA_UTILS + ".SaharaScenario.generate_random_name",373 return_value="42")374 def test_create_output_ds(self, mock_generate_random_name):375 self.context.update({376 "sahara": {377 "output_conf": {378 "output_type": "hdfs",379 "output_url_prefix": "hdfs://test_out/"380 }381 }382 })383 scenario = utils.SaharaScenario(self.context)384 scenario._create_output_ds()385 self.clients("sahara").data_sources.create.assert_called_once_with(386 name="42",387 description="",388 data_source_type="hdfs",389 url="hdfs://test_out/42"390 )391 @mock.patch(SAHARA_UTILS + ".SaharaScenario.generate_random_name",392 return_value="42")393 def test_create_output_ds_swift(self, mock_generate_random_name):394 self.context.update({395 "sahara": {396 "output_conf": {397 "output_type": "swift",398 "output_url_prefix": "swift://test_out/"399 }400 }401 })402 scenario = utils.SaharaScenario(self.context)403 self.assertRaises(exceptions.RallyException,404 scenario._create_output_ds)405 def test_run_job_execution(self):406 self.clients("sahara").job_executions.get.side_effect = [407 mock.MagicMock(info={"status": "pending"}, id="42"),408 mock.MagicMock(info={"status": "SUCCESS"}, id="42")]409 self.clients("sahara").job_executions.create.return_value = (410 mock.MagicMock(id="42"))411 scenario = utils.SaharaScenario(self.context)412 scenario._run_job_execution(job_id="test_job_id",413 cluster_id="test_cluster_id",414 input_id="test_input_id",415 output_id="test_output_id",416 configs={"k": "v"},417 job_idx=0)418 self.clients("sahara").job_executions.create.assert_called_once_with(419 job_id="test_job_id",420 cluster_id="test_cluster_id",421 input_id="test_input_id",422 output_id="test_output_id",423 configs={"k": "v"}424 )425 je_get_expected = mock.call("42")426 self.clients("sahara").job_executions.get.assert_has_calls(427 [je_get_expected, je_get_expected]428 )429 def test_run_job_execution_fail(self):430 self.clients("sahara").job_executions.get.side_effect = [431 mock.MagicMock(info={"status": "pending"}, id="42"),432 mock.MagicMock(info={"status": "killed"}, id="42")]433 self.clients("sahara").job_executions.create.return_value = (434 mock.MagicMock(id="42"))435 scenario = utils.SaharaScenario(self.context)436 self.assertRaises(exceptions.RallyException,437 scenario._run_job_execution,438 job_id="test_job_id",439 cluster_id="test_cluster_id",440 input_id="test_input_id",441 output_id="test_output_id",442 configs={"k": "v"},443 job_idx=0)444 self.clients("sahara").job_executions.create.assert_called_once_with(445 job_id="test_job_id",446 cluster_id="test_cluster_id",447 input_id="test_input_id",448 output_id="test_output_id",449 configs={"k": "v"}...

Full Screen

Full Screen

iso_settings.py

Source:iso_settings.py Github

copy

Full Screen

1# Copyright 2015 Mirantis, Inc.2#3# Licensed under the Apache License, Version 2.0 (the "License"); you may4# not use this file except in compliance with the License. You may obtain5# a copy of the License at6#7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the12# License for the specific language governing permissions and limitations13# under the License.14# Services tests15SERVTEST_LOCAL_PATH = '~/images'16SERVTEST_USERNAME = 'admin'17SERVTEST_PASSWORD = SERVTEST_USERNAME18SERVTEST_TENANT = SERVTEST_USERNAME19# TODO(esikachev): Need add ambari image, when sahara-image-elements20# be able to build them21images = [22 {23 "url": "http://sahara-files.mirantis.com/mos70",24 "image": "sahara-kilo-vanilla-2.6.0-ubuntu-14.04.qcow2",25 "mos_versions": ['7.0'],26 "name": "vanilla2-70",27 "md5sum": "c794e8066b8893eaa15ebf44ee55e9ee",28 "meta": {'_sahara_tag_2.6.0': 'True', '_sahara_tag_vanilla': 'True',29 '_sahara_username': 'ubuntu'}30 },31 {32 "url": "http://sahara-files.mirantis.com/mos80",33 "image": "sahara-liberty-vanilla-2.7.1-ubuntu-14.04.qcow2",34 "mos_versions": ['8.0'],35 "name": "sahara",36 "md5sum": "3da49911332fc46db0c5fb7c197e3a77",37 "meta": {'_sahara_tag_2.7.1': 'True', '_sahara_tag_vanilla': 'True',38 '_sahara_username': 'ubuntu'}39 },40 {41 "url": "http://sahara-files.mirantis.com/images/upstream/liberty",42 "image": "sahara-liberty-ambari-2.2-centos-6.6.qcow2.qcow2",43 "mos_versions": ['8.0'],44 "name": "ambari22",45 "md5sum": "445086de3e9a9562201ff30276af5496",46 "meta": {'_sahara_tag_2.2': 'True', '_sahara_tag_ambari': 'True',47 '_sahara_tag_2.3': 'True', '_sahara_username': 'cloud_user'}48 },49 {50 "url": "http://sahara-files.mirantis.com/images/upstream/liberty",51 "image": "sahara-liberty-cdh-5.4.0-ubuntu-14.04.qcow2",52 "mos_versions": ['8.0'],53 "name": "cdh54",54 "md5sum": "f5c833d2d34a41ea9b52a6c1f95054be",55 "meta": {'_sahara_tag_5.4.0': 'True', '_sahara_tag_cdh': 'True',56 '_sahara_username': 'ubuntu'}57 },58 {59 "url": "http://sahara-files.mirantis.com/images/upstream/liberty",60 "image": "sahara-liberty-mapr-5.0.0-ubuntu-14.04.qcow2",61 "mos_versions": ['8.0'],62 "name": "mapr5",63 "md5sum": "77d16c462311a7c5db9144e1e8ab30a8",64 "meta": {'_sahara_tag_5.0.0.mrv2': 'True', '_sahara_tag_mapr': 'True',65 '_sahara_username': 'ubuntu'}66 },67 {68 "url": "http://sahara-files.mirantis.com/mos70",69 "image": "sahara-kilo-cdh-5.4.0-ubuntu-12.04.qcow2",70 "mos_versions": ['7.0'],71 "name": "cdh540",72 "md5sum": "3c40ca050305eac7d5fdfb33f4af8d66",73 "meta": {'_sahara_tag_5.4.0': 'True', '_sahara_tag_cdh': 'True',74 '_sahara_username': 'ubuntu'}75 },76 {77 "url": "http://sahara-files.mirantis.com/mos70",78 "image": "sahara-kilo-mapr-4.0.2-ubuntu-14.04.qcow2",79 "mos_versions": ['7.0'],80 "name": "mapr402",81 "md5sum": "1191778635972e9559474a3a5b9a8b54",82 "meta": {'_sahara_tag_4.0.2.mrv2': 'True', '_sahara_tag_mapr': 'True',83 '_sahara_username': 'ubuntu'}84 },85 {86 "url": "http://sahara-files.mirantis.com/mos70",87 "image": "sahara-kilo-spark-1.3.1-ubuntu-14.04.qcow2",88 "mos_versions": ['7.0', '8.0'],89 "name": "spark131",90 "md5sum": "4004994e10920f23b2b2a4a3f47281d3",91 "meta": {'_sahara_tag_1.3.1': 'True', '_sahara_tag_spark': 'True',92 '_sahara_username': 'ubuntu'}93 },94 {95 "url": "http://sahara-files.mirantis.com/mos61",96 "image": "sahara-juno-vanilla-2.4.1-ubuntu-14.04.qcow2",97 "mos_versions": ['6.0', '6.1'],98 "name": "vanilla2-60",99 "md5sum": "04603154484f58827e02244cb8efdd17",100 "meta": {'_sahara_tag_2.4.1': 'True', '_sahara_tag_vanilla': 'True',101 '_sahara_username': 'ubuntu'}102 },103 {104 "url": "http://sahara-files.mirantis.com/mos61",105 "image": "sahara-juno-cdh-5-ubuntu-12.04.qcow2",106 "mos_versions": ['6.0', '6.1'],107 "name": "cdh5",108 "md5sum": "f2c989057d1dbf373069867fa6123b84",109 "meta": {'_sahara_tag_5': 'True', '_sahara_tag_cdh': 'True',110 '_sahara_username': 'ubuntu'}111 },112 {113 "url": "http://sahara-files.mirantis.com/mos61",114 "image": "sahara-juno-hdp-2.0.6-centos-6.6.qcow2",115 "mos_versions": ['6.0', '6.1'],116 "name": "hdp2",117 "md5sum": "e3435ad985d8bae17a3d670e2074fcd4",118 "meta": {'_sahara_tag_2.0.6': 'True', '_sahara_tag_hdp': 'True',119 '_sahara_username': 'cloud-user'}120 },121 {122 "url": "http://sahara-files.mirantis.com/mos61",123 "image": "sahara-juno-hdp-2.2.0-centos-6.6.qcow2",124 "mos_versions": ['6.1'],125 "name": "hdp22",126 "md5sum": "20763652e7ef6a741a5dc666a48a700f",127 "meta": {'_sahara_tag_2.2.0': 'True', '_sahara_tag_hdp': 'True',128 '_sahara_username': 'cloud-user'}129 },130 {131 "url": "http://sahara-files.mirantis.com/mos61",132 "image": "sahara-juno-spark-1.0.0-ubuntu-14.04.qcow2",133 "mos_versions": ['6.1'],134 "name": "spark1",135 "md5sum": "6a54136d5bf3750c66788fc4fe305c5d",136 "meta": {'_sahara_tag_1.0.0': 'True', '_sahara_tag_spark': 'True',137 '_sahara_username': 'ubuntu'}138 },139 {140 "url": "http://sahara-files.mirantis.com/mos61",141 "image": "sahara-juno-vanilla-1.2.1-ubuntu-14.04.qcow2",142 "mos_versions": ['6.0', '6.1'],143 "name": "vanilla1",144 "md5sum": "1e0e6e8b141f1bc1f8486ac9519bc162",145 "meta": {'_sahara_tag_1.2.1': 'True', '_sahara_tag_vanilla': 'True',146 '_sahara_username': 'ubuntu'}147 },148 {149 "url": "http://murano-files.mirantis.com",150 "mos_versions": ['6.0'],151 "image": "F17-x86_64-cfntools.qcow2",152 "name": "F17-x86_64-cfntools",153 "md5sum": "afab0f79bac770d61d24b4d0560b5f70",154 "meta": {}155 },156 {157 "url": "http://storage.apps.openstack.org/images",158 "image": "ubuntu-14.04-m-agent.qcow2",159 "mos_versions": ['6.1', '7.0', '8.0'],160 "name": "ubuntu-14.04-m-agent.qcow2",161 "md5sum": "cbd9ded8587b98d144d9cf0faea991a9",162 "meta": {"type": "linux",163 "title": "Ubuntu with pre installed murano-agent"}164 },165 {166 "url": "http://storage.apps.openstack.org/images",167 "image": "debian-8-m-agent.qcow2",168 "mos_versions": ['6.1', '7.0', '8.0'],169 "name": "debian-8-m-agent.qcow2",170 "md5sum": "6fa21e861d08a7cc2fbc40b0c99745a7",171 "meta": {"type": "linux",172 "title": "Debian with pre-installed murano-agent"}173 },174 {175 "url": "http://storage.apps.openstack.org/images",176 "image": "debian-8-docker.qcow2",177 "mos_versions": ['6.1', '7.0', '8.0'],178 "name": "debian-8-docker.qcow2",179 "md5sum": "f9f2466c39dac98a1e4ed03fb5701225",180 "meta": {"type": "linux",181 "title": "Debian with pre-installed docker and murano-agent"}182 },183 {184 "url": "http://storage.apps.openstack.org/images",185 "image": "ubuntu14.04-x64-kubernetes.qcow2",186 "mos_versions": ['6.1', '7.0', '8.0'],187 "name": "ubuntu14.04-x64-kubernetes",188 "md5sum": "0d959023d0551d68f9dc7139cb814e92",189 "meta": {"type": "linux", "title": "ubuntu14.04-x64-kubernetes"}190 }...

Full Screen

Full Screen

test_sahara_job_binaries.py

Source:test_sahara_job_binaries.py Github

copy

Full Screen

...68 self,69 mock_osclients,70 mock_sahara_job_binaries_download_and_save_lib,71 mock_cleanup):72 mock_sahara = mock_osclients.Clients(mock.MagicMock()).sahara()73 sahara_ctx = sahara_job_binaries.SaharaJobBinaries(self.context)74 download_calls = []75 for i in range(self.tenants_num):76 download_calls.append(mock.call(77 sahara=mock_sahara,78 lib_type="mains",79 name="test.jar",80 download_url="http://example.com/test.jar",81 tenant_id=str(i)))82 download_calls.append(mock.call(83 sahara=mock_sahara,84 lib_type="libs",85 name="test.jar",86 download_url="http://example.com/test.jar",87 tenant_id=str(i)))88 sahara_ctx.setup()89 (mock_sahara_job_binaries_download_and_save_lib.90 assert_has_calls(download_calls))91 sahara_ctx.cleanup()92 mock_cleanup.assert_called_once_with(93 names=["sahara.job_binary_internals", "sahara.job_binaries"],94 users=self.context["users"])95 @mock.patch("%s.sahara_job_binaries.requests" % CTX)96 @mock.patch("%s.sahara_job_binaries.osclients" % CTX)97 def test_download_and_save_lib(self, mock_osclients, mock_requests):98 mock_requests.get.content.return_value = "some_binary_content"99 mock_sahara = mock_osclients.Clients(mock.MagicMock()).sahara()100 mock_sahara.job_binary_internals.create.return_value = (101 mock.MagicMock(id=42))102 sahara_ctx = sahara_job_binaries.SaharaJobBinaries(self.context)103 sahara_ctx.context["tenants"]["0"]["sahara"] = {"mains": []}104 sahara_ctx.context["tenants"]["0"]["sahara"]["libs"] = []105 sahara_ctx.download_and_save_lib(sahara=mock_sahara,106 lib_type="mains",107 name="test_binary",108 download_url="http://somewhere",109 tenant_id="0")110 sahara_ctx.download_and_save_lib(sahara=mock_sahara,111 lib_type="libs",112 name="test_binary_2",113 download_url="http://somewhere",...

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