OmniSciDB  085a039ca4
 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  for (int i = 0; i < max; i++) {
35  String tableName = "table_" + prefix + "_" + i;
36  String viewName = "view_" + prefix + "_" + i;
37  String dashName = "dash_" + prefix + "_" + i;
38  long tid = Thread.currentThread().getId();
39 
40  logger.info("[" + tid + "]"
41  + "CREATE " + tableName);
42  user.runSql("CREATE TABLE " + tableName + " (id text);");
43  HeavyDBAsserts.assertEqual(true, null != dba.get_table_details(tableName));
44  logger.info("[" + tid + "]"
45  + "INSERT INTO " + tableName);
46  user.runSql("INSERT INTO " + tableName + " VALUES(1);");
47  dba.runSql("GRANT SELECT ON TABLE " + tableName + " TO bob;");
48 
49  logger.info("[" + tid + "]"
50  + "CREATE " + viewName);
51  user.runSql("CREATE VIEW " + viewName + " AS SELECT * FROM " + tableName + ";");
52  HeavyDBAsserts.assertEqual(true, null != dba.get_table_details(viewName));
53  dba.runSql("GRANT SELECT ON VIEW " + viewName + " TO bob;");
54 
55  logger.info("[" + tid + "]"
56  + "CREATE " + dashName);
57  int dash_id = user.create_dashboard(dashName);
58  HeavyDBAsserts.assertEqual(true, null != dba.get_dashboard(dash_id));
59  dba.runSql("GRANT VIEW ON DASHBOARD " + dash_id + " TO bob;");
60 
61  dba.runSql("REVOKE VIEW ON DASHBOARD " + dash_id + " FROM bob;");
62  dba.runSql("REVOKE SELECT ON VIEW " + viewName + " FROM bob;");
63  dba.runSql("REVOKE SELECT ON TABLE " + tableName + " FROM bob;");
64 
65  logger.info("[" + tid + "]"
66  + "DROP " + dashName);
67  dba.delete_dashboard(dash_id);
68  logger.info("[" + tid + "]"
69  + "DROP " + viewName);
70  dba.runSql("DROP VIEW " + viewName + ";");
71  logger.info("[" + tid + "]"
72  + "DROP " + tableName);
73  dba.runSql("DROP TABLE " + tableName + ";");
74  }
75  }

+ 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 77 of file CatalogConcurrencyTest.java.

References run, and com.mapd.tests.CatalogConcurrencyTest.run_test().

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

79  {
80  int num_threads = 5;
81  final int runs = 25;
82  Exception exceptions[] = new Exception[num_threads];
83 
84  ArrayList<Thread> threads = new ArrayList<>();
85  for (int i = 0; i < num_threads; i++) {
86  logger.info("Starting " + i);
87  final String prefix = "for_bob_" + i + "_";
88  final int threadId = i;
89  Thread t = new Thread(new Runnable() {
90  @Override
91  public void run() {
92  try {
93  HeavyDBTestClient dba = HeavyDBTestClient.getClient(
94  "localhost", 6274, db, dbaUser, dbaPassword);
95  HeavyDBTestClient user = HeavyDBTestClient.getClient(
96  "localhost", 6274, db, dbUser, dbPassword);
97  run_test(dba, user, prefix, runs);
98  } catch (Exception e) {
99  logger.error("[" + Thread.currentThread().getId() + "]"
100  + "Caught Exception: " + e.getMessage(),
101  e);
102  exceptions[threadId] = e;
103  }
104  }
105  });
106  t.start();
107  threads.add(t);
108  }
109 
110  for (Thread t : threads) {
111  t.join();
112  }
113 
114  for (Exception e : exceptions) {
115  if (null != e) {
116  logger.error("Exception: " + e.getMessage(), e);
117  throw new Exception(e.getMessage(), e);
118  }
119  }
120  }
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 122 of file CatalogConcurrencyTest.java.

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

122  {
123  logger.info("testCatalogConcurrency()");
124 
125  HeavyDBTestClient su = HeavyDBTestClient.getClient(
126  "localhost", 6274, "heavyai", "admin", "HyperInteractive");
127  su.runSql("CREATE USER dba (password = 'password', is_super = 'true');");
128  su.runSql("CREATE USER bob (password = 'password', is_super = 'false');");
129 
130  su.runSql("GRANT CREATE on DATABASE heavyai TO bob;");
131  su.runSql("GRANT CREATE VIEW on DATABASE heavyai TO bob;");
132  su.runSql("GRANT CREATE DASHBOARD on DATABASE heavyai TO bob;");
133 
134  su.runSql("GRANT DROP on DATABASE heavyai TO bob;");
135  su.runSql("GRANT DROP VIEW on DATABASE heavyai TO bob;");
136  su.runSql("GRANT DELETE DASHBOARD on DATABASE heavyai TO bob;");
137 
138  su.runSql("CREATE DATABASE db1;");
139 
140  su.runSql("GRANT CREATE on DATABASE db1 TO bob;");
141  su.runSql("GRANT CREATE VIEW on DATABASE db1 TO bob;");
142  su.runSql("GRANT CREATE DASHBOARD on DATABASE db1 TO bob;");
143 
144  su.runSql("GRANT DROP on DATABASE db1 TO bob;");
145  su.runSql("GRANT DROP VIEW on DATABASE db1 TO bob;");
146  su.runSql("GRANT DELETE DASHBOARD on DATABASE db1 TO bob;");
147 
148  su.runSql("GRANT ACCESS on database heavyai TO dba;");
149  su.runSql("GRANT ACCESS on database heavyai TO bob;");
150  su.runSql("GRANT ACCESS on database db1 TO dba;");
151  su.runSql("GRANT ACCESS on database db1 TO bob;");
152 
153  runTest("db1", "admin", "HyperInteractive", "admin", "HyperInteractive");
154  runTest("db1", "admin", "HyperInteractive", "dba", "password");
155  runTest("db1", "admin", "HyperInteractive", "bob", "password");
156  runTest("db1", "dba", "password", "admin", "HyperInteractive");
157  runTest("db1", "dba", "password", "bob", "password");
158 
159  runTest("heavyai", "admin", "HyperInteractive", "admin", "HyperInteractive");
160  runTest("heavyai", "admin", "HyperInteractive", "dba", "password");
161  runTest("heavyai", "admin", "HyperInteractive", "bob", "password");
162  runTest("heavyai", "dba", "password", "admin", "HyperInteractive");
163  runTest("heavyai", "dba", "password", "bob", "password");
164 
165  su.runSql("DROP DATABASE db1;");
166  su.runSql("DROP USER bob;");
167  su.runSql("DROP USER dba;");
168 
169  logger.info("testCatalogConcurrency() done");
170  }
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: