Example #1
0
    def setUp(self):
        super(AllowSSHContextTestCase, self).setUp()
        self.users = 2
        self.secgroup_name = "test-secgroup"

        self.ctx_with_secgroup = test.get_test_context()
        self.ctx_with_secgroup.update({
            "users": [
                {
                    "tenant_id": "uuid1",
                    "endpoint": "endpoint",
                    "secgroup": {"id": "secgroup_id", "name": "secgroup"}
                }
            ] * self.users,
            "admin": {"tenant_id": "uuid2", "endpoint": "admin_endpoint"},
            "tenants": {"uuid1": {"id": "uuid1", "name": "uuid1"}},
        })
        self.ctx_without_secgroup = test.get_test_context()
        self.ctx_without_secgroup.update({
            "users": [{"tenant_id": "uuid1",
                       "endpoint": "endpoint"},
                      {"tenant_id": "uuid1",
                       "endpoint": "endpoint"}],
            "admin": {"tenant_id": "uuid2", "endpoint": "admin_endpoint"},
            "tenants": {"uuid1": {"id": "uuid1", "name": "uuid1"}},
        })
Example #2
0
 def test_dummy_timed_atomic_actions(self, mock_interruptable_sleep,
                                     number_of_actions, sleep_factor):
     dummy.DummyRandomAction(test.get_test_context()).run(
         number_of_actions, sleep_factor)
     scenario = dummy.DummyTimedAtomicAction(test.get_test_context())
     scenario.run(number_of_actions, sleep_factor)
     for i in range(number_of_actions):
         self._test_atomic_action_timer(scenario.atomic_actions(),
                                        "action_%d" % i)
         mock_interruptable_sleep.assert_any_call(i * sleep_factor)
Example #3
0
 def test_dummy_timed_atomic_actions(self, mock_interruptable_sleep,
                                     number_of_actions, sleep_factor):
     dummy.DummyRandomAction(test.get_test_context()).run(
         number_of_actions, sleep_factor)
     scenario = dummy.DummyTimedAtomicAction(test.get_test_context())
     scenario.run(number_of_actions, sleep_factor)
     for i in range(number_of_actions):
         self._test_atomic_action_timer(scenario.atomic_actions(),
                                        "action_%d" % i)
         mock_interruptable_sleep.assert_any_call(i * sleep_factor)
Example #4
0
 def _gen_context(self, tenants_count, users_per_tenant,
                  resources_per_tenant, samples_per_resource):
     tenants = self._gen_tenants(tenants_count)
     users = []
     for id_ in tenants.keys():
         for i in range(users_per_tenant):
             users.append({"id": i, "tenant_id": id_,
                           "endpoint": mock.MagicMock()})
     context = test.get_test_context()
     context.update({
         "config": {
             "users": {
                 "tenants": tenants_count,
                 "users_per_tenant": users_per_tenant,
                 "concurrent": 10,
             },
             "ceilometer": {
                 "counter_name": "fake-counter-name",
                 "counter_type": "fake-counter-type",
                 "counter_unit": "fake-counter-unit",
                 "counter_volume": 100,
                 "resources_per_tenant": resources_per_tenant,
                 "samples_per_resource": samples_per_resource
             }
         },
         "admin": {
             "endpoint": mock.MagicMock()
         },
         "users": users,
         "tenants": tenants
     })
     return tenants, context
Example #5
0
 def test_setup_failure_clients_put_object(self, mock_clients):
     context = test.get_test_context()
     context.update({
         "tenants": {
             "t1": {"name": "t1_name"},
             "t2": {"name": "t2_name"}
         },
         "users": [
             {
                 "id": "u1",
                 "tenant_id": "t1",
                 "credential": mock.MagicMock()
             },
             {
                 "id": "u2",
                 "tenant_id": "t2",
                 "credential": mock.MagicMock()
             }
         ]
     })
     mock_swift = mock_clients.return_value.swift.return_value
     mock_swift.put_object.side_effect = [Exception, True]
     objects_ctx = objects.SwiftObjectGenerator(context)
     self.assertRaisesRegex(exceptions.ContextSetupFailure,
                            "objects, expected 2 but got 1",
                            objects_ctx.setup)
Example #6
0
 def _gen_context(self, tenants_count, users_per_tenant,
                  resources_per_tenant, samples_per_resource):
     tenants = self._gen_tenants(tenants_count)
     users = []
     for id_ in tenants.keys():
         for i in range(users_per_tenant):
             users.append({"id": i, "tenant_id": id_,
                           "endpoint": mock.MagicMock()})
     context = test.get_test_context()
     context.update({
         "config": {
             "users": {
                 "tenants": tenants_count,
                 "users_per_tenant": users_per_tenant,
                 "concurrent": 10,
             },
             "ceilometer": {
                 "counter_name": "fake-counter-name",
                 "counter_type": "fake-counter-type",
                 "counter_unit": "fake-counter-unit",
                 "counter_volume": 100,
                 "resources_per_tenant": resources_per_tenant,
                 "samples_per_resource": samples_per_resource
             }
         },
         "admin": {
             "endpoint": mock.MagicMock()
         },
         "users": users,
         "tenants": tenants
     })
     return tenants, context
Example #7
0
 def setUp(self):
     super(OpenStackScenarioTestCase, self).setUp()
     self.osclients = fixtures.MockPatch(
         "rally.plugins.openstack.osclients.Clients")
     self.useFixture(self.osclients)
     self.context = test.get_test_context()
     self.context.update({"foo": "bar"})
Example #8
0
    def test_dummy_exception(self, mock_interruptable_sleep):
        scenario = dummy.Dummy(test.get_test_context())

        size_of_message = 5
        self.assertRaises(dummy.DummyScenarioException,
                          scenario.dummy_exception, size_of_message, sleep=10)
        mock_interruptable_sleep.assert_called_once_with(10)
Example #9
0
 def _get_context(self, resource=None):
     context = test.get_test_context()
     if resource in ("network", "router"):
         context.update({
             "user": {
                 "id": "fake_user",
                 "tenant_id": "fake_tenant",
                 "credential": mock.MagicMock()
             }
         })
         if resource == "network":
             context.update({
                 "tenant": {
                     "id":
                     "fake_tenant",
                     resource + "s": [{
                         "id": "fake_net",
                         "tenant_id": "fake_tenant"
                     }]
                 }
             })
         elif resource == "router":
             context.update({
                 "tenant": {
                     "id":
                     "fake_tenant",
                     resource + "s": [{
                         resource: {
                             "id": "fake_net",
                             "tenant_id": "fake_tenant"
                         }
                     }]
                 }
             })
     return context
Example #10
0
 def test_setup_failure_clients_put_object(self, mock_clients):
     context = test.get_test_context()
     context.update({
         "tenants": {
             "t1": {
                 "name": "t1_name"
             },
             "t2": {
                 "name": "t2_name"
             }
         },
         "users": [{
             "id": "u1",
             "tenant_id": "t1",
             "credential": mock.MagicMock()
         }, {
             "id": "u2",
             "tenant_id": "t2",
             "credential": mock.MagicMock()
         }]
     })
     mock_swift = mock_clients.return_value.swift.return_value
     mock_swift.put_object.side_effect = [Exception, True]
     objects_ctx = objects.SwiftObjectGenerator(context)
     self.assertRaisesRegex(exceptions.ContextSetupFailure,
                            "objects, expected 2 but got 1",
                            objects_ctx.setup)
Example #11
0
 def get_wrapper(self, *skip_cidrs, **kwargs):
     mock_clients = mock.Mock()
     mock_clients.nova.return_value.networks.list.return_value = [
         self.Net(cidr=cidr) for cidr in skip_cidrs]
     return network.NovaNetworkWrapper(mock_clients,
                                       test.get_test_context()["task"],
                                       config=kwargs)
Example #12
0
    def test_dummy_random_fail_in_atomic(self):
        scenario = dummy.DummyRandomFailInAtomic(test.get_test_context())

        for i in range(10):
            scenario.run(exception_probability=0)
        for i in range(10):
            self.assertRaises(KeyError, scenario.run, exception_probability=1)
Example #13
0
 def setUp(self):
     super(OpenStackScenarioTestCase, self).setUp()
     self.osclients = fixtures.MockPatch(
         "rally_openstack.osclients.Clients")
     self.useFixture(self.osclients)
     self.context = test.get_test_context()
     self.context.update({"foo": "bar"})
Example #14
0
 def context_without_edp_keys(self):
     context = test.get_test_context()
     context.update({
         "config": {
             "users": {
                 "tenants": self.tenants_num,
                 "users_per_tenant": self.users_per_tenant,
             },
             "sahara_edp": {
                 "input_type": "hdfs",
                 "output_type": "hdfs",
                 "input_url": "hdfs://test_host/",
                 "output_url_prefix": "hdfs://test_host/out_",
                 "libs": [
                     {
                         "name": "test.jar",
                         "download_url": "http://example.com/test.jar"
                     }
                 ]
             },
         },
         "admin": {"endpoint": mock.MagicMock()},
         "users": self.users_key,
         "tenants": self.tenants
     })
     return context
Example #15
0
    def setUp(self):
        super(BaseCustomImageContextVMTestCase, self).setUp()

        self.context = test.get_test_context()
        self.context.update({
            "config": {
                "test_custom_image": {
                    "image": {
                        "name": "image"
                    },
                    "flavor": {
                        "name": "flavor"
                    },
                    "username": "******",
                    "floating_network": "floating",
                    "port": 1022,
                }
            },
            "admin": {
                "endpoint": "endpoint",
            },
            "users": [{
                "tenant_id": "tenant_id0"
            }, {
                "tenant_id": "tenant_id1"
            }, {
                "tenant_id": "tenant_id2"
            }],
            "tenants": {
                "tenant_id0": {},
                "tenant_id1": {},
                "tenant_id2": {}
            }
        })
Example #16
0
    def test_setup(self, mock_clients):
        containers_per_tenant = 2
        objects_per_container = 7
        context = test.get_test_context()
        context.update({
            "config": {
                "swift_objects": {
                    "containers_per_tenant": containers_per_tenant,
                    "objects_per_container": objects_per_container,
                    "object_size": 1024,
                    "resource_management_workers": 10
                }
            },
            "tenants": {
                "t1": {"name": "t1_name"},
                "t2": {"name": "t2_name"}
            },
            "users": [
                {"id": "u1", "tenant_id": "t1", "endpoint": "e1"},
                {"id": "u2", "tenant_id": "t2", "endpoint": "e2"}
            ]
        })

        objects_ctx = objects.SwiftObjectGenerator(context)
        objects_ctx.setup()

        for tenant_id in context["tenants"]:
            containers = context["tenants"][tenant_id]["containers"]
            self.assertEqual(containers_per_tenant, len(containers))
            for container in containers:
                self.assertEqual(objects_per_container,
                                 len(container["objects"]))
Example #17
0
 def test_cleanup_failure_clients_delete_object(self, mock_clients):
     context = test.get_test_context()
     context.update({
         "tenants": {
             "t1": {
                 "name":
                 "t1_name",
                 "containers": [{
                     "user": {
                         "id": "u1",
                         "tenant_id": "t1",
                         "credential": mock.MagicMock()
                     },
                     "container": "c1",
                     "objects": ["oooo"] * 3
                 }]
             }
         }
     })
     mock_swift = mock_clients.return_value.swift.return_value
     mock_swift.delete_object.side_effect = [True, Exception, True]
     objects_ctx = objects.SwiftObjectGenerator(context)
     objects_ctx._delete_containers = mock.MagicMock()
     objects_ctx.cleanup()
     self.assertEqual(
         1,
         sum([
             len(container["objects"])
             for container in context["tenants"]["t1"]["containers"]
         ]))
Example #18
0
    def setUp(self):
        super(ExistingNetworkTestCase, self).setUp()

        self.config = {"foo": "bar"}
        self.context = test.get_test_context()
        self.context.update({
            "users": [
                {
                    "id": 1,
                    "tenant_id": "tenant1",
                    "credential": mock.Mock()
                },
                {
                    "id": 2,
                    "tenant_id": "tenant2",
                    "credential": mock.Mock()
                },
            ],
            "tenants": {
                "tenant1": {},
                "tenant2": {},
            },
            "config": {
                "existing_network": self.config
            },
        })
Example #19
0
 def test_setup_failure_clients_put_container(self, mock_clients):
     context = test.get_test_context()
     context.update({
         "config": {
             "swift_objects": {
                 "containers_per_tenant": 2,
                 "object_size": 10,
                 "resource_management_workers": 5
             }
         },
         "tenants": {
             "t1": {"name": "t1_name"},
             "t2": {"name": "t2_name"}
         },
         "users": [
             {"id": "u1", "tenant_id": "t1", "endpoint": "e1"},
             {"id": "u2", "tenant_id": "t2", "endpoint": "e2"}
         ]
     })
     mock_swift = mock_clients.return_value.swift.return_value
     mock_swift.put_container.side_effect = [Exception, True,
                                             Exception, Exception]
     objects_ctx = objects.SwiftObjectGenerator(context)
     self.assertRaisesRegexp(exceptions.ContextSetupFailure,
                             "containers, expected 4 but got 1",
                             objects_ctx.setup)
Example #20
0
    def setUp(self):
        super(BaseCustomImageContextVMTestCase, self).setUp()

        self.context = test.get_test_context()
        self.context.update({
            "config": {
                "test_custom_image": {
                    "image": {"name": "image"},
                    "flavor": {"name": "flavor"},
                    "username": "******",
                    "floating_network": "floating",
                    "port": 1022,
                }
            },
            "admin": {
                "credential": mock.Mock(),
            },
            "users": [
                {"tenant_id": "tenant_id0"},
                {"tenant_id": "tenant_id1"},
                {"tenant_id": "tenant_id2"}
            ],
            "tenants": {
                "tenant_id0": {},
                "tenant_id1": {},
                "tenant_id2": {}
            }
        })
Example #21
0
    def test__create_containers(self, mock_clients):
        tenants = 2
        containers_per_tenant = 2
        context = test.get_test_context()
        context.update({
            "tenants": {
                "1001": {"name": "t1_name"},
                "1002": {"name": "t2_name"}
            },
            "users": [
                {"id": "u1", "tenant_id": "1001", "endpoint": "e1"},
                {"id": "u2", "tenant_id": "1002", "endpoint": "e2"}
            ]
        })

        mixin = utils.SwiftObjectMixin()
        containers = mixin._create_containers(context, containers_per_tenant,
                                              15)

        self.assertEqual(tenants * containers_per_tenant, len(containers))
        for index, container in enumerate(sorted(containers)):
            offset = int(index / containers_per_tenant) + 1
            self.assertEqual(str(1000 + offset), container[0])

        for index, tenant_id in enumerate(sorted(context["tenants"]), start=1):
            containers = context["tenants"][tenant_id]["containers"]
            self.assertEqual(containers_per_tenant, len(containers))
            for container in containers:
                self.assertEqual("u%d" % index, container["user"]["id"])
                self.assertEqual("e%d" % index, container["user"]["endpoint"])
                self.assertEqual(0, len(container["objects"]))
Example #22
0
    def _get_context(self):
        context = test.get_test_context()

        cred = credential.OpenStackCredential(auth_url="url",
                                              username="******",
                                              password="******")
        context.update({
            "admin": {
                "id": "fake_user_id",
                "credential": cred
            },
            "user": {
                "id": "fake_user_id",
                "credential": cred
            },
            "tenant": {
                "id": "fake",
                "name": "fake",
                "volumes": [{
                    "id": "uuid",
                    "size": 1
                }],
                "servers": [1]
            }
        })
        return context
Example #23
0
 def setUp(self):
     super(OpenStackScenarioTestCase, self).setUp()
     self.osclients = mockpatch.Patch(
         "rally.osclients.Clients")
     self.useFixture(self.osclients)
     self.context = test.get_test_context()
     self.context.update({"foo": "bar"})
Example #24
0
 def test_dummy_dummy_with_scenario_output(self):
     scenario = dummy.Dummy(test.get_test_context())
     result = scenario.dummy_with_scenario_output()
     self.assertEqual(result["errors"], "")
     # Since the data is generated in random,
     # checking for not None
     self.assertIsNotNone(result["data"])
 def context_without_edp_keys(self):
     context = test.get_test_context()
     context.update({
         "config": {
             "users": {
                 "tenants": self.tenants_num,
                 "users_per_tenant": self.users_per_tenant,
             },
             "sahara_edp": {
                 "input_type":
                 "hdfs",
                 "output_type":
                 "hdfs",
                 "input_url":
                 "hdfs://test_host/",
                 "output_url_prefix":
                 "hdfs://test_host/out_",
                 "libs": [{
                     "name": "test.jar",
                     "download_url": "http://example.com/test.jar"
                 }]
             },
         },
         "admin": {
             "endpoint": mock.MagicMock()
         },
         "users": self.users_key,
         "tenants": self.tenants
     })
     return context
Example #26
0
    def test__create_containers(self, mock_clients):
        tenants = 2
        containers_per_tenant = 2
        context = test.get_test_context()
        c = [mock.MagicMock(), mock.MagicMock()]
        context.update({
            "tenants": {
                "1001": {"name": "t1_name"},
                "1002": {"name": "t2_name"}
            },
            "users": [
                {"id": "u1", "tenant_id": "1001", "credential": c[0]},
                {"id": "u2", "tenant_id": "1002", "credential": c[1]}
            ]
        })

        mixin = utils.SwiftObjectMixin()
        containers = mixin._create_containers(context, containers_per_tenant,
                                              15)

        self.assertEqual(tenants * containers_per_tenant, len(containers))
        for index, container in enumerate(sorted(containers)):
            offset = int(index / containers_per_tenant) + 1
            self.assertEqual(str(1000 + offset), container[0])

        for index, tenant_id in enumerate(sorted(context["tenants"]), start=1):
            containers = context["tenants"][tenant_id]["containers"]
            self.assertEqual(containers_per_tenant, len(containers))
            for container in containers:
                self.assertEqual("u%d" % index, container["user"]["id"])
                self.assertEqual(c[index - 1],
                                 container["user"]["credential"])
                self.assertEqual(0, len(container["objects"]))
Example #27
0
    def setUp(self):
        super(AllowSSHContextTestCase, self).setUp()
        self.users = 2
        self.secgroup_name = allow_ssh.SSH_GROUP_NAME + "_foo"
        self.secgroup_name = "test-secgroup"

        self.ctx_with_secgroup = test.get_test_context()
        self.ctx_with_secgroup.update({
            "users": [{
                "tenant_id": "uuid1",
                "endpoint": "endpoint",
                "secgroup": {
                    "id": "secgroup_id",
                    "name": "secgroup"
                }
            }] * self.users,
            "admin": {
                "tenant_id": "uuid2",
                "endpoint": "admin_endpoint"
            },
            "tenants": {
                "uuid1": {
                    "id": "uuid1",
                    "name": "uuid1"
                }
            },
        })
        self.ctx_without_secgroup = test.get_test_context()
        self.ctx_without_secgroup.update({
            "users": [{
                "tenant_id": "uuid1",
                "endpoint": "endpoint"
            }, {
                "tenant_id": "uuid1",
                "endpoint": "endpoint"
            }],
            "admin": {
                "tenant_id": "uuid2",
                "endpoint": "admin_endpoint"
            },
            "tenants": {
                "uuid1": {
                    "id": "uuid1",
                    "name": "uuid1"
                }
            },
        })
Example #28
0
 def test_check_random_request(self, mock_choice, mock__check_request):
     mock_choice.return_value = {"url": "sample_url"}
     Requests = http_requests.HttpRequests(test.get_test_context())
     Requests.check_random_request(status_code=200,
                                   requests=[{"url": "sample_url"}])
     mock_choice.assert_called_once_with([{"url": "sample_url"}])
     mock__check_request.assert_called_once_with(
         status_code=200, url="sample_url")
    def test_dummy(self, mock_sleep):
        scenario = dummy.Dummy(test.get_test_context())
        scenario.sleep_between = mock.MagicMock()
        scenario.dummy()
        self.assertFalse(mock_sleep.sleep.called)

        scenario.dummy(sleep=10)
        mock_sleep.assert_called_once_with(10)
Example #30
0
    def setUp(self):
        super(SaharaJobTestCase, self).setUp()

        self.context = test.get_test_context()
        CONF.set_override("sahara_cluster_check_interval", 0, "benchmark",
                          enforce_type=True)
        CONF.set_override("sahara_job_check_interval", 0, "benchmark",
                          enforce_type=True)
Example #31
0
    def setUp(self):
        super(AllowSSHContextTestCase, self).setUp()
        self.users = 2
        self.secgroup_name = "test-secgroup"

        self.ctx_with_secgroup = test.get_test_context()
        self.ctx_with_secgroup.update({
            "users": [{
                "tenant_id": "uuid1",
                "credential": "credential",
                "secgroup": {
                    "id": "secgroup_id",
                    "name": "secgroup"
                }
            }] * self.users,
            "admin": {
                "tenant_id": "uuid2",
                "credential": "admin_credential"
            },
            "tenants": {
                "uuid1": {
                    "id": "uuid1",
                    "name": "uuid1"
                }
            },
        })
        self.ctx_without_secgroup = test.get_test_context()
        self.ctx_without_secgroup.update({
            "users": [{
                "tenant_id": "uuid1",
                "credential": "credential"
            }, {
                "tenant_id": "uuid1",
                "credential": "credential"
            }],
            "admin": {
                "tenant_id": "uuid2",
                "credential": "admin_credential"
            },
            "tenants": {
                "uuid1": {
                    "id": "uuid1",
                    "name": "uuid1"
                }
            },
        })
Example #32
0
    def test_dummy(self, mock_sleep):
        scenario = dummy.Dummy(test.get_test_context())
        scenario.sleep_between = mock.MagicMock()
        scenario.dummy()
        self.assertFalse(mock_sleep.sleep.called)

        scenario.dummy(sleep=10)
        mock_sleep.assert_called_once_with(10)
Example #33
0
 def test_check_random_request(self, mock_choice, mock__check_request):
     mock_choice.return_value = {"url": "sample_url"}
     Requests = http_requests.HttpRequestsCheckRandomRequest(
         test.get_test_context())
     Requests.run(status_code=200, requests=[{"url": "sample_url"}])
     mock_choice.assert_called_once_with([{"url": "sample_url"}])
     mock__check_request.assert_called_once_with(status_code=200,
                                                 url="sample_url")
Example #34
0
    def test__check_request(self, mock_request):
        mock_request.return_value = mock.MagicMock(status_code=200)
        scenario = utils.RequestScenario(test.get_test_context())
        scenario._check_request(status_code=200, url="sample", method="GET")

        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "requests.check_request")
        mock_request.assert_called_once_with("GET", "sample")
Example #35
0
    def test__check_request(self, mock_request):
        mock_request.return_value = mock.MagicMock(status_code=200)
        scenario = utils.RequestScenario(test.get_test_context())
        scenario._check_request(status_code=200, url="sample", method="GET")

        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "requests.check_request")
        mock_request.assert_called_once_with("GET", "sample")
Example #36
0
 def _gen_context(self, tenants_count, users_per_tenant,
                  resources_per_tenant, samples_per_resource):
     tenants = self._gen_tenants(tenants_count)
     users = []
     for id_ in tenants.keys():
         for i in range(users_per_tenant):
             users.append({
                 "id": i,
                 "tenant_id": id_,
                 "credential": mock.MagicMock()
             })
     context = test.get_test_context()
     context.update({
         "config": {
             "users": {
                 "tenants": tenants_count,
                 "users_per_tenant": users_per_tenant,
                 "concurrent": 10,
             },
             "ceilometer": {
                 "counter_name":
                 "fake-counter-name",
                 "counter_type":
                 "fake-counter-type",
                 "counter_unit":
                 "fake-counter-unit",
                 "counter_volume":
                 100,
                 "resources_per_tenant":
                 resources_per_tenant,
                 "samples_per_resource":
                 samples_per_resource,
                 "timestamp_interval":
                 60,
                 "metadata_list": (
                     {
                         "status": "active",
                         "name": "fake_resource",
                         "deleted": "False",
                         "created_at": "2015-09-04T12:34:19.000000"
                     },
                     {
                         "status": "not_active",
                         "name": "fake_resource_1",
                         "deleted": "False",
                         "created_at": "2015-09-10T06:55:12.000000"
                     },
                 )
             }
         },
         "admin": {
             "credential": mock.MagicMock()
         },
         "users": users,
         "tenants": tenants,
         "user_choice_method": "random",
     })
     return tenants, context
Example #37
0
 def get_test_context():
     ctx = test.get_test_context()
     ctx.update(user_choice_method="random",
                tenants={"tenant-1": {}},
                users=[{
                    "tenant_id": "tenant-1",
                    "credential": {}
                }])
     return ctx
 def _get_context(self):
     context = test.get_test_context()
     context.update(
         {
             "user": {"id": "fake_user", "tenant_id": "fake_tenant", "credential": mock.MagicMock()},
             "tenant": {"id": "fake_tenant", "networks": [{"id": "fake_net", "subnets": ["fake_subnet"]}]},
         }
     )
     return context
Example #39
0
 def _get_context(self):
     context = test.get_test_context()
     context.update({
         "user": {"tenant_id": "fake",
                  "endpoint": mock.MagicMock()},
         "tenant": {"id": "fake", "name": "fake",
                    "volumes": [{"id": "uuid"}],
                    "servers": [1]}})
     return context
Example #40
0
 def _get_context():
     context = test.get_test_context()
     context.update({
         "tenant": {
             "id": "rally_tenant_id",
             "cluster_template": "rally_cluster_template_uuid"
         }
     })
     return context
Example #41
0
 def _get_context(self):
     context = test.get_test_context()
     context.update({
         "user": {"tenant_id": "fake",
                  "credential": mock.MagicMock()},
         "tenant": {"id": "fake", "name": "fake",
                    "volumes": [{"id": "uuid", "size": 1}],
                    "servers": [1]}})
     return context
Example #42
0
 def _get_context():
     context = test.get_test_context()
     context.update({
         "tenant": {
             "id": "rally_tenant_id",
             "cluster_template": "rally_cluster_template_uuid"
         }
     })
     return context
Example #43
0
    def test_dummy_random_fail_in_atomic(self):
        scenario = dummy.DummyRandomFailInAtomic(test.get_test_context())

        for i in range(10):
            scenario.run(exception_probability=0)
        for i in range(10):
            self.assertRaises(KeyError,
                              scenario.run,
                              exception_probability=1)
Example #44
0
    def setUp(self):
        super(TempestLogWrappersTestCase, self).setUp()
        verifier = mock.MagicMock()
        verifier.parse_results.return_value = mock.MagicMock(total={"time": 0}, tests={})

        context = test.get_test_context()
        context.update({"tmp_results_dir": "/tmp/dir", "verifier": verifier})
        self.scenario = tempest.TempestScenario(context)
        self.scenario._add_atomic_actions = mock.MagicMock()
Example #45
0
    def test_check_wrong_request(self, mock_request):
        mock_request.return_value = mock.MagicMock(status_code=200)
        scenario = utils.RequestScenario(test.get_test_context())

        self.assertRaises(ValueError,
                          scenario._check_request,
                          status_code=201,
                          url="sample",
                          method="GET")
Example #46
0
 def _get_context():
     context = test.get_test_context()
     context.update({
         "user": {
             "id": "fake_user_id",
             "endpoint": mock.MagicMock()
         },
         "tenant": {"id": "fake_tenant_id"}
     })
     return context
Example #47
0
 def setUp(self):
     super(TempestScenarioTestCase, self).setUp()
     self.verifier = verifier.Tempest("fake_uuid")
     self.verifier.log_file_raw = "/dev/null"
     self.verifier.parse_results = mock.MagicMock()
     self.verifier.parse_results.return_value = mock.MagicMock(tests={}, total={"time": 0})
     self.context = test.get_test_context()
     self.context.update({"verifier": self.verifier, "tmp_results_dir": "/dev"})
     self.scenario = tempest.TempestScenario(self.context)
     self.scenario._add_atomic_actions = mock.MagicMock()
Example #48
0
 def _get_context():
     context = test.get_test_context()
     context.update({
         "user": {
             "id": "fake_user_id",
             "endpoint": mock.MagicMock()
         },
         "tenant": {"id": "fake_tenant_id"}
     })
     return context
Example #49
0
    def test_check_wrong_request(self, mock_request):
        mock_request.return_value = mock.MagicMock(status_code=200)
        scenario = utils.RequestScenario(test.get_test_context())

        self.assertRaises(
            ValueError,
            scenario._check_request,
            status_code=201,
            url="sample",
            method="GET")
Example #50
0
    def setUp(self):
        super(TempestLogWrappersTestCase, self).setUp()
        verifier = mock.MagicMock()
        verifier.parse_results.return_value = mock.MagicMock(total={"time": 0},
                                                             tests={})

        context = test.get_test_context()
        context.update({"tmp_results_dir": "/tmp/dir", "verifier": verifier})
        self.scenario = tempest.TempestScenario(context)
        self.scenario._add_atomic_actions = mock.MagicMock()
Example #51
0
 def _get_context():
     context = test.get_test_context()
     context.update({
         "tenant": {
             "id": "rally_tenant_id"
         },
         "user": {"id": "fake_user_id",
                  "credential": mock.MagicMock()},
         "config": {}
     })
     return context
Example #52
0
 def _get_context(self):
     context = test.get_test_context()
     context.update({
         "admin": {
             "id": "fake_user_id",
             "credential": mock.MagicMock()
         },
         "user": {"id": "fake_user_id",
                  "credential": mock.MagicMock()},
         "tenant": {"id": "fake", "name": "fake"}})
     return context
Example #53
0
 def test_run(self, mock_interruptable_sleep, iteration, kwargs,
              raises=True):
     scenario = dummy.DummyFailure(
         test.get_test_context(iteration=iteration))
     if raises:
         self.assertRaises(dummy.DummyScenarioException, scenario.run,
                           **kwargs)
     else:
         scenario.run(**kwargs)
     mock_interruptable_sleep.assert_called_once_with(
         kwargs.get("sleep", 0.1))
Example #54
0
    def test_cleanup(self, mock_swift_scenario, mock_clients):
        context = test.get_test_context()
        context.update({
            "config": {
                "swift_objects": {
                    "resource_management_workers": 1
                }
            },
            "tenants": {
                "t1": {
                    "name":
                    "t1_name",
                    "containers": [{
                        "user": {
                            "id": "u1",
                            "tenant_id": "t1",
                            "credential": "c1"
                        },
                        "container": "c1",
                        "objects": ["o1", "o2", "o3"]
                    }]
                },
                "t2": {
                    "name":
                    "t2_name",
                    "containers": [{
                        "user": {
                            "id": "u2",
                            "tenant_id": "t2",
                            "credential": "c2"
                        },
                        "container": "c2",
                        "objects": ["o4", "o5", "o6"]
                    }]
                }
            }
        })

        objects_ctx = objects.SwiftObjectGenerator(context)
        objects_ctx.cleanup()

        expected_containers = ["c1", "c2"]
        mock_swift_scenario.return_value._delete_container.assert_has_calls(
            [mock.call(con) for con in expected_containers], any_order=True)

        expected_objects = [("c1", "o1"), ("c1", "o2"), ("c1", "o3"),
                            ("c2", "o4"), ("c2", "o5"), ("c2", "o6")]
        mock_swift_scenario.return_value._delete_object.assert_has_calls(
            [mock.call(con, obj) for con, obj in expected_objects],
            any_order=True)

        for tenant_id in context["tenants"]:
            self.assertEqual(0,
                             len(context["tenants"][tenant_id]["containers"]))
Example #55
0
 def _get_context(self):
     context = test.get_test_context()
     context.update({
         "admin": {
             "id": "fake_user_id",
             "credential": mock.MagicMock()
         },
         "user": {"id": "fake_user_id",
                  "credential": mock.MagicMock()},
         "tenant": {"id": "fake", "name": "fake"}})
     return context
Example #56
0
    def test_dummy_exception_probability(self):
        scenario = dummy.Dummy(test.get_test_context())

        # should not raise an exception as probability is 0
        for i in range(100):
            scenario.dummy_exception_probability(exception_probability=0)

        # should always raise an exception as probability is 1
        for i in range(100):
            self.assertRaises(dummy.DummyScenarioException,
                              scenario.dummy_exception_probability,
                              exception_probability=1)