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_rec3 extends OnlineCompressTest {
38:
39: public oc_rec3() {
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_rec3 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:
54: String table_name_2 = table_name + "_2";
55: if (!checkConsistency(conn, "APP", table_name_2)) {
56: logError("conistency check failed.");
57: }
58:
59: // make sure we can add data to the existing table after redo
60: // recovery.
61: createAndLoadTable(conn, false, table_name, 2000, 0);
62: if (!checkConsistency(conn, "APP", table_name)) {
63: logError("conistency check failed.");
64: }
65:
66: // setup to test redo recovery on:
67: // add more rows, delete rows, compress, add more, no commit
68: createAndLoadTable(conn, false, table_name_2, 4000, 2000);
69: executeQuery(conn, "delete from " + table_name_2, true);
70: callCompress(conn, "APP", table_name_2, true, true, true, false);
71:
72: endTest(conn, test_name);
73: }
74:
75: public void testList(Connection conn) throws SQLException {
76: test1(conn, "test1", "TEST1");
77: }
78:
79: public static void main(String[] argv) throws Throwable {
80: oc_rec3 test = new oc_rec3();
81:
82: ij.getPropertyArg(argv);
83: Connection conn = ij.startJBMS();
84: conn.setAutoCommit(false);
85:
86: try {
87: test.testList(conn);
88: } catch (SQLException sqle) {
89: org.apache.derby.tools.JDBCDisplayUtil.ShowSQLException(
90: System.out, sqle);
91: sqle.printStackTrace(System.out);
92: }
93: }
94: }
|