[ https://issues.apache.org/jira/browse/ZOOKEEPER-1364?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15746927#comment-15746927 ]
ASF GitHub Bot commented on ZOOKEEPER-1364: ------------------------------------------- Github user eribeiro commented on a diff in the pull request: https://github.com/apache/zookeeper/pull/123#discussion_r92309178 --- Diff: src/java/test/org/apache/zookeeper/server/ServerCxnExceptionsTest.java --- @@ -0,0 +1,160 @@ +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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.zookeeper.server; + +import org.apache.zookeeper.CreateMode; +import org.apache.zookeeper.KeeperException; +import org.apache.zookeeper.ZooDefs; +import org.apache.zookeeper.ZooKeeper; +import org.apache.zookeeper.data.Stat; +import org.apache.zookeeper.test.ClientBase; +import org.jboss.byteman.contrib.bmunit.BMRule; +import org.jboss.byteman.contrib.bmunit.BMUnitRunner; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.junit.Assert.fail; + +/** + * Unit tests to test different exceptions scenarios in sendResponse + */ +@RunWith(BMUnitRunner.class) +public class ServerCxnExceptionsTest extends ClientBase { + + private static final Logger LOG = LoggerFactory.getLogger(ServerCxnExceptionsTest.class); + private static String previousFactory = null; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + previousFactory = System.getProperty(ServerCnxnFactory.ZOOKEEPER_SERVER_CNXN_FACTORY); + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + if (previousFactory != null) { + System.setProperty(ServerCnxnFactory.ZOOKEEPER_SERVER_CNXN_FACTORY, previousFactory); + } + } + + @Test(timeout = 60000, expected = KeeperException.ConnectionLossException.class) + @BMRule(name = "IOExceptionNetty", + targetClass = "org.apache.zookeeper.server.NettyServerCnxn", + targetMethod = "sendResponse", + action = "throw new IOException(\"Test IOException from ServerCxnExceptionsTest with Netty\");", + targetLocation = "AT ENTRY" + ) + public void testIOExceptionNetty() throws Exception { + tearDown(); + nettySetup(); + testZKHelper(true); + } + + @Test(timeout = 60000, expected = KeeperException.ConnectionLossException.class) --- End diff -- switch annotations > Add orthogonal fault injection mechanism/framework > -------------------------------------------------- > > Key: ZOOKEEPER-1364 > URL: https://issues.apache.org/jira/browse/ZOOKEEPER-1364 > Project: ZooKeeper > Issue Type: Test > Components: tests > Reporter: Andrei Savu > Assignee: Andrei Savu > > Hadoop has a mechanism for doing fault injection (HDFS-435). I think it would > be useful if something similar would be available for ZooKeeper. -- This message was sent by Atlassian JIRA (v6.3.4#6332)