OmniSciDB  b24e664e58
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 (MapdTestClient dba, MapdTestClient 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 ( MapdTestClient  dba,
MapdTestClient  user,
String  prefix,
int  max 
) throws Exception
inlineprivate

Definition at line 31 of file CatalogConcurrencyTest.java.

References Experimental.String.

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

32  {
33  for (int i = 0; i < max; i++) {
34  String tableName = "table_" + prefix + "_" + i;
35  String viewName = "view_" + prefix + "_" + i;
36  String dashName = "dash_" + prefix + "_" + i;
37  long tid = Thread.currentThread().getId();
38 
39  logger.info("[" + tid + "]"
40  + "CREATE " + tableName);
41  user.runSql("CREATE TABLE " + tableName + " (id integer);");
42  MapdAsserts.assertEqual(true, null != dba.get_table_details(tableName));
43  dba.runSql("GRANT SELECT ON TABLE " + tableName + " TO bob;");
44 
45  logger.info("[" + tid + "]"
46  + "CREATE " + viewName);
47  user.runSql("CREATE VIEW " + viewName + " AS SELECT * FROM " + tableName + ";");
48  MapdAsserts.assertEqual(true, null != dba.get_table_details(viewName));
49  dba.runSql("GRANT SELECT ON VIEW " + viewName + " TO bob;");
50 
51  logger.info("[" + tid + "]"
52  + "CREATE " + dashName);
53  int dash_id = user.create_dashboard(dashName);
54  MapdAsserts.assertEqual(true, null != dba.get_dashboard(dash_id));
55  dba.runSql("GRANT VIEW ON DASHBOARD " + dash_id + " TO bob;");
56 
57  dba.runSql("REVOKE VIEW ON DASHBOARD " + dash_id + " FROM bob;");
58  dba.runSql("REVOKE SELECT ON VIEW " + viewName + " FROM bob;");
59  dba.runSql("REVOKE SELECT ON TABLE " + tableName + " FROM bob;");
60 
61  logger.info("[" + tid + "]"
62  + "DROP " + dashName);
63  dba.delete_dashboard(dash_id);
64  logger.info("[" + tid + "]"
65  + "DROP " + viewName);
66  dba.runSql("DROP VIEW " + viewName + ";");
67  logger.info("[" + tid + "]"
68  + "DROP " + tableName);
69  dba.runSql("DROP TABLE " + tableName + ";");
70  }
71  }

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

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

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

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

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

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