-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Register CcrRepository based on settings update #36086
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
c92a1c7
Work RepositoriesService into CCR
Tim-Brooks a2c7576
WIP
Tim-Brooks e1b260e
WIP
Tim-Brooks b637022
Merge remote-tracking branch 'upstream/master' into add_ccr_repo_inte…
Tim-Brooks e45dfe7
Work on creating actions
Tim-Brooks 68823cc
WIP
Tim-Brooks 719e7e8
WIP
Tim-Brooks 1949578
WIP
Tim-Brooks 0f77fce
WIP
Tim-Brooks 3852087
Merge remote-tracking branch 'upstream/master' into add_ccr_repo_inte…
Tim-Brooks 3dd4a44
WIP
Tim-Brooks 8bf1a1d
WIP
Tim-Brooks 9dbf0c3
comment
Tim-Brooks 9e4736e
Fix checkstyle
Tim-Brooks 8f11a77
Changes from review
Tim-Brooks 4d58c11
Changes from review
Tim-Brooks a15bffd
Fix licenses
Tim-Brooks 2b79524
Fix license
Tim-Brooks 6cb2750
Changes for review
Tim-Brooks 777ece2
Merge remote-tracking branch 'upstream/master' into add_ccr_repo_inte…
Tim-Brooks 0259d7d
Changes
Tim-Brooks a7400cc
Add validation
Tim-Brooks 2dd4981
Changes for review
Tim-Brooks 987c5a5
Merge remote-tracking branch 'upstream/master' into add_ccr_repo_inte…
Tim-Brooks d5b9de8
Merge remote-tracking branch 'upstream/master' into add_ccr_repo_inte…
Tim-Brooks c73877a
Merge remote-tracking branch 'upstream/master' into add_ccr_repo_inte…
Tim-Brooks 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
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
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
101 changes: 101 additions & 0 deletions
101
server/src/test/java/org/elasticsearch/repositories/RepositoriesModuleTests.java
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 |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.repositories; | ||
|
||
import org.elasticsearch.cluster.service.ClusterService; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.common.xcontent.NamedXContentRegistry; | ||
import org.elasticsearch.env.Environment; | ||
import org.elasticsearch.plugins.RepositoryPlugin; | ||
import org.elasticsearch.test.ESTestCase; | ||
import org.elasticsearch.threadpool.ThreadPool; | ||
import org.elasticsearch.transport.TransportService; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
public class RepositoriesModuleTests extends ESTestCase { | ||
|
||
private Environment environment; | ||
private NamedXContentRegistry contentRegistry; | ||
private List<RepositoryPlugin> repoPlugins = new ArrayList<>(); | ||
private RepositoryPlugin plugin1; | ||
private RepositoryPlugin plugin2; | ||
private Repository.Factory factory; | ||
|
||
@Override | ||
public void setUp() throws Exception { | ||
super.setUp(); | ||
environment = mock(Environment.class); | ||
contentRegistry = mock(NamedXContentRegistry.class); | ||
plugin1 = mock(RepositoryPlugin.class); | ||
plugin2 = mock(RepositoryPlugin.class); | ||
factory = mock(Repository.Factory.class); | ||
repoPlugins.add(plugin1); | ||
repoPlugins.add(plugin2); | ||
when(environment.settings()).thenReturn(Settings.EMPTY); | ||
} | ||
|
||
public void testCanRegisterTwoRepositoriesWithDifferentTypes() { | ||
when(plugin1.getRepositories(environment, contentRegistry)).thenReturn(Collections.singletonMap("type1", factory)); | ||
when(plugin2.getRepositories(environment, contentRegistry)).thenReturn(Collections.singletonMap("type2", factory)); | ||
|
||
// Would throw | ||
new RepositoriesModule(environment, repoPlugins, mock(TransportService.class), mock(ClusterService.class), | ||
mock(ThreadPool.class), contentRegistry); | ||
} | ||
|
||
public void testCannotRegisterTwoRepositoriesWithSameTypes() { | ||
when(plugin1.getRepositories(environment, contentRegistry)).thenReturn(Collections.singletonMap("type1", factory)); | ||
when(plugin2.getRepositories(environment, contentRegistry)).thenReturn(Collections.singletonMap("type1", factory)); | ||
|
||
IllegalArgumentException ex = expectThrows(IllegalArgumentException.class, | ||
() -> new RepositoriesModule(environment, repoPlugins, mock(TransportService.class), mock(ClusterService.class), | ||
mock(ThreadPool.class), contentRegistry)); | ||
|
||
assertEquals("Repository type [type1] is already registered", ex.getMessage()); | ||
} | ||
|
||
public void testCannotRegisterTwoInternalRepositoriesWithSameTypes() { | ||
when(plugin1.getInternalRepositories(environment, contentRegistry)).thenReturn(Collections.singletonMap("type1", factory)); | ||
when(plugin2.getInternalRepositories(environment, contentRegistry)).thenReturn(Collections.singletonMap("type1", factory)); | ||
|
||
IllegalArgumentException ex = expectThrows(IllegalArgumentException.class, | ||
() -> new RepositoriesModule(environment, repoPlugins, mock(TransportService.class), mock(ClusterService.class), | ||
mock(ThreadPool.class), contentRegistry)); | ||
|
||
assertEquals("Internal repository type [type1] is already registered", ex.getMessage()); | ||
} | ||
|
||
public void testCannotRegisterNormalAndInternalRepositoriesWithSameTypes() { | ||
when(plugin1.getRepositories(environment, contentRegistry)).thenReturn(Collections.singletonMap("type1", factory)); | ||
when(plugin2.getInternalRepositories(environment, contentRegistry)).thenReturn(Collections.singletonMap("type1", factory)); | ||
|
||
IllegalArgumentException ex = expectThrows(IllegalArgumentException.class, | ||
() -> new RepositoriesModule(environment, repoPlugins, mock(TransportService.class), mock(ClusterService.class), | ||
mock(ThreadPool.class), contentRegistry)); | ||
|
||
assertEquals("Internal repository type [type1] is already registered as a non-internal repository", ex.getMessage()); | ||
} | ||
} |
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.
should we enforce that these types are distinct to the non-internal ones?
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.
add a test for this?