Files
impala/be/src/util/thread-pool-test.cc
Alex Behm 7e76e92bef Consolidate test and cluster logs under a single directory.
All logs, test results and SQL files generated during data
loading and testing are now consolidated under a single new
directory $IMPALA_HOME/logs. The goal is to simplify archiving
in Jenkins runs and debugging.

The new structure is as follows:

$IMPALA_HOME/logs/cluster
- logs of Hadoop components and Impala

$IMPALA_HOME/logs/data_loading
- logs and SQL files produced in data loading

$IMPALA_HOME/logs/fe_tests
- logs and test output of Frontend unit tests

$IMPALA_HOME/logs/be_tests
- logs and test output of Backend unit tests

$IMPALA_HOME/logs/ee_tests
- logs and test output of end-to-end tests

$IMPALA_HOME/logs/custom_cluster_tests
- logs and test output of custom cluster tests

I tested this change with a full data load which
was successful.

Change-Id: Ief1f58f3320ec39d31b3c6bc6ef87f58ff7dfdfa
Reviewed-on: http://gerrit.cloudera.org:8080/2456
Reviewed-by: Alex Behm <alex.behm@cloudera.com>
Tested-by: Internal Jenkins
2016-03-28 19:23:22 +00:00

75 lines
2.1 KiB
C++

// Copyright 2013 Cloudera Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <boost/thread.hpp>
#include <boost/thread/mutex.hpp>
#include <glog/logging.h>
#include <gtest/gtest.h>
#include <unistd.h>
#include "common/init.h"
#include "common/logging.h"
#include "util/thread-pool.h"
#include "common/names.h"
namespace impala {
const int NUM_THREADS = 5;
int thread_counters[NUM_THREADS];
// Per-thread mutex to ensure visibility of counters after thread pool terminates
mutex thread_mutexes[NUM_THREADS];
void Count(int thread_id, const int& i) {
lock_guard<mutex> l(thread_mutexes[thread_id]);
thread_counters[thread_id] += i;
}
TEST(ThreadPoolTest, BasicTest) {
const int OFFERED_RANGE = 10000;
for (int i = 0; i < NUM_THREADS; ++i) {
thread_counters[i] = 0;
}
ThreadPool<int> thread_pool("thread-pool", "worker", 5, 250, Count);
for (int i = 0; i <= OFFERED_RANGE; ++i) {
ASSERT_TRUE(thread_pool.Offer(i));
}
thread_pool.DrainAndShutdown();
// Check that Offer() after Shutdown() will return false
ASSERT_FALSE(thread_pool.Offer(-1));
EXPECT_EQ(0, thread_pool.GetQueueSize());
int expected_count = (OFFERED_RANGE * (OFFERED_RANGE + 1)) / 2;
int count = 0;
for (int i = 0; i < NUM_THREADS; ++i) {
lock_guard<mutex> l(thread_mutexes[i]);
LOG(INFO) << "Counter " << i << ": " << thread_counters[i];
count += thread_counters[i];
}
EXPECT_EQ(expected_count, count);
}
}
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
impala::InitCommonRuntime(argc, argv, true, impala::TestInfo::BE_TEST);
return RUN_ALL_TESTS();
}