17 package com.mapd.parser.server.test;
19 import static org.junit.Assert.*;
23 import org.apache.thrift.TException;
24 import org.apache.thrift.protocol.TBinaryProtocol;
25 import org.apache.thrift.protocol.TProtocol;
26 import org.apache.thrift.transport.TSocket;
27 import org.apache.thrift.transport.TTransport;
28 import org.junit.Ignore;
29 import org.junit.Test;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
33 import java.util.Random;
34 import java.util.concurrent.ExecutorService;
35 import java.util.concurrent.Executors;
37 import ai.heavy.thrift.server.Heavy;
38 import ai.heavy.thrift.server.TDBException;
39 import ai.heavy.thrift.server.TQueryResult;
42 private final static Logger
HEAVYDBLOGGER = LoggerFactory.getLogger(TestDBServer.class);
46 private volatile AssertionError
ae;
53 Runnable r =
new Runnable() {
58 Random r =
new Random();
59 int calCount = r.nextInt(9) + 1;
61 for (
int i = 1; i <= 100; i++) {
63 System.out.println(
"i is " + i);
65 if (calls > calCount) {
68 calCount = r.nextInt(9) + 1;
75 }
catch (AssertionError x) {
76 HEAVYDBLOGGER.error(
"error during Runnable");
90 while (!pool.isShutdown()) {
99 Random r =
new Random();
100 int aliasID = r.nextInt(100000) + 1000000;
101 int limit = r.nextInt(20) + 1;
107 "SELECT date_trunc(day, arr_timestamp) as key0,CASE when carrier_name IN ('Southwest Airlines','American Airlines','Skywest Airlines','American Eagle Airlines','US Airways') then carrier_name ELSE 'other' END as key1,COUNT(*) AS val FROM flights_2008_7m WHERE (arr_timestamp >= TIMESTAMP(0) '2008-01-01 00:57:00' AND arr_timestamp < TIMESTAMP(0) '2009-01-01 18:27:00') GROUP BY key0, key1 ORDER BY key0,key1",
112 String session = null;
113 TTransport transport = null;
114 Heavy.Client client = null;
116 transport =
new TSocket(
"localhost", 6274);
118 TProtocol protocol =
new TBinaryProtocol(transport);
119 client =
new Heavy.Client(protocol);
120 session = client.connect(
"admin",
"HyperInteractive",
"omnisci");
121 }
catch (TException x) {
122 fail(
"Exception on create occurred " + x.toString());
124 return new ConnInfo(session, transport, client);
129 TQueryResult
res = conn.client.sql_execute(conn.session, query,
true, null, -1, -1);
130 if (resultCount != res.row_set.columns.get(0).nulls.size()) {
131 fail(
"result doesn't match " + resultCount
132 +
" != " + res.row_set.columns.get(0).nulls.size());
134 }
catch (TDBException x) {
135 fail(
"Exception on EXECUTE " + x.getError_msg());
136 }
catch (TException x) {
137 fail(
"Exception on EXECUTE " + x.toString());
143 conn.client.disconnect(conn.session);
144 conn.transport.close();
145 }
catch (TException x) {
146 fail(
"Exception on close occurred " + x.toString());
void executeQuery(ConnInfo conn, String query, int resultCount)
ConnInfo createDBConnection()
static final Logger HEAVYDBLOGGER
volatile boolean threadHadFailure
static CalciteServerWrapper csw
volatile AssertionError ae
ConnInfo(String session, TTransport transport, Heavy.Client client)
void closeDBConnection(ConnInfo conn)
void randomDBCall(ConnInfo conn)
static final int TEST_THREAD_COUNT