|
static void | main (String[] args) throws Exception |
|
|
void | runTest (String db, String dbaUser, String dbaPassword, String dbUser, String dbPassword) throws Exception |
|
static void com.mapd.tests.SelectUpdateDeleteDifferentTables.main |
( |
String[] |
args | ) |
throws Exception |
|
inlinestatic |
void com.mapd.tests.SelectUpdateDeleteDifferentTables.runTest |
( |
String |
db, |
|
|
String |
dbaUser, |
|
|
String |
dbaPassword, |
|
|
String |
dbUser, |
|
|
String |
dbPassword |
|
) |
| throws Exception |
|
inlineprivate |
Definition at line 54 of file SelectUpdateDeleteDifferentTables.java.
References run, and com.mapd.tests.SelectUpdateDeleteDifferentTables.text_values.
Referenced by com.mapd.tests.SelectUpdateDeleteDifferentTables.testConcurrency().
59 final int num_rows = 400;
60 final int fragment_size = 25;
61 Exception exceptions[] =
new Exception[num_threads];
63 ArrayList<Thread> threads =
new ArrayList<>();
64 for (
int i = 0; i < num_threads; i++) {
65 logger.info(
"Starting " + i);
66 final int threadId = i;
68 Thread t =
new Thread(
new Runnable() {
71 long tid = Thread.currentThread().getId();
72 String logPrefix =
"[" + tid +
"]";
75 for (
int runId = 0; runId < runs; runId++) {
76 final String tableName = dbaUser +
"_" + threadId +
"_" + runId;
79 HeavyDBTestClient user = HeavyDBTestClient.getClient(
80 "localhost", 6274, db, dbUser, dbPassword);
82 user.runSql(
"CREATE TABLE " + tableName
83 +
"(x BIGINT, y INTEGER, z SMALLINT, a TINYINT, f FLOAT, d DOUBLE, deci DECIMAL(18,6), str TEXT ENCODING NONE) WITH (FRAGMENT_SIZE = "
84 + fragment_size +
")");
86 for (
int i = 0; i < num_rows; i++) {
87 final String integer_val = Integer.toString(i);
88 final String small_val = Integer.toString(i % 128);
89 final String fp_val = Double.toString(i * 1.1);
90 final String deci_val = Double.toString(i + 0.01);
91 final String str_val =
"'" +
text_values[i % text_values.length] +
"'";
92 final String values_string = String.join(
" , ",
101 user.runSql(
"INSERT INTO " + tableName +
" VALUES "
102 +
"(" + values_string +
")");
105 Random rand =
new Random(tid);
107 sql =
"ALTER TABLE " + tableName +
" ADD COLUMN zz TEXT ENCODING DICT(8);";
108 logger.info(logPrefix +
" " + sql);
113 sql =
"SELECT * FROM " + tableName +
" LIMIT 2;";
114 logger.info(logPrefix +
" " + sql);
117 sql =
"DELETE FROM " + tableName +
" WHERE y = " + rand.nextInt(num_rows)
119 logger.info(logPrefix +
" " + sql);
122 sql =
"ALTER TABLE " + tableName +
" DROP COLUMN x;";
123 logger.info(logPrefix +
" " + sql);
126 sql =
"SELECT * FROM " + tableName +
" WHERE str = '"
127 +
text_values[rand.nextInt(text_values.length)] +
"';";
128 logger.info(logPrefix +
" " + sql);
131 sql =
"SELECT COUNT(*) FROM " + tableName +
";";
132 logger.info(logPrefix +
" VALIDATE " + sql);
133 user.sqlValidate(sql);
135 final String tableRename = tableName +
"_rename";
136 sql =
"ALTER TABLE " + tableName +
" RENAME TO " + tableRename;
139 sql =
"TRUNCATE TABLE " + tableRename +
";";
140 logger.info(logPrefix +
" " + sql);
143 sql =
"INSERT INTO " + tableRename +
" VALUES "
144 +
"(" + tid +
"," + tid +
"," + tid +
"," + tid +
"," + tid +
","
145 + tid +
"," + tid +
"," + (tid % 2 == 0 ?
"'value_1'" :
"'value_2'")
147 logger.info(logPrefix +
" " + sql);
150 sql =
"DROP TABLE " + tableRename +
";";
151 logger.info(logPrefix +
" " + sql);
154 }
catch (Exception e) {
155 logger.error(logPrefix +
" Caught Exception: " + e.getMessage(), e);
156 exceptions[threadId] = e;
165 for (Thread t : threads) {
169 for (Exception e : exceptions) {
171 logger.error(
"Exception: " + e.getMessage(), e);
static final String[] text_values
void com.mapd.tests.SelectUpdateDeleteDifferentTables.testConcurrency |
( |
| ) |
throws Exception |
|
inline |
Definition at line 177 of file SelectUpdateDeleteDifferentTables.java.
References com.mapd.tests.SelectUpdateDeleteDifferentTables.runTest().
178 logger.info(
"SelectUpdateDeleteDifferentTables()");
180 HeavyDBTestClient su = HeavyDBTestClient.getClient(
181 "localhost", 6274,
"heavyai",
"admin",
"HyperInteractive");
182 su.runSql(
"CREATE USER dba (password = 'password', is_super = 'true');");
183 su.runSql(
"CREATE USER bob (password = 'password', is_super = 'false');");
185 su.runSql(
"GRANT CREATE on DATABASE heavyai TO bob;");
187 su.runSql(
"CREATE DATABASE db1;");
188 su.runSql(
"GRANT CREATE on DATABASE db1 TO bob;");
189 su.runSql(
"GRANT CREATE VIEW on DATABASE db1 TO bob;");
190 su.runSql(
"GRANT DROP on DATABASE db1 TO bob;");
191 su.runSql(
"GRANT DROP VIEW on DATABASE db1 TO bob;");
193 runTest(
"db1",
"admin",
"HyperInteractive",
"admin",
"HyperInteractive");
196 su.runSql(
"DROP DATABASE db1;");
197 su.runSql(
"DROP USER bob;");
198 su.runSql(
"DROP USER dba;");
200 logger.info(
"SelectUpdateDeleteDifferentTables() done");
void runTest(String db, String dbaUser, String dbaPassword, String dbUser, String dbPassword)
final Logger com.mapd.tests.SelectUpdateDeleteDifferentTables.logger |
|
staticpackage |
final String [] com.mapd.tests.SelectUpdateDeleteDifferentTables.text_values |
|
staticpackage |
Initial value:= {"foo",
"bar",
"hello",
"world",
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p"}
Definition at line 28 of file SelectUpdateDeleteDifferentTables.java.
Referenced by com.mapd.tests.SelectUpdateDeleteDifferentTables.runTest().
The documentation for this class was generated from the following file: