This is an automated email from the ASF dual-hosted git repository.

abukor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git

commit 1487467194075aaa285e4249f8e9552a756e9f01
Author: Attila Bukor <[email protected]>
AuthorDate: Thu Jan 6 18:47:05 2022 +0100

    [test] Add option to run tests with encrypted env
    
    Sometimes it's useful to run tests with data at rest encryption enabled.
    To make this possible, this patch introduces a new environment variable:
    KUDU_ENCRYPT_DATA_IN_TESTS.
    
    Change-Id: Id7cb84c3853126f561e31a2d843fa46a3a71d85a
    Reviewed-on: http://gerrit.cloudera.org:8080/18130
    Tested-by: Kudu Jenkins
    Reviewed-by: Andrew Wong <[email protected]>
---
 src/kudu/util/test_util.cc | 9 +++++++++
 src/kudu/util/test_util.h  | 2 ++
 2 files changed, 11 insertions(+)

diff --git a/src/kudu/util/test_util.cc b/src/kudu/util/test_util.cc
index a01fbb0..d6b12c7 100644
--- a/src/kudu/util/test_util.cc
+++ b/src/kudu/util/test_util.cc
@@ -66,6 +66,7 @@ DEFINE_string(test_leave_files, "on_failure",
 DEFINE_int32(test_random_seed, 0, "Random seed to use for randomized tests");
 
 DECLARE_string(time_source);
+DECLARE_bool(encrypt_data_at_rest);
 
 using std::string;
 using std::vector;
@@ -80,6 +81,7 @@ namespace kudu {
 const char* kInvalidPath = "/dev/invalid-path-for-kudu-tests";
 static const char* const kSlowTestsEnvVar = "KUDU_ALLOW_SLOW_TESTS";
 static const char* const kLargeKeysEnvVar = "KUDU_USE_LARGE_KEYS_IN_TESTS";
+static const char* const kEncryptDataInTests = "KUDU_ENCRYPT_DATA_IN_TESTS";
 
 static const uint64_t kTestBeganAtMicros = Env::Default()->NowMicros();
 
@@ -136,6 +138,11 @@ KuduTest::KuduTest()
     // reports an error since the flag is unknown to the gflags runtime.
     google::SetCommandLineOptionWithMode(e.first, e.second, 
google::SET_FLAGS_DEFAULT);
   }
+
+  if (EnableEncryption()) {
+    FLAGS_encrypt_data_at_rest = true;
+  }
+
   // If the TEST_TMPDIR variable has been set, then glog will automatically 
use that
   // as its default log directory. We would prefer that the default log 
directory
   // instead be the test-case-specific subdirectory.
@@ -195,6 +202,8 @@ bool AllowSlowTests() { return 
GetBooleanEnvironmentVariable(kSlowTestsEnvVar);
 
 bool UseLargeKeys() { return GetBooleanEnvironmentVariable(kLargeKeysEnvVar); }
 
+bool EnableEncryption() { return 
GetBooleanEnvironmentVariable(kEncryptDataInTests); }
+
 void OverrideFlagForSlowTests(const std::string& flag_name,
                               const std::string& new_value) {
   // Ensure that the flag is valid.
diff --git a/src/kudu/util/test_util.h b/src/kudu/util/test_util.h
index 47bdd0e..da972f4 100644
--- a/src/kudu/util/test_util.h
+++ b/src/kudu/util/test_util.h
@@ -95,6 +95,8 @@ bool AllowSlowTests();
 // to true. This is required to pass certain tests in FIPS approved mode.
 bool UseLargeKeys();
 
+bool EnableEncryption();
+
 // Override the given gflag to the new value, only in the case that
 // slow tests are enabled and the user hasn't otherwise overridden
 // it on the command line.

Reply via email to