Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
statestore-test.cc
Go to the documentation of this file.
1 // Copyright 2012 Cloudera Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
16 
17 #include <gtest/gtest.h>
18 #include "common/init.h"
19 #include "util/metrics.h"
21 
22 #include "common/names.h"
23 
24 using namespace impala;
25 
26 DECLARE_int32(webserver_port);
27 DECLARE_int32(state_store_port);
28 
29 namespace impala {
30 
31 TEST(StatestoreTest, SmokeTest) {
32  // All allocations done by 'new' to avoid problems shutting down Thrift servers
33  // gracefully.
34 
35  InProcessStatestore* statestore =
36  new InProcessStatestore(FLAGS_state_store_port, FLAGS_webserver_port);
37  ASSERT_TRUE(statestore->Start().ok());
38 
39  InProcessStatestore* statestore_wont_start =
40  new InProcessStatestore(FLAGS_state_store_port, FLAGS_webserver_port);
41  ASSERT_FALSE(statestore_wont_start->Start().ok());
42 
43  StatestoreSubscriber* sub_will_start = new StatestoreSubscriber("sub1",
44  MakeNetworkAddress("localhost", 12345),
45  MakeNetworkAddress("localhost", FLAGS_state_store_port), new MetricGroup(""));
46  ASSERT_TRUE(sub_will_start->Start().ok());
47 
48  // Confirm that a subscriber trying to use an in-use port will fail to start.
49  StatestoreSubscriber* sub_will_not_start = new StatestoreSubscriber("sub2",
50  MakeNetworkAddress("localhost", 12345),
51  MakeNetworkAddress("localhost", FLAGS_state_store_port), new MetricGroup(""));
52  ASSERT_FALSE(sub_will_not_start->Start().ok());
53 
54 }
55 
56 }
57 
58 int main(int argc, char **argv) {
59  InitCommonRuntime(argc, argv, false);
60  ::testing::InitGoogleTest(&argc, argv);
61  return RUN_ALL_TESTS();
62 }
An in-process statestore, with webserver and metrics.
int main(int argc, char **argv)
void InitCommonRuntime(int argc, char **argv, bool init_jvm, TestInfo::Mode m=TestInfo::NON_TEST)
Definition: init.cc:122
MetricGroups may be organised hierarchically as a tree.
Definition: metrics.h:200
TEST(AtomicTest, Basic)
Definition: atomic-test.cc:28
TNetworkAddress MakeNetworkAddress(const string &hostname, int port)
Definition: network-util.cc:96
DECLARE_int32(webserver_port)
Status Start()
Starts the statestore server, and the processing thread.
bool ok() const
Definition: status.h:172