OmniSciDB  f17484ade4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
com.mapd.tests.CatalogConcurrencyTest Class Reference
+ Collaboration diagram for com.mapd.tests.CatalogConcurrencyTest:

Public Member Functions

void testCatalogConcurrency () throws Exception
 

Static Public Member Functions

static void main (String[] args) throws Exception
 

Static Package Attributes

static final Logger logger = LoggerFactory.getLogger(CatalogConcurrencyTest.class)
 

Private Member Functions

void run_test (HeavyDBTestClient dba, HeavyDBTestClient user, String prefix, int max) throws Exception
 
void runTest (String db, String dbaUser, String dbaPassword, String dbUser, String dbPassword) throws Exception
 

Detailed Description

Definition at line 23 of file CatalogConcurrencyTest.java.

Member Function Documentation

static void com.mapd.tests.CatalogConcurrencyTest.main ( String[]  args) throws Exception
inlinestatic

Definition at line 26 of file CatalogConcurrencyTest.java.

26  {
27  CatalogConcurrencyTest test = new CatalogConcurrencyTest();
28  test.testCatalogConcurrency();
29  }
void com.mapd.tests.CatalogConcurrencyTest.run_test ( HeavyDBTestClient  dba,
HeavyDBTestClient  user,
String  prefix,
int  max 
) throws Exception
inlineprivate

Definition at line 31 of file CatalogConcurrencyTest.java.

Referenced by com.mapd.tests.CatalogConcurrencyTest.runTest().

33  {
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();
40 
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;");
49 
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;");
55 
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;");
61 
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;");
65 
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 + ";");
75 
76  logger.info("[" + tid + "]"
77  + "CREATE IF NOT EXISTS " + sharedTableName);
78  dba.runSql("CREATE TABLE IF NOT EXISTS " + sharedTableName + " (id INTEGER);");
79 
80  logger.info("[" + tid + "]"
81  + "DROP IF EXISTS " + sharedTableName);
82  dba.runSql("DROP TABLE IF EXISTS " + sharedTableName + ";");
83  }
84  }

+ Here is the caller graph for this function:

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().

88  {
89  int num_threads = 5;
90  final int runs = 25;
91  Exception exceptions[] = new Exception[num_threads];
92 
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() {
99  @Override
100  public void run() {
101  try {
102  HeavyDBTestClient dba = HeavyDBTestClient.getClient(
103  "localhost", 6274, db, dbaUser, dbaPassword);
104  HeavyDBTestClient user = HeavyDBTestClient.getClient(
105  "localhost", 6274, db, dbUser, dbPassword);
106  run_test(dba, user, prefix, runs);
107  } catch (Exception e) {
108  logger.error("[" + Thread.currentThread().getId() + "]"
109  + "Caught Exception: " + e.getMessage(),
110  e);
111  exceptions[threadId] = e;
112  }
113  }
114  });
115  t.start();
116  threads.add(t);
117  }
118 
119  for (Thread t : threads) {
120  t.join();
121  }
122 
123  for (Exception e : exceptions) {
124  if (null != e) {
125  logger.error("Exception: " + e.getMessage(), e);
126  throw new Exception(e.getMessage(), e);
127  }
128  }
129  }
void run_test(HeavyDBTestClient dba, HeavyDBTestClient user, String prefix, int max)
static bool run

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void com.mapd.tests.CatalogConcurrencyTest.testCatalogConcurrency ( ) throws Exception
inline

Definition at line 131 of file CatalogConcurrencyTest.java.

References com.mapd.tests.CatalogConcurrencyTest.runTest().

131  {
132  logger.info("testCatalogConcurrency()");
133 
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');");
138 
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;");
142 
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;");
146 
147  su.runSql("CREATE DATABASE db1;");
148 
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;");
152 
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;");
156 
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;");
161 
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");
167 
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");
173 
174  su.runSql("DROP DATABASE db1;");
175  su.runSql("DROP USER bob;");
176  su.runSql("DROP USER dba;");
177 
178  logger.info("testCatalogConcurrency() done");
179  }
void runTest(String db, String dbaUser, String dbaPassword, String dbUser, String dbPassword)

+ Here is the call graph for this function:

Member Data Documentation

final Logger com.mapd.tests.CatalogConcurrencyTest.logger = LoggerFactory.getLogger(CatalogConcurrencyTest.class)
staticpackage

Definition at line 24 of file CatalogConcurrencyTest.java.


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