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

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(EagainConcurrencyTest.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 EagainConcurrencyTest.java.

Member Function Documentation

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

Definition at line 26 of file EagainConcurrencyTest.java.

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

Definition at line 31 of file EagainConcurrencyTest.java.

References Experimental.String.

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

32  {
33  String tableName = "table_" + prefix + "_";
34  long tid = Thread.currentThread().getId();
35  logger.info("[" + tid + "]"
36  + "CREATE " + tableName);
37  user.runSql("CREATE TABLE " + tableName + " (id integer);");
38 
39  for (int i = 0; i < max; i++) {
40  logger.info("[" + tid + "]"
41  + "INSERT INTO " + tableName);
42  user.runSql("INSERT INTO " + tableName + " VALUES (" + i + ");");
43 
44  user.get_status();
45  user.get_server_status();
46  user.get_hardware_info();
47 
48  logger.info("[" + tid + "]"
49  + "SELECT FROM " + tableName);
50  user.runSql("SELECT * FROM " + tableName + ";");
51  }
52 
53  logger.info("[" + tid + "]"
54  + "DROP " + tableName);
55  dba.runSql("DROP TABLE " + tableName + ";");
56  }

+ Here is the caller graph for this function:

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

Definition at line 58 of file EagainConcurrencyTest.java.

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

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

60  {
61  int num_threads = 5;
62  final int runs = 25;
63  Exception exceptions[] = new Exception[num_threads];
64 
65  ArrayList<Thread> threads = new ArrayList<>();
66  for (int i = 0; i < num_threads; i++) {
67  logger.info("Starting " + i);
68  final String prefix = "for_bob_" + i + "_";
69  final int threadId = i;
70  Thread t = new Thread(new Runnable() {
71  @Override
72  public void run() {
73  try {
74  MapdTestClient dba =
75  MapdTestClient.getClient("localhost", 6274, db, dbaUser, dbaPassword);
76  MapdTestClient user =
77  MapdTestClient.getClient("localhost", 6274, db, dbUser, dbPassword);
78  run_test(dba, user, prefix, runs);
79  } catch (Exception e) {
80  logger.error("[" + Thread.currentThread().getId() + "]"
81  + "Caught Exception: " + e.getMessage(),
82  e);
83  exceptions[threadId] = e;
84  }
85  }
86  });
87  t.start();
88  threads.add(t);
89  }
90 
91  for (Thread t : threads) {
92  t.join();
93  }
94 
95  for (Exception e : exceptions) {
96  if (null != e) {
97  logger.error("Exception: " + e.getMessage(), e);
98  throw new Exception(e.getMessage(), e);
99  }
100  }
101  }
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.EagainConcurrencyTest.testCatalogConcurrency ( ) throws Exception
inline

Definition at line 103 of file EagainConcurrencyTest.java.

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

103  {
104  logger.info("testCatalogConcurrency()");
105 
106  MapdTestClient su = MapdTestClient.getClient(
107  "localhost", 6274, "omnisci", "admin", "HyperInteractive");
108  su.runSql("CREATE USER dba (password = 'password', is_super = 'true');");
109  su.runSql("CREATE USER bob (password = 'password', is_super = 'false');");
110 
111  su.runSql("GRANT CREATE on DATABASE omnisci TO bob;");
112  su.runSql("GRANT CREATE VIEW on DATABASE omnisci TO bob;");
113  su.runSql("GRANT CREATE DASHBOARD on DATABASE omnisci TO bob;");
114 
115  su.runSql("GRANT DROP on DATABASE omnisci TO bob;");
116  su.runSql("GRANT DROP VIEW on DATABASE omnisci TO bob;");
117  su.runSql("GRANT DELETE DASHBOARD on DATABASE omnisci TO bob;");
118 
119  su.runSql("CREATE DATABASE db1;");
120 
121  su.runSql("GRANT CREATE on DATABASE db1 TO bob;");
122  su.runSql("GRANT CREATE VIEW on DATABASE db1 TO bob;");
123  su.runSql("GRANT CREATE DASHBOARD on DATABASE db1 TO bob;");
124 
125  su.runSql("GRANT DROP on DATABASE db1 TO bob;");
126  su.runSql("GRANT DROP VIEW on DATABASE db1 TO bob;");
127  su.runSql("GRANT DELETE DASHBOARD on DATABASE db1 TO bob;");
128 
129  su.runSql("GRANT ACCESS on database omnisci TO dba;");
130  su.runSql("GRANT ACCESS on database omnisci TO bob;");
131  su.runSql("GRANT ACCESS on database db1 TO dba;");
132  su.runSql("GRANT ACCESS on database db1 TO bob;");
133 
134  runTest("db1", "admin", "HyperInteractive", "admin", "HyperInteractive");
135  runTest("db1", "admin", "HyperInteractive", "dba", "password");
136  runTest("db1", "admin", "HyperInteractive", "bob", "password");
137  runTest("db1", "dba", "password", "admin", "HyperInteractive");
138  runTest("db1", "dba", "password", "bob", "password");
139 
140  runTest("omnisci", "admin", "HyperInteractive", "admin", "HyperInteractive");
141  runTest("omnisci", "admin", "HyperInteractive", "dba", "password");
142  runTest("omnisci", "admin", "HyperInteractive", "bob", "password");
143  runTest("omnisci", "dba", "password", "admin", "HyperInteractive");
144  runTest("omnisci", "dba", "password", "bob", "password");
145 
146  su.runSql("DROP DATABASE db1;");
147  su.runSql("DROP USER bob;");
148  su.runSql("DROP USER dba;");
149  }
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.EagainConcurrencyTest.logger = LoggerFactory.getLogger(EagainConcurrencyTest.class)
staticpackage

Definition at line 24 of file EagainConcurrencyTest.java.


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