YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/src/yb/rocksdb/db/db_test2.cc
Line
Count
Source
1
//  Copyright (c) 2011-present, Facebook, Inc.  All rights reserved.
2
//  This source code is licensed under the BSD-style license found in the
3
//  LICENSE file in the root directory of this source tree. An additional grant
4
//  of patent rights can be found in the PATENTS file in the same directory.
5
//
6
// The following only applies to changes made to this file as part of YugaByte development.
7
//
8
// Portions Copyright (c) YugaByte, Inc.
9
//
10
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
11
// in compliance with the License.  You may obtain a copy of the License at
12
//
13
// http://www.apache.org/licenses/LICENSE-2.0
14
//
15
// Unless required by applicable law or agreed to in writing, software distributed under the License
16
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
17
// or implied.  See the License for the specific language governing permissions and limitations
18
// under the License.
19
//
20
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
21
// Use of this source code is governed by a BSD-style license that can be
22
// found in the LICENSE file. See the AUTHORS file for names of contributors.
23
#include "yb/rocksdb/db/db_test_util.h"
24
#include "yb/rocksdb/port/stack_trace.h"
25
26
namespace rocksdb {
27
28
class DBTest2 : public DBTestBase {
29
 public:
30
1
  DBTest2() : DBTestBase("/db_test2") {}
31
};
32
33
1
TEST_F(DBTest2, IteratorPropertyVersionNumber) {
34
1
  ASSERT_OK(Put("", ""));
35
1
  Iterator* iter1 = db_->NewIterator(ReadOptions());
36
1
  std::string prop_value;
37
1
  ASSERT_OK(
38
1
      iter1->GetProperty("rocksdb.iterator.super-version-number", &prop_value));
39
1
  uint64_t version_number1 =
40
1
      static_cast<uint64_t>(std::atoi(prop_value.c_str()));
41
42
1
  ASSERT_OK(Put("", ""));
43
1
  ASSERT_OK(Flush());
44
45
1
  Iterator* iter2 = db_->NewIterator(ReadOptions());
46
1
  ASSERT_OK(
47
1
      iter2->GetProperty("rocksdb.iterator.super-version-number", &prop_value));
48
1
  uint64_t version_number2 =
49
1
      static_cast<uint64_t>(std::atoi(prop_value.c_str()));
50
51
1
  ASSERT_GT(version_number2, version_number1);
52
53
1
  ASSERT_OK(Put("", ""));
54
55
1
  Iterator* iter3 = db_->NewIterator(ReadOptions());
56
1
  ASSERT_OK(
57
1
      iter3->GetProperty("rocksdb.iterator.super-version-number", &prop_value));
58
1
  uint64_t version_number3 =
59
1
      static_cast<uint64_t>(std::atoi(prop_value.c_str()));
60
61
1
  ASSERT_EQ(version_number2, version_number3);
62
63
1
  iter1->SeekToFirst();
64
1
  ASSERT_OK(
65
1
      iter1->GetProperty("rocksdb.iterator.super-version-number", &prop_value));
66
1
  uint64_t version_number1_new =
67
1
      static_cast<uint64_t>(std::atoi(prop_value.c_str()));
68
1
  ASSERT_EQ(version_number1, version_number1_new);
69
70
1
  delete iter1;
71
1
  delete iter2;
72
1
  delete iter3;
73
1
}
74
}  // namespace rocksdb
75
76
13.2k
int main(int argc, char** argv) {
77
13.2k
  rocksdb::port::InstallStackTraceHandler();
78
13.2k
  ::testing::InitGoogleTest(&argc, argv);
79
13.2k
  return RUN_ALL_TESTS();
80
13.2k
}