01: /*
02:
03: Derby - Class org.apache.derbyTesting.functionTests.harness.procedure
04:
05: Licensed to the Apache Software Foundation (ASF) under one or more
06: contributor license agreements. See the NOTICE file distributed with
07: this work for additional information regarding copyright ownership.
08: The ASF licenses this file to You under the Apache License, Version 2.0
09: (the "License"); you may not use this file except in compliance with
10: the License. You may obtain a copy of the License at
11:
12: http://www.apache.org/licenses/LICENSE-2.0
13:
14: Unless required by applicable law or agreed to in writing, software
15: distributed under the License is distributed on an "AS IS" BASIS,
16: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: See the License for the specific language governing permissions and
18: limitations under the License.
19:
20: */
21:
22: package org.apache.derbyTesting.functionTests.tests.store;
23:
24: import org.apache.derby.iapi.db.OnlineCompress;
25:
26: import org.apache.derby.iapi.services.sanity.SanityManager;
27:
28: import java.sql.CallableStatement;
29: import java.sql.Connection;
30: import java.sql.PreparedStatement;
31: import java.sql.ResultSet;
32: import java.sql.SQLException;
33: import java.sql.Statement;
34:
35: import org.apache.derby.tools.ij;
36:
37: public class oc_rec2 extends OnlineCompressTest {
38:
39: public oc_rec2() {
40: }
41:
42: /**
43: * setup for restart recovery test.
44: * <p>
45: * Do setup to test restart recovery of online compress. Real work
46: * is done in next test oc_rec2 which will run restart recovery on
47: * the work done in this test.
48: *
49: **/
50: private void test1(Connection conn, String test_name,
51: String table_name) throws SQLException {
52: beginTest(conn, test_name);
53: if (!checkConsistency(conn, "APP", table_name)) {
54: logError("conistency check failed.");
55: }
56: // make sure we can add data to the existing table after redo
57: // recovery.
58: createAndLoadTable(conn, false, table_name, 6000, 0);
59: if (!checkConsistency(conn, "APP", table_name)) {
60: logError("conistency check failed.");
61: }
62:
63: // setup to test redo recovery on:
64: // create table, delete rows, compress, add rows, commit
65: String table_name_2 = table_name + "_2";
66: createAndLoadTable(conn, true, table_name_2, 2000, 0);
67: executeQuery(conn, "delete from " + table_name, true);
68: callCompress(conn, "APP", table_name, true, true, true, true);
69:
70: endTest(conn, test_name);
71: }
72:
73: public void testList(Connection conn) throws SQLException {
74: test1(conn, "test1", "TEST1");
75: }
76:
77: public static void main(String[] argv) throws Throwable {
78: oc_rec2 test = new oc_rec2();
79:
80: ij.getPropertyArg(argv);
81: Connection conn = ij.startJBMS();
82: conn.setAutoCommit(false);
83:
84: try {
85: test.testList(conn);
86: } catch (SQLException sqle) {
87: org.apache.derby.tools.JDBCDisplayUtil.ShowSQLException(
88: System.out, sqle);
89: sqle.printStackTrace(System.out);
90: }
91: }
92: }
|