[GitHub] accumulo pull request #219: ACCUMULO-4584 Remove oneway method checks

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[GitHub] accumulo pull request #219: ACCUMULO-4584 Remove oneway method checks

joshelser
GitHub user ctubbsii opened a pull request:

    https://github.com/apache/accumulo/pull/219

    ACCUMULO-4584 Remove oneway method checks

    Remove the unnecessary oneway method checking in RpcWrapper (no longer
    needed with Thrift 0.10.0) and simplify RpcWrapper.
   
    Provide more comprehensive test of RpcWrapper behavior with in-memory
    transport to test for exception handling behavior in regular and oneway
    thrift service methods.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/ctubbsii/accumulo ACCUMULO-4584-oneway-checks-removal

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/accumulo/pull/219.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #219
   
----
commit a99b23764b3dd15fa0e3b64ef39e2440cc3e081b
Author: Christopher Tubbs <[hidden email]>
Date:   2017-02-22T05:23:03Z

    ACCUMULO-4584 Remove oneway method checks
   
    Remove the unnecessary oneway method checking in RpcWrapper (no longer
    needed with Thrift 0.10.0) and simplify RpcWrapper.
   
    Provide more comprehensive test of RpcWrapper behavior with in-memory
    transport to test for exception handling behavior in regular and oneway
    thrift service methods.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[GitHub] accumulo pull request #219: ACCUMULO-4584 Remove oneway method checks

joshelser
Github user joshelser commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/219#discussion_r102494321
 
    --- Diff: test/src/main/java/org/apache/accumulo/test/rpc/ThriftBehaviorIT.java ---
    @@ -0,0 +1,191 @@
    +/*
    + * 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.accumulo.test.rpc;
    +
    +import java.util.Arrays;
    +import java.util.HashMap;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +import org.apache.accumulo.test.categories.SunnyDayTests;
    +import org.apache.accumulo.test.rpc.thrift.SimpleThriftService;
    +import org.apache.log4j.Level;
    +import org.apache.log4j.Logger;
    +import org.apache.thrift.ProcessFunction;
    +import org.apache.thrift.TApplicationException;
    +import org.apache.thrift.TException;
    +import org.apache.thrift.server.TSimpleServer;
    +import org.hamcrest.core.IsInstanceOf;
    +import org.junit.After;
    +import org.junit.Assert;
    +import org.junit.Before;
    +import org.junit.Rule;
    +import org.junit.Test;
    +import org.junit.experimental.categories.Category;
    +import org.junit.rules.ExpectedException;
    +import org.junit.rules.TestName;
    +import org.junit.rules.Timeout;
    +
    +@Category(SunnyDayTests.class)
    +public class ThriftBehaviorIT {
    +
    +  @Rule
    +  public Timeout timeout = new Timeout(5, TimeUnit.SECONDS);
    +
    +  @Rule
    +  public TestName testName = new TestName();
    +
    +  @Rule
    +  public ExpectedException exception = ExpectedException.none();
    +
    +  private SimpleThriftService.Client client;
    +  private SimpleThriftServiceHandler handler;
    +  private SimpleThriftServiceRunner serviceRunner;
    +  private String propName;
    +  private Map<Logger,Level> oldLogLevels = new HashMap<>();
    +
    +  private static final String KITTY_MSG = "🐈 Kitty! 🐈";
    +
    +  // can delete wrapper when tests pass without using it (assuming tests are good enough)
    +  private static final boolean USE_RPC_WRAPPER = true;
    +
    +  private static final boolean SUPPRESS_SPAMMY_LOGGERS = true;
    +
    +  @Before
    +  public void createClientAndServer() {
    +    Arrays.stream(new Class<?>[] {TSimpleServer.class, ProcessFunction.class}).forEach(spammyClass -> {
    +      Logger spammyLogger = Logger.getLogger(spammyClass);
    +      oldLogLevels.put(spammyLogger, spammyLogger.getLevel());
    +      if (SUPPRESS_SPAMMY_LOGGERS) {
    +        spammyLogger.setLevel(Level.OFF);
    +      }
    +    });
    +
    +    String threadName = ThriftBehaviorIT.class.getSimpleName() + "." + testName.getMethodName();
    +    serviceRunner = new SimpleThriftServiceRunner(threadName, USE_RPC_WRAPPER);
    +    serviceRunner.startService();
    +    client = serviceRunner.client();
    +    handler = serviceRunner.handler();
    +
    +    propName = testName.getMethodName();
    +    if (propName.endsWith("Handler")) {
    +      propName = propName.substring(0, propName.length() - 7);
    +    }
    +    propName = SimpleThriftServiceHandler.class.getSimpleName() + "." + propName;
    +
    +    System.setProperty(propName, "-");
    +    Assert.assertEquals("-", System.getProperty(propName));
    +  }
    +
    +  @After
    +  public void shutdownServer() {
    +    serviceRunner.stopService();
    +
    +    oldLogLevels.forEach((spammyLogger, oldLevel) -> {
    +      spammyLogger.setLevel(oldLevel);
    +    });
    +
    +    Assert.assertEquals(KITTY_MSG, System.getProperty(propName));
    +  }
    +
    +  @Test
    +  public void echoFailHandler() throws TException {
    +    exception.expect(TException.class);
    +    exception.expectCause(IsInstanceOf.instanceOf(UnsupportedOperationException.class));
    +    handler.echoFail(KITTY_MSG);
    +  }
    +
    +  @Test
    +  public void echoFail() throws TException {
    +    try {
    +      client.echoFail(KITTY_MSG);
    +      Assert.fail();
    +    } catch (Exception e) {
    +      Assert.assertEquals(TApplicationException.class.getName(), e.getClass().getName());
    +    }
    +    // verify normal two-way method still passes using same client
    +    echoPass();
    +  }
    +
    +  @Test
    +  public void echoRuntimeFailHandler() throws TException {
    +    exception.expect(UnsupportedOperationException.class);
    +    handler.echoRuntimeFail(KITTY_MSG);
    +  }
    +
    +  @Test
    +  public void echoRuntimeFail() throws TException {
    +    try {
    +      client.echoRuntimeFail(KITTY_MSG);
    +      Assert.fail();
    --- End diff --
   
    Failure message, please.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[GitHub] accumulo pull request #219: ACCUMULO-4584 Remove oneway method checks

joshelser
In reply to this post by joshelser
Github user joshelser commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/219#discussion_r102493777
 
    --- Diff: test/src/main/java/org/apache/accumulo/test/rpc/ThriftBehaviorIT.java ---
    @@ -0,0 +1,191 @@
    +/*
    + * 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.accumulo.test.rpc;
    +
    +import java.util.Arrays;
    +import java.util.HashMap;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +import org.apache.accumulo.test.categories.SunnyDayTests;
    +import org.apache.accumulo.test.rpc.thrift.SimpleThriftService;
    +import org.apache.log4j.Level;
    +import org.apache.log4j.Logger;
    +import org.apache.thrift.ProcessFunction;
    +import org.apache.thrift.TApplicationException;
    +import org.apache.thrift.TException;
    +import org.apache.thrift.server.TSimpleServer;
    +import org.hamcrest.core.IsInstanceOf;
    +import org.junit.After;
    +import org.junit.Assert;
    +import org.junit.Before;
    +import org.junit.Rule;
    +import org.junit.Test;
    +import org.junit.experimental.categories.Category;
    +import org.junit.rules.ExpectedException;
    +import org.junit.rules.TestName;
    +import org.junit.rules.Timeout;
    +
    +@Category(SunnyDayTests.class)
    +public class ThriftBehaviorIT {
    +
    +  @Rule
    +  public Timeout timeout = new Timeout(5, TimeUnit.SECONDS);
    +
    +  @Rule
    +  public TestName testName = new TestName();
    +
    +  @Rule
    +  public ExpectedException exception = ExpectedException.none();
    +
    +  private SimpleThriftService.Client client;
    +  private SimpleThriftServiceHandler handler;
    +  private SimpleThriftServiceRunner serviceRunner;
    +  private String propName;
    +  private Map<Logger,Level> oldLogLevels = new HashMap<>();
    +
    +  private static final String KITTY_MSG = "🐈 Kitty! 🐈";
    +
    +  // can delete wrapper when tests pass without using it (assuming tests are good enough)
    +  private static final boolean USE_RPC_WRAPPER = true;
    +
    +  private static final boolean SUPPRESS_SPAMMY_LOGGERS = true;
    +
    +  @Before
    +  public void createClientAndServer() {
    +    Arrays.stream(new Class<?>[] {TSimpleServer.class, ProcessFunction.class}).forEach(spammyClass -> {
    +      Logger spammyLogger = Logger.getLogger(spammyClass);
    +      oldLogLevels.put(spammyLogger, spammyLogger.getLevel());
    +      if (SUPPRESS_SPAMMY_LOGGERS) {
    +        spammyLogger.setLevel(Level.OFF);
    --- End diff --
   
    Is this worth another reference to Log4j specific APIs?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[GitHub] accumulo pull request #219: ACCUMULO-4584 Remove oneway method checks

joshelser
In reply to this post by joshelser
Github user joshelser commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/219#discussion_r102494824
 
    --- Diff: test/src/main/java/org/apache/accumulo/test/rpc/ThriftBehaviorIT.java ---
    @@ -0,0 +1,191 @@
    +/*
    + * 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.accumulo.test.rpc;
    +
    +import java.util.Arrays;
    +import java.util.HashMap;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +import org.apache.accumulo.test.categories.SunnyDayTests;
    +import org.apache.accumulo.test.rpc.thrift.SimpleThriftService;
    +import org.apache.log4j.Level;
    +import org.apache.log4j.Logger;
    +import org.apache.thrift.ProcessFunction;
    +import org.apache.thrift.TApplicationException;
    +import org.apache.thrift.TException;
    +import org.apache.thrift.server.TSimpleServer;
    +import org.hamcrest.core.IsInstanceOf;
    +import org.junit.After;
    +import org.junit.Assert;
    +import org.junit.Before;
    +import org.junit.Rule;
    +import org.junit.Test;
    +import org.junit.experimental.categories.Category;
    +import org.junit.rules.ExpectedException;
    +import org.junit.rules.TestName;
    +import org.junit.rules.Timeout;
    +
    +@Category(SunnyDayTests.class)
    +public class ThriftBehaviorIT {
    +
    +  @Rule
    +  public Timeout timeout = new Timeout(5, TimeUnit.SECONDS);
    +
    +  @Rule
    +  public TestName testName = new TestName();
    +
    +  @Rule
    +  public ExpectedException exception = ExpectedException.none();
    +
    +  private SimpleThriftService.Client client;
    +  private SimpleThriftServiceHandler handler;
    +  private SimpleThriftServiceRunner serviceRunner;
    +  private String propName;
    +  private Map<Logger,Level> oldLogLevels = new HashMap<>();
    +
    +  private static final String KITTY_MSG = "🐈 Kitty! 🐈";
    +
    +  // can delete wrapper when tests pass without using it (assuming tests are good enough)
    +  private static final boolean USE_RPC_WRAPPER = true;
    --- End diff --
   
    I would have thought this would be `false` with Thrift 0.10.0. Is that not the case?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[GitHub] accumulo pull request #219: ACCUMULO-4584 Remove oneway method checks

joshelser
In reply to this post by joshelser
Github user joshelser commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/219#discussion_r102494283
 
    --- Diff: test/src/main/java/org/apache/accumulo/test/rpc/ThriftBehaviorIT.java ---
    @@ -0,0 +1,191 @@
    +/*
    + * 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.accumulo.test.rpc;
    +
    +import java.util.Arrays;
    +import java.util.HashMap;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +import org.apache.accumulo.test.categories.SunnyDayTests;
    +import org.apache.accumulo.test.rpc.thrift.SimpleThriftService;
    +import org.apache.log4j.Level;
    +import org.apache.log4j.Logger;
    +import org.apache.thrift.ProcessFunction;
    +import org.apache.thrift.TApplicationException;
    +import org.apache.thrift.TException;
    +import org.apache.thrift.server.TSimpleServer;
    +import org.hamcrest.core.IsInstanceOf;
    +import org.junit.After;
    +import org.junit.Assert;
    +import org.junit.Before;
    +import org.junit.Rule;
    +import org.junit.Test;
    +import org.junit.experimental.categories.Category;
    +import org.junit.rules.ExpectedException;
    +import org.junit.rules.TestName;
    +import org.junit.rules.Timeout;
    +
    +@Category(SunnyDayTests.class)
    +public class ThriftBehaviorIT {
    +
    +  @Rule
    +  public Timeout timeout = new Timeout(5, TimeUnit.SECONDS);
    +
    +  @Rule
    +  public TestName testName = new TestName();
    +
    +  @Rule
    +  public ExpectedException exception = ExpectedException.none();
    +
    +  private SimpleThriftService.Client client;
    +  private SimpleThriftServiceHandler handler;
    +  private SimpleThriftServiceRunner serviceRunner;
    +  private String propName;
    +  private Map<Logger,Level> oldLogLevels = new HashMap<>();
    +
    +  private static final String KITTY_MSG = "🐈 Kitty! 🐈";
    +
    +  // can delete wrapper when tests pass without using it (assuming tests are good enough)
    +  private static final boolean USE_RPC_WRAPPER = true;
    +
    +  private static final boolean SUPPRESS_SPAMMY_LOGGERS = true;
    +
    +  @Before
    +  public void createClientAndServer() {
    +    Arrays.stream(new Class<?>[] {TSimpleServer.class, ProcessFunction.class}).forEach(spammyClass -> {
    +      Logger spammyLogger = Logger.getLogger(spammyClass);
    +      oldLogLevels.put(spammyLogger, spammyLogger.getLevel());
    +      if (SUPPRESS_SPAMMY_LOGGERS) {
    +        spammyLogger.setLevel(Level.OFF);
    +      }
    +    });
    +
    +    String threadName = ThriftBehaviorIT.class.getSimpleName() + "." + testName.getMethodName();
    +    serviceRunner = new SimpleThriftServiceRunner(threadName, USE_RPC_WRAPPER);
    +    serviceRunner.startService();
    +    client = serviceRunner.client();
    +    handler = serviceRunner.handler();
    +
    +    propName = testName.getMethodName();
    +    if (propName.endsWith("Handler")) {
    +      propName = propName.substring(0, propName.length() - 7);
    +    }
    +    propName = SimpleThriftServiceHandler.class.getSimpleName() + "." + propName;
    +
    +    System.setProperty(propName, "-");
    +    Assert.assertEquals("-", System.getProperty(propName));
    +  }
    +
    +  @After
    +  public void shutdownServer() {
    +    serviceRunner.stopService();
    +
    +    oldLogLevels.forEach((spammyLogger, oldLevel) -> {
    +      spammyLogger.setLevel(oldLevel);
    +    });
    +
    +    Assert.assertEquals(KITTY_MSG, System.getProperty(propName));
    +  }
    +
    +  @Test
    +  public void echoFailHandler() throws TException {
    +    exception.expect(TException.class);
    +    exception.expectCause(IsInstanceOf.instanceOf(UnsupportedOperationException.class));
    +    handler.echoFail(KITTY_MSG);
    +  }
    +
    +  @Test
    +  public void echoFail() throws TException {
    +    try {
    +      client.echoFail(KITTY_MSG);
    +      Assert.fail();
    --- End diff --
   
    Message as to why the test failed, please.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[GitHub] accumulo pull request #219: ACCUMULO-4584 Remove oneway method checks

joshelser
In reply to this post by joshelser
Github user joshelser commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/219#discussion_r102495875
 
    --- Diff: test/src/main/java/org/apache/accumulo/test/rpc/ThriftBehaviorIT.java ---
    @@ -0,0 +1,191 @@
    +/*
    + * 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.accumulo.test.rpc;
    +
    +import java.util.Arrays;
    +import java.util.HashMap;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +import org.apache.accumulo.test.categories.SunnyDayTests;
    +import org.apache.accumulo.test.rpc.thrift.SimpleThriftService;
    +import org.apache.log4j.Level;
    +import org.apache.log4j.Logger;
    +import org.apache.thrift.ProcessFunction;
    +import org.apache.thrift.TApplicationException;
    +import org.apache.thrift.TException;
    +import org.apache.thrift.server.TSimpleServer;
    +import org.hamcrest.core.IsInstanceOf;
    +import org.junit.After;
    +import org.junit.Assert;
    +import org.junit.Before;
    +import org.junit.Rule;
    +import org.junit.Test;
    +import org.junit.experimental.categories.Category;
    +import org.junit.rules.ExpectedException;
    +import org.junit.rules.TestName;
    +import org.junit.rules.Timeout;
    +
    +@Category(SunnyDayTests.class)
    +public class ThriftBehaviorIT {
    +
    +  @Rule
    +  public Timeout timeout = new Timeout(5, TimeUnit.SECONDS);
    +
    +  @Rule
    +  public TestName testName = new TestName();
    +
    +  @Rule
    +  public ExpectedException exception = ExpectedException.none();
    +
    +  private SimpleThriftService.Client client;
    +  private SimpleThriftServiceHandler handler;
    +  private SimpleThriftServiceRunner serviceRunner;
    +  private String propName;
    +  private Map<Logger,Level> oldLogLevels = new HashMap<>();
    +
    +  private static final String KITTY_MSG = "🐈 Kitty! 🐈";
    +
    +  // can delete wrapper when tests pass without using it (assuming tests are good enough)
    +  private static final boolean USE_RPC_WRAPPER = true;
    +
    +  private static final boolean SUPPRESS_SPAMMY_LOGGERS = true;
    +
    +  @Before
    +  public void createClientAndServer() {
    +    Arrays.stream(new Class<?>[] {TSimpleServer.class, ProcessFunction.class}).forEach(spammyClass -> {
    +      Logger spammyLogger = Logger.getLogger(spammyClass);
    +      oldLogLevels.put(spammyLogger, spammyLogger.getLevel());
    +      if (SUPPRESS_SPAMMY_LOGGERS) {
    +        spammyLogger.setLevel(Level.OFF);
    +      }
    +    });
    +
    +    String threadName = ThriftBehaviorIT.class.getSimpleName() + "." + testName.getMethodName();
    +    serviceRunner = new SimpleThriftServiceRunner(threadName, USE_RPC_WRAPPER);
    +    serviceRunner.startService();
    +    client = serviceRunner.client();
    +    handler = serviceRunner.handler();
    +
    +    propName = testName.getMethodName();
    +    if (propName.endsWith("Handler")) {
    +      propName = propName.substring(0, propName.length() - 7);
    +    }
    +    propName = SimpleThriftServiceHandler.class.getSimpleName() + "." + propName;
    +
    +    System.setProperty(propName, "-");
    +    Assert.assertEquals("-", System.getProperty(propName));
    +  }
    +
    +  @After
    +  public void shutdownServer() {
    +    serviceRunner.stopService();
    +
    +    oldLogLevels.forEach((spammyLogger, oldLevel) -> {
    +      spammyLogger.setLevel(oldLevel);
    +    });
    +
    +    Assert.assertEquals(KITTY_MSG, System.getProperty(propName));
    --- End diff --
   
    What's this assertion meant to be checking? That you had the expected method last executed?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[GitHub] accumulo pull request #219: ACCUMULO-4584 Remove oneway method checks

joshelser
In reply to this post by joshelser
Github user joshelser commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/219#discussion_r102494498
 
    --- Diff: test/src/main/java/org/apache/accumulo/test/rpc/ThriftBehaviorIT.java ---
    @@ -0,0 +1,191 @@
    +/*
    + * 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.accumulo.test.rpc;
    +
    +import java.util.Arrays;
    +import java.util.HashMap;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +import org.apache.accumulo.test.categories.SunnyDayTests;
    +import org.apache.accumulo.test.rpc.thrift.SimpleThriftService;
    +import org.apache.log4j.Level;
    +import org.apache.log4j.Logger;
    +import org.apache.thrift.ProcessFunction;
    +import org.apache.thrift.TApplicationException;
    +import org.apache.thrift.TException;
    +import org.apache.thrift.server.TSimpleServer;
    +import org.hamcrest.core.IsInstanceOf;
    +import org.junit.After;
    +import org.junit.Assert;
    +import org.junit.Before;
    +import org.junit.Rule;
    +import org.junit.Test;
    +import org.junit.experimental.categories.Category;
    +import org.junit.rules.ExpectedException;
    +import org.junit.rules.TestName;
    +import org.junit.rules.Timeout;
    +
    +@Category(SunnyDayTests.class)
    +public class ThriftBehaviorIT {
    +
    +  @Rule
    +  public Timeout timeout = new Timeout(5, TimeUnit.SECONDS);
    +
    +  @Rule
    +  public TestName testName = new TestName();
    +
    +  @Rule
    +  public ExpectedException exception = ExpectedException.none();
    +
    +  private SimpleThriftService.Client client;
    +  private SimpleThriftServiceHandler handler;
    +  private SimpleThriftServiceRunner serviceRunner;
    +  private String propName;
    +  private Map<Logger,Level> oldLogLevels = new HashMap<>();
    +
    +  private static final String KITTY_MSG = "🐈 Kitty! 🐈";
    +
    +  // can delete wrapper when tests pass without using it (assuming tests are good enough)
    +  private static final boolean USE_RPC_WRAPPER = true;
    +
    +  private static final boolean SUPPRESS_SPAMMY_LOGGERS = true;
    +
    +  @Before
    +  public void createClientAndServer() {
    +    Arrays.stream(new Class<?>[] {TSimpleServer.class, ProcessFunction.class}).forEach(spammyClass -> {
    +      Logger spammyLogger = Logger.getLogger(spammyClass);
    +      oldLogLevels.put(spammyLogger, spammyLogger.getLevel());
    +      if (SUPPRESS_SPAMMY_LOGGERS) {
    +        spammyLogger.setLevel(Level.OFF);
    +      }
    +    });
    +
    +    String threadName = ThriftBehaviorIT.class.getSimpleName() + "." + testName.getMethodName();
    +    serviceRunner = new SimpleThriftServiceRunner(threadName, USE_RPC_WRAPPER);
    +    serviceRunner.startService();
    +    client = serviceRunner.client();
    +    handler = serviceRunner.handler();
    +
    +    propName = testName.getMethodName();
    +    if (propName.endsWith("Handler")) {
    +      propName = propName.substring(0, propName.length() - 7);
    +    }
    +    propName = SimpleThriftServiceHandler.class.getSimpleName() + "." + propName;
    +
    +    System.setProperty(propName, "-");
    +    Assert.assertEquals("-", System.getProperty(propName));
    --- End diff --
   
    Testing the JVM now? :P


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[GitHub] accumulo pull request #219: ACCUMULO-4584 Remove oneway method checks

joshelser
In reply to this post by joshelser
Github user joshelser commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/219#discussion_r102493588
 
    --- Diff: test/src/main/java/org/apache/accumulo/test/rpc/ThriftBehaviorIT.java ---
    @@ -0,0 +1,191 @@
    +/*
    + * 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.accumulo.test.rpc;
    +
    +import java.util.Arrays;
    +import java.util.HashMap;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +import org.apache.accumulo.test.categories.SunnyDayTests;
    +import org.apache.accumulo.test.rpc.thrift.SimpleThriftService;
    +import org.apache.log4j.Level;
    +import org.apache.log4j.Logger;
    +import org.apache.thrift.ProcessFunction;
    +import org.apache.thrift.TApplicationException;
    +import org.apache.thrift.TException;
    +import org.apache.thrift.server.TSimpleServer;
    +import org.hamcrest.core.IsInstanceOf;
    +import org.junit.After;
    +import org.junit.Assert;
    +import org.junit.Before;
    +import org.junit.Rule;
    +import org.junit.Test;
    +import org.junit.experimental.categories.Category;
    +import org.junit.rules.ExpectedException;
    +import org.junit.rules.TestName;
    +import org.junit.rules.Timeout;
    +
    +@Category(SunnyDayTests.class)
    +public class ThriftBehaviorIT {
    +
    +  @Rule
    +  public Timeout timeout = new Timeout(5, TimeUnit.SECONDS);
    +
    +  @Rule
    +  public TestName testName = new TestName();
    +
    +  @Rule
    +  public ExpectedException exception = ExpectedException.none();
    +
    +  private SimpleThriftService.Client client;
    +  private SimpleThriftServiceHandler handler;
    +  private SimpleThriftServiceRunner serviceRunner;
    +  private String propName;
    +  private Map<Logger,Level> oldLogLevels = new HashMap<>();
    +
    +  private static final String KITTY_MSG = "🐈 Kitty! 🐈";
    --- End diff --
   
    /me shakes head


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[GitHub] accumulo pull request #219: ACCUMULO-4584 Remove oneway method checks

joshelser
In reply to this post by joshelser
Github user ctubbsii commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/219#discussion_r102538743
 
    --- Diff: test/src/main/java/org/apache/accumulo/test/rpc/ThriftBehaviorIT.java ---
    @@ -0,0 +1,191 @@
    +/*
    + * 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.accumulo.test.rpc;
    +
    +import java.util.Arrays;
    +import java.util.HashMap;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +import org.apache.accumulo.test.categories.SunnyDayTests;
    +import org.apache.accumulo.test.rpc.thrift.SimpleThriftService;
    +import org.apache.log4j.Level;
    +import org.apache.log4j.Logger;
    +import org.apache.thrift.ProcessFunction;
    +import org.apache.thrift.TApplicationException;
    +import org.apache.thrift.TException;
    +import org.apache.thrift.server.TSimpleServer;
    +import org.hamcrest.core.IsInstanceOf;
    +import org.junit.After;
    +import org.junit.Assert;
    +import org.junit.Before;
    +import org.junit.Rule;
    +import org.junit.Test;
    +import org.junit.experimental.categories.Category;
    +import org.junit.rules.ExpectedException;
    +import org.junit.rules.TestName;
    +import org.junit.rules.Timeout;
    +
    +@Category(SunnyDayTests.class)
    +public class ThriftBehaviorIT {
    +
    +  @Rule
    +  public Timeout timeout = new Timeout(5, TimeUnit.SECONDS);
    +
    +  @Rule
    +  public TestName testName = new TestName();
    +
    +  @Rule
    +  public ExpectedException exception = ExpectedException.none();
    +
    +  private SimpleThriftService.Client client;
    +  private SimpleThriftServiceHandler handler;
    +  private SimpleThriftServiceRunner serviceRunner;
    +  private String propName;
    +  private Map<Logger,Level> oldLogLevels = new HashMap<>();
    +
    +  private static final String KITTY_MSG = "🐈 Kitty! 🐈";
    --- End diff --
   
    Carefully chosen multi-byte characters to test end-to-end behavior! 🐈


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[GitHub] accumulo pull request #219: ACCUMULO-4584 Remove oneway method checks

joshelser
In reply to this post by joshelser
Github user ctubbsii commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/219#discussion_r102539210
 
    --- Diff: test/src/main/java/org/apache/accumulo/test/rpc/ThriftBehaviorIT.java ---
    @@ -0,0 +1,191 @@
    +/*
    + * 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.accumulo.test.rpc;
    +
    +import java.util.Arrays;
    +import java.util.HashMap;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +import org.apache.accumulo.test.categories.SunnyDayTests;
    +import org.apache.accumulo.test.rpc.thrift.SimpleThriftService;
    +import org.apache.log4j.Level;
    +import org.apache.log4j.Logger;
    +import org.apache.thrift.ProcessFunction;
    +import org.apache.thrift.TApplicationException;
    +import org.apache.thrift.TException;
    +import org.apache.thrift.server.TSimpleServer;
    +import org.hamcrest.core.IsInstanceOf;
    +import org.junit.After;
    +import org.junit.Assert;
    +import org.junit.Before;
    +import org.junit.Rule;
    +import org.junit.Test;
    +import org.junit.experimental.categories.Category;
    +import org.junit.rules.ExpectedException;
    +import org.junit.rules.TestName;
    +import org.junit.rules.Timeout;
    +
    +@Category(SunnyDayTests.class)
    +public class ThriftBehaviorIT {
    +
    +  @Rule
    +  public Timeout timeout = new Timeout(5, TimeUnit.SECONDS);
    +
    +  @Rule
    +  public TestName testName = new TestName();
    +
    +  @Rule
    +  public ExpectedException exception = ExpectedException.none();
    +
    +  private SimpleThriftService.Client client;
    +  private SimpleThriftServiceHandler handler;
    +  private SimpleThriftServiceRunner serviceRunner;
    +  private String propName;
    +  private Map<Logger,Level> oldLogLevels = new HashMap<>();
    +
    +  private static final String KITTY_MSG = "🐈 Kitty! 🐈";
    +
    +  // can delete wrapper when tests pass without using it (assuming tests are good enough)
    +  private static final boolean USE_RPC_WRAPPER = true;
    --- End diff --
   
    We don't need the wrapper for oneway checks, and that has been removed from the wrapper. However, we still need it to handle the lack of RuntimeException - to - TApplicationException mapping that regressed in THRIFT-1805. The fact that the tests pass without the oneway checks means that we don't need them any more in the wrapper.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[GitHub] accumulo pull request #219: ACCUMULO-4584 Remove oneway method checks

joshelser
In reply to this post by joshelser
Github user ctubbsii commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/219#discussion_r102539589
 
    --- Diff: test/src/main/java/org/apache/accumulo/test/rpc/ThriftBehaviorIT.java ---
    @@ -0,0 +1,191 @@
    +/*
    + * 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.accumulo.test.rpc;
    +
    +import java.util.Arrays;
    +import java.util.HashMap;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +import org.apache.accumulo.test.categories.SunnyDayTests;
    +import org.apache.accumulo.test.rpc.thrift.SimpleThriftService;
    +import org.apache.log4j.Level;
    +import org.apache.log4j.Logger;
    +import org.apache.thrift.ProcessFunction;
    +import org.apache.thrift.TApplicationException;
    +import org.apache.thrift.TException;
    +import org.apache.thrift.server.TSimpleServer;
    +import org.hamcrest.core.IsInstanceOf;
    +import org.junit.After;
    +import org.junit.Assert;
    +import org.junit.Before;
    +import org.junit.Rule;
    +import org.junit.Test;
    +import org.junit.experimental.categories.Category;
    +import org.junit.rules.ExpectedException;
    +import org.junit.rules.TestName;
    +import org.junit.rules.Timeout;
    +
    +@Category(SunnyDayTests.class)
    +public class ThriftBehaviorIT {
    +
    +  @Rule
    +  public Timeout timeout = new Timeout(5, TimeUnit.SECONDS);
    +
    +  @Rule
    +  public TestName testName = new TestName();
    +
    +  @Rule
    +  public ExpectedException exception = ExpectedException.none();
    +
    +  private SimpleThriftService.Client client;
    +  private SimpleThriftServiceHandler handler;
    +  private SimpleThriftServiceRunner serviceRunner;
    +  private String propName;
    +  private Map<Logger,Level> oldLogLevels = new HashMap<>();
    +
    +  private static final String KITTY_MSG = "🐈 Kitty! 🐈";
    +
    +  // can delete wrapper when tests pass without using it (assuming tests are good enough)
    +  private static final boolean USE_RPC_WRAPPER = true;
    +
    +  private static final boolean SUPPRESS_SPAMMY_LOGGERS = true;
    +
    +  @Before
    +  public void createClientAndServer() {
    +    Arrays.stream(new Class<?>[] {TSimpleServer.class, ProcessFunction.class}).forEach(spammyClass -> {
    +      Logger spammyLogger = Logger.getLogger(spammyClass);
    +      oldLogLevels.put(spammyLogger, spammyLogger.getLevel());
    +      if (SUPPRESS_SPAMMY_LOGGERS) {
    +        spammyLogger.setLevel(Level.OFF);
    --- End diff --
   
    Maybe not, but I think it's fine for tests. Mainly, I put this in to suppress the noise, so I could see my own debugging output while writing the test. Didn't see a need to remove it when I was done.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[GitHub] accumulo pull request #219: ACCUMULO-4584 Remove oneway method checks

joshelser
In reply to this post by joshelser
Github user ctubbsii commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/219#discussion_r102539758
 
    --- Diff: test/src/main/java/org/apache/accumulo/test/rpc/ThriftBehaviorIT.java ---
    @@ -0,0 +1,191 @@
    +/*
    + * 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.accumulo.test.rpc;
    +
    +import java.util.Arrays;
    +import java.util.HashMap;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +import org.apache.accumulo.test.categories.SunnyDayTests;
    +import org.apache.accumulo.test.rpc.thrift.SimpleThriftService;
    +import org.apache.log4j.Level;
    +import org.apache.log4j.Logger;
    +import org.apache.thrift.ProcessFunction;
    +import org.apache.thrift.TApplicationException;
    +import org.apache.thrift.TException;
    +import org.apache.thrift.server.TSimpleServer;
    +import org.hamcrest.core.IsInstanceOf;
    +import org.junit.After;
    +import org.junit.Assert;
    +import org.junit.Before;
    +import org.junit.Rule;
    +import org.junit.Test;
    +import org.junit.experimental.categories.Category;
    +import org.junit.rules.ExpectedException;
    +import org.junit.rules.TestName;
    +import org.junit.rules.Timeout;
    +
    +@Category(SunnyDayTests.class)
    +public class ThriftBehaviorIT {
    +
    +  @Rule
    +  public Timeout timeout = new Timeout(5, TimeUnit.SECONDS);
    +
    +  @Rule
    +  public TestName testName = new TestName();
    +
    +  @Rule
    +  public ExpectedException exception = ExpectedException.none();
    +
    +  private SimpleThriftService.Client client;
    +  private SimpleThriftServiceHandler handler;
    +  private SimpleThriftServiceRunner serviceRunner;
    +  private String propName;
    +  private Map<Logger,Level> oldLogLevels = new HashMap<>();
    +
    +  private static final String KITTY_MSG = "🐈 Kitty! 🐈";
    +
    +  // can delete wrapper when tests pass without using it (assuming tests are good enough)
    +  private static final boolean USE_RPC_WRAPPER = true;
    +
    +  private static final boolean SUPPRESS_SPAMMY_LOGGERS = true;
    +
    +  @Before
    +  public void createClientAndServer() {
    +    Arrays.stream(new Class<?>[] {TSimpleServer.class, ProcessFunction.class}).forEach(spammyClass -> {
    +      Logger spammyLogger = Logger.getLogger(spammyClass);
    +      oldLogLevels.put(spammyLogger, spammyLogger.getLevel());
    +      if (SUPPRESS_SPAMMY_LOGGERS) {
    +        spammyLogger.setLevel(Level.OFF);
    +      }
    +    });
    +
    +    String threadName = ThriftBehaviorIT.class.getSimpleName() + "." + testName.getMethodName();
    +    serviceRunner = new SimpleThriftServiceRunner(threadName, USE_RPC_WRAPPER);
    +    serviceRunner.startService();
    +    client = serviceRunner.client();
    +    handler = serviceRunner.handler();
    +
    +    propName = testName.getMethodName();
    +    if (propName.endsWith("Handler")) {
    +      propName = propName.substring(0, propName.length() - 7);
    +    }
    +    propName = SimpleThriftServiceHandler.class.getSimpleName() + "." + propName;
    +
    +    System.setProperty(propName, "-");
    +    Assert.assertEquals("-", System.getProperty(propName));
    --- End diff --
   
    Testing the test code in the test of the test of the code. :)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[GitHub] accumulo pull request #219: ACCUMULO-4584 Remove oneway method checks

joshelser
In reply to this post by joshelser
Github user ctubbsii commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/219#discussion_r102539870
 
    --- Diff: test/src/main/java/org/apache/accumulo/test/rpc/ThriftBehaviorIT.java ---
    @@ -0,0 +1,191 @@
    +/*
    + * 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.accumulo.test.rpc;
    +
    +import java.util.Arrays;
    +import java.util.HashMap;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +import org.apache.accumulo.test.categories.SunnyDayTests;
    +import org.apache.accumulo.test.rpc.thrift.SimpleThriftService;
    +import org.apache.log4j.Level;
    +import org.apache.log4j.Logger;
    +import org.apache.thrift.ProcessFunction;
    +import org.apache.thrift.TApplicationException;
    +import org.apache.thrift.TException;
    +import org.apache.thrift.server.TSimpleServer;
    +import org.hamcrest.core.IsInstanceOf;
    +import org.junit.After;
    +import org.junit.Assert;
    +import org.junit.Before;
    +import org.junit.Rule;
    +import org.junit.Test;
    +import org.junit.experimental.categories.Category;
    +import org.junit.rules.ExpectedException;
    +import org.junit.rules.TestName;
    +import org.junit.rules.Timeout;
    +
    +@Category(SunnyDayTests.class)
    +public class ThriftBehaviorIT {
    +
    +  @Rule
    +  public Timeout timeout = new Timeout(5, TimeUnit.SECONDS);
    +
    +  @Rule
    +  public TestName testName = new TestName();
    +
    +  @Rule
    +  public ExpectedException exception = ExpectedException.none();
    +
    +  private SimpleThriftService.Client client;
    +  private SimpleThriftServiceHandler handler;
    +  private SimpleThriftServiceRunner serviceRunner;
    +  private String propName;
    +  private Map<Logger,Level> oldLogLevels = new HashMap<>();
    +
    +  private static final String KITTY_MSG = "🐈 Kitty! 🐈";
    +
    +  // can delete wrapper when tests pass without using it (assuming tests are good enough)
    +  private static final boolean USE_RPC_WRAPPER = true;
    +
    +  private static final boolean SUPPRESS_SPAMMY_LOGGERS = true;
    +
    +  @Before
    +  public void createClientAndServer() {
    +    Arrays.stream(new Class<?>[] {TSimpleServer.class, ProcessFunction.class}).forEach(spammyClass -> {
    +      Logger spammyLogger = Logger.getLogger(spammyClass);
    +      oldLogLevels.put(spammyLogger, spammyLogger.getLevel());
    +      if (SUPPRESS_SPAMMY_LOGGERS) {
    +        spammyLogger.setLevel(Level.OFF);
    +      }
    +    });
    +
    +    String threadName = ThriftBehaviorIT.class.getSimpleName() + "." + testName.getMethodName();
    +    serviceRunner = new SimpleThriftServiceRunner(threadName, USE_RPC_WRAPPER);
    +    serviceRunner.startService();
    +    client = serviceRunner.client();
    +    handler = serviceRunner.handler();
    +
    +    propName = testName.getMethodName();
    +    if (propName.endsWith("Handler")) {
    +      propName = propName.substring(0, propName.length() - 7);
    +    }
    +    propName = SimpleThriftServiceHandler.class.getSimpleName() + "." + propName;
    +
    +    System.setProperty(propName, "-");
    +    Assert.assertEquals("-", System.getProperty(propName));
    +  }
    +
    +  @After
    +  public void shutdownServer() {
    +    serviceRunner.stopService();
    +
    +    oldLogLevels.forEach((spammyLogger, oldLevel) -> {
    +      spammyLogger.setLevel(oldLevel);
    +    });
    +
    +    Assert.assertEquals(KITTY_MSG, System.getProperty(propName));
    --- End diff --
   
    Yes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[GitHub] accumulo pull request #219: ACCUMULO-4584 Remove oneway method checks

joshelser
In reply to this post by joshelser
Github user ctubbsii commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/219#discussion_r102541139
 
    --- Diff: test/src/main/java/org/apache/accumulo/test/rpc/ThriftBehaviorIT.java ---
    @@ -0,0 +1,191 @@
    +/*
    + * 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.accumulo.test.rpc;
    +
    +import java.util.Arrays;
    +import java.util.HashMap;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +import org.apache.accumulo.test.categories.SunnyDayTests;
    +import org.apache.accumulo.test.rpc.thrift.SimpleThriftService;
    +import org.apache.log4j.Level;
    +import org.apache.log4j.Logger;
    +import org.apache.thrift.ProcessFunction;
    +import org.apache.thrift.TApplicationException;
    +import org.apache.thrift.TException;
    +import org.apache.thrift.server.TSimpleServer;
    +import org.hamcrest.core.IsInstanceOf;
    +import org.junit.After;
    +import org.junit.Assert;
    +import org.junit.Before;
    +import org.junit.Rule;
    +import org.junit.Test;
    +import org.junit.experimental.categories.Category;
    +import org.junit.rules.ExpectedException;
    +import org.junit.rules.TestName;
    +import org.junit.rules.Timeout;
    +
    +@Category(SunnyDayTests.class)
    +public class ThriftBehaviorIT {
    +
    +  @Rule
    +  public Timeout timeout = new Timeout(5, TimeUnit.SECONDS);
    +
    +  @Rule
    +  public TestName testName = new TestName();
    +
    +  @Rule
    +  public ExpectedException exception = ExpectedException.none();
    +
    +  private SimpleThriftService.Client client;
    +  private SimpleThriftServiceHandler handler;
    +  private SimpleThriftServiceRunner serviceRunner;
    +  private String propName;
    +  private Map<Logger,Level> oldLogLevels = new HashMap<>();
    +
    +  private static final String KITTY_MSG = "🐈 Kitty! 🐈";
    +
    +  // can delete wrapper when tests pass without using it (assuming tests are good enough)
    +  private static final boolean USE_RPC_WRAPPER = true;
    +
    +  private static final boolean SUPPRESS_SPAMMY_LOGGERS = true;
    +
    +  @Before
    +  public void createClientAndServer() {
    +    Arrays.stream(new Class<?>[] {TSimpleServer.class, ProcessFunction.class}).forEach(spammyClass -> {
    +      Logger spammyLogger = Logger.getLogger(spammyClass);
    +      oldLogLevels.put(spammyLogger, spammyLogger.getLevel());
    +      if (SUPPRESS_SPAMMY_LOGGERS) {
    +        spammyLogger.setLevel(Level.OFF);
    +      }
    +    });
    +
    +    String threadName = ThriftBehaviorIT.class.getSimpleName() + "." + testName.getMethodName();
    +    serviceRunner = new SimpleThriftServiceRunner(threadName, USE_RPC_WRAPPER);
    +    serviceRunner.startService();
    +    client = serviceRunner.client();
    +    handler = serviceRunner.handler();
    +
    +    propName = testName.getMethodName();
    +    if (propName.endsWith("Handler")) {
    +      propName = propName.substring(0, propName.length() - 7);
    +    }
    +    propName = SimpleThriftServiceHandler.class.getSimpleName() + "." + propName;
    +
    +    System.setProperty(propName, "-");
    +    Assert.assertEquals("-", System.getProperty(propName));
    +  }
    +
    +  @After
    +  public void shutdownServer() {
    +    serviceRunner.stopService();
    +
    +    oldLogLevels.forEach((spammyLogger, oldLevel) -> {
    +      spammyLogger.setLevel(oldLevel);
    +    });
    +
    +    Assert.assertEquals(KITTY_MSG, System.getProperty(propName));
    +  }
    +
    +  @Test
    +  public void echoFailHandler() throws TException {
    +    exception.expect(TException.class);
    +    exception.expectCause(IsInstanceOf.instanceOf(UnsupportedOperationException.class));
    +    handler.echoFail(KITTY_MSG);
    +  }
    +
    +  @Test
    +  public void echoFail() throws TException {
    +    try {
    +      client.echoFail(KITTY_MSG);
    +      Assert.fail();
    +    } catch (Exception e) {
    +      Assert.assertEquals(TApplicationException.class.getName(), e.getClass().getName());
    +    }
    +    // verify normal two-way method still passes using same client
    +    echoPass();
    +  }
    +
    +  @Test
    +  public void echoRuntimeFailHandler() throws TException {
    +    exception.expect(UnsupportedOperationException.class);
    +    handler.echoRuntimeFail(KITTY_MSG);
    +  }
    +
    +  @Test
    +  public void echoRuntimeFail() throws TException {
    +    try {
    +      client.echoRuntimeFail(KITTY_MSG);
    +      Assert.fail();
    --- End diff --
   
    I suppose I can add a message, but the name of the method and the being wrapped by a try-catch make it pretty obvious.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[GitHub] accumulo pull request #219: ACCUMULO-4584 Remove oneway method checks

joshelser
In reply to this post by joshelser
Github user joshelser commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/219#discussion_r102561440
 
    --- Diff: test/src/main/java/org/apache/accumulo/test/rpc/ThriftBehaviorIT.java ---
    @@ -0,0 +1,191 @@
    +/*
    + * 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.accumulo.test.rpc;
    +
    +import java.util.Arrays;
    +import java.util.HashMap;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +import org.apache.accumulo.test.categories.SunnyDayTests;
    +import org.apache.accumulo.test.rpc.thrift.SimpleThriftService;
    +import org.apache.log4j.Level;
    +import org.apache.log4j.Logger;
    +import org.apache.thrift.ProcessFunction;
    +import org.apache.thrift.TApplicationException;
    +import org.apache.thrift.TException;
    +import org.apache.thrift.server.TSimpleServer;
    +import org.hamcrest.core.IsInstanceOf;
    +import org.junit.After;
    +import org.junit.Assert;
    +import org.junit.Before;
    +import org.junit.Rule;
    +import org.junit.Test;
    +import org.junit.experimental.categories.Category;
    +import org.junit.rules.ExpectedException;
    +import org.junit.rules.TestName;
    +import org.junit.rules.Timeout;
    +
    +@Category(SunnyDayTests.class)
    +public class ThriftBehaviorIT {
    +
    +  @Rule
    +  public Timeout timeout = new Timeout(5, TimeUnit.SECONDS);
    +
    +  @Rule
    +  public TestName testName = new TestName();
    +
    +  @Rule
    +  public ExpectedException exception = ExpectedException.none();
    +
    +  private SimpleThriftService.Client client;
    +  private SimpleThriftServiceHandler handler;
    +  private SimpleThriftServiceRunner serviceRunner;
    +  private String propName;
    +  private Map<Logger,Level> oldLogLevels = new HashMap<>();
    +
    +  private static final String KITTY_MSG = "🐈 Kitty! 🐈";
    +
    +  // can delete wrapper when tests pass without using it (assuming tests are good enough)
    +  private static final boolean USE_RPC_WRAPPER = true;
    +
    +  private static final boolean SUPPRESS_SPAMMY_LOGGERS = true;
    +
    +  @Before
    +  public void createClientAndServer() {
    +    Arrays.stream(new Class<?>[] {TSimpleServer.class, ProcessFunction.class}).forEach(spammyClass -> {
    +      Logger spammyLogger = Logger.getLogger(spammyClass);
    +      oldLogLevels.put(spammyLogger, spammyLogger.getLevel());
    +      if (SUPPRESS_SPAMMY_LOGGERS) {
    +        spammyLogger.setLevel(Level.OFF);
    +      }
    +    });
    +
    +    String threadName = ThriftBehaviorIT.class.getSimpleName() + "." + testName.getMethodName();
    +    serviceRunner = new SimpleThriftServiceRunner(threadName, USE_RPC_WRAPPER);
    +    serviceRunner.startService();
    +    client = serviceRunner.client();
    +    handler = serviceRunner.handler();
    +
    +    propName = testName.getMethodName();
    +    if (propName.endsWith("Handler")) {
    +      propName = propName.substring(0, propName.length() - 7);
    +    }
    +    propName = SimpleThriftServiceHandler.class.getSimpleName() + "." + propName;
    +
    +    System.setProperty(propName, "-");
    +    Assert.assertEquals("-", System.getProperty(propName));
    +  }
    +
    +  @After
    +  public void shutdownServer() {
    +    serviceRunner.stopService();
    +
    +    oldLogLevels.forEach((spammyLogger, oldLevel) -> {
    +      spammyLogger.setLevel(oldLevel);
    +    });
    +
    +    Assert.assertEquals(KITTY_MSG, System.getProperty(propName));
    +  }
    +
    +  @Test
    +  public void echoFailHandler() throws TException {
    +    exception.expect(TException.class);
    +    exception.expectCause(IsInstanceOf.instanceOf(UnsupportedOperationException.class));
    +    handler.echoFail(KITTY_MSG);
    +  }
    +
    +  @Test
    +  public void echoFail() throws TException {
    +    try {
    +      client.echoFail(KITTY_MSG);
    +      Assert.fail();
    +    } catch (Exception e) {
    +      Assert.assertEquals(TApplicationException.class.getName(), e.getClass().getName());
    +    }
    +    // verify normal two-way method still passes using same client
    +    echoPass();
    +  }
    +
    +  @Test
    +  public void echoRuntimeFailHandler() throws TException {
    +    exception.expect(UnsupportedOperationException.class);
    +    handler.echoRuntimeFail(KITTY_MSG);
    +  }
    +
    +  @Test
    +  public void echoRuntimeFail() throws TException {
    +    try {
    +      client.echoRuntimeFail(KITTY_MSG);
    +      Assert.fail();
    --- End diff --
   
    Specifically from the surefire report, the code snippets are included (as, say, compared to pytest). Having a human-readable error message can really help analyzing the unexpected condition when this test fails (especially if it was by someone other than you or I that don't have context to the problem this test is checking for).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[GitHub] accumulo pull request #219: ACCUMULO-4584 Remove oneway method checks

joshelser
In reply to this post by joshelser
Github user joshelser commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/219#discussion_r102561579
 
    --- Diff: test/src/main/java/org/apache/accumulo/test/rpc/ThriftBehaviorIT.java ---
    @@ -0,0 +1,191 @@
    +/*
    + * 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.accumulo.test.rpc;
    +
    +import java.util.Arrays;
    +import java.util.HashMap;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +import org.apache.accumulo.test.categories.SunnyDayTests;
    +import org.apache.accumulo.test.rpc.thrift.SimpleThriftService;
    +import org.apache.log4j.Level;
    +import org.apache.log4j.Logger;
    +import org.apache.thrift.ProcessFunction;
    +import org.apache.thrift.TApplicationException;
    +import org.apache.thrift.TException;
    +import org.apache.thrift.server.TSimpleServer;
    +import org.hamcrest.core.IsInstanceOf;
    +import org.junit.After;
    +import org.junit.Assert;
    +import org.junit.Before;
    +import org.junit.Rule;
    +import org.junit.Test;
    +import org.junit.experimental.categories.Category;
    +import org.junit.rules.ExpectedException;
    +import org.junit.rules.TestName;
    +import org.junit.rules.Timeout;
    +
    +@Category(SunnyDayTests.class)
    +public class ThriftBehaviorIT {
    +
    +  @Rule
    +  public Timeout timeout = new Timeout(5, TimeUnit.SECONDS);
    +
    +  @Rule
    +  public TestName testName = new TestName();
    +
    +  @Rule
    +  public ExpectedException exception = ExpectedException.none();
    +
    +  private SimpleThriftService.Client client;
    +  private SimpleThriftServiceHandler handler;
    +  private SimpleThriftServiceRunner serviceRunner;
    +  private String propName;
    +  private Map<Logger,Level> oldLogLevels = new HashMap<>();
    +
    +  private static final String KITTY_MSG = "🐈 Kitty! 🐈";
    +
    +  // can delete wrapper when tests pass without using it (assuming tests are good enough)
    +  private static final boolean USE_RPC_WRAPPER = true;
    --- End diff --
   
    Gotcha, thanks for explaining.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[GitHub] accumulo pull request #219: ACCUMULO-4584 Remove oneway method checks

joshelser
In reply to this post by joshelser
Github user asfgit closed the pull request at:

    https://github.com/apache/accumulo/pull/219


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [hidden email] or file a JIRA ticket
with INFRA.
---
Loading...