-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Dharmesh 💤 <[email protected]>
- Loading branch information
Showing
5 changed files
with
179 additions
and
1 deletion.
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
71 changes: 71 additions & 0 deletions
71
server/src/internalClusterTest/java/org/opensearch/snapshots/SystemRepositoryIT.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,71 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.snapshots; | ||
|
||
import org.opensearch.client.Client; | ||
import org.opensearch.common.settings.Settings; | ||
import org.opensearch.core.common.unit.ByteSizeValue; | ||
import org.opensearch.repositories.RepositoryException; | ||
import org.opensearch.repositories.fs.FsRepository; | ||
import org.opensearch.test.OpenSearchIntegTestCase; | ||
import org.junit.Before; | ||
|
||
import java.nio.file.Path; | ||
|
||
import static org.opensearch.remotestore.RemoteStoreBaseIntegTestCase.remoteStoreClusterSettings; | ||
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked; | ||
|
||
@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, numDataNodes = 0) | ||
public class SystemRepositoryIT extends AbstractSnapshotIntegTestCase { | ||
protected Path absolutePath; | ||
final String systemRepoName = "system-repo-name"; | ||
|
||
@Before | ||
public void setup() { | ||
absolutePath = randomRepoPath().toAbsolutePath(); | ||
} | ||
|
||
@Override | ||
protected Settings nodeSettings(int nodeOrdinal) { | ||
return Settings.builder() | ||
.put(super.nodeSettings(nodeOrdinal)) | ||
.put(remoteStoreClusterSettings(systemRepoName, absolutePath)) | ||
.build(); | ||
} | ||
|
||
public void testRestrictedSettingsCantBeUpdated() { | ||
disableRepoConsistencyCheck("System repository is being used for the test"); | ||
|
||
internalCluster().startNode(); | ||
final Client client = client(); | ||
final Settings.Builder repoSettings = Settings.builder().put("location", randomRepoPath()); | ||
|
||
RepositoryException e = expectThrows( | ||
RepositoryException.class, | ||
() -> client.admin().cluster().preparePutRepository(systemRepoName).setType("mock").setSettings(repoSettings).get() | ||
); | ||
assertEquals( | ||
e.getMessage(), | ||
"[system-repo-name] trying to modify an unmodifiable attribute type of system " | ||
+ "repository from current value [fs] to new value [mock]" | ||
); | ||
} | ||
|
||
public void testSystemRepositoryNonRestrictedSettingsCanBeUpdated() { | ||
disableRepoConsistencyCheck("System repository is being used for the test"); | ||
|
||
internalCluster().startNode(); | ||
final Client client = client(); | ||
final Settings.Builder repoSettings = Settings.builder().put("location", absolutePath).put("chunk_size", new ByteSizeValue(20)); | ||
|
||
assertAcked( | ||
client.admin().cluster().preparePutRepository(systemRepoName).setType(FsRepository.TYPE).setSettings(repoSettings).get() | ||
); | ||
} | ||
} |