Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️ apiserver: review and increase test coverage before extending #3626

Closed
6 of 16 tasks
Tracked by #952
pcrespov opened this issue Nov 30, 2022 · 0 comments · Fixed by #4437
Closed
6 of 16 tasks
Tracked by #952

♻️ apiserver: review and increase test coverage before extending #3626

pcrespov opened this issue Nov 30, 2022 · 0 comments · Fixed by #4437
Assignees
Labels
a:apiserver api-server service t:maintenance Some planned maintenance work
Milestone

Comments

@pcrespov
Copy link
Member

pcrespov commented Nov 30, 2022

api-server has lowest coverage of the repo (70%).

  • refactor/create mocks for stack services
  • cover all API routes
  • test handling errors
  • stress tests?
  • plugins/catalog.py : handlers should not capture outputs
# TODO: handlers should not capture outputs
# @handle_errors("catalog", logger, return_json=True)
# @handle_retry(logger)
# async def get(self, path: str, *args, **kwargs) -> JSON:
#     return await self.client.get(path, *args, **kwargs)
  • plugins/catalog.py:list_solvers: move filter to catalog
# TODO: move this sorting down to catalog service?
        solvers = []
        for data in response.json():
            try:
                service = TruncatedCatalogServiceOut.parse_obj(data)
                if service.service_type == ServiceType.COMPUTATIONAL:
                    solver = service.to_solver()
                    if predicate is None or predicate(solver):
                        solvers.append(solver)
  • # TODO: shall schemas of internal APIs be in models_library as well?? or is against
  • progress is incomplete: see plugins/directorv2:ComputationTaskGet.guess_progress
  • DirectorV2Api error handling
    # NOTE: keep here tmp as reference
    # @handle_errors("director", logger, return_json=True)
    # @handle_retry(logger)
    # async def get(self, path: str, *args, **kwargs) -> JSON:
    #     return await self.client.get(path, *args, **kwargs)

    # director2 API ---------------------------
    # TODO: error handling
    #
    #  HTTPStatusError: 404 Not Found
    #  ValidationError
    #  ServiceUnabalabe: 503
  • high level inteface for jobs (include studyes and solver jobs)?
    # HIGHER lever interface with job* resources
    # or better in another place?
    async def create_job(self):
        pass

    async def list_jobs(self):
        pass

    async def get_job(self):
        pass
  • plugin.storage Add column in meta_data table of storage and stop guessing
meta = File(
        id=file_id,  # type: ignore
        filename=filename,
        # FIXME: UploadFile gets content from the request header while here is
        # mimetypes.guess_type used. Sometimes it does not match.
        # Add column in meta_data table of storage and stop guessing :-)
        content_type=guess_type(filename)[0] or "application/octet-stream",
        checksum=stored_file_meta.entity_tag,
    )
  • plugin.storage error handling
    # FIXME: error handling and retrying policies?
    # @handle_errors("storage", logger, return_json=True)
    # @handle_retry(logger)
    # async def get(self, path: str, *args, **kwargs) -> JSON:
    #     return await self.client.get(path, *args, **kwargs)

        # FIXME: handle HTTPStatusError

        # FIXME: handle errors properly
        response.raise_for_status()


        # FIXME: was hanging when resp.join()["data"] -> None
        stored_file_meta = StorageFileMetaData.parse_obj(response.json()["data"])
  • plugin.webserver refactor
    # OPERATIONS
    # TODO: refactor and code below
    # TODO: policy to retry if NetworkError/timeout?
    # TODO: add ping to healthcheck
  • plugin.webserve error handling
            # FIXME: error handling
        except Exception as err:
            logger.exception("Failed to put %s", url)
            raise HTTPException(status.HTTP_503_SERVICE_UNAVAILABLE) from err
  • plugin.webserver.list_projects pagination and filter
    async def list_projects(self, solver_name: str) -> list[Project]:
        # TODO: pagination?

        # FIXME: move filter to webserver API (next PR)

  • puling.webserver.setup
 # TODO: old startup. need to integrat
    # TODO: init client and then build sessions from client using depenencies

class WebserverApi(BaseServiceClientApi):
    """Access to web-server API"""

    # def create_auth_session(self, session_cookies) -> AuthSession:
    #     """ Needed per request, so it can perform """
    #     return AuthSession(client=self.client, vtag="v0", session_cookies=session_cookies)


@pcrespov pcrespov added the a:apiserver api-server service label Nov 30, 2022
@pcrespov pcrespov added this to the Athena milestone Nov 30, 2022
@pcrespov pcrespov self-assigned this Nov 30, 2022
@pcrespov pcrespov modified the milestones: Athena, Mithril Mar 14, 2023
@pcrespov pcrespov added t:maintenance Some planned maintenance work a:models-library and removed a:apiserver api-server service labels Mar 14, 2023
@sanderegg sanderegg modified the milestones: Mithril, The Next Milestone Mar 31, 2023
@pcrespov pcrespov added a:apiserver api-server service and removed a:models-library labels Apr 12, 2023
@pcrespov pcrespov changed the title apiserver: increase test coverate apiserver: increase test coverage Apr 28, 2023
@pcrespov pcrespov changed the title apiserver: increase test coverage ♻️ apiserver: review and increase test coverage Apr 28, 2023
@pcrespov pcrespov changed the title ♻️ apiserver: review and increase test coverage ♻️ apiserver: review and increase test coverage before extending Apr 28, 2023
@pcrespov pcrespov modified the milestones: Jelly Beans, Pastel de Nata May 5, 2023
@pcrespov pcrespov modified the milestones: Pastel de Nata, Watermelon Jun 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:apiserver api-server service t:maintenance Some planned maintenance work
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants