[
https://issues.apache.org/jira/browse/APEXMALHAR-2161?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15411604#comment-15411604
]
ASF GitHub Bot commented on APEXMALHAR-2161:
--------------------------------------------
Github user yogidevendra commented on a diff in the pull request:
https://github.com/apache/apex-malhar/pull/359#discussion_r73849553
--- Diff:
library/src/test/java/com/datatorrent/lib/io/fs/AbstractThroughputFileInputOperatorTest.java
---
@@ -0,0 +1,129 @@
+/**
+ * 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 com.datatorrent.lib.io.fs;
+
+import java.io.IOException;
+import java.util.Collections;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+import org.apache.commons.lang.mutable.MutableLong;
+
+import com.datatorrent.api.Partitioner.Partition;
+import com.datatorrent.api.Stats.OperatorStats;
+import com.datatorrent.api.StatsListener.BatchedOperatorStats;
+import com.datatorrent.api.StatsListener.Response;
+import com.datatorrent.lib.counters.BasicCounters;
+import com.datatorrent.lib.io.fs.AbstractFileInputOperator.FileCounters;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.when;
+
+public class AbstractThroughputFileInputOperatorTest
+{
+ private AbstractThroughputFileInputOperator<String> underTest;
+ @Mock
+ private Partition<AbstractFileInputOperator<String>> mockPartition;
+ @Mock
+ private BatchedOperatorStats mockBatchStats;
+ @Mock
+ private OperatorStats mockOperatorStats;
+ @Mock
+ private BasicCounters<MutableLong> fileCountersMock;
+ @Mock
+ private MutableLong fileCounterMock;
+
+ @Before
+ public void setup()
+ {
+ underTest = new ThroughputFileInputOperator();
+ MockitoAnnotations.initMocks(this);
+
+ when(mockPartition.getPartitionedInstance()).thenReturn(underTest);
+ }
+
+ @Test
+ public void testInitialPartitioning()
+ {
+ underTest.setPartitionCount(4);
+ underTest.setPreferredMaxPendingFilesPerOperator(6);
+
+ for (int i = 0; i < 74; i++) {
+ underTest.pendingFiles.add("file-" + i);
+ }
+
+ int partitioncount =
underTest.getNewPartitionCount(Collections.singleton(mockPartition), null);
+ Assert.assertEquals(4, partitioncount);
+ }
+
+ @Test
+ public void testProcessStats() throws Exception
+ {
+ underTest.setPartitionCount(4);
+ underTest.setPreferredMaxPendingFilesPerOperator(10);
+
+ for (int i = 0; i < 21; i++) {
+ underTest.pendingFiles.add("file-" + i);
+ }
+
+ mockOperatorStats.counters = fileCountersMock;
+ when(mockPartition.getStats()).thenReturn(mockBatchStats);
+
when(mockBatchStats.getLastWindowedStats()).thenReturn(Collections.singletonList(mockOperatorStats));
+
when(fileCountersMock.getCounter(any(FileCounters.class))).thenReturn(fileCounterMock);
+ when(fileCounterMock.getValue()).thenReturn(20L);
+
+ Response response = underTest.processStats(mockBatchStats);
+
+ Assert.assertTrue(response.repartitionRequired);
--- End diff --
Could you please add test scenario for repartitionRequired=false.
> Add tests for AbstractThroughputFileInputOperator
> -------------------------------------------------
>
> Key: APEXMALHAR-2161
> URL: https://issues.apache.org/jira/browse/APEXMALHAR-2161
> Project: Apache Apex Malhar
> Issue Type: Bug
> Reporter: Priyanka Gugale
> Assignee: Priyanka Gugale
> Priority: Minor
> Original Estimate: 24h
> Time Spent: 8h
> Remaining Estimate: 16h
>
> Add unit tests for AbstractThroughputFileInputOperator
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)