17 package com.mapd.parser.server.test;
19 import static org.junit.Assert.*;
22 import com.omnisci.thrift.server.OmniSci;
23 import com.omnisci.thrift.server.TOmniSciException;
24 import com.omnisci.thrift.server.TQueryResult;
26 import org.apache.thrift.TException;
27 import org.apache.thrift.protocol.TBinaryProtocol;
28 import org.apache.thrift.protocol.TProtocol;
29 import org.apache.thrift.transport.TSocket;
30 import org.apache.thrift.transport.TTransport;
31 import org.junit.Ignore;
32 import org.junit.Test;
33 import org.slf4j.Logger;
34 import org.slf4j.LoggerFactory;
36 import java.util.Random;
37 import java.util.concurrent.ExecutorService;
38 import java.util.concurrent.Executors;
41 private final static Logger
MAPDLOGGER = LoggerFactory.getLogger(TestMapDServer.class);
45 private volatile AssertionError
ae;
52 Runnable r =
new Runnable() {
57 Random r =
new Random();
58 int calCount = r.nextInt(9) + 1;
60 for (
int i = 1; i <= 100; i++) {
62 System.out.println(
"i is " + i);
64 if (calls > calCount) {
67 calCount = r.nextInt(9) + 1;
74 }
catch (AssertionError x) {
75 MAPDLOGGER.error(
"error during Runnable");
89 while (!pool.isShutdown()) {
98 Random r =
new Random();
99 int aliasID = r.nextInt(100000) + 1000000;
100 int limit = r.nextInt(20) + 1;
106 "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",
111 String session = null;
112 TTransport transport = null;
113 OmniSci.Client client = null;
115 transport =
new TSocket(
"localhost", 6274);
117 TProtocol protocol =
new TBinaryProtocol(transport);
118 client =
new OmniSci.Client(protocol);
119 session = client.connect(
"admin",
"HyperInteractive",
"omnisci");
120 }
catch (TException x) {
121 fail(
"Exception on create occurred " + x.toString());
123 return new ConnInfo(session, transport, client);
128 TQueryResult
res = conn.client.sql_execute(conn.session, query,
true, null, -1, -1);
129 if (resultCount != res.row_set.columns.get(0).nulls.size()) {
130 fail(
"result doesn't match " + resultCount
131 +
" != " + res.row_set.columns.get(0).nulls.size());
133 }
catch (TOmniSciException x) {
134 fail(
"Exception on EXECUTE " + x.toString());
135 }
catch (TException x) {
136 fail(
"Exception on EXECUTE " + x.toString());
142 conn.client.disconnect(conn.session);
143 conn.transport.close();
144 }
catch (TException x) {
145 fail(
"Exception on close occurred " + x.toString());
void randomMapDCall(ConnInfo conn)
static final Logger MAPDLOGGER
void executeQuery(ConnInfo conn, String query, int resultCount)
void closeMapDConnection(ConnInfo conn)
volatile AssertionError ae
ConnInfo createMapDConnection()
static CalciteServerWrapper csw
ConnInfo(String session, TTransport transport, OmniSci.Client client)
static final int TEST_THREAD_COUNT
volatile boolean threadHadFailure