OmniSciDB  8a228a1076
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

◆ main()

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

Definition at line 26 of file CatalogConcurrencyTest.java.

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

26  {
27  CatalogConcurrencyTest test = new CatalogConcurrencyTest();
28  test.testCatalogConcurrency();
29  }
+ Here is the call graph for this function:

◆ run_test()

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 com.mapd.tests.MapdAsserts.assertEqual().

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 text);");
42  MapdAsserts.assertEqual(true, null != dba.get_table_details(tableName));
43  logger.info("[" + tid + "]"
44  + "INSERT INTO " + tableName);
45  user.runSql("INSERT INTO " + tableName + " VALUES(1);");
46  dba.runSql("GRANT SELECT ON TABLE " + tableName + " TO bob;");
47 
48  logger.info("[" + tid + "]"
49  + "CREATE " + viewName);
50  user.runSql("CREATE VIEW " + viewName + " AS SELECT * FROM " + tableName + ";");
51  MapdAsserts.assertEqual(true, null != dba.get_table_details(viewName));
52  dba.runSql("GRANT SELECT ON VIEW " + viewName + " TO bob;");
53 
54  logger.info("[" + tid + "]"
55  + "CREATE " + dashName);
56  int dash_id = user.create_dashboard(dashName);
57  MapdAsserts.assertEqual(true, null != dba.get_dashboard(dash_id));
58  dba.runSql("GRANT VIEW ON DASHBOARD " + dash_id + " TO bob;");
59 
60  dba.runSql("REVOKE VIEW ON DASHBOARD " + dash_id + " FROM bob;");
61  dba.runSql("REVOKE SELECT ON VIEW " + viewName + " FROM bob;");
62  dba.runSql("REVOKE SELECT ON TABLE " + tableName + " FROM bob;");
63 
64  logger.info("[" + tid + "]"
65  + "DROP " + dashName);
66  dba.delete_dashboard(dash_id);
67  logger.info("[" + tid + "]"
68  + "DROP " + viewName);
69  dba.runSql("DROP VIEW " + viewName + ";");
70  logger.info("[" + tid + "]"
71  + "DROP " + tableName);
72  dba.runSql("DROP TABLE " + tableName + ";");
73  }
74  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ runTest()

void com.mapd.tests.CatalogConcurrencyTest.runTest ( String  db,
String  dbaUser,
String  dbaPassword,
String  dbUser,
String  dbPassword 
) throws Exception
inlineprivate

Definition at line 76 of file CatalogConcurrencyTest.java.

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

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

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

◆ testCatalogConcurrency()

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

Definition at line 121 of file CatalogConcurrencyTest.java.

References com.mapd.tests.MapdTestClient.getClient(), com.mapd.tests.MapdTestClient.runSql(), and com.mapd.tests.CatalogConcurrencyTest.runTest().

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

121  {
122  logger.info("testCatalogConcurrency()");
123 
124  MapdTestClient su = MapdTestClient.getClient(
125  "localhost", 6274, "omnisci", "admin", "HyperInteractive");
126  su.runSql("CREATE USER dba (password = 'password', is_super = 'true');");
127  su.runSql("CREATE USER bob (password = 'password', is_super = 'false');");
128 
129  su.runSql("GRANT CREATE on DATABASE omnisci TO bob;");
130  su.runSql("GRANT CREATE VIEW on DATABASE omnisci TO bob;");
131  su.runSql("GRANT CREATE DASHBOARD on DATABASE omnisci TO bob;");
132 
133  su.runSql("GRANT DROP on DATABASE omnisci TO bob;");
134  su.runSql("GRANT DROP VIEW on DATABASE omnisci TO bob;");
135  su.runSql("GRANT DELETE DASHBOARD on DATABASE omnisci TO bob;");
136 
137  su.runSql("CREATE DATABASE db1;");
138 
139  su.runSql("GRANT CREATE on DATABASE db1 TO bob;");
140  su.runSql("GRANT CREATE VIEW on DATABASE db1 TO bob;");
141  su.runSql("GRANT CREATE DASHBOARD on DATABASE db1 TO bob;");
142 
143  su.runSql("GRANT DROP on DATABASE db1 TO bob;");
144  su.runSql("GRANT DROP VIEW on DATABASE db1 TO bob;");
145  su.runSql("GRANT DELETE DASHBOARD on DATABASE db1 TO bob;");
146 
147  su.runSql("GRANT ACCESS on database omnisci TO dba;");
148  su.runSql("GRANT ACCESS on database omnisci TO bob;");
149  su.runSql("GRANT ACCESS on database db1 TO dba;");
150  su.runSql("GRANT ACCESS on database db1 TO bob;");
151 
152  runTest("db1", "admin", "HyperInteractive", "admin", "HyperInteractive");
153  runTest("db1", "admin", "HyperInteractive", "dba", "password");
154  runTest("db1", "admin", "HyperInteractive", "bob", "password");
155  runTest("db1", "dba", "password", "admin", "HyperInteractive");
156  runTest("db1", "dba", "password", "bob", "password");
157 
158  runTest("omnisci", "admin", "HyperInteractive", "admin", "HyperInteractive");
159  runTest("omnisci", "admin", "HyperInteractive", "dba", "password");
160  runTest("omnisci", "admin", "HyperInteractive", "bob", "password");
161  runTest("omnisci", "dba", "password", "admin", "HyperInteractive");
162  runTest("omnisci", "dba", "password", "bob", "password");
163 
164  su.runSql("DROP DATABASE db1;");
165  su.runSql("DROP USER bob;");
166  su.runSql("DROP USER dba;");
167 
168  logger.info("testCatalogConcurrency() done");
169  }
void runTest(String db, String dbaUser, String dbaPassword, String dbUser, String dbPassword)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ logger

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: