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).
8 import org
.junit
.ClassRule
;
11 import java
.util
.Random
;
13 import static org
.assertj
.core
.api
.Assertions
.assertThat
;
15 public class IngestExternalFileOptionsTest
{
17 public static final RocksMemoryResource rocksMemoryResource
18 = new RocksMemoryResource();
20 public static final Random rand
=
21 PlatformRandomHelper
.getPlatformSpecificRandomFactory();
24 public void createExternalSstFileInfoWithoutParameters() {
25 try (final IngestExternalFileOptions options
=
26 new IngestExternalFileOptions()) {
27 assertThat(options
).isNotNull();
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
);
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
);
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
);
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
);
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
);
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();
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();