Search in sources :

Example 16 with UserInfo

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

the class TestJSONInterface method runConnectionsWithUpdateCatalog.

public void runConnectionsWithUpdateCatalog(boolean securityOn) throws Exception {
    try {
        String simpleSchema = "CREATE TABLE test1 (\n" + "    fld1 BIGINT NOT NULL,\n" + "    PRIMARY KEY (fld1)\n" + ");";
        File schemaFile = VoltProjectBuilder.writeStringToTempFile(simpleSchema);
        String schemaPath = schemaFile.getPath();
        schemaPath = URLEncoder.encode(schemaPath, "UTF-8");
        VoltProjectBuilder builder = new VoltProjectBuilder();
        builder.addSchema(schemaPath);
        builder.addPartitionInfo("test1", "fld1");
        builder.addProcedures(WorkerProc.class);
        UserInfo[] ui = new UserInfo[5];
        if (securityOn) {
            RoleInfo ri = new RoleInfo("role1", true, false, true, true, false, false);
            builder.addRoles(new RoleInfo[] { ri });
            for (int i = 0; i < ui.length; i++) {
                ui[i] = new UserInfo("user" + String.valueOf(i), "password" + String.valueOf(i), new String[] { "role1" });
            }
            builder.addUsers(ui);
            builder.setSecurityEnabled(true, true);
        }
        builder.setHTTPDPort(8095);
        boolean success = builder.compile(Configuration.getPathToCatalogForTest("json.jar"));
        assertTrue(success);
        VoltDB.Configuration config = new VoltDB.Configuration();
        config.m_pathToCatalog = config.setPathToCatalogForTest("json.jar");
        config.m_pathToDeployment = builder.getPathToDeployment();
        server = new ServerThread(config);
        server.start();
        server.waitForInitialization();
        TestWorker.s_insertCount = new AtomicLong(0);
        int poolSize = 25;
        ExecutorService executor = Executors.newFixedThreadPool(poolSize);
        int workCount = 200;
        for (int i = 0; i < workCount; i++) {
            executor.execute(new TestWorker(i, workCount / 10, (securityOn ? ui[workCount % ui.length].name : null), (securityOn ? ui[workCount % ui.length].password : null)));
        }
        // wait for everything to be done and check status
        executor.shutdown();
        if (!executor.awaitTermination(60, TimeUnit.SECONDS)) {
            fail("Workers should have finished execution by now");
        }
        assertTrue(TestWorker.s_success);
    } finally {
        if (server != null) {
            server.shutdown();
            server.join();
        }
        server = null;
    }
}
Also used : Configuration(org.voltdb.VoltDB.Configuration) UserInfo(org.voltdb.compiler.VoltProjectBuilder.UserInfo) AtomicLong(java.util.concurrent.atomic.AtomicLong) RoleInfo(org.voltdb.compiler.VoltProjectBuilder.RoleInfo) VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) Configuration(org.voltdb.VoltDB.Configuration) ExecutorService(java.util.concurrent.ExecutorService) File(java.io.File)

Example 17 with UserInfo

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

the class TestQueryTimeout method suite.

public static junit.framework.Test suite() {
    VoltServerConfig config = null;
    MultiConfigSuiteBuilder builder = new MultiConfigSuiteBuilder(TestQueryTimeout.class);
    VoltProjectBuilder project = new VoltProjectBuilder();
    final String literalSchema = "CREATE TABLE R1 ( " + "phone_number INTEGER NOT NULL, " + "state VARCHAR(2) NOT NULL, " + "contestant_number INTEGER NOT NULL);" + "CREATE TABLE P1 ( " + "phone_number INTEGER NOT NULL, " + "state VARCHAR(2) NOT NULL, " + "contestant_number INTEGER NOT NULL);" + "PARTITION TABLE P1 ON COLUMN phone_number;" + "";
    try {
        project.addLiteralSchema(literalSchema);
    } catch (IOException e) {
        fail();
    }
    project.addProcedures(PROCEDURES);
    project.setQueryTimeout(TIMEOUT);
    UserInfo[] users = new UserInfo[] { new UserInfo("adminUser", "password", new String[] { "AdMINISTRATOR" }), new UserInfo("userWithAllProc", "password", new String[] { "GroupWithAllProcPerm" }) };
    project.addUsers(users);
    RoleInfo[] groups = new RoleInfo[] { new RoleInfo("GroupWithAllProcPerm", true, true, false, true, true, true) };
    project.addRoles(groups);
    // suite defines its own ADMINISTRATOR user
    project.setSecurityEnabled(true, false);
    boolean success;
    config = new LocalCluster("querytimeout-onesite.jar", 1, 1, 0, BackendTarget.NATIVE_EE_JNI);
    success = config.compile(project);
    assertTrue(success);
    builder.addServerConfig(config);
    /* disabled until we work the kinks out of ipc support for fragment progress updates
        config = new LocalCluster("querytimeout-onesite.jar", 1, 1, 0, BackendTarget.NATIVE_EE_IPC);
        success = config.compile(project);
        assertTrue(success);
        builder.addServerConfig(config);
*/
    // Cluster
    config = new LocalCluster("querytimeout-cluster.jar", 2, 3, 1, BackendTarget.NATIVE_EE_JNI);
    success = config.compile(project);
    assertTrue(success);
    builder.addServerConfig(config);
    return builder;
}
Also used : RoleInfo(org.voltdb.compiler.VoltProjectBuilder.RoleInfo) VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) UserInfo(org.voltdb.compiler.VoltProjectBuilder.UserInfo) IOException(java.io.IOException)

Example 18 with UserInfo

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

the class TestPasswordMaskSuite method suite.

/**
     * Build a list of the tests that will be run when TestSecuritySuite gets run by JUnit.
     * Use helper classes that are part of the RegressionSuite framework.
     * This particular class runs all tests on the the local JNI backend with both
     * one and two partition configurations, as well as on the hsql backend.
     *
     * @return The TestSuite containing all the tests to be run.
     */
public static Test suite() {
    VoltServerConfig config = null;
    // the suite made here will all be using the tests from this class
    MultiConfigSuiteBuilder builder = new MultiConfigSuiteBuilder(TestPasswordMaskSuite.class);
    // build up a project builder for the workload
    TPCCProjectBuilder project = new TPCCProjectBuilder();
    project.addDefaultSchema();
    project.addDefaultPartitioning();
    UserInfo[] users = new UserInfo[] { new UserInfo("admin", "D033E22AE348AEB5660FC2140AEC35850C4DA9978C6976E5B5410415BDE908BD4DEE15DFB167A9C873FC4BB8A81F6F2AB448A918", new String[] { "administrator" }, false) };
    project.addUsers(users);
    // suite defines its own ADMINISTRATOR user
    project.setSecurityEnabled(true, false);
    /////////////////////////////////////////////////////////////
    // CONFIG #1: 1 Local Site/Partitions running on JNI backend
    /////////////////////////////////////////////////////////////
    // get a server config for the native backend with one sites/partitions
    config = new LocalCluster("passwordmask-onesite.jar", 1, 1, 0, BackendTarget.NATIVE_EE_JNI);
    // build the jarfile
    if (!config.compile(project))
        fail();
    // add this config to the set of tests to run
    builder.addServerConfig(config);
    return builder;
}
Also used : UserInfo(org.voltdb.compiler.VoltProjectBuilder.UserInfo) TPCCProjectBuilder(org.voltdb.benchmark.tpcc.TPCCProjectBuilder)

Aggregations

UserInfo (org.voltdb.compiler.VoltProjectBuilder.UserInfo)18 RoleInfo (org.voltdb.compiler.VoltProjectBuilder.RoleInfo)14 VoltProjectBuilder (org.voltdb.compiler.VoltProjectBuilder)7 File (java.io.File)6 Configuration (org.voltdb.VoltDB.Configuration)6 TPCCProjectBuilder (org.voltdb.benchmark.tpcc.TPCCProjectBuilder)4 IOException (java.io.IOException)3 ProcedureInfo (org.voltdb.compiler.VoltProjectBuilder.ProcedureInfo)3 Test (org.junit.Test)2 ClientResponse (org.voltdb.client.ClientResponse)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ExecutorService (java.util.concurrent.ExecutorService)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 HttpResponse (org.apache.http.HttpResponse)1 VoltDB (org.voltdb.VoltDB)1 VoltTable (org.voltdb.VoltTable)1 Catalog (org.voltdb.catalog.Catalog)1 Client (org.voltdb.client.Client)1 ClientConfig (org.voltdb.client.ClientConfig)1