/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @summary sanity test for log sudden-death and recovery
* @run ignore Requires special hooks in ReliableLog not yet putback.
*/
/* The ReliableLog uses three filenames and renaming to effect atomic
* versionFile updates. First, a newVersionFile (an intention list)
* is written. Next, the current versionFile is renamed to an
* oldVersionFile (an undo list). Finally, the newVersionFile is
* renamed to the current versionFile, and the undo list is discarded.
* If the current version file does not exist on restart, then
* stability can always be restored by reading the oldVersionFile.
*
* This test uses little conditional bombs. When a switch is flipped
* in ReliableLog, the code will abort with an InternalError at a
* particular point. We then pretend to have come up from scratch and
* recover from the bombed situation.
*/
//import javasoft.sqe.harness.Status;
//import javasoft.sqe.harness.Test;
public class Recovery
extends LogHandler
implements Serializable //, Test
{
{
//Status status = test.run (argv, System.err, System.out);
//status.exit();
}
//public Status run (String argv[], PrintStream log, PrintStream out)
{
try {
int size;
int deathpoint;
// Trash the log directory
try {
} catch (Exception e) {
}
try {
} catch (Exception e) {
}
try {
} catch (Exception e) {
}
}
}
// Generate a number of updates (size - 1) until failing
int i;
char[] u = new char[1];
for (i = 1; i < size; i++) {
u[0] = (char)(64 + (i % 26));
}
// Fail
boolean failed_as_desired = false;
try {
handler.basicUpdate(f);
} catch (InternalError e) {
if (!e.getMessage().equals(f))
throw e; // oops, not ours
failed_as_desired = true;
} finally {
try {
} catch (IOException ign) {
}
}
// deathpoint == 0 means that there is no deathpoint and we are testing
// undisastered behaviour.
" this test; test skipped");
return;
}
// Now try to recover.
try {
} catch (IOException ign) {
}
// Recovered thingy must be equal to writ or to writ + f, but nothing
// else (or in between).
{
+ ": rolled back to v1");
{
+ ": committed to v2");
} else {
final String q = "\"";
+ f.length() + ": " + q + f + q);
+ " (size/deathpoint):");
}
}
}
} catch (Exception e) {
e.printStackTrace(lg);
//return (Status.failed
throw (new RuntimeException
("Exception in sanity test for sun.rmi.log.ReliableLog"));
}
//return (Status.passed ("OKAY"));
}
public Recovery()
{
super();
this.contents = "?";
}
// implements LogHandler.initialSnapshot()
throws Exception
{
this.contents = "";
return (this);
}
// implements LogHandler.applyUpdate()
throws Exception
{
// basicUpdate appends the string
return (state);
}
// an "update" is a short string to append to this.contents (must ignore state)
{
}
}