use of org.voltdb.catalog.Database in project voltdb by VoltDB.
the class TestCatalogUtil method testScrambledPasswords.
public void testScrambledPasswords() throws Exception {
final String depRole = "<?xml version='1.0' encoding='UTF-8' standalone='no'?>" + "<deployment>" + "<security enabled=\"true\"/>" + "<cluster hostcount='3' kfactor='1' sitesperhost='2'/>" + "<paths><voltdbroot path=\"/tmp/" + System.getProperty("user.name") + "\" /></paths>" + "<httpd port='0'>" + "<jsonapi enabled='true'/>" + "</httpd>" + "<users> " + "<user name=\"joe\" password=\"D033E22AE348AEB5660FC2140AEC35850C4DA9978C6976E5B5410415BDE908BD4DEE15DFB167A9C873FC4BB8A81F6F2AB448A918\" plaintext=\"false\" roles=\"louno,administrator\"/>" + "</users>" + "</deployment>";
catalog_db.getGroups().add("louno");
final File tmpRole = VoltProjectBuilder.writeStringToTempFile(depRole);
CatalogUtil.compileDeployment(catalog, tmpRole.getPath(), false);
Database db = catalog.getClusters().get("cluster").getDatabases().get("database");
User joe = db.getUsers().get("joe");
assertNotNull(joe);
assertNotNull(joe.getGroups().get("louno"));
assertNotNull(joe.getShadowpassword());
}
use of org.voltdb.catalog.Database in project voltdb by VoltDB.
the class TestLiveDDLCompiler method testMultiplePartitionStatements.
// Test that multiple partition statements are accepted and that
// the final result is the final requested partitioning
public void testMultiplePartitionStatements() throws Exception {
File jarOut = new File("partitionfun.jar");
jarOut.deleteOnExit();
String schema = "CREATE TABLE T (C1 INTEGER NOT NULL, C2 INTEGER NOT NULL, C3 INTEGER NOT NULL);\n" + "PARTITION TABLE T ON COLUMN C1;\n" + "PARTITION TABLE T ON COLUMN C2;\n";
File schemaFile = VoltProjectBuilder.writeStringToTempFile(schema);
String schemaPath = schemaFile.getPath();
VoltCompiler compiler = new VoltCompiler(false);
boolean success = compiler.compileFromDDL(jarOut.getPath(), schemaPath);
assertTrue("Compilation failed unexpectedly", success);
Catalog catalog = new Catalog();
catalog.execute(CatalogUtil.getSerializedCatalogStringFromJar(CatalogUtil.loadAndUpgradeCatalogFromJar(MiscUtils.fileToBytes(new File(jarOut.getPath())), false).getFirst()));
Database db = catalog.getClusters().get("cluster").getDatabases().get("database");
Table t = db.getTables().get("T");
assertEquals("C2", t.getPartitioncolumn().getTypeName());
}
use of org.voltdb.catalog.Database in project voltdb by VoltDB.
the class TestLiveDDLCompiler method testDropExportTable.
public void testDropExportTable() throws Exception {
File jarOut = new File("partitionfun.jar");
jarOut.deleteOnExit();
String schema = "CREATE STREAM T (C1 INTEGER NOT NULL, C2 INTEGER NOT NULL, C3 INTEGER NOT NULL);\n" + "DROP STREAM T;\n";
File schemaFile = VoltProjectBuilder.writeStringToTempFile(schema);
String schemaPath = schemaFile.getPath();
VoltCompiler compiler = new VoltCompiler(false);
boolean success = compiler.compileFromDDL(jarOut.getPath(), schemaPath);
assertTrue("Compilation failed unexpectedly", success);
Catalog catalog = new Catalog();
catalog.execute(CatalogUtil.getSerializedCatalogStringFromJar(CatalogUtil.loadAndUpgradeCatalogFromJar(MiscUtils.fileToBytes(new File(jarOut.getPath())), false).getFirst()));
Database db = catalog.getClusters().get("cluster").getDatabases().get("database");
Table t = db.getTables().get("T");
assertEquals(null, t);
}
use of org.voltdb.catalog.Database in project voltdb by VoltDB.
the class TestLiveDDLCompiler method testDropPartitionedTable.
public void testDropPartitionedTable() throws Exception {
File jarOut = new File("partitionfun.jar");
jarOut.deleteOnExit();
String schema = "CREATE TABLE T (C1 INTEGER NOT NULL, C2 INTEGER NOT NULL, C3 INTEGER NOT NULL);\n" + "PARTITION TABLE T ON COLUMN C1;\n" + "DROP TABLE T;\n";
File schemaFile = VoltProjectBuilder.writeStringToTempFile(schema);
String schemaPath = schemaFile.getPath();
VoltCompiler compiler = new VoltCompiler(false);
boolean success = compiler.compileFromDDL(jarOut.getPath(), schemaPath);
assertTrue("Compilation failed unexpectedly", success);
Catalog catalog = new Catalog();
catalog.execute(CatalogUtil.getSerializedCatalogStringFromJar(CatalogUtil.loadAndUpgradeCatalogFromJar(MiscUtils.fileToBytes(new File(jarOut.getPath())), false).getFirst()));
Database db = catalog.getClusters().get("cluster").getDatabases().get("database");
Table t = db.getTables().get("T");
assertEquals(null, t);
}
use of org.voltdb.catalog.Database in project voltdb by VoltDB.
the class TestVoltCompiler method checkRoleDDL.
private void checkRoleDDL(String ddl, String errorRegex, TestRole... roles) throws Exception {
VoltCompiler compiler = new VoltCompiler(false);
final boolean success = compileDDL(ddl, compiler);
String error = (success || compiler.m_errors.size() == 0 ? "" : compiler.m_errors.get(compiler.m_errors.size() - 1).message);
if (errorRegex == null) {
assertTrue(String.format("Expected success\nDDL: %s\nERR: %s", ddl, error), success);
Database db = compiler.getCatalog().getClusters().get("cluster").getDatabases().get("database");
CatalogMap<Group> groups = db.getGroups();
CatalogMap<Connector> connectors = db.getConnectors();
if (connectors.get("0") == null) {
connectors.add("0");
}
assertNotNull(groups);
assertTrue(roles.length <= groups.size());
for (TestRole role : roles) {
Group group = groups.get(role.name);
assertNotNull(String.format("Missing role \"%s\"", role.name), group);
assertEquals(String.format("Role \"%s\" sql flag mismatch:", role.name), role.sql, group.getSql());
assertEquals(String.format("Role \"%s\" sqlread flag mismatch:", role.name), role.sqlread, group.getSqlread());
assertEquals(String.format("Role \"%s\" admin flag mismatch:", role.name), role.sysproc, group.getAdmin());
assertEquals(String.format("Role \"%s\" defaultproc flag mismatch:", role.name), role.defaultproc, group.getDefaultproc());
assertEquals(String.format("Role \"%s\" defaultprocread flag mismatch:", role.name), role.defaultprocread, group.getDefaultprocread());
assertEquals(String.format("Role \"%s\" allproc flag mismatch:", role.name), role.allproc, group.getAllproc());
}
} else {
assertFalse(String.format("Expected error (\"%s\")\n\nDDL: %s", errorRegex, ddl), success);
assertFalse("Expected at least one error message.", error.isEmpty());
Matcher m = Pattern.compile(errorRegex).matcher(error);
assertTrue(String.format("%s\nEXPECTED: %s", error, errorRegex), m.matches());
}
}
Aggregations