Search in sources :

Example 1 with TestAll

use of org.h2.test.TestAll in project h2database by h2database.

the class TestDataPage method testAll.

private void testAll() {
    Data page = Data.create(this, 128);
    char[] data = new char[0x10000];
    for (int i = 0; i < data.length; i++) {
        data[i] = (char) i;
    }
    String s = new String(data);
    page.checkCapacity(s.length() * 4);
    page.writeString(s);
    int len = page.length();
    assertEquals(len, Data.getStringLen(s));
    page.reset();
    assertEquals(s, page.readString());
    page.reset();
    page.writeString("H\u1111!");
    page.writeString("John\tBrack's \"how are you\" M\u1111ller");
    page.writeValue(ValueInt.get(10));
    page.writeValue(ValueString.get("test"));
    page.writeValue(ValueFloat.get(-2.25f));
    page.writeValue(ValueDouble.get(10.40));
    page.writeValue(ValueNull.INSTANCE);
    trace(new String(page.getBytes()));
    page.reset();
    trace(page.readString());
    trace(page.readString());
    trace(page.readValue().getInt());
    trace(page.readValue().getString());
    trace("" + page.readValue().getFloat());
    trace("" + page.readValue().getDouble());
    trace(page.readValue().toString());
    page.reset();
    page.writeInt(0);
    page.writeInt(Integer.MAX_VALUE);
    page.writeInt(Integer.MIN_VALUE);
    page.writeInt(1);
    page.writeInt(-1);
    page.writeInt(1234567890);
    page.writeInt(54321);
    trace(new String(page.getBytes()));
    page.reset();
    trace(page.readInt());
    trace(page.readInt());
    trace(page.readInt());
    trace(page.readInt());
    trace(page.readInt());
    trace(page.readInt());
    trace(page.readInt());
    page = null;
}
Also used : Data(org.h2.store.Data) ValueString(org.h2.value.ValueString)

Example 2 with TestAll

use of org.h2.test.TestAll in project h2database by h2database.

the class TestAll method testAll.

private void testAll() throws Exception {
    runTests();
    if (!travis && !vmlens) {
        Profiler prof = new Profiler();
        prof.depth = 16;
        prof.interval = 1;
        prof.startCollecting();
        TestPerformance.main("-init", "-db", "1", "-size", "1000");
        prof.stopCollecting();
        System.out.println(prof.getTop(5));
        TestPerformance.main("-init", "-db", "1", "-size", "1000");
    }
}
Also used : Profiler(org.h2.util.Profiler)

Example 3 with TestAll

use of org.h2.test.TestAll 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 4 with TestAll

use of org.h2.test.TestAll in project h2database by h2database.

the class TestCrashAPI method init.

@Override
public TestBase init(TestAll conf) throws Exception {
    super.init(conf);
    if (config.mvcc || config.networked) {
        return this;
    }
    startServerIfRequired();
    TestScript script = new TestScript();
    ArrayList<String> add = script.getAllStatements(config);
    initMethods();
    org.h2.Driver.load();
    statements.addAll(add);
    return this;
}
Also used : TestScript(org.h2.test.scripts.TestScript)

Example 5 with TestAll

use of org.h2.test.TestAll in project h2database by h2database.

the class TestGeneralCommonTableQueries method testSimple3RowRecursiveQueryWithLazyEval.

private void testSimple3RowRecursiveQueryWithLazyEval() throws Exception {
    String[] expectedRowData = new String[] { "|6" };
    String[] expectedColumnTypes = new String[] { "BIGINT" };
    String[] expectedColumnNames = new String[] { "SUM(N)" };
    // back up the config - to restore it after this test
    TestAll backupConfig = config;
    config = new TestAll();
    try {
        // Test with settings: lazy mvStore memory mvcc multiThreaded
        // connection url is
        // mem:script;MV_STORE=true;LOG=1;LOCK_TIMEOUT=50;MVCC=TRUE;
        // MULTI_THREADED=TRUE;LAZY_QUERY_EXECUTION=1
        config.lazy = true;
        config.mvStore = true;
        config.memory = true;
        config.mvcc = true;
        config.multiThreaded = true;
        String setupSQL = "--no config set";
        String withQuery = "select sum(n) from (\n" + "    with recursive r(n) as (\n" + "        (select 1) union all (select n+1 from r where n < 3) \n" + "    )\n" + "    select n from r \n" + ")\n";
        int maxRetries = 10;
        int expectedNumberOfRows = expectedRowData.length;
        testRepeatedQueryWithSetup(maxRetries, expectedRowData, expectedColumnNames, expectedNumberOfRows, setupSQL, withQuery, maxRetries - 1, expectedColumnTypes);
    } finally {
        config = backupConfig;
    }
}
Also used : TestAll(org.h2.test.TestAll)

Aggregations

Data (org.h2.store.Data)1 TestAll (org.h2.test.TestAll)1 TestScript (org.h2.test.scripts.TestScript)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 TestReopen (org.h2.test.unit.TestReopen)1 Profiler (org.h2.util.Profiler)1 ValueString (org.h2.value.ValueString)1