Ejemplo n.º 1
0
    def test_setup_with_service_name(self):
        self.mock_kc.services.list.return_value = [
            utils.Struct(type="computev21", name="NovaV21")
        ]
        context = {
            "config": {
                api_versions.OpenStackAPIVersions.get_name(): {
                    "nova": {
                        "service_name": "NovaV21"
                    }
                }
            },
            "admin": {
                "endpoint": mock.MagicMock()
            },
            "users": [{
                "endpoint": mock.MagicMock()
            }]
        }
        ctx = api_versions.OpenStackAPIVersions(copy.deepcopy(context))

        ctx.setup()

        self.mock_kc.service_catalog.get_endpoints.assert_called_once_with()
        self.mock_kc.services.list.assert_called_once_with()

        self.assertEqual("computev21", ctx.config["nova"]["service_type"])
Ejemplo n.º 2
0
 def test_setup_with_wrong_service_type(self):
     context = {
         "config": {
             api_versions.OpenStackAPIVersions.get_name(): {
                 "nova": {
                     "service_type": "service_type"
                 }
             }
         },
         "users": [{
             "endpoint": mock.MagicMock()
         }]
     }
     ctx = api_versions.OpenStackAPIVersions(context)
     self.assertRaises(exceptions.ValidationError, ctx.setup)
     self.mock_kc.service_catalog.get_endpoints.assert_called_once_with()
Ejemplo n.º 3
0
 def test_setup_with_wrong_service_name(self, mock_clients_services):
     context = {
         "config": {
             api_versions.OpenStackAPIVersions.get_name(): {
                 "nova": {
                     "service_name": "service_name"
                 }
             }
         },
         "admin": {
             "endpoint": mock.MagicMock()
         }
     }
     ctx = api_versions.OpenStackAPIVersions(context)
     self.assertRaises(exceptions.ValidationError, ctx.setup)
     mock_clients_services.assert_called_once_with()
Ejemplo n.º 4
0
 def test_setup_with_wrong_service_name_and_without_admin(self):
     context = {
         "config": {
             api_versions.OpenStackAPIVersions.get_name(): {
                 "nova": {
                     "service_name": "service_name"
                 }
             }
         },
         "users": [{
             "endpoint": mock.MagicMock()
         }]
     }
     ctx = api_versions.OpenStackAPIVersions(context)
     self.assertRaises(exceptions.BenchmarkSetupFailure, ctx.setup)
     self.mock_kc.service_catalog.get_endpoints.assert_called_once_with()
     self.assertFalse(self.mock_kc.services.list.called)
Ejemplo n.º 5
0
    def test_setup_with_service_name(self, mock_clients_services):
        mock_clients_services.return_value = {"computev21": "NovaV21"}
        context = {
            "config": {
                api_versions.OpenStackAPIVersions.get_name(): {
                    "nova": {
                        "service_name": "NovaV21"
                    }
                }
            },
            "admin": {
                "endpoint": mock.MagicMock()
            }
        }
        ctx = api_versions.OpenStackAPIVersions(copy.deepcopy(context))

        ctx.setup()

        mock_clients_services.assert_called_once_with()

        self.assertEqual("computev21", ctx.config["nova"]["service_type"])