/Users/deen/code/yugabyte-db/src/yb/docdb/docdb_test_base.cc
Line | Count | Source |
1 | | // Copyright (c) YugaByte, Inc. |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
4 | | // in compliance with the License. You may obtain a copy of the License at |
5 | | // |
6 | | // http://www.apache.org/licenses/LICENSE-2.0 |
7 | | // |
8 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
9 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
10 | | // or implied. See the License for the specific language governing permissions and limitations |
11 | | // under the License. |
12 | | // |
13 | | |
14 | | #include "yb/docdb/docdb_test_base.h" |
15 | | |
16 | | #include "yb/docdb/docdb.h" |
17 | | #include "yb/docdb/docdb_test_util.h" |
18 | | |
19 | | namespace yb { |
20 | | namespace docdb { |
21 | | |
22 | 119 | DocDBTestBase::DocDBTestBase() { |
23 | 119 | } |
24 | | |
25 | 118 | DocDBTestBase::~DocDBTestBase() { |
26 | 118 | } |
27 | | |
28 | 119 | void DocDBTestBase::SetUp() { |
29 | 119 | YBTest::SetUp(); |
30 | 119 | ASSERT_OK(InitRocksDBOptions()); |
31 | 119 | ASSERT_OK(InitRocksDBDir()); |
32 | 119 | ASSERT_OK(OpenRocksDB()); |
33 | 119 | ResetMonotonicCounter(); |
34 | 119 | } |
35 | | |
36 | 118 | void DocDBTestBase::TearDown() { |
37 | 118 | ASSERT_OK(DestroyRocksDB()); |
38 | 118 | YBTest::TearDown(); |
39 | 118 | } |
40 | | |
41 | 14 | void DocDBTestBase::CaptureLogicalSnapshot() { |
42 | 14 | logical_snapshots_.emplace_back(); |
43 | 14 | logical_snapshots_.back().Capture(rocksdb()); |
44 | 14 | } |
45 | | |
46 | 12 | void DocDBTestBase::ClearLogicalSnapshots() { |
47 | 12 | logical_snapshots_.clear(); |
48 | 12 | } |
49 | | |
50 | 18 | void DocDBTestBase::RestoreToRocksDBLogicalSnapshot(size_t snapshot_index) { |
51 | 18 | CHECK_LE(0, snapshot_index); |
52 | 18 | CHECK_LT(snapshot_index, logical_snapshots_.size()); |
53 | 18 | logical_snapshots_[snapshot_index].RestoreTo(rocksdb()); |
54 | 18 | } |
55 | | |
56 | | } // namespace docdb |
57 | | } // namespace yb |