Search in sources :

Example 6 with Database

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());
}
Also used : User(org.voltdb.catalog.User) Database(org.voltdb.catalog.Database) File(java.io.File)

Example 7 with Database

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());
}
Also used : Table(org.voltdb.catalog.Table) Database(org.voltdb.catalog.Database) File(java.io.File) Catalog(org.voltdb.catalog.Catalog)

Example 8 with Database

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);
}
Also used : Table(org.voltdb.catalog.Table) Database(org.voltdb.catalog.Database) File(java.io.File) Catalog(org.voltdb.catalog.Catalog)

Example 9 with Database

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);
}
Also used : Table(org.voltdb.catalog.Table) Database(org.voltdb.catalog.Database) File(java.io.File) Catalog(org.voltdb.catalog.Catalog)

Example 10 with Database

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());
    }
}
Also used : Group(org.voltdb.catalog.Group) Connector(org.voltdb.catalog.Connector) Matcher(java.util.regex.Matcher) Database(org.voltdb.catalog.Database)

Aggregations

Database (org.voltdb.catalog.Database)62 Table (org.voltdb.catalog.Table)22 Catalog (org.voltdb.catalog.Catalog)12 Cluster (org.voltdb.catalog.Cluster)10 File (java.io.File)9 Column (org.voltdb.catalog.Column)9 Procedure (org.voltdb.catalog.Procedure)9 IOException (java.io.IOException)5 VoltTable (org.voltdb.VoltTable)5 ArrayList (java.util.ArrayList)4 Group (org.voltdb.catalog.Group)4 Connector (org.voltdb.catalog.Connector)3 Constraint (org.voltdb.catalog.Constraint)3 Statement (org.voltdb.catalog.Statement)3 FileNotFoundException (java.io.FileNotFoundException)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 SimpleDateFormat (java.text.SimpleDateFormat)2 HashMap (java.util.HashMap)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 JAXBException (javax.xml.bind.JAXBException)2