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

Public Member Functions

 ImportAlterValidateSelectConcurrencyTest (String csv_file_path, String geo_file_path)
 
void testConcurrency () throws Exception
 

Static Public Member Functions

static void main (String[] args) throws Exception
 

Package Attributes

String csv_file_path
 
String geo_file_path
 

Static Package Attributes

static final Logger logger
 

Private Member Functions

void runTest (String db, String dbaUser, String dbaPassword, String dbUser, String dbPassword) throws Exception
 

Detailed Description

Constructor & Destructor Documentation

com.mapd.tests.ImportAlterValidateSelectConcurrencyTest.ImportAlterValidateSelectConcurrencyTest ( String  csv_file_path,
String  geo_file_path 
)
inline

Definition at line 36 of file ImportAlterValidateSelectConcurrencyTest.java.

References com.mapd.tests.ImportAlterValidateSelectConcurrencyTest.csv_file_path, and com.mapd.tests.ImportAlterValidateSelectConcurrencyTest.geo_file_path.

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

+ Here is the caller graph for this function:

Member Function Documentation

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

Definition at line 42 of file ImportAlterValidateSelectConcurrencyTest.java.

References run_benchmark_import.args, assert(), and com.mapd.tests.ImportAlterValidateSelectConcurrencyTest.ImportAlterValidateSelectConcurrencyTest().

42  {
43  // Command Line Args:
44  // 0: CSV file to import (absolute path accessible by server)
45  // 1: Geo file to import (absolute path accessible by server)
46  assert args.length == 2;
49  test.testConcurrency();
50  }
ImportAlterValidateSelectConcurrencyTest(String csv_file_path, String geo_file_path)
int64_t const int32_t sz assert(dest)

+ Here is the call graph for this function:

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

Definition at line 52 of file ImportAlterValidateSelectConcurrencyTest.java.

References com.mapd.tests.ImportAlterValidateSelectConcurrencyTest.csv_file_path, com.mapd.tests.ImportAlterValidateSelectConcurrencyTest.geo_file_path, and run.

Referenced by com.mapd.tests.ImportAlterValidateSelectConcurrencyTest.testConcurrency().

54  {
55  int num_threads = 4;
56  final int runs = 25;
57  final int fragment_size = 10;
58  final String csvTableName = "import_test_mixed_varlen";
59  final String geoTableName = "geospatial";
60  Exception exceptions[] = new Exception[num_threads];
61 
62  final CyclicBarrier barrier = new CyclicBarrier(num_threads, new Runnable() {
63  public void run() {
64  try {
65  MapdTestClient dba =
66  MapdTestClient.getClient("localhost", 6274, db, dbaUser, dbaPassword);
67  dba.runSql("CREATE TABLE " + csvTableName
68  + "(pt GEOMETRY(POINT), ls GEOMETRY(LINESTRING), faii INTEGER[2], fadc DECIMAL(5, 2)[2], fatx TEXT[] ENCODING DICT(32), fatx2 TEXT[2] ENCODING DICT(32)) WITH(FRAGMENT_SIZE = "
69  + fragment_size + ")");
70 
71  dba.runSql("CREATE TABLE " + geoTableName
72  + "( trip INT, omnisci_geo MULTIPOLYGON ) WITH(FRAGMENT_SIZE = "
73  + fragment_size + ")");
74 
75  } catch (Exception e) {
76  logger.error("[" + Thread.currentThread().getId() + "]"
77  + " Caught Exception: " + e.getMessage(),
78  e);
79  exceptions[0] = e;
80  }
81  }
82  });
83 
84  ArrayList<Thread> threads = new ArrayList<>();
85  for (int i = 0; i < num_threads; i++) {
86  logger.info("Starting " + i);
87  final int threadId = i;
88 
89  Thread t = new Thread(new Runnable() {
90  @Override
91  public void run() {
92  long tid = Thread.currentThread().getId();
93  String logPrefix = "[" + tid + "]";
94  String sql = "";
95 
96  TCopyParams copy_params = new TCopyParams();
97  copy_params.has_header = TImportHeaderRow.NO_HEADER;
98  copy_params.delimiter = ",";
99  copy_params.null_str = "\\N";
100  copy_params.quoted = true;
101  copy_params.quote = "\"";
102  copy_params.escape = "\"";
103  copy_params.line_delim = "\n";
104  copy_params.array_delim = ",";
105  copy_params.array_begin = "{";
106  copy_params.array_end = "}";
107  copy_params.threads = 0;
108 
109  TCopyParams geo_copy_params = new TCopyParams();
110  geo_copy_params.delimiter = ",";
111  geo_copy_params.null_str = "\\N";
112  geo_copy_params.quoted = true;
113  geo_copy_params.quote = "\"";
114  geo_copy_params.escape = "\"";
115  geo_copy_params.line_delim = "\n";
116  geo_copy_params.array_delim = ",";
117  geo_copy_params.array_begin = "{";
118  geo_copy_params.array_end = "}";
119  geo_copy_params.threads = 0;
120 
121  try {
122  barrier.await();
123 
124  MapdTestClient user =
125  MapdTestClient.getClient("localhost", 6274, db, dbUser, dbPassword);
126 
127  if (tid % 2 == 0) {
128  logger.info(logPrefix + " IMPORT TABLE");
129  user.import_table(csvTableName, csv_file_path, copy_params);
130  }
131 
132  sql = "DELETE FROM " + csvTableName + " WHERE fatx2 IS NULL;";
133  logger.info(logPrefix + " " + sql);
134  user.runSql(sql);
135 
136  sql = "SELECT COUNT(*) FROM " + csvTableName + ";";
137  logger.info(logPrefix + " " + sql);
138  user.runSql(sql);
139 
140  if (threadId == 1) {
141  Thread.sleep(5000); // Ensure import is launched
142  sql = "ALTER TABLE " + csvTableName + " DROP COLUMN faii;";
143  logger.info(logPrefix + " " + sql);
144  user.runSql(sql);
145  }
146 
147  // TODO(adb): add get_table_details once thread safe
148 
149  sql = "SELECT * FROM " + geoTableName + ";";
150  logger.info(logPrefix + " VALIDATE " + sql);
151  user.sqlValidate(sql);
152 
153  if (threadId == 3) {
154  logger.info(logPrefix + " IMPORT GEO TABLE");
155  user.import_geo_table(geoTableName,
157  copy_params,
158  new java.util.ArrayList<TColumnType>(),
159  new TCreateParams());
160  }
161 
162  sql = "SELECT * FROM " + geoTableName + " LIMIT 2;";
163  logger.info(logPrefix + " " + sql);
164  user.runSql(sql);
165 
166  sql = "SELECT * FROM " + csvTableName + ";";
167  logger.info(logPrefix + " VALIDATE " + sql);
168  user.sqlValidate(sql);
169 
170  for (int i = 0; i < 5; i++) {
171  sql = "INSERT INTO " + geoTableName + " VALUES (" + i
172  + ", 'MULTIPOLYGON(((0 0, 1 1, 2 2)))');";
173  logger.info(logPrefix + " " + sql);
174  user.runSql(sql);
175  }
176 
177  sql = "TRUNCATE TABLE " + csvTableName + ";";
178  logger.info(logPrefix + " " + sql);
179  user.runSql(sql);
180 
181  sql = "SELECT COUNT(*) FROM " + csvTableName + ";";
182  logger.info(logPrefix + " VALIDATE " + sql);
183  user.sqlValidate(sql);
184 
185  if (threadId == 0) {
186  Thread.sleep(5000); // Ensure import is launched
187  sql = "DROP TABLE " + geoTableName + ";";
188  logger.info(logPrefix + " " + sql);
189  user.runSql(sql);
190  }
191  } catch (Exception e) {
192  logger.error(logPrefix + " Caught Exception: " + e.getMessage(), e);
193  exceptions[threadId] = e;
194  }
195  }
196  });
197  t.start();
198  threads.add(t);
199  }
200 
201  for (Thread t : threads) {
202  t.join();
203  }
204 
205  MapdTestClient dba =
206  MapdTestClient.getClient("localhost", 6274, db, dbaUser, dbaPassword);
207  dba.runSql("DROP TABLE " + csvTableName + ";");
208 
209  for (Exception e : exceptions) {
210  if (null != e) {
211  logger.error("Exception: " + e.getMessage(), e);
212  throw e;
213  }
214  }
215  }
static bool run

+ Here is the caller graph for this function:

void com.mapd.tests.ImportAlterValidateSelectConcurrencyTest.testConcurrency ( ) throws Exception
inline

Definition at line 217 of file ImportAlterValidateSelectConcurrencyTest.java.

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

217  {
218  logger.info("ImportAlterValidateSelectConcurrencyTest()");
219 
220  MapdTestClient su = MapdTestClient.getClient(
221  "localhost", 6274, "omnisci", "admin", "HyperInteractive");
222  su.runSql("CREATE USER dba (password = 'password', is_super = 'true');");
223  su.runSql("CREATE USER bob (password = 'password', is_super = 'false');");
224 
225  su.runSql("GRANT CREATE on DATABASE omnisci TO bob;");
226 
227  su.runSql("CREATE DATABASE db1;");
228  su.runSql("GRANT CREATE on DATABASE db1 TO bob;");
229  su.runSql("GRANT CREATE VIEW on DATABASE db1 TO bob;");
230  su.runSql("GRANT DROP on DATABASE db1 TO bob;");
231  su.runSql("GRANT DROP VIEW on DATABASE db1 TO bob;");
232 
233  runTest("db1", "admin", "HyperInteractive", "admin", "HyperInteractive");
234  // TODO: run some tests as bob
235 
236  su.runSql("DROP DATABASE db1;");
237  su.runSql("DROP USER bob;");
238  su.runSql("DROP USER dba;");
239 
240  logger.info("ImportAlterValidateSelectConcurrencyTest() done");
241  }
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.ImportAlterValidateSelectConcurrencyTest.logger
staticpackage
Initial value:
=
LoggerFactory.getLogger(ImportAlterValidateSelectConcurrencyTest.class)

Definition at line 33 of file ImportAlterValidateSelectConcurrencyTest.java.


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