|
static void | main (String[] args) throws Exception |
|
|
static final Logger | logger = LoggerFactory.getLogger(CatalogConcurrencyTest.class) |
|
Definition at line 23 of file CatalogConcurrencyTest.java.
static void com.mapd.tests.CatalogConcurrencyTest.main |
( |
String[] |
args | ) |
throws Exception |
|
inlinestatic |
Definition at line 26 of file CatalogConcurrencyTest.java.
27 CatalogConcurrencyTest test =
new CatalogConcurrencyTest();
28 test.testCatalogConcurrency();
Definition at line 31 of file CatalogConcurrencyTest.java.
Referenced by com.mapd.tests.CatalogConcurrencyTest.runTest().
34 final String sharedTableName =
"table_shared";
35 for (
int i = 0; i < max; i++) {
36 String tableName =
"table_" + prefix +
"_" + i;
37 String viewName =
"view_" + prefix +
"_" + i;
38 String dashName =
"dash_" + prefix +
"_" + i;
39 long tid = Thread.currentThread().getId();
41 logger.info(
"[" + tid +
"]"
42 +
"CREATE " + tableName);
43 user.runSql(
"CREATE TABLE " + tableName +
" (id text);");
44 HeavyDBAsserts.assertEqual(
true, null != dba.get_table_details(tableName));
45 logger.info(
"[" + tid +
"]"
46 +
"INSERT INTO " + tableName);
47 user.runSql(
"INSERT INTO " + tableName +
" VALUES(1);");
48 dba.runSql(
"GRANT SELECT ON TABLE " + tableName +
" TO bob;");
50 logger.info(
"[" + tid +
"]"
51 +
"CREATE " + viewName);
52 user.runSql(
"CREATE VIEW " + viewName +
" AS SELECT * FROM " + tableName +
";");
53 HeavyDBAsserts.assertEqual(
true, null != dba.get_table_details(viewName));
54 dba.runSql(
"GRANT SELECT ON VIEW " + viewName +
" TO bob;");
56 logger.info(
"[" + tid +
"]"
57 +
"CREATE " + dashName);
58 int dash_id = user.create_dashboard(dashName);
59 HeavyDBAsserts.assertEqual(
true, null != dba.get_dashboard(dash_id));
60 dba.runSql(
"GRANT VIEW ON DASHBOARD " + dash_id +
" TO bob;");
62 dba.runSql(
"REVOKE VIEW ON DASHBOARD " + dash_id +
" FROM bob;");
63 dba.runSql(
"REVOKE SELECT ON VIEW " + viewName +
" FROM bob;");
64 dba.runSql(
"REVOKE SELECT ON TABLE " + tableName +
" FROM bob;");
66 logger.info(
"[" + tid +
"]"
67 +
"DROP " + dashName);
68 dba.delete_dashboard(dash_id);
69 logger.info(
"[" + tid +
"]"
70 +
"DROP " + viewName);
71 dba.runSql(
"DROP VIEW " + viewName +
";");
72 logger.info(
"[" + tid +
"]"
73 +
"DROP " + tableName);
74 dba.runSql(
"DROP TABLE " + tableName +
";");
76 logger.info(
"[" + tid +
"]"
77 +
"CREATE IF NOT EXISTS " + sharedTableName);
78 dba.runSql(
"CREATE TABLE IF NOT EXISTS " + sharedTableName +
" (id INTEGER);");
80 logger.info(
"[" + tid +
"]"
81 +
"DROP IF EXISTS " + sharedTableName);
82 dba.runSql(
"DROP TABLE IF EXISTS " + sharedTableName +
";");
void com.mapd.tests.CatalogConcurrencyTest.runTest |
( |
String |
db, |
|
|
String |
dbaUser, |
|
|
String |
dbaPassword, |
|
|
String |
dbUser, |
|
|
String |
dbPassword |
|
) |
| throws Exception |
|
inlineprivate |
Definition at line 86 of file CatalogConcurrencyTest.java.
References run, and com.mapd.tests.CatalogConcurrencyTest.run_test().
Referenced by com.mapd.tests.CatalogConcurrencyTest.testCatalogConcurrency().
91 Exception exceptions[] =
new Exception[num_threads];
93 ArrayList<Thread> threads =
new ArrayList<>();
94 for (
int i = 0; i < num_threads; i++) {
95 logger.info(
"Starting " + i);
96 final String prefix =
"for_bob_" + i +
"_";
97 final int threadId = i;
98 Thread t =
new Thread(
new Runnable() {
102 HeavyDBTestClient dba = HeavyDBTestClient.getClient(
103 "localhost", 6274, db, dbaUser, dbaPassword);
104 HeavyDBTestClient user = HeavyDBTestClient.getClient(
105 "localhost", 6274, db, dbUser, dbPassword);
107 }
catch (Exception e) {
108 logger.error(
"[" + Thread.currentThread().getId() +
"]"
109 +
"Caught Exception: " + e.getMessage(),
111 exceptions[threadId] = e;
119 for (Thread t : threads) {
123 for (Exception e : exceptions) {
125 logger.error(
"Exception: " + e.getMessage(), e);
126 throw new Exception(e.getMessage(), e);
void run_test(HeavyDBTestClient dba, HeavyDBTestClient user, String prefix, int max)
void com.mapd.tests.CatalogConcurrencyTest.testCatalogConcurrency |
( |
| ) |
throws Exception |
|
inline |
Definition at line 131 of file CatalogConcurrencyTest.java.
References com.mapd.tests.CatalogConcurrencyTest.runTest().
132 logger.info(
"testCatalogConcurrency()");
134 HeavyDBTestClient su = HeavyDBTestClient.getClient(
135 "localhost", 6274,
"heavyai",
"admin",
"HyperInteractive");
136 su.runSql(
"CREATE USER dba (password = 'password', is_super = 'true');");
137 su.runSql(
"CREATE USER bob (password = 'password', is_super = 'false');");
139 su.runSql(
"GRANT CREATE on DATABASE heavyai TO bob;");
140 su.runSql(
"GRANT CREATE VIEW on DATABASE heavyai TO bob;");
141 su.runSql(
"GRANT CREATE DASHBOARD on DATABASE heavyai TO bob;");
143 su.runSql(
"GRANT DROP on DATABASE heavyai TO bob;");
144 su.runSql(
"GRANT DROP VIEW on DATABASE heavyai TO bob;");
145 su.runSql(
"GRANT DELETE DASHBOARD on DATABASE heavyai TO bob;");
147 su.runSql(
"CREATE DATABASE db1;");
149 su.runSql(
"GRANT CREATE on DATABASE db1 TO bob;");
150 su.runSql(
"GRANT CREATE VIEW on DATABASE db1 TO bob;");
151 su.runSql(
"GRANT CREATE DASHBOARD on DATABASE db1 TO bob;");
153 su.runSql(
"GRANT DROP on DATABASE db1 TO bob;");
154 su.runSql(
"GRANT DROP VIEW on DATABASE db1 TO bob;");
155 su.runSql(
"GRANT DELETE DASHBOARD on DATABASE db1 TO bob;");
157 su.runSql(
"GRANT ACCESS on database heavyai TO dba;");
158 su.runSql(
"GRANT ACCESS on database heavyai TO bob;");
159 su.runSql(
"GRANT ACCESS on database db1 TO dba;");
160 su.runSql(
"GRANT ACCESS on database db1 TO bob;");
162 runTest(
"db1",
"admin",
"HyperInteractive",
"admin",
"HyperInteractive");
163 runTest(
"db1",
"admin",
"HyperInteractive",
"dba",
"password");
164 runTest(
"db1",
"admin",
"HyperInteractive",
"bob",
"password");
165 runTest(
"db1",
"dba",
"password",
"admin",
"HyperInteractive");
166 runTest(
"db1",
"dba",
"password",
"bob",
"password");
168 runTest(
"heavyai",
"admin",
"HyperInteractive",
"admin",
"HyperInteractive");
169 runTest(
"heavyai",
"admin",
"HyperInteractive",
"dba",
"password");
170 runTest(
"heavyai",
"admin",
"HyperInteractive",
"bob",
"password");
171 runTest(
"heavyai",
"dba",
"password",
"admin",
"HyperInteractive");
172 runTest(
"heavyai",
"dba",
"password",
"bob",
"password");
174 su.runSql(
"DROP DATABASE db1;");
175 su.runSql(
"DROP USER bob;");
176 su.runSql(
"DROP USER dba;");
178 logger.info(
"testCatalogConcurrency() done");
void runTest(String db, String dbaUser, String dbaPassword, String dbUser, String dbPassword)
final Logger com.mapd.tests.CatalogConcurrencyTest.logger = LoggerFactory.getLogger(CatalogConcurrencyTest.class) |
|
staticpackage |
The documentation for this class was generated from the following file: