Example #1
0
 def test_cleanup(self):
     result1 = existing.OpenStack({}).cleanup()
     result2 = existing.OpenStack({}).cleanup(task_uuid="any")
     self.assertEqual(result1, result2)
     self.assertEqual(
         {
             "message": "Coming soon!",
             "discovered": 0,
             "deleted": 0,
             "failed": 0,
             "resources": {},
             "errors": []
         },
         result1
     )
     self._check_cleanup_schema(result1)
Example #2
0
 def test_create_admin_only(self):
     spec = {
         "auth_url": "https://best",
         "endpoint_type": "public",
         "https_insecure": True,
         "https_cacert": "/my.ca",
         "profiler_hmac_key": "key",
         "profiler_conn_str": "http://prof",
         "admin": {
             "domain_name": "d", "user_domain_name": "d",
             "project_domain_name": "d", "project_name": "d",
             "username": "******", "password": "******"
         }
     }
     self.assertEqual(
         (
             {
                 "admin": {
                     "auth_url": "https://best",
                     "endpoint_type": "public",
                     "https_insecure": True, "https_cacert": "/my.ca",
                     "profiler_hmac_key": "key",
                     "profiler_conn_str": "http://prof",
                     "region_name": None, "domain_name": "d",
                     "user_domain_name": "d", "project_domain_name": "d",
                     "tenant_name": "d", "username": "******", "password": "******"
                 },
                 "users": []
             },
             {}
         ),
         existing.OpenStack(spec).create())
Example #3
0
 def test_check_health(self, mock_clients):
     pdata = {
         "admin": mock.MagicMock(),
         "users": [mock.MagicMock(), mock.MagicMock()]
     }
     result = existing.OpenStack({}, platform_data=pdata).check_health()
     self._check_health_schema(result)
     self.assertEqual({"available": True}, result)
     mock_clients.assert_has_calls(
         [mock.call(pdata["users"][0]), mock.call().keystone(),
          mock.call(pdata["users"][1]), mock.call().keystone(),
          mock.call(pdata["admin"]), mock.call().verified_keystone()])
Example #4
0
 def test_check_health_with_api_info(self, mock_clients):
     pdata = {"admin": mock.MagicMock(),
              "users": [],
              "api_info": {"fakeclient": "version"}}
     result = existing.OpenStack({}, platform_data=pdata).check_health()
     self._check_health_schema(result)
     self.assertEqual({"available": True}, result)
     mock_clients.assert_has_calls(
         [mock.call(pdata["admin"]), mock.call().verified_keystone(),
          mock.call().fakeclient.choose_version(),
          mock.call().fakeclient.validate_version(
              mock_clients.return_value.fakeclient.choose_version
              .return_value),
          mock.call().fakeclient.create_client()])
Example #5
0
 def test_check_failed_with_native_rally_exc(self, mock_clients):
     e = exceptions.RallyException("foo")
     mock_clients.return_value.keystone.side_effect = e
     pdata = {"admin": None,
              "users": [{"username": "******", "password": "******"}]}
     result = existing.OpenStack({}, platform_data=pdata).check_health()
     self._check_health_schema(result)
     self.assertEqual(
         {
             "available": False,
             "message": e.format_message(),
             "traceback": mock.ANY
         },
         result)
Example #6
0
    def test_check_version_failed_with_api_info(self, mock_clients):
        pdata = {"admin": mock.MagicMock(),
                 "users": [],
                 "api_info": {"fakeclient": "version"}}

        def validate_version(version):
            raise exceptions.RallyException("Version is not supported.")
        (mock_clients.return_value.fakeclient
         .validate_version) = validate_version
        result = existing.OpenStack({}, platform_data=pdata).check_health()
        self._check_health_schema(result)
        self.assertEqual({"available": False,
                          "message": ("Invalid setting for 'fakeclient':"
                                      " Version is not supported.")},
                         result)
Example #7
0
 def test_check_failed_users(self, mock_clients):
     mock_clients.return_value.keystone.side_effect = Exception
     pdata = {"admin": None,
              "users": [{"username": "******", "password": "******"}]}
     result = existing.OpenStack({}, platform_data=pdata).check_health()
     self._check_health_schema(result)
     self.assertEqual(
         {"available": False,
          "message":
             "Bad user creds: \n%s"
             % json.dumps({"username": "******", "password": "******",
                           "api_info": {}},
                          indent=2, sort_keys=True),
          "traceback": mock.ANY},
         result)
     self.assertIn("Traceback (most recent call last)", result["traceback"])
Example #8
0
    def test_check_unexpected_failed_with_api_info(self, mock_clients):
        pdata = {"admin": mock.MagicMock(),
                 "users": [],
                 "api_info": {"fakeclient": "version"}}

        def create_client():
            raise Exception("Invalid client.")

        (mock_clients.return_value.fakeclient
         .choose_version.return_value) = "1.0"
        mock_clients.return_value.fakeclient.create_client = create_client
        result = existing.OpenStack({}, platform_data=pdata).check_health()
        self._check_health_schema(result)
        self.assertEqual({"available": False,
                          "message": ("Can not create 'fakeclient' with"
                                      " 1.0 version."),
                          "traceback": mock.ANY},
                         result)
Example #9
0
    def test_info(self, mock_clients):
        mock_clients.return_value.services.return_value = {
            "foo": "bar",
            "volumev4": "__unknown__"}
        platform_data = {
            "admin": None,
            "users": [{"username": "******", "password": "******"}]
        }
        p = existing.OpenStack({}, platform_data=platform_data)

        result = p.info()
        mock_clients.assert_called_once_with(platform_data["users"][0])
        mock_clients.return_value.services.assert_called_once_with()
        self.assertEqual(
            {
                "info": {
                    "services": [{"type": "foo", "name": "bar"},
                                 {"type": "volumev4"}]}},
            result)
        self._check_info_schema(result)
Example #10
0
    def test_create_users_only(self):

        spec = {
            "auth_url": "https://best",
            "endpoint": "check_that_its_poped",
            "users": [
                {"project_name": "a", "username": "******", "password": "******"},
                {"project_name": "b", "username": "******", "password": "******"}
            ]
        }

        self.assertEqual(
            ({
                "admin": None,
                "users": [
                    {
                        "auth_url": "https://best", "endpoint_type": None,
                        "region_name": None,
                        "domain_name": None,
                        "user_domain_name": "default",
                        "project_domain_name": "default",
                        "https_insecure": False, "https_cacert": None,
                        "tenant_name": "a", "username": "******", "password": "******"
                    },
                    {
                        "auth_url": "https://best", "endpoint_type": None,
                        "region_name": None,
                        "domain_name": None,
                        "user_domain_name": "default",
                        "project_domain_name": "default",
                        "https_insecure": False, "https_cacert": None,
                        "tenant_name": "b", "username": "******", "password": "******"
                    }
                ]
            }, {}),
            existing.OpenStack(spec).create())
Example #11
0
 def test_destroy(self):
     self.assertIsNone(existing.OpenStack({}).destroy())