Search in sources :

Example 51 with VoltProjectBuilder

use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.

the class TestCatalogDiffs method testConnectorPropertiesChanges.

public void testConnectorPropertiesChanges() throws Exception {
    // not supported in community
    if (!MiscUtils.isPro()) {
        return;
    }
    String testDir = BuildDirectoryUtils.getBuildDirectoryPath();
    final String ddl = "CREATE STREAM export_data export to target default ( id BIGINT default 0 , value BIGINT DEFAULT 0 );";
    VoltProjectBuilder builder = new VoltProjectBuilder();
    builder.addLiteralSchema(ddl);
    final String origXml = "<?xml version='1.0' encoding='UTF-8' standalone='no'?>" + "<deployment>" + "<cluster hostcount='3' kfactor='1' sitesperhost='2'/>" + "    <export>" + "        <configuration target='default' enabled='true' type='file'>" + "            <property name=\"type\">CSV</property>" + "            <property name=\"with-schema\">false</property>" + "            <property name=\"nonce\">pre-fix</property>" + "            <property name=\"outdir\">" + m_dir + "</property>" + "        </configuration>" + "    </export>" + "</deployment>";
    builder.compile(testDir + File.separator + "propexport1.jar");
    Catalog origCat = catalogForJar(testDir + File.separator + "propexport1.jar");
    final File origFile = VoltProjectBuilder.writeStringToTempFile(origXml);
    DeploymentType origDepl = CatalogUtil.getDeployment(new FileInputStream(origFile));
    String msg = CatalogUtil.compileDeployment(origCat, origDepl, false);
    assertTrue("Deployment file failed to parse: " + msg, msg == null);
    final String newPropXml = "<?xml version='1.0' encoding='UTF-8' standalone='no'?>" + "<deployment>" + "<cluster hostcount='3' kfactor='1' sitesperhost='2'/>" + "    <export>" + "        <configuration target='default' enabled='true' type='file'>" + "            <property name=\"type\">CSV</property>" + "            <property name=\"with-schema\">false</property>" + "            <property name=\"nonce\">pre-fix</property>" + "            <property name=\"outdir\">" + m_dir + "</property>" + "            <property name=\"iamnew\">see_me_roar</property>" + "        </configuration>" + "    </export>" + "</deployment>";
    builder.compile(testDir + File.separator + "propexport2.jar");
    Catalog newPropCat = catalogForJar(testDir + File.separator + "propexport2.jar");
    final File newPropFile = VoltProjectBuilder.writeStringToTempFile(newPropXml);
    DeploymentType newPropDepl = CatalogUtil.getDeployment(new FileInputStream(newPropFile));
    msg = CatalogUtil.compileDeployment(newPropCat, newPropDepl, false);
    assertTrue("Deployment file failed to parse: " + msg, msg == null);
    final String modPropXml = "<?xml version='1.0' encoding='UTF-8' standalone='no'?>" + "<deployment>" + "<cluster hostcount='3' kfactor='1' sitesperhost='2'/>" + "    <export>" + "        <configuration target='default' enabled='true' type='file'>" + "            <property name=\"type\">TSV</property>" + "            <property name=\"with-schema\">true</property>" + "            <property name=\"nonce\">pre-fix-other</property>" + "            <property name=\"outdir\">" + m_dir + "</property>" + "        </configuration>" + "    </export>" + "</deployment>";
    builder.compile(testDir + File.separator + "propexport3.jar");
    Catalog modPropCat = catalogForJar(testDir + File.separator + "propexport3.jar");
    final File modPropFile = VoltProjectBuilder.writeStringToTempFile(modPropXml);
    DeploymentType modPropDepl = CatalogUtil.getDeployment(new FileInputStream(modPropFile));
    msg = CatalogUtil.compileDeployment(modPropCat, modPropDepl, false);
    assertTrue("Deployment file failed to parse: " + msg, msg == null);
    final String modTypeXml = "<?xml version='1.0' encoding='UTF-8' standalone='no'?>" + "<deployment>" + "<cluster hostcount='3' kfactor='1' sitesperhost='2'/>" + "    <export>" + "        <configuration target='default' enabled='false' type='custom' exportconnectorclass=\"org.voltdb.exportclient.NoOpTestExportClient\" >" + "            <property name=\"foo\">false</property>" + "            <property name=\"type\">CSV</property>" + "            <property name=\"with-schema\">false</property>" + "        </configuration>" + "    </export>" + "</deployment>";
    builder.compile(testDir + File.separator + "propexport4.jar");
    Catalog modTypeCat = catalogForJar(testDir + File.separator + "propexport4.jar");
    final File modTypeFile = VoltProjectBuilder.writeStringToTempFile(modTypeXml);
    DeploymentType modTypeDepl = CatalogUtil.getDeployment(new FileInputStream(modTypeFile));
    msg = CatalogUtil.compileDeployment(modTypeCat, modTypeDepl, false);
    assertTrue("Deployment file failed to parse: " + msg, msg == null);
    // test delete
    verifyDiff(newPropCat, origCat, null, null, true, true, false);
    // test add
    verifyDiff(origCat, newPropCat, null, null, true, true, false);
    // test modification
    verifyDiff(origCat, modPropCat, null, null, true, true, false);
    // test modification
    verifyDiff(modPropCat, modTypeCat, null, null, true, true, false);
}
Also used : VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) DeploymentType(org.voltdb.compiler.deploymentfile.DeploymentType) File(java.io.File) VoltFile(org.voltdb.utils.VoltFile) FileInputStream(java.io.FileInputStream)

Example 52 with VoltProjectBuilder

use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.

the class TestCatalogDiffs method testDropTable.

public void testDropTable() throws IOException {
    // Start with table A and B.
    VoltProjectBuilder builder = new VoltProjectBuilder();
    builder.addLiteralSchema("\nCREATE TABLE A (C1 BIGINT NOT NULL, PRIMARY KEY(C1));" + "\nCREATE TABLE B (C1 BIGINT NOT NULL, PRIMARY KEY(C1));");
    builder.addPartitionInfo("A", "C1");
    builder.addPartitionInfo("B", "C1");
    builder.addProcedures(org.voltdb.catalog.ProcedureA.class, org.voltdb.catalog.ProcedureB.class);
    String testDir = BuildDirectoryUtils.getBuildDirectoryPath();
    assertTrue("Failed to compile schema", builder.compile(testDir + File.separator + "testdroptable1.jar"));
    Catalog catOriginal = catalogForJar(testDir + File.separator + "testdroptable1.jar");
    // Create a catalog with just table A
    Catalog catUpdated = getCatalogForTable("A", "droptable2");
    verifyDiff(catOriginal, catUpdated, false, null, true, false, true);
}
Also used : VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder)

Example 53 with VoltProjectBuilder

use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.

the class TestCatalogDiffs method testModifyMaterializedViewStructureRejectedIfEmpty.

public void testModifyMaterializedViewStructureRejectedIfEmpty() throws IOException {
    String testDir = BuildDirectoryUtils.getBuildDirectoryPath();
    // with a view
    VoltProjectBuilder builder = new VoltProjectBuilder();
    builder.addLiteralSchema("\nCREATE TABLE A (C1 BIGINT NOT NULL, C2 BIGINT NOT NULL);");
    builder.addLiteralSchema("\nCREATE TABLE B (C1 BIGINT NOT NULL, C2 BIGINT NOT NULL);");
    builder.addLiteralSchema("\nCREATE VIEW MATVIEW(C1, NUM) AS " + "\n    SELECT C1, COUNT(*) FROM A GROUP BY C1;");
    builder.addLiteralSchema("\nCREATE VIEW MATVIEWJOIN(C1, NUM) AS " + "\n    SELECT A.C1, COUNT(*) FROM A JOIN B ON A.C1=B.C2 GROUP BY A.C1;");
    builder.addPartitionInfo("A", "C1");
    builder.addProcedures(org.voltdb.catalog.ProcedureA.class);
    assertTrue("Failed to compile schema", builder.compile(testDir + File.separator + "modmatview1.jar"));
    Catalog catOriginal = catalogForJar(testDir + File.separator + "modmatview1.jar");
    // with a quite different view
    builder = new VoltProjectBuilder();
    builder.addLiteralSchema("\nCREATE TABLE A (C1 BIGINT NOT NULL, C2 BIGINT NOT NULL);");
    builder.addLiteralSchema("\nCREATE TABLE B (C1 BIGINT NOT NULL, C2 BIGINT NOT NULL);");
    builder.addLiteralSchema("\nCREATE VIEW MATVIEW(C2, C1, NUM) AS " + "\n    SELECT C2, C1, COUNT(*) FROM A GROUP BY C2, C1;");
    builder.addLiteralSchema("\nCREATE VIEW MATVIEWJOIN(C1, NUM) AS " + "\n    SELECT A.C2, COUNT(*) FROM A JOIN B ON A.C1=B.C1 GROUP BY A.C2;");
    builder.addPartitionInfo("A", "C1");
    builder.addProcedures(org.voltdb.catalog.ProcedureA.class);
    assertTrue("Failed to compile schema", builder.compile(testDir + File.separator + "modmatview2.jar"));
    Catalog catUpdated = catalogForJar(testDir + File.separator + "modmatview2.jar");
    verifyDiffIfEmptyTable(catOriginal, catUpdated);
}
Also used : VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder)

Example 54 with VoltProjectBuilder

use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.

the class TestCatalogDiffs method testDiffOfIdenticalCatalogs.

public void testDiffOfIdenticalCatalogs() throws IOException {
    String testDir = BuildDirectoryUtils.getBuildDirectoryPath();
    VoltProjectBuilder builder = new VoltProjectBuilder();
    builder.addLiteralSchema("\nCREATE TABLE A (C1 BIGINT NOT NULL, C2 BIGINT NOT NULL);");
    builder.addLiteralSchema("\nCREATE TABLE B (C1 BIGINT NOT NULL, C2 BIGINT NOT NULL);");
    builder.addLiteralSchema("\nCREATE VIEW MATVIEW(C1, NUM) AS " + "\n    SELECT C1, COUNT(*) FROM A GROUP BY C1;");
    builder.addLiteralSchema("\nCREATE VIEW MATVIEWJOIN(C1, NUM) AS " + "\n    SELECT A.C1, COUNT(*) FROM A JOIN B ON A.C1=B.C2 GROUP BY A.C1;");
    builder.addPartitionInfo("A", "C1");
    builder.addProcedures(org.voltdb.catalog.ProcedureA.class);
    assertTrue("Failed to compile schema", builder.compile(testDir + File.separator + "identical3.jar"));
    Catalog c3 = catalogForJar(testDir + File.separator + "identical3.jar");
    builder = new VoltProjectBuilder();
    builder.addLiteralSchema("\nCREATE TABLE A (C1 BIGINT NOT NULL, C2 BIGINT NOT NULL);");
    builder.addLiteralSchema("\nCREATE TABLE B (C1 BIGINT NOT NULL, C2 BIGINT NOT NULL);");
    builder.addLiteralSchema("\nCREATE VIEW MATVIEW(C1, NUM) AS " + "\n    SELECT C1, COUNT(*) FROM A GROUP BY C1;");
    builder.addLiteralSchema("\nCREATE VIEW MATVIEWJOIN(C1, NUM) AS " + "\n    SELECT A.C1, COUNT(*) FROM A JOIN B ON A.C1=B.C2 GROUP BY A.C1;");
    builder.addPartitionInfo("A", "C1");
    builder.addProcedures(org.voltdb.catalog.ProcedureA.class);
    assertTrue("Failed to compile schema", builder.compile(testDir + File.separator + "identical4.jar"));
    Catalog c4 = catalogForJar(testDir + File.separator + "identical4.jar");
    CatalogDiffEngine diff = new CatalogDiffEngine(c3, c4);
    // don't reach this point.
    c3.execute(diff.commands());
    assertTrue(diff.supported());
    String updatedOriginalSerialized = c3.serialize();
    assertEquals(updatedOriginalSerialized, c4.serialize());
}
Also used : VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder)

Example 55 with VoltProjectBuilder

use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.

the class TestCatalogDiffs method generateCatalogWithDeployment.

private static Catalog generateCatalogWithDeployment(String ddl, String defaultDepXml) throws IOException {
    VoltProjectBuilder builder = new VoltProjectBuilder();
    builder.addLiteralSchema(ddl);
    final File jarPath = VoltFile.createTempFile("drrole", "jar");
    builder.compile(jarPath.getAbsolutePath());
    Catalog catalog = catalogForJar(jarPath.getAbsolutePath());
    File file = VoltProjectBuilder.writeStringToTempFile(defaultDepXml);
    DeploymentType deployment = CatalogUtil.getDeployment(new FileInputStream(file));
    CatalogUtil.compileDeployment(catalog, deployment, false);
    jarPath.delete();
    return catalog;
}
Also used : VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) DeploymentType(org.voltdb.compiler.deploymentfile.DeploymentType) File(java.io.File) VoltFile(org.voltdb.utils.VoltFile) FileInputStream(java.io.FileInputStream)

Aggregations

VoltProjectBuilder (org.voltdb.compiler.VoltProjectBuilder)269 Configuration (org.voltdb.VoltDB.Configuration)89 IOException (java.io.IOException)49 Test (org.junit.Test)45 File (java.io.File)40 ProcCallException (org.voltdb.client.ProcCallException)38 ClientResponse (org.voltdb.client.ClientResponse)37 VoltDB (org.voltdb.VoltDB)22 LocalCluster (org.voltdb.regressionsuites.LocalCluster)18 Client (org.voltdb.client.Client)17 Before (org.junit.Before)14 HashMap (java.util.HashMap)13 VoltTable (org.voltdb.VoltTable)13 ServerThread (org.voltdb.ServerThread)12 InMemoryJarfile (org.voltdb.utils.InMemoryJarfile)12 VoltCompiler (org.voltdb.compiler.VoltCompiler)11 HttpResponse (org.apache.http.HttpResponse)10 BeforeClass (org.junit.BeforeClass)8 ClientConfig (org.voltdb.client.ClientConfig)7 UserInfo (org.voltdb.compiler.VoltProjectBuilder.UserInfo)7