YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/src/yb/consensus/log_util-test.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 <gtest/gtest.h>
15
16
#include "yb/consensus/log_util.h"
17
#include "yb/util/test_macros.h"
18
19
namespace yb {
20
21
#if defined(__linux__)
22
TEST(TestLogUtil, TestModifyDurableWriteFlagIfNotDirectNegative) {
23
  gflags::FlagSaver flag_saver;
24
  FLAGS_fs_data_dirs = "/var/run";
25
26
  // Test that the method does not crash and durable_wal_write is flipped
27
  // when directory is not O_DIRECT writable.
28
  FLAGS_durable_wal_write = true;
29
  FLAGS_require_durable_wal_write = false;
30
  ASSERT_OK(log::ModifyDurableWriteFlagIfNotODirect());
31
  ASSERT_EQ(FLAGS_durable_wal_write, false);
32
33
  // Test that the method crashes when durable_wal_write is set to true.
34
  FLAGS_durable_wal_write = true;
35
  FLAGS_require_durable_wal_write = true;
36
  ASSERT_NOK(log::ModifyDurableWriteFlagIfNotODirect());
37
}
38
#endif
39
40
1
TEST(TestLogUtil, TestModifyDurableWriteFlagIfNotODirectPositive) {
41
1
  gflags::FlagSaver flag_saver;
42
  // Test that the method does not crash when durable_wal_write is set true and paths are O_DIRECT
43
  // Writable.
44
1
  FLAGS_durable_wal_write = true;
45
1
  ASSERT_OK(log::ModifyDurableWriteFlagIfNotODirect());
46
  // Test that the method does not crash when durable_wal_write is set to false.
47
1
  FLAGS_durable_wal_write = false;
48
1
  ASSERT_OK(log::ModifyDurableWriteFlagIfNotODirect());
49
1
}
50
} // namespace yb