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

Fix SCT-3001, SCT-3002 and friends #52

Merged
merged 21 commits into from
Apr 21, 2021

Conversation

eapearson
Copy link
Contributor

This is a big PR, as it incorporates the fixes for the original issues reported in SCT-3001 and SCT-3002, a handful of bugs encountered while generating tests for those fixes, and many test changes.

I also conducted some renaming refactoring, because it could be quite difficult to follow the code with some of the key names chosen (e.g. "timestamp", "type").

I wouldn't blame you, dear reviewer, if you asked me to break this up into multiple PRs.

Still, here we go. I'll summarize the changes:

SCT-3001: was caused by in invalid "kbase_id" field, which is essentially an "ups" or object reference. It was resolved by removing the "kbase_id" field, renaming the workspace id, object id, and object version individual fields to be more user friendly, and refactoring the front ends to use the individual fields to create an object reference, rather than the now-absent kbase_id. At the same time, removed the "guid" field, and replaced usages of guid with id (there is no longer a guid, but it is functionally the same as the "id" field)

SCT-3002: was caused by an invalid index name being included in results; rather than the index alias, the concrete alias was being returned. The cause of this was an incorrect parsing of the concrete index name, which is composed of a prefix (search2) and suffix (the index version). The bug was that the parser assumed the prefix and suffix separators are the same, but they are not -- the prefix uses a "." and the suffix a "_". Fixing this required adding the suffix separator constant, adjusting the parsing code, and adjusting tests.

While fixing the above code, it was clear that the key naming, while mostly adhering to the original search1 api where applicable, was confusing and difficult to trace. Generic names like "timestamp", "type" or "version" are meaningless out of context, and others were inconsistent.

In addition, the testing support needed improvement (it still does.) One of the main problem areas was test data and strictness of schemas. Several fields were in the incorrect location, appearing under the type-specific data key rather than in the firmly-typed search results. That is, the type-specific data (the specific fields indexed for an object) is an unchecked object, so fields appearing in it are simply allowed without validation. It so happened that, given the way the search results are transformed from the es results to the api results, it was quite easy to miss fields which should appear in the top level search result rather than in the type-specific data. Those fields, while mandatory, were also not specified as required in the schema.

It took some juggling of schemas, the transformation parser, test data, and the front end code to get that sorted out. But I did it in this PR since to have tests pass I would otherwise have to accept that they were also broken.

So that leads to the final area of change - tests. I found that test data, certainly in the areas I was testing, was minimal, hand-crafted, and not reflective of the real usage of the api. So I rebuilt the test around real, generated data, and re-oriented the mocking from the higher level api to the lower level service api (workspace, user profile service). This allowed me to create a small set of supporting mocks which support the test data (covers all workspaces and user profiles), which can be reused in many tests. Further work is needed in that area to DRY out those tests.

…ame result fields to align with rest of kbase and be easier to understand, add suffix delimiter and fix index parsing.

Most of the functional changes to fix SCT-3001 and SCT-3002.
… to as the "context" (but just passes auth token around); missing access group throw error does not silently succeed; missing profile throws error does not silently succeed; fix dates to be uniform epoch ms; improve (make more uniform and understandable) result keys; refactor key mapping, copying, transformation, exclusion - the old logic was difficult to trace;
…indexed (at least no uniformly) and not supported in the user search tools; if features or subobjects should return to general search, it should be a generic feature without hardcoding of types.
@eapearson eapearson requested a review from scanon as a code owner April 20, 2021 00:22
@codecov
Copy link

codecov bot commented Apr 20, 2021

Codecov Report

Merging #52 (26173ab) into develop (925f322) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##           develop       #52   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           21        21           
  Lines          658       661    +3     
=========================================
+ Hits           658       661    +3     
Impacted Files Coverage Δ
src/es_client/query.py 100.00% <ø> (ø)
src/search2_rpc/service.py 100.00% <ø> (ø)
src/exceptions.py 100.00% <100.00%> (ø)
src/search1_conversion/convert_params.py 100.00% <100.00%> (ø)
src/search1_conversion/convert_result.py 100.00% <100.00%> (ø)
src/search1_rpc/service.py 100.00% <100.00%> (ø)
src/utils/config.py 100.00% <100.00%> (ø)
src/utils/formatting.py 100.00% <100.00%> (ø)
src/utils/user_profiles.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 925f322...26173ab. Read the comment docs.

Copy link
Member

@scanon scanon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing major. Just some questions.

I'm a little unclear on how the black listing is working now. Or was that a hold over when we were still doing wild card searches?

tests/integration/docker/docker-compose.yaml Show resolved Hide resolved
src/server/__main__.py Show resolved Hide resolved
src/search1_conversion/convert_result.py Outdated Show resolved Hide resolved
src/search1_conversion/convert_result.py Show resolved Hide resolved
src/search1_conversion/convert_params.py Show resolved Hide resolved
@scanon scanon merged commit e94fe95 into kbase:develop Apr 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants