This repository was archived by the owner on May 15, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Allow a configurable default queue value on push and index requests #18
Open
cjohnson78
wants to merge
2
commits into
google-cloudsearch:master
Choose a base branch
from
sadasystems:default-queue-for-push-and-index-items
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -149,10 +149,10 @@ public class IndexingServiceTest { | |
|
|
||
| @Before | ||
| public void createService() throws IOException, GeneralSecurityException { | ||
| createService(false, false); | ||
| createService(false, false, null); | ||
| } | ||
|
|
||
| private void createService(boolean enableDebugging, boolean allowUnknownGsuitePrincipals) | ||
| private void createService(boolean enableDebugging, boolean allowUnknownGsuitePrincipals, String defaultQueue) | ||
| throws IOException, GeneralSecurityException { | ||
| this.transport = new TestingHttpTransport("datasources/source/connectors/unitTest"); | ||
| JsonFactory jsonFactory = JacksonFactory.getDefaultInstance(); | ||
|
|
@@ -191,6 +191,7 @@ private void createService(boolean enableDebugging, boolean allowUnknownGsuitePr | |
| .setConnectorId("unitTest") | ||
| .setEnableDebugging(enableDebugging) | ||
| .setAllowUnknownGsuitePrincipals(allowUnknownGsuitePrincipals) | ||
| .setDefaultQueue(defaultQueue) | ||
| .build(); | ||
| this.indexingService.startAsync().awaitRunning(); | ||
| } | ||
|
|
@@ -564,7 +565,7 @@ public void testUpdateItem() throws IOException, InterruptedException { | |
|
|
||
| @Test | ||
| public void testUpdateItemDebugOptionsEnabled() throws Exception { | ||
| createService(/*debugging*/ true, /*allowUnknownGsuitePrincipals*/ false); | ||
| createService(/*debugging*/ true, /*allowUnknownGsuitePrincipals*/ false, /*defaultQueue*/ null); | ||
| doAnswer( | ||
| invocation -> { | ||
| Items.Index updateRequest = invocation.getArgument(0); | ||
|
|
@@ -582,7 +583,7 @@ public void testUpdateItemDebugOptionsEnabled() throws Exception { | |
|
|
||
| @Test | ||
| public void testUpdateItemAllowUnknownGsuitePrincipals() throws Exception { | ||
| createService(/*debugging*/ false, /*allowUnknownGsuitePrincipals*/ true); | ||
| createService(/*debugging*/ false, /*allowUnknownGsuitePrincipals*/ true, /*defaultQueue*/ null); | ||
| doAnswer( | ||
| invocation -> { | ||
| Items.Index updateRequest = invocation.getArgument(0); | ||
|
|
@@ -731,6 +732,19 @@ public void testUpdateItemWithContentHash() throws IOException { | |
| verify(quotaServer, times(1)).acquire(Operations.DEFAULT); | ||
| } | ||
|
|
||
| @Test | ||
| public void testUpdateItemWithDefaultQueue() throws GeneralSecurityException, IOException { | ||
|
Contributor
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. nit, just throw Exception for tests (instead of all named individual exception).
Author
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. I was just copying existing test cases ; ) |
||
| createService(/*debugging*/ false, /*allowUnknownGsuitePrincipals*/ false, /*defaultQueue*/ "specialqueue"); | ||
| Item item = new Item().setName(GOOD_ID); | ||
| ByteArrayContent content = ByteArrayContent.fromString("text/plain", ""); | ||
| this.indexingService.indexItemAndContent( | ||
| item, content, null, ContentFormat.TEXT, RequestMode.ASYNCHRONOUS); | ||
| assertEquals( | ||
| "specialqueue", | ||
| item.getQueue()); | ||
| verify(quotaServer, times(1)).acquire(Operations.DEFAULT); | ||
| } | ||
|
|
||
| @Test | ||
| public void testUpdateItemError() throws IOException, InterruptedException { | ||
| doAnswer( | ||
|
|
@@ -1044,6 +1058,17 @@ public void testPushItemNull() throws IOException { | |
| this.indexingService.push(GOOD_ID, null); | ||
| } | ||
|
|
||
| @Test | ||
| public void testPushItemWithDefaultQueue() throws GeneralSecurityException, IOException { | ||
| createService(/*debugging*/ false, /*allowUnknownGsuitePrincipals*/ false, /*defaultQueue*/ "specialqueue"); | ||
| this.transport.addPushItemReqResp(GOOD_ID, SOURCE_ID, new Item()); | ||
| PushItem pushItem = new PushItem(); | ||
| this.indexingService.push(GOOD_ID, pushItem); | ||
| assertEquals( | ||
| "specialqueue", | ||
| pushItem.getQueue()); | ||
| } | ||
|
|
||
| /* unreserve */ | ||
| @Test | ||
| public void testUnreserveItem() throws IOException { | ||
|
|
||
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.
the method can be static
do we want to check if queue.isEmpty() ?
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.
added check for queue.isEmpty().
I do not see how this could be static, as it depends on this.defaultQueue