Search in sources :

Example 1 with TestReopen

use of org.h2.test.unit.TestReopen in project h2database by h2database.

the class TestAll method run.

private static void run(String... args) throws Exception {
    SelfDestructor.startCountdown(4 * 60);
    long time = System.nanoTime();
    printSystemInfo();
    // use lower values, to better test those cases,
    // and (for delays) to speed up the tests
    System.setProperty("h2.maxMemoryRows", "100");
    System.setProperty("h2.check2", "true");
    System.setProperty("h2.delayWrongPasswordMin", "0");
    System.setProperty("h2.delayWrongPasswordMax", "0");
    System.setProperty("h2.useThreadContextClassLoader", "true");
    // System.setProperty("h2.modifyOnWrite", "true");
    // speedup
    // System.setProperty("h2.syncMethod", "");
    /*

recovery tests with small freeList pages, page size 64

reopen org.h2.test.unit.TestPageStore
-Xmx1500m -D reopenOffset=3 -D reopenShift=1

power failure test
power failure test: MULTI_THREADED=TRUE
power failure test: larger binaries and additional index.
power failure test with randomly generating / dropping indexes and tables.

drop table test;
create table test(id identity, name varchar(100) default space(100));
@LOOP 10 insert into test select null, null from system_range(1, 100000);
delete from test;

documentation: review package and class level javadocs
documentation: rolling review at main.html

-------------

remove old TODO, move to roadmap

kill a test:
kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`

*/
    TestAll test = new TestAll();
    if (args.length > 0) {
        if ("travis".equals(args[0])) {
            test.travis = true;
            test.testAll();
        } else if ("vmlens".equals(args[0])) {
            test.vmlens = true;
            test.testAll();
        } else if ("reopen".equals(args[0])) {
            System.setProperty("h2.delayWrongPasswordMin", "0");
            System.setProperty("h2.check2", "false");
            System.setProperty("h2.analyzeAuto", "100");
            System.setProperty("h2.pageSize", "64");
            System.setProperty("h2.reopenShift", "5");
            FilePathRec.register();
            test.reopen = true;
            TestReopen reopen = new TestReopen();
            reopen.init();
            FilePathRec.setRecorder(reopen);
            test.runTests();
        } else if ("crash".equals(args[0])) {
            test.endless = true;
            new TestCrashAPI().runTest(test);
        } else if ("synth".equals(args[0])) {
            new TestSynth().runTest(test);
        } else if ("kill".equals(args[0])) {
            new TestKill().runTest(test);
        } else if ("random".equals(args[0])) {
            test.endless = true;
            new TestRandomSQL().runTest(test);
        } else if ("join".equals(args[0])) {
            new TestJoin().runTest(test);
            test.endless = true;
        } else if ("btree".equals(args[0])) {
            new TestBtreeIndex().runTest(test);
        } else if ("all".equals(args[0])) {
            test.testEverything();
        } else if ("codeCoverage".equals(args[0])) {
            test.codeCoverage = true;
            test.runCoverage();
        } else if ("multiThread".equals(args[0])) {
            new TestMulti().runTest(test);
        } else if ("halt".equals(args[0])) {
            new TestHaltApp().runTest(test);
        } else if ("timer".equals(args[0])) {
            new TestTimer().runTest(test);
        }
    } else {
        test.testAll();
    }
    System.out.println(TestBase.formatTime(TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - time)) + " total");
}
Also used : TestBtreeIndex(org.h2.test.synth.TestBtreeIndex) TestCrashAPI(org.h2.test.synth.TestCrashAPI) TestHaltApp(org.h2.test.synth.TestHaltApp) TestJoin(org.h2.test.synth.TestJoin) TestTimer(org.h2.test.synth.TestTimer) TestMulti(org.h2.test.synth.thread.TestMulti) TestKill(org.h2.test.synth.TestKill) TestReopen(org.h2.test.unit.TestReopen) TestSynth(org.h2.test.synth.sql.TestSynth) TestRandomSQL(org.h2.test.synth.TestRandomSQL)

Example 2 with TestReopen

use of org.h2.test.unit.TestReopen in project h2database by h2database.

the class TestTempTableCrash method test.

private static void test() throws Exception {
    Connection conn;
    Statement stat;
    System.setProperty("h2.delayWrongPasswordMin", "0");
    System.setProperty("h2.check2", "false");
    FilePathRec.register();
    System.setProperty("reopenShift", "4");
    TestReopen reopen = new TestReopen();
    FilePathRec.setRecorder(reopen);
    String url = "jdbc:h2:rec:memFS:data;PAGE_SIZE=64;ANALYZE_AUTO=100";
    // String url = "jdbc:h2:" + RecordingFileSystem.PREFIX +
    // "data/test;PAGE_SIZE=64";
    Class.forName("org.h2.Driver");
    DeleteDbFiles.execute("data", "test", true);
    conn = DriverManager.getConnection(url, "sa", "sa");
    stat = conn.createStatement();
    Random random = new Random(1);
    long start = System.nanoTime();
    for (int i = 0; i < 10000; i++) {
        long now = System.nanoTime();
        if (now > start + TimeUnit.SECONDS.toNanos(1)) {
            System.out.println("i: " + i);
            start = now;
        }
        int x;
        x = random.nextInt(100);
        stat.execute("drop table if exists test" + x);
        String type = random.nextBoolean() ? "temp" : "";
        // String type = "";
        stat.execute("create " + type + " table test" + x + "(id int primary key, name varchar)");
        if (random.nextBoolean()) {
            stat.execute("create index idx_" + x + " on test" + x + "(name, id)");
        }
        if (random.nextBoolean()) {
            stat.execute("insert into test" + x + " select x, x " + "from system_range(1, " + random.nextInt(100) + ")");
        }
        if (random.nextInt(10) == 1) {
            conn.close();
            conn = DriverManager.getConnection(url, "sa", "sa");
            stat = conn.createStatement();
        }
    }
    conn.close();
}
Also used : Random(java.util.Random) Statement(java.sql.Statement) Connection(java.sql.Connection) TestReopen(org.h2.test.unit.TestReopen)

Example 3 with TestReopen

use of org.h2.test.unit.TestReopen in project h2database by h2database.

the class TestMVTableEngine method testReopen.

private void testReopen() throws SQLException {
    if (config.memory) {
        return;
    }
    Connection conn;
    Statement stat;
    deleteDb(getTestName());
    conn = getConnection(getTestName() + ";MV_STORE=TRUE");
    stat = conn.createStatement();
    stat.execute("create table test(id int, name varchar)");
    conn.close();
    conn = getConnection(getTestName() + ";MV_STORE=TRUE");
    stat = conn.createStatement();
    stat.execute("drop table test");
    conn.close();
}
Also used : PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Connection(java.sql.Connection) JdbcConnection(org.h2.jdbc.JdbcConnection)

Aggregations

Connection (java.sql.Connection)2 Statement (java.sql.Statement)2 TestReopen (org.h2.test.unit.TestReopen)2 PreparedStatement (java.sql.PreparedStatement)1 Random (java.util.Random)1 JdbcConnection (org.h2.jdbc.JdbcConnection)1 TestBtreeIndex (org.h2.test.synth.TestBtreeIndex)1 TestCrashAPI (org.h2.test.synth.TestCrashAPI)1 TestHaltApp (org.h2.test.synth.TestHaltApp)1 TestJoin (org.h2.test.synth.TestJoin)1 TestKill (org.h2.test.synth.TestKill)1 TestRandomSQL (org.h2.test.synth.TestRandomSQL)1 TestTimer (org.h2.test.synth.TestTimer)1 TestSynth (org.h2.test.synth.sql.TestSynth)1 TestMulti (org.h2.test.synth.thread.TestMulti)1