mirror of https://github.com/apache/cassandra
Stop CommitLogTest hanging
patch by branimir; reviewed by aweisberg for CASSANDRA-8992
This commit is contained in:
parent
028e7cb5af
commit
50e5802a7d
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.cassandra.db;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.cassandra.config.Config;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.db.commitlog.CommitLog;
|
||||
import org.apache.cassandra.exceptions.ConfigurationException;
|
||||
import org.apache.cassandra.gms.Gossiper;
|
||||
import org.apache.cassandra.service.StorageService;
|
||||
|
||||
public class CommitLogFailurePolicyTest
|
||||
{
|
||||
@Test
|
||||
public void testCommitFailurePolicy_stop() throws ConfigurationException
|
||||
{
|
||||
// Need storage service active so stop policy can shutdown gossip
|
||||
StorageService.instance.initServer();
|
||||
Assert.assertTrue(Gossiper.instance.isEnabled());
|
||||
|
||||
Config.CommitFailurePolicy oldPolicy = DatabaseDescriptor.getCommitFailurePolicy();
|
||||
try
|
||||
{
|
||||
DatabaseDescriptor.setCommitFailurePolicy(Config.CommitFailurePolicy.stop);
|
||||
CommitLog.handleCommitError("Test stop error", new Throwable());
|
||||
Assert.assertFalse(Gossiper.instance.isEnabled());
|
||||
}
|
||||
finally
|
||||
{
|
||||
DatabaseDescriptor.setCommitFailurePolicy(oldPolicy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,26 +23,23 @@ import java.io.*;
|
|||
import java.nio.ByteBuffer;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.zip.CRC32;
|
||||
import java.util.zip.Checksum;
|
||||
|
||||
import com.google.common.util.concurrent.Uninterruptibles;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.cassandra.SchemaLoader;
|
||||
import org.apache.cassandra.Util;
|
||||
import org.apache.cassandra.config.Config;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.db.commitlog.CommitLog;
|
||||
import org.apache.cassandra.db.commitlog.CommitLogDescriptor;
|
||||
import org.apache.cassandra.db.commitlog.ReplayPosition;
|
||||
import org.apache.cassandra.db.compaction.CompactionManager;
|
||||
import org.apache.cassandra.db.filter.NamesQueryFilter;
|
||||
import org.apache.cassandra.exceptions.ConfigurationException;
|
||||
import org.apache.cassandra.gms.Gossiper;
|
||||
import org.apache.cassandra.net.MessagingService;
|
||||
import org.apache.cassandra.service.StorageService;
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
import org.apache.cassandra.utils.FBUtilities;
|
||||
|
||||
|
|
@ -50,6 +47,12 @@ import static org.apache.cassandra.utils.ByteBufferUtil.bytes;
|
|||
|
||||
public class CommitLogTest extends SchemaLoader
|
||||
{
|
||||
@BeforeClass
|
||||
public static void init() throws ConfigurationException
|
||||
{
|
||||
CompactionManager.instance.disableAutoCompaction();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRecoveryWithEmptyLog() throws Exception
|
||||
{
|
||||
|
|
@ -238,26 +241,6 @@ public class CommitLogTest extends SchemaLoader
|
|||
Assert.assertEquals(MessagingService.current_version, CommitLogDescriptor.fromFileName(newCLName).getMessagingVersion());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCommitFailurePolicy_stop() throws ConfigurationException
|
||||
{
|
||||
// Need storage service active so stop policy can shutdown gossip
|
||||
StorageService.instance.initServer();
|
||||
Assert.assertTrue(Gossiper.instance.isEnabled());
|
||||
|
||||
Config.CommitFailurePolicy oldPolicy = DatabaseDescriptor.getCommitFailurePolicy();
|
||||
try
|
||||
{
|
||||
DatabaseDescriptor.setCommitFailurePolicy(Config.CommitFailurePolicy.stop);
|
||||
CommitLog.handleCommitError("Test stop error", new Throwable());
|
||||
Assert.assertFalse(Gossiper.instance.isEnabled());
|
||||
}
|
||||
finally
|
||||
{
|
||||
DatabaseDescriptor.setCommitFailurePolicy(oldPolicy);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTruncateWithoutSnapshot() throws ExecutionException, InterruptedException
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue