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

    https://github.com/apache/drill/pull/1045#discussion_r162495593
  
    --- Diff: 
exec/java-exec/src/test/java/org/apache/drill/test/OperatorFixture.java ---
    @@ -175,19 +210,189 @@ public DrillConfig getConfig() {
         }
     
         @Override
    -    public DrillbitContext getDrillbitContext() {
    -      throw new UnsupportedOperationException("Drillbit context not 
available for operator unit tests");
    +    public ExecutorService getScanDecodeExecutor() {
    +      return null;
    +    }
    +
    +    @Override
    +    public ExecutorService getScanExecutor() {
    +      return null;
    +    }
    +
    +    @Override
    +    public ExecutorService getExecutor() {
    +      return null;
    +    }
    +
    +    @Override
    +    public ExecutorState getExecutorState() {
    +      return executorState;
    +    }
    +
    +    @Override
    +    public BufferAllocator getNewChildAllocator(String operatorName, int 
operatorId,
    +                                                long initialReservation, 
long maximumReservation) {
    +      return allocator.newChildAllocator(
    +        "op:" + operatorId + ":" + operatorName,
    +        initialReservation,
    +        maximumReservation);
         }
     
         @Override
    -    protected CodeCompiler getCompiler() {
    +    public ExecProtos.FragmentHandle getHandle() {
    +      return ExecProtos.FragmentHandle.newBuilder().build();
    +    }
    +
    +    @Override
    +    public BufferAllocator getAllocator() {
    +      return allocator;
    +    }
    +
    +    @Override
    +    public OperatorContext newOperatorContext(PhysicalOperator popConfig) {
    +      return mockOperatorContext;
    +    }
    +
    +    @Override
    +    public OperatorContext newOperatorContext(PhysicalOperator popConfig, 
OperatorStats stats) {
    +      return mockOperatorContext;
    +    }
    +
    +    @Override
    +    public SchemaPlus getFullRootSchema() {
    +      return null;
    +    }
    +
    +    @Override
    +    public String getQueryUserName() {
    +      return null;
    +    }
    +
    +    @Override
    +    public String getFragIdString() {
    +      return null;
    +    }
    +
    +    @Override
    +    public CodeCompiler getCompiler() {
            return compiler;
         }
     
         @Override
         protected BufferManager getBufferManager() {
           return bufferManager;
         }
    +
    +    @Override
    +    public void close() {
    +      bufferManager.close();
    +    }
    +
    +    @Override
    +    public ContextInformation getContextInformation() {
    +      return null;
    +    }
    +
    +    @Override
    +    public PartitionExplorer getPartitionExplorer() {
    +      return null;
    +    }
    +
    +    @Override
    +    public ValueHolder getConstantValueHolder(String value, 
TypeProtos.MinorType type, Function<DrillBuf, ValueHolder> holderInitializer) {
    +      return null;
    +    }
    +  }
    +
    +  public static class MockExecutorFragmentContext extends 
MockFragmentContext implements ExecutorFragmentContext {
    +
    +    public MockExecutorFragmentContext(DrillConfig config, OptionManager 
optionManager, BufferAllocator allocator) {
    +      super(config, optionManager, allocator);
    +    }
    +
    +    @Override
    +    public PhysicalPlanReader getPlanReader() {
    +      throw new UnsupportedOperationException();
    +    }
    +
    +    @Override
    +    public ClusterCoordinator getClusterCoordinator() {
    +      throw new UnsupportedOperationException();
    +    }
    +
    +    @Override
    +    public CoordinationProtos.DrillbitEndpoint getForemanEndpoint() {
    +      throw new UnsupportedOperationException();
    +    }
    +
    +    @Override
    +    public CoordinationProtos.DrillbitEndpoint getEndpoint() {
    +      throw new UnsupportedOperationException();
    +    }
    +
    +    @Override
    +    public Collection<CoordinationProtos.DrillbitEndpoint> getBits() {
    +      throw new UnsupportedOperationException();
    +    }
    +
    +    @Override
    +    public OperatorCreatorRegistry getOperatorCreatorRegistry() {
    +      return null;
    +    }
    +
    +    @Override
    +    public void setBuffers(IncomingBuffers buffers) {
    +
    +    }
    +
    +    @Override
    +    public Set<Map.Entry<UserServer.BitToUserConnection, 
UserServer.BitToUserConnectionConfig>> getUserConnections() {
    +      return null;
    +    }
    +
    +    @Override
    +    public QueryProfileStoreContext getProfileStoreContext() {
    +      return null;
    +    }
    +
    +    @Override
    +    public void waitForSendComplete() {
    +      throw new UnsupportedOperationException();
    +    }
    +
    +    @Override
    +    public AccountingDataTunnel 
getDataTunnel(CoordinationProtos.DrillbitEndpoint endpoint) {
    --- End diff --
    
    Agreed. This is actually not exposed in the FragmentContext used by 
operators, it is only exposed in the **ExecutorFragmentContext** which is used 
by the FragmentExecutor and passed to the BatchCreators. Unfortunately we still 
need a simple mock of the ExecutorFragmentContext because batchCreators are 
used in PhysicalOpUnitTestBase. Furthermore the networking methods aren't even 
used in that test so we don't even have to provide functional mocks of them for 
that one test. Since PhysicalOpUnitTestBase is the only test that requires an 
ExecutorFragmentContext I will move this mock class into PhysicalOpUnitTestBase 
and will add a comment that this Mock class should not be used outside of 
PhysicalOpUnitTestBase. All the other tests are able to get away with 
FragmentContext, which does not have any networking methods. And eventually we 
should remove PhysicalOpUnitTestBase in favor of the Fixture classes you added, 
and we will then be able to delete this MockClass entirely.


---

Reply via email to