Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

Commit 14aead0

Browse files
committed
Add scope guards for config changes
1 parent 345026f commit 14aead0

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

omniscidb/Tests/GroupByTest.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "QueryEngine/CardinalityEstimator.h"
2323
#include "QueryEngine/Execute.h"
2424
#include "QueryEngine/InputMetadata.h"
25+
#include "Shared/scope.h"
2526

2627
#include <boost/filesystem.hpp>
2728
#include <fstream>
@@ -313,13 +314,16 @@ class LowCardinalityThresholdTest : public ::testing::Test {
313314
};
314315

315316
TEST_F(LowCardinalityThresholdTest, GroupBy) {
317+
const auto allow_cpu_retry_state = config().exec.heterogeneous.allow_cpu_retry;
318+
ScopeGuard reset = [&] {
319+
config().exec.heterogeneous.allow_cpu_retry = allow_cpu_retry_state;
320+
};
316321
config().exec.heterogeneous.allow_cpu_retry = true;
317322
for (auto dt : testedDevices()) {
318323
auto result = run_multiple_agg(
319324
R"(select fl,ar,dep from low_cardinality group by fl,ar,dep;)", dt);
320325
EXPECT_EQ(result->rowCount(), config().exec.group_by.big_group_threshold);
321326
}
322-
config().exec.heterogeneous.allow_cpu_retry = false;
323327
}
324328

325329
class BigCardinalityThresholdTest : public ::testing::Test {

omniscidb/Tests/ResultSetTest.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include "ArrowSQLRunner/ArrowSQLRunner.h"
2525
#include "ResultSetTestUtils.h"
26+
#include "Shared/scope.h"
2627
#include "TestHelpers.h"
2728

2829
#include "DataMgr/DataMgrDataProvider.h"
@@ -2967,6 +2968,14 @@ TEST(ResultsetConversion, EnforceParallelColumnarConversion) {
29672968
// we trigger parallel columnarize conversion for SELECT query
29682969
// so, the purpose of this test is to check
29692970
// whether the large columnar conversion is done correctly
2971+
const auto allow_cpu_retry_state = config().exec.heterogeneous.allow_cpu_retry;
2972+
const auto allow_query_step_cpu_retry_state =
2973+
config().exec.heterogeneous.allow_query_step_cpu_retry;
2974+
ScopeGuard reset = [&] {
2975+
config().exec.heterogeneous.allow_cpu_retry = allow_cpu_retry_state;
2976+
config().exec.heterogeneous.allow_query_step_cpu_retry =
2977+
allow_query_step_cpu_retry_state;
2978+
};
29702979
config().exec.heterogeneous.allow_cpu_retry = true;
29712980
config().exec.heterogeneous.allow_query_step_cpu_retry = true;
29722981

@@ -3014,8 +3023,6 @@ TEST(ResultsetConversion, EnforceParallelColumnarConversion) {
30143023
const auto crt_row2 = res2.get()->getNextRow(false, false);
30153024
EXPECT_EQ(answer, v<int64_t>(crt_row1[0]));
30163025
}
3017-
config().exec.heterogeneous.allow_cpu_retry = true;
3018-
config().exec.heterogeneous.allow_query_step_cpu_retry = true;
30193026
}
30203027

30213028
TEST(Util, ReinterpretBits) {

0 commit comments

Comments
 (0)