|
40 | 40 | import org.apache.doris.thrift.TMetadataTableRequestParams; |
41 | 41 | import org.apache.doris.thrift.TMetadataType; |
42 | 42 | import org.apache.doris.thrift.TNullableStringLiteral; |
| 43 | +import org.apache.doris.thrift.TRestoreSnapshotRequest; |
| 44 | +import org.apache.doris.thrift.TRestoreSnapshotResult; |
43 | 45 | import org.apache.doris.thrift.TSchemaTableName; |
44 | 46 | import org.apache.doris.thrift.TShowUserRequest; |
45 | 47 | import org.apache.doris.thrift.TShowUserResult; |
46 | 48 | import org.apache.doris.thrift.TStatusCode; |
47 | 49 | import org.apache.doris.utframe.UtFrameUtils; |
48 | 50 |
|
49 | 51 | import mockit.Mocked; |
| 52 | +import org.apache.thrift.TException; |
50 | 53 | import org.junit.AfterClass; |
51 | 54 | import org.junit.Assert; |
52 | 55 | import org.junit.BeforeClass; |
|
58 | 61 | import java.util.Arrays; |
59 | 62 | import java.util.HashMap; |
60 | 63 | import java.util.List; |
| 64 | +import java.util.Map; |
61 | 65 | import java.util.UUID; |
62 | 66 | import java.util.stream.Collectors; |
63 | 67 |
|
@@ -247,4 +251,66 @@ public void testShowUser() { |
247 | 251 | TShowUserResult result = impl.showUser(request); |
248 | 252 | System.out.println(result); |
249 | 253 | } |
| 254 | + |
| 255 | + @Test |
| 256 | + public void testRestoreSnapshotWithStorageMedium() throws TException { |
| 257 | + FrontendServiceImpl impl = new FrontendServiceImpl(exeEnv); |
| 258 | + TRestoreSnapshotRequest request = new TRestoreSnapshotRequest(); |
| 259 | + |
| 260 | + // Test with storage_medium parameter in properties |
| 261 | + Map<String, String> properties = new HashMap<>(); |
| 262 | + properties.put("storage_medium", "ssd"); |
| 263 | + request.setProperties(properties); |
| 264 | + |
| 265 | + TRestoreSnapshotResult result = impl.restoreSnapshot(request); |
| 266 | + Assert.assertNotNull(result); |
| 267 | + Assert.assertNotNull(result.getStatus()); |
| 268 | + } |
| 269 | + |
| 270 | + @Test |
| 271 | + public void testRestoreSnapshotWithMediumAllocationMode() throws TException { |
| 272 | + FrontendServiceImpl impl = new FrontendServiceImpl(exeEnv); |
| 273 | + TRestoreSnapshotRequest request = new TRestoreSnapshotRequest(); |
| 274 | + |
| 275 | + // Test with medium_allocation_mode parameter in properties |
| 276 | + Map<String, String> properties = new HashMap<>(); |
| 277 | + properties.put("medium_allocation_mode", "adaptive"); |
| 278 | + request.setProperties(properties); |
| 279 | + |
| 280 | + TRestoreSnapshotResult result = impl.restoreSnapshot(request); |
| 281 | + Assert.assertNotNull(result); |
| 282 | + Assert.assertNotNull(result.getStatus()); |
| 283 | + } |
| 284 | + |
| 285 | + @Test |
| 286 | + public void testRestoreSnapshotWithBothParameters() throws TException { |
| 287 | + FrontendServiceImpl impl = new FrontendServiceImpl(exeEnv); |
| 288 | + TRestoreSnapshotRequest request = new TRestoreSnapshotRequest(); |
| 289 | + |
| 290 | + // Test with both storage_medium and medium_allocation_mode in properties |
| 291 | + Map<String, String> properties = new HashMap<>(); |
| 292 | + properties.put("storage_medium", "hdd"); |
| 293 | + properties.put("medium_allocation_mode", "strict"); |
| 294 | + request.setProperties(properties); |
| 295 | + |
| 296 | + TRestoreSnapshotResult result = impl.restoreSnapshot(request); |
| 297 | + Assert.assertNotNull(result); |
| 298 | + Assert.assertNotNull(result.getStatus()); |
| 299 | + } |
| 300 | + |
| 301 | + @Test |
| 302 | + public void testRestoreSnapshotWithSameWithUpstream() throws TException { |
| 303 | + FrontendServiceImpl impl = new FrontendServiceImpl(exeEnv); |
| 304 | + TRestoreSnapshotRequest request = new TRestoreSnapshotRequest(); |
| 305 | + |
| 306 | + // Test with same_with_upstream storage medium in properties |
| 307 | + Map<String, String> properties = new HashMap<>(); |
| 308 | + properties.put("storage_medium", "same_with_upstream"); |
| 309 | + properties.put("medium_allocation_mode", "adaptive"); |
| 310 | + request.setProperties(properties); |
| 311 | + |
| 312 | + TRestoreSnapshotResult result = impl.restoreSnapshot(request); |
| 313 | + Assert.assertNotNull(result); |
| 314 | + Assert.assertNotNull(result.getStatus()); |
| 315 | + } |
250 | 316 | } |
0 commit comments