]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/java/src/test/java/org/rocksdb/IngestExternalFileOptionsTest.java
import 14.2.4 nautilus point release
[ceph.git] / ceph / src / rocksdb / java / src / test / java / org / rocksdb / IngestExternalFileOptionsTest.java
1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under both the GPLv2 (found in the
3 // COPYING file in the root directory) and Apache 2.0 License
4 // (found in the LICENSE.Apache file in the root directory).
5
6 package org.rocksdb;
7
8 import org.junit.ClassRule;
9 import org.junit.Test;
10
11 import java.util.Random;
12
13 import static org.assertj.core.api.Assertions.assertThat;
14
15 public class IngestExternalFileOptionsTest {
16 @ClassRule
17 public static final RocksMemoryResource rocksMemoryResource
18 = new RocksMemoryResource();
19
20 public static final Random rand =
21 PlatformRandomHelper.getPlatformSpecificRandomFactory();
22
23 @Test
24 public void createExternalSstFileInfoWithoutParameters() {
25 try (final IngestExternalFileOptions options =
26 new IngestExternalFileOptions()) {
27 assertThat(options).isNotNull();
28 }
29 }
30
31 @Test
32 public void createExternalSstFileInfoWithParameters() {
33 final boolean moveFiles = rand.nextBoolean();
34 final boolean snapshotConsistency = rand.nextBoolean();
35 final boolean allowGlobalSeqNo = rand.nextBoolean();
36 final boolean allowBlockingFlush = rand.nextBoolean();
37 try (final IngestExternalFileOptions options =
38 new IngestExternalFileOptions(moveFiles, snapshotConsistency,
39 allowGlobalSeqNo, allowBlockingFlush)) {
40 assertThat(options).isNotNull();
41 assertThat(options.moveFiles()).isEqualTo(moveFiles);
42 assertThat(options.snapshotConsistency()).isEqualTo(snapshotConsistency);
43 assertThat(options.allowGlobalSeqNo()).isEqualTo(allowGlobalSeqNo);
44 assertThat(options.allowBlockingFlush()).isEqualTo(allowBlockingFlush);
45 }
46 }
47
48 @Test
49 public void moveFiles() {
50 try (final IngestExternalFileOptions options =
51 new IngestExternalFileOptions()) {
52 final boolean moveFiles = rand.nextBoolean();
53 options.setMoveFiles(moveFiles);
54 assertThat(options.moveFiles()).isEqualTo(moveFiles);
55 }
56 }
57
58 @Test
59 public void snapshotConsistency() {
60 try (final IngestExternalFileOptions options =
61 new IngestExternalFileOptions()) {
62 final boolean snapshotConsistency = rand.nextBoolean();
63 options.setSnapshotConsistency(snapshotConsistency);
64 assertThat(options.snapshotConsistency()).isEqualTo(snapshotConsistency);
65 }
66 }
67
68 @Test
69 public void allowGlobalSeqNo() {
70 try (final IngestExternalFileOptions options =
71 new IngestExternalFileOptions()) {
72 final boolean allowGlobalSeqNo = rand.nextBoolean();
73 options.setAllowGlobalSeqNo(allowGlobalSeqNo);
74 assertThat(options.allowGlobalSeqNo()).isEqualTo(allowGlobalSeqNo);
75 }
76 }
77
78 @Test
79 public void allowBlockingFlush() {
80 try (final IngestExternalFileOptions options =
81 new IngestExternalFileOptions()) {
82 final boolean allowBlockingFlush = rand.nextBoolean();
83 options.setAllowBlockingFlush(allowBlockingFlush);
84 assertThat(options.allowBlockingFlush()).isEqualTo(allowBlockingFlush);
85 }
86 }
87
88 @Test
89 public void ingestBehind() {
90 try (final IngestExternalFileOptions options =
91 new IngestExternalFileOptions()) {
92 assertThat(options.ingestBehind()).isFalse();
93 options.setIngestBehind(true);
94 assertThat(options.ingestBehind()).isTrue();
95 }
96 }
97
98 @Test
99 public void writeGlobalSeqno() {
100 try (final IngestExternalFileOptions options =
101 new IngestExternalFileOptions()) {
102 assertThat(options.writeGlobalSeqno()).isTrue();
103 options.setWriteGlobalSeqno(false);
104 assertThat(options.writeGlobalSeqno()).isFalse();
105 }
106 }
107 }