35
35
36
36
import org .opensearch .action .admin .cluster .snapshots .create .CreateSnapshotResponse ;
37
37
import org .opensearch .action .admin .cluster .snapshots .restore .RestoreSnapshotResponse ;
38
- import org .opensearch .action .support .master .AcknowledgedResponse ;
39
38
import org .opensearch .client .Client ;
40
39
import org .opensearch .cluster .ClusterState ;
41
40
import org .opensearch .common .settings .Settings ;
45
44
import org .opensearch .repositories .blobstore .BlobStoreRepository ;
46
45
import org .opensearch .repositories .blobstore .BlobStoreTestUtil ;
47
46
import org .opensearch .snapshots .SnapshotState ;
47
+ import org .opensearch .test .OpenSearchIntegTestCase ;
48
48
import org .opensearch .test .OpenSearchSingleNodeTestCase ;
49
49
import org .opensearch .threadpool .ThreadPool ;
50
50
@@ -63,21 +63,13 @@ protected Collection<Class<? extends Plugin>> getPlugins() {
63
63
64
64
public void testSimpleWorkflow () {
65
65
Client client = client ();
66
-
67
- AcknowledgedResponse putRepositoryResponse = client .admin ()
68
- .cluster ()
69
- .preparePutRepository ("test-repo" )
70
- .setType ("hdfs" )
71
- .setSettings (
72
- Settings .builder ()
73
- .put ("uri" , "hdfs:///" )
74
- .put ("conf.fs.AbstractFileSystem.hdfs.impl" , TestingFs .class .getName ())
75
- .put ("path" , "foo" )
76
- .put ("chunk_size" , randomIntBetween (100 , 1000 ) + "k" )
77
- .put ("compress" , randomBoolean ())
78
- )
79
- .get ();
80
- assertThat (putRepositoryResponse .isAcknowledged (), equalTo (true ));
66
+ Settings .Builder settings = Settings .builder ()
67
+ .put ("uri" , "hdfs:///" )
68
+ .put ("conf.fs.AbstractFileSystem.hdfs.impl" , TestingFs .class .getName ())
69
+ .put ("path" , "foo" )
70
+ .put ("chunk_size" , randomIntBetween (100 , 1000 ) + "k" )
71
+ .put ("compress" , randomBoolean ());
72
+ OpenSearchIntegTestCase .putRepository (client .admin ().cluster (), "test-repo" , "hdfs" , settings );
81
73
82
74
createIndex ("test-idx-1" );
83
75
createIndex ("test-idx-2" );
@@ -168,7 +160,7 @@ public void testSimpleWorkflow() {
168
160
169
161
public void testMissingUri () {
170
162
try {
171
- client ().admin ().cluster (). preparePutRepository ( "test-repo" ). setType ( "hdfs" ). setSettings ( Settings .EMPTY ). get ( );
163
+ OpenSearchIntegTestCase . putRepository ( client ().admin ().cluster (), "test-repo" , "hdfs" , Settings .builder () );
172
164
fail ();
173
165
} catch (RepositoryException e ) {
174
166
assertTrue (e .getCause () instanceof IllegalArgumentException );
@@ -178,12 +170,8 @@ public void testMissingUri() {
178
170
179
171
public void testEmptyUri () {
180
172
try {
181
- client ().admin ()
182
- .cluster ()
183
- .preparePutRepository ("test-repo" )
184
- .setType ("hdfs" )
185
- .setSettings (Settings .builder ().put ("uri" , "/path" ).build ())
186
- .get ();
173
+ Settings .Builder settings = Settings .builder ().put ("uri" , "/path" );
174
+ OpenSearchIntegTestCase .putRepository (client ().admin ().cluster (), "test-repo" , "hdfs" , settings );
187
175
fail ();
188
176
} catch (RepositoryException e ) {
189
177
assertTrue (e .getCause () instanceof IllegalArgumentException );
@@ -193,12 +181,8 @@ public void testEmptyUri() {
193
181
194
182
public void testNonHdfsUri () {
195
183
try {
196
- client ().admin ()
197
- .cluster ()
198
- .preparePutRepository ("test-repo" )
199
- .setType ("hdfs" )
200
- .setSettings (Settings .builder ().put ("uri" , "file:///" ).build ())
201
- .get ();
184
+ Settings .Builder settings = Settings .builder ().put ("uri" , "file:///" );
185
+ OpenSearchIntegTestCase .putRepository (client ().admin ().cluster (), "test-repo" , "hdfs" , settings );
202
186
fail ();
203
187
} catch (RepositoryException e ) {
204
188
assertTrue (e .getCause () instanceof IllegalArgumentException );
@@ -208,12 +192,8 @@ public void testNonHdfsUri() {
208
192
209
193
public void testPathSpecifiedInHdfs () {
210
194
try {
211
- client ().admin ()
212
- .cluster ()
213
- .preparePutRepository ("test-repo" )
214
- .setType ("hdfs" )
215
- .setSettings (Settings .builder ().put ("uri" , "hdfs:///some/path" ).build ())
216
- .get ();
195
+ Settings .Builder settings = Settings .builder ().put ("uri" , "hdfs:///some/path" );
196
+ OpenSearchIntegTestCase .putRepository (client ().admin ().cluster (), "test-repo" , "hdfs" , settings );
217
197
fail ();
218
198
} catch (RepositoryException e ) {
219
199
assertTrue (e .getCause () instanceof IllegalArgumentException );
@@ -223,12 +203,8 @@ public void testPathSpecifiedInHdfs() {
223
203
224
204
public void testMissingPath () {
225
205
try {
226
- client ().admin ()
227
- .cluster ()
228
- .preparePutRepository ("test-repo" )
229
- .setType ("hdfs" )
230
- .setSettings (Settings .builder ().put ("uri" , "hdfs:///" ).build ())
231
- .get ();
206
+ Settings .Builder settings = Settings .builder ().put ("uri" , "hdfs:///" );
207
+ OpenSearchIntegTestCase .putRepository (client ().admin ().cluster (), "test-repo" , "hdfs" , settings );
232
208
fail ();
233
209
} catch (RepositoryException e ) {
234
210
assertTrue (e .getCause () instanceof IllegalArgumentException );
0 commit comments