16 package com.mapd.tests;
18 import static com.mapd.tests.HeavyDBAsserts.shouldThrowException;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
23 import java.util.ArrayList;
24 import java.util.List;
27 final static Logger
logger = LoggerFactory.getLogger(CalciteViewsConcurrencyTest.class);
29 public static void main(String[]
args)
throws Exception {
31 test.testViewsResolutionConcurrency();
35 logger.info(
"testViewsResolutionConcurrency()");
38 "localhost", 6274,
"heavyai",
"admin",
"HyperInteractive");
40 su.runSql(
"CREATE DATABASE db1;");
41 su.runSql(
"CREATE DATABASE db2;");
44 "localhost", 6274,
"db1",
"admin",
"HyperInteractive");
45 db1.runSql(
"create table table1 (id integer, description varchar(30));");
46 db1.runSql(
"create table table2 (id integer, description varchar(30));");
47 db1.runSql(
"insert into table1 values (1, 'hello');");
48 db1.runSql(
"insert into table2 values (1, 'db1');");
50 "create view v_goodview as select t1.id, t1.description, t2.description as tbl2Desc from db1.table1 t1, db1.table2 t2;");
53 "localhost", 6274,
"db2",
"admin",
"HyperInteractive");
54 db2.runSql(
"create table table1 (id integer, description varchar(30));");
55 db2.runSql(
"create table table2 (id integer, description varchar(30));");
56 db2.runSql(
"insert into table1 values (1, 'hello');");
57 db2.runSql(
"insert into table2 values (1, 'db2');");
59 "create view v_goodview as select t1.id, t1.description, t2.description as tbl2Desc from db2.table1 t1, db2.table2 t2;");
62 Exception exceptions[] =
new Exception[num_threads];
63 List<Thread> threads =
new ArrayList<>();
64 for (
int i = 0; i < num_threads; i++) {
65 final int threadId = i;
67 "localhost", 6274,
"db1",
"admin",
"HyperInteractive");
69 "localhost", 6274,
"db2",
"admin",
"HyperInteractive");
70 Thread t =
new Thread(
new Runnable() {
74 for (
int i = 0; i < 25; i++) {
75 con1.runSql(
"SELECT * FROM v_goodview;");
76 con2.runSql(
"SELECT * FROM v_goodview;");
78 }
catch (Exception e) {
80 exceptions[threadId] = e;
89 for (Thread t : threads) {
93 su.runSql(
"DROP DATABASE db1;");
94 su.runSql(
"DROP DATABASE db2;");
96 for (Exception e : exceptions) {
void testViewsResolutionConcurrency()
static final Logger logger
static void main(String[] args)