OmniSciDB  c07336695a
com.mapd.parser.server.test.TestServer Class Reference
+ Collaboration diagram for com.mapd.parser.server.test.TestServer:

Public Member Functions

void testThreadedCall ()
 
void testSimpleCall ()
 
void testRandomCall ()
 

Static Public Member Functions

static void startServer ()
 
static void stopServer ()
 

Private Member Functions

void randomCalciteCall ()
 
void callCalciteCheck (String query, String result)
 

Private Attributes

volatile int threadsRun = 0
 
volatile boolean threadHadFailure = false
 
volatile AssertionError ae
 

Static Private Attributes

static final Logger MAPDLOGGER = LoggerFactory.getLogger(TestServer.class)
 
static final int TEST_THREAD_COUNT = 3
 
static CalciteServerWrapper csw = null
 
static SockTransportProperties client_skT = null
 
static SockTransportProperties server_skT = null
 

Detailed Description

Definition at line 43 of file TestServer.java.

Member Function Documentation

◆ callCalciteCheck()

void com.mapd.parser.server.test.TestServer.callCalciteCheck ( String  query,
String  result 
)
inlineprivate

Definition at line 240 of file TestServer.java.

References client, and Testing.fail.

Referenced by com.mapd.parser.server.test.TestServer.randomCalciteCall(), and com.mapd.parser.server.test.TestServer.testSimpleCall().

240  {
241  try {
242  TTransport transport;
243  transport = new TSocket("localhost", 11000);
244  transport.open();
245  TProtocol protocol = new TBinaryProtocol(transport);
246  CalciteServer.Client client = new CalciteServer.Client(protocol);
247  TPlanResult algebra = client.process(
248  "user", "passwd", "SALES", query, new ArrayList<>(), false, false, false);
249  transport.close();
250  try {
251  assertEquals(algebra.plan_result, result);
252  } catch (AssertionError s) {
253  MAPDLOGGER.error("error during callCalciteCheck");
254  throw s;
255  }
256  } catch (TException x) {
257  fail("Exception occurred " + x.toString());
258  }
259  }
mapd::shared_ptr< MapDClient > client
static unsigned fail
Definition: testing.h:30
+ Here is the caller graph for this function:

◆ randomCalciteCall()

void com.mapd.parser.server.test.TestServer.randomCalciteCall ( )
inlineprivate

Definition at line 147 of file TestServer.java.

References com.mapd.parser.server.test.TestServer.callCalciteCheck(), and Experimental.String.

Referenced by com.mapd.parser.server.test.TestServer.testRandomCall(), and com.mapd.parser.server.test.TestServer.testThreadedCall().

147  {
148  Random r = new Random();
149  int aliasID = r.nextInt(100000) + 1000000;
151  String.format(
152  "Select TABALIAS%d.ENAME AS COLALIAS%d from EMP TABALIAS%d LIMIT %d",
153  aliasID,
154  aliasID,
155  aliasID,
156  aliasID),
157  String.format("{\n"
158  + " \"rels\": [\n"
159  + " {\n"
160  + " \"id\": \"0\",\n"
161  + " \"relOp\": \"LogicalTableScan\",\n"
162  + " \"fieldNames\": [\n"
163  + " \"EMPNO\",\n"
164  + " \"ENAME\",\n"
165  + " \"JOB\",\n"
166  + " \"MGR\",\n"
167  + " \"HIREDATE\",\n"
168  + " \"SAL\",\n"
169  + " \"COMM\",\n"
170  + " \"DEPTNO\",\n"
171  + " \"SLACKER\",\n"
172  + " \"SLACKARR1\",\n"
173  + " \"SLACKARR2\"\n"
174  + " ],\n"
175  + " \"table\": [\n"
176  + " \"CATALOG\",\n"
177  + " \"SALES\",\n"
178  + " \"EMP\"\n"
179  + " ],\n"
180  + " \"inputs\": []\n"
181  + " },\n"
182  + " {\n"
183  + " \"id\": \"1\",\n"
184  + " \"relOp\": \"LogicalProject\",\n"
185  + " \"fields\": [\n"
186  + " \"COLALIAS%d\"\n"
187  + " ],\n"
188  + " \"exprs\": [\n"
189  + " {\n"
190  + " \"input\": 1\n"
191  + " }\n"
192  + " ]\n"
193  + " },\n"
194  + " {\n"
195  + " \"id\": \"2\",\n"
196  + " \"relOp\": \"LogicalSort\",\n"
197  + " \"collation\": [],\n"
198  + " \"fetch\": {\n"
199  + " \"literal\": %d,\n"
200  + " \"type\": \"DECIMAL\",\n"
201  + " \"scale\": 0,\n"
202  + " \"precision\": 7,\n"
203  + " \"type_scale\": 0,\n"
204  + " \"type_precision\": 10\n"
205  + " }\n"
206  + " },\n"
207  + " {\n"
208  + " \"id\": \"3\",\n"
209  + " \"relOp\": \"LogicalProject\",\n"
210  + " \"fields\": [\n"
211  + " \"COLALIAS%d\"\n"
212  + " ],\n"
213  + " \"exprs\": [\n"
214  + " {\n"
215  + " \"input\": 0\n"
216  + " }\n"
217  + " ]\n"
218  + " },\n"
219  + " {\n"
220  + " \"id\": \"4\",\n"
221  + " \"relOp\": \"LogicalSort\",\n"
222  + " \"collation\": [],\n"
223  + " \"fetch\": {\n"
224  + " \"literal\": %d,\n"
225  + " \"type\": \"DECIMAL\",\n"
226  + " \"scale\": 0,\n"
227  + " \"precision\": 7,\n"
228  + " \"type_scale\": 0,\n"
229  + " \"type_precision\": 10\n"
230  + " }\n"
231  + " }\n"
232  + " ]\n"
233  + "}",
234  aliasID,
235  aliasID,
236  aliasID,
237  aliasID));
238  }
void callCalciteCheck(String query, String result)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ startServer()

static void com.mapd.parser.server.test.TestServer.startServer ( )
inlinestatic

Definition at line 54 of file TestServer.java.

54  {
55  csw = new CalciteServerWrapper(11000, 11001, "/data", null, client_skT, server_skT);
56  new Thread(csw).start();
57  }
static CalciteServerWrapper csw
Definition: TestServer.java:49
static SockTransportProperties client_skT
Definition: TestServer.java:50
static SockTransportProperties server_skT
Definition: TestServer.java:51

◆ stopServer()

static void com.mapd.parser.server.test.TestServer.stopServer ( )
inlinestatic

Definition at line 60 of file TestServer.java.

References com.mapd.parser.server.CalciteServerWrapper.stopServer().

+ Here is the call graph for this function:

◆ testRandomCall()

void com.mapd.parser.server.test.TestServer.testRandomCall ( )
inline

Definition at line 143 of file TestServer.java.

References com.mapd.parser.server.test.TestServer.randomCalciteCall().

143  {
145  }
+ Here is the call graph for this function:

◆ testSimpleCall()

void com.mapd.parser.server.test.TestServer.testSimpleCall ( )
inline

Definition at line 99 of file TestServer.java.

References com.mapd.parser.server.test.TestServer.callCalciteCheck().

99  {
100  callCalciteCheck("Select ENAME from EMP",
101  "{\n"
102  + " \"rels\": [\n"
103  + " {\n"
104  + " \"id\": \"0\",\n"
105  + " \"relOp\": \"LogicalTableScan\",\n"
106  + " \"fieldNames\": [\n"
107  + " \"EMPNO\",\n"
108  + " \"ENAME\",\n"
109  + " \"JOB\",\n"
110  + " \"MGR\",\n"
111  + " \"HIREDATE\",\n"
112  + " \"SAL\",\n"
113  + " \"COMM\",\n"
114  + " \"DEPTNO\",\n"
115  + " \"SLACKER\",\n"
116  + " \"SLACKARR1\",\n"
117  + " \"SLACKARR2\"\n"
118  + " ],\n"
119  + " \"table\": [\n"
120  + " \"CATALOG\",\n"
121  + " \"SALES\",\n"
122  + " \"EMP\"\n"
123  + " ],\n"
124  + " \"inputs\": []\n"
125  + " },\n"
126  + " {\n"
127  + " \"id\": \"1\",\n"
128  + " \"relOp\": \"LogicalProject\",\n"
129  + " \"fields\": [\n"
130  + " \"ENAME\"\n"
131  + " ],\n"
132  + " \"exprs\": [\n"
133  + " {\n"
134  + " \"input\": 1\n"
135  + " }\n"
136  + " ]\n"
137  + " }\n"
138  + " ]\n"
139  + "}");
140  }
void callCalciteCheck(String query, String result)
+ Here is the call graph for this function:

◆ testThreadedCall()

void com.mapd.parser.server.test.TestServer.testThreadedCall ( )
inline

Definition at line 65 of file TestServer.java.

References com.mapd.parser.server.test.TestServer.ae, com.mapd.parser.server.test.TestServer.randomCalciteCall(), run, and com.mapd.parser.server.test.TestServer.TEST_THREAD_COUNT.

65  {
66  final ExecutorService pool = Executors.newFixedThreadPool(TEST_THREAD_COUNT);
67 
68  Runnable r = new Runnable() {
69  @Override
70  public void run() {
71  try {
72  for (int i = 1; i <= 5; i++) {
74  }
75  } catch (AssertionError x) {
76  MAPDLOGGER.error("error during Runnable");
77  threadHadFailure = true;
78  ae = x;
79  }
80  threadsRun++;
82  pool.shutdown();
83  }
84  }
85  };
86 
87  for (int i = 0; i < TEST_THREAD_COUNT; i++) {
88  pool.submit(r);
89  }
90  while (!pool.isShutdown()) {
91  // stay alive
92  }
93  if (threadHadFailure) {
94  throw ae;
95  }
96  }
static bool run
+ Here is the call graph for this function:

Member Data Documentation

◆ ae

volatile AssertionError com.mapd.parser.server.test.TestServer.ae
private

◆ client_skT

SockTransportProperties com.mapd.parser.server.test.TestServer.client_skT = null
staticprivate

Definition at line 50 of file TestServer.java.

◆ csw

CalciteServerWrapper com.mapd.parser.server.test.TestServer.csw = null
staticprivate

Definition at line 49 of file TestServer.java.

◆ MAPDLOGGER

final Logger com.mapd.parser.server.test.TestServer.MAPDLOGGER = LoggerFactory.getLogger(TestServer.class)
staticprivate

Definition at line 44 of file TestServer.java.

◆ server_skT

SockTransportProperties com.mapd.parser.server.test.TestServer.server_skT = null
staticprivate

Definition at line 51 of file TestServer.java.

◆ TEST_THREAD_COUNT

final int com.mapd.parser.server.test.TestServer.TEST_THREAD_COUNT = 3
staticprivate

◆ threadHadFailure

volatile boolean com.mapd.parser.server.test.TestServer.threadHadFailure = false
private

Definition at line 47 of file TestServer.java.

◆ threadsRun

volatile int com.mapd.parser.server.test.TestServer.threadsRun = 0
private

Definition at line 46 of file TestServer.java.


The documentation for this class was generated from the following file: