This repository has been archived by the owner on Mar 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 86
Random test failures because of work item creation error (#1676) #1677
Merged
xcoulon
merged 21 commits into
fabric8-services:master
from
xcoulon:Issue1676_test_failures_duplicate_key
Oct 12, 2017
Merged
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
27d530d
Stabilize/disable tests related to if_modified_since_header (#1655)
xcoulon 3481ff7
Random test failures because of work item creation error (#1676)
xcoulon 79ce30a
Taking comments into account
xcoulon d175ffd
Merge branch 'master' into Issue1676_test_failures_duplicate_key
xcoulon 461eeca
Refactor the `SearchByText` test
xcoulon b01a50c
Merge branch 'master' into Issue1676_test_failures_duplicate_key
xcoulon afe48ec
Addressing review comments
xcoulon d981209
Merge branch 'master' into Issue1676_test_failures_duplicate_key
xcoulon 4477a20
Fix test failures (register URL pattern)
xcoulon 1cb3ca8
Adding a test to create work items concurrently
xcoulon 6e24feb
Merge branch 'master' into Issue1676_test_failures_duplicate_key
xcoulon d07b413
Refactor identities creation in test
xcoulon c74f9b0
Refactor TestSearch (again)
xcoulon 15a49f8
Using constants for work item states
xcoulon 9df5af2
Simplify tests
xcoulon 65f499b
Merge branch 'master' into Issue1676_test_failures_duplicate_key
xcoulon fb7379e
More review comments
xcoulon 21d67d8
Merge branch 'master' into Issue1676_test_failures_duplicate_key
xcoulon 0cfb792
Create 10 work items per test
xcoulon 6cc2e96
refactor the search tests using subtests, and fix race condition in c…
xcoulon 239517b
Merge branch 'master' into Issue1676_test_failures_duplicate_key
xcoulon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -174,7 +174,9 @@ func getSearchQueryFromURLPattern(patternName, stringToMatch string) string { | |
searchQueryString = fmt.Sprintf("%s:*", searchQueryString) | ||
if result["id"] != "" { | ||
// Look for pattern's ID field, if exists update searchQueryString | ||
searchQueryString = fmt.Sprintf("(%v:* | %v)", result["id"], searchQueryString) | ||
// `*A` is used to add sme weight to the work item number in the search results. | ||
// See https://www.postgresql.org/docs/9.6/static/textsearch-controls.html | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @xcoulon for adding this reference! |
||
searchQueryString = fmt.Sprintf("(%v:*A | %v)", result["id"], searchQueryString) | ||
// searchQueryString = "(" + result["id"] + ":*" + " | " + searchQueryString + ")" | ||
} | ||
return searchQueryString | ||
|
@@ -239,9 +241,11 @@ func parseSearchString(ctx context.Context, rawSearchString string) (searchKeywo | |
} | ||
res.workItemTypes = append(res.workItemTypes, typeID) | ||
} else if govalidator.IsURL(part) { | ||
log.Debug(ctx, map[string]interface{}{"url": part}, "found a URL in the query string") | ||
part := strings.ToLower(part) | ||
part = trimProtocolFromURLString(part) | ||
searchQueryFromURL := getSearchQueryFromURLString(part) | ||
log.Debug(ctx, map[string]interface{}{"url": part, "search_query": searchQueryFromURL}, "found a URL in the query string") | ||
res.words = append(res.words, searchQueryFromURL) | ||
} else { | ||
part := strings.ToLower(part) | ||
|
@@ -446,7 +450,6 @@ func (q Query) generateExpression() (criteria.Expression, error) { | |
|
||
// parseFilterString accepts a raw string and generates a criteria expression | ||
func parseFilterString(ctx context.Context, rawSearchString string) (criteria.Expression, error) { | ||
|
||
fm := map[string]interface{}{} | ||
// Parsing/Unmarshalling JSON encoding/json | ||
err := json.Unmarshal([]byte(rawSearchString), &fm) | ||
|
@@ -481,7 +484,6 @@ func generateSQLSearchInfo(keywords searchKeyword) (sqlParameter string) { | |
// extracted this function from List() in order to close the rows object with "defer" for more readability | ||
// workaround for https://github.com/lib/pq/issues/81 | ||
func (r *GormSearchRepository) search(ctx context.Context, sqlSearchQueryParameter string, workItemTypes []uuid.UUID, start *int, limit *int, spaceID *string) ([]workitem.WorkItemStorage, uint64, error) { | ||
log.Info(ctx, nil, "Searching work items...") | ||
db := r.db.Model(workitem.WorkItemStorage{}).Where("tsv @@ query") | ||
if start != nil { | ||
if *start < 0 { | ||
|
@@ -573,6 +575,7 @@ func (r *GormSearchRepository) SearchFullText(ctx context.Context, rawSearchStri | |
|
||
sqlSearchQueryParameter := generateSQLSearchInfo(parsedSearchDict) | ||
var rows []workitem.WorkItemStorage | ||
log.Debug(ctx, map[string]interface{}{"search query": sqlSearchQueryParameter}, "searching for work items") | ||
rows, count, err := r.search(ctx, sqlSearchQueryParameter, parsedSearchDict.workItemTypes, start, limit, spaceID) | ||
if err != nil { | ||
return nil, 0, errs.WithStack(err) | ||
|
@@ -741,10 +744,3 @@ func (r *GormSearchRepository) Filter(ctx context.Context, rawFilterString strin | |
} | ||
return res, count, nil | ||
} | ||
|
||
func init() { | ||
// While registering URLs do not include protocol because it will be removed before scanning starts | ||
// Please do not include trailing slashes because it will be removed before scanning starts | ||
RegisterAsKnownURL("test-work-item-list-details", `(?P<domain>demo.almighty.io)(?P<path>/work-item/list/detail/)(?P<id>\d*)`) | ||
RegisterAsKnownURL("test-work-item-board-details", `(?P<domain>demo.almighty.io)(?P<path>/work-item/board/detail/)(?P<id>\d*)`) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to just reduce the test output by setting
F8_LOG_LEVEL=error
instead of changing the level code-wise. Most repo create functions uselog.Info
. Also run tests withgo test
instead ofgo test -v
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know I can do that (
F8_LOG_LEVEL=error
andgo test
without theverbose
flag), but do we really need those logs statements at theINFO
level ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not. Did you cover all "created X" log messages? Then it is fine to change to Debug if you ask me. I mostly feared mixing concerns of this PR.