How to use create_qos method in tempest

Best Python code snippet using tempest_python

test_qos_specs.py

Source:test_qos_specs.py Github

copy

Full Screen

1# All Rights Reserved.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.14from unittest import mock15from rally import exceptions as rally_exceptions16from rally_openstack.task.scenarios.cinder import qos_specs17from tests.unit import test18class CinderQosTestCase(test.ScenarioTestCase):19 def setUp(self):20 super(CinderQosTestCase, self).setUp()21 patch = mock.patch(22 "rally_openstack.common.services.storage.block.BlockStorage")23 self.addCleanup(patch.stop)24 self.mock_cinder = patch.start()25 def _get_context(self):26 context = test.get_test_context()27 context.update({28 "admin": {29 "id": "fake_user_id",30 "credential": mock.MagicMock()31 },32 "user": {"id": "fake_user_id",33 "credential": mock.MagicMock()},34 "tenant": {"id": "fake", "name": "fake"}})35 return context36 def test_create_and_list_qos(self):37 mock_service = self.mock_cinder.return_value38 qos = mock.MagicMock()39 list_qos = [mock.MagicMock(),40 mock.MagicMock(),41 qos]42 specs = {"consumer": "both",43 "write_iops_sec": "10",44 "read_iops_sec": "1000"}45 scenario = qos_specs.CreateAndListQos(self._get_context())46 mock_service.create_qos.return_value = qos47 mock_service.list_qos.return_value = list_qos48 scenario.run("both", "10", "1000")49 mock_service.create_qos.assert_called_once_with(specs)50 mock_service.list_qos.assert_called_once_with()51 def test_create_and_list_qos_with_fails(self):52 mock_service = self.mock_cinder.return_value53 qos = mock.MagicMock()54 list_qos = [mock.MagicMock(),55 mock.MagicMock(),56 mock.MagicMock()]57 specs = {"consumer": "both",58 "write_iops_sec": "10",59 "read_iops_sec": "1000"}60 scenario = qos_specs.CreateAndListQos(self._get_context())61 mock_service.create_qos.return_value = qos62 mock_service.list_qos.return_value = list_qos63 self.assertRaises(rally_exceptions.RallyAssertionError,64 scenario.run, "both", "10", "1000")65 mock_service.create_qos.assert_called_once_with(specs)66 mock_service.list_qos.assert_called_once_with()67 def test_create_and_get_qos(self):68 mock_service = self.mock_cinder.return_value69 qos = mock.MagicMock()70 specs = {"consumer": "both",71 "write_iops_sec": "10",72 "read_iops_sec": "1000"}73 scenario = qos_specs.CreateAndGetQos(self._get_context())74 mock_service.create_qos.return_value = qos75 scenario.run("both", "10", "1000")76 mock_service.create_qos.assert_called_once_with(specs)77 mock_service.get_qos.assert_called_once_with(qos.id)78 def test_create_and_set_qos(self):79 mock_service = self.mock_cinder.return_value80 qos = mock.MagicMock()81 create_specs_args = {"consumer": "back-end",82 "write_iops_sec": "10",83 "read_iops_sec": "1000"}84 set_specs_args = {"consumer": "both",85 "write_iops_sec": "11",86 "read_iops_sec": "1001"}87 scenario = qos_specs.CreateAndSetQos(self._get_context())88 mock_service.create_qos.return_value = qos89 scenario.run("back-end", "10", "1000",90 "both", "11", "1001")91 mock_service.create_qos.assert_called_once_with(create_specs_args)92 mock_service.set_qos.assert_called_once_with(93 qos=qos, set_specs_args=set_specs_args)94 def test_create_qos_associate_and_disassociate_type(self):95 mock_service = self.mock_cinder.return_value96 context = self._get_context()97 context.update({98 "volume_types": [{"id": "fake_id",99 "name": "fake_name"}],100 "iteration": 1})101 qos = mock.MagicMock()102 specs = {"consumer": "both",103 "write_iops_sec": "10",104 "read_iops_sec": "1000"}105 scenario = qos_specs.CreateQosAssociateAndDisassociateType(context)106 mock_service.create_qos.return_value = qos107 scenario.run("both", "10", "1000")108 mock_service.create_qos.assert_called_once_with(specs)109 mock_service.qos_associate_type.assert_called_once_with(110 qos_specs=qos, volume_type="fake_id")111 mock_service.qos_disassociate_type.assert_called_once_with(...

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