1818
1919package org .apache .hadoop .fs .azurebfs ;
2020
21- import org .junit .Assert ;
2221import org .junit .Test ;
2322
23+ import org .slf4j .Logger ;
24+ import org .slf4j .LoggerFactory ;
25+
2426import org .apache .hadoop .fs .FSDataOutputStream ;
2527import org .apache .hadoop .fs .FSDataInputStream ;
2628import org .apache .hadoop .fs .FileSystem ;
@@ -35,6 +37,9 @@ public class ITestAbfsStreamStatistics extends AbstractAbfsIntegrationTest {
3537 public ITestAbfsStreamStatistics () throws Exception {
3638 }
3739
40+ private static final Logger LOG =
41+ LoggerFactory .getLogger (ITestAbfsStreamStatistics .class );
42+
3843 private static int LARGE_NUMBER_OF_OPS = 1000000 ;
3944
4045 /***
@@ -71,20 +76,29 @@ public void testAbfsStreamOps() throws Exception {
7176 //Test for a single write operation
7277 assertReadWriteOps ("write" , 1 , statistics .getWriteOps ());
7378
79+ //Flushing output stream to see content to read
80+ outForOneOperation .hflush ();
7481 inForOneOperation = fs .open (smallOperationsFile );
75- inForOneOperation .read (testReadWriteOps .getBytes (), 0 ,
82+ statistics .reset ();
83+ int result = inForOneOperation .read (testReadWriteOps .getBytes (), 0 ,
7684 testReadWriteOps .getBytes ().length );
7785
78- //Test for a single read operation
79- assertReadWriteOps ("read" , 1 , statistics .getReadOps ());
86+ LOG .info ("Result of Read operation : {}" , result );
87+ /*
88+ Testing if 2 read_ops value is coming after reading full content from a
89+ file (3 if anything to read from Buffer too).
90+ Reason: read() call gives read_ops=1,
91+ reading from AbfsClient(http GET) gives read_ops=2.
92+ */
93+ assertReadWriteOps ("read" , 2 , statistics .getReadOps ());
8094
8195 } finally {
82- IOUtils .cleanupWithLogger (null , inForOneOperation ,
96+ IOUtils .cleanupWithLogger (LOG , inForOneOperation ,
8397 outForOneOperation );
8498 }
8599
86100 //Validating if content is being written in the smallOperationsFile
87- Assert . assertEquals ("Mismatch in content validation" , true ,
101+ assertTrue ("Mismatch in content validation" ,
88102 validateContent (fs , smallOperationsFile ,
89103 testReadWriteOps .getBytes ()));
90104
@@ -101,6 +115,8 @@ public void testAbfsStreamOps() throws Exception {
101115 //Creating the String for content Validation
102116 largeOperationsValidationString .append (testReadWriteOps );
103117 }
118+ LOG .info ("Number of bytes of Large data written: {}" ,
119+ largeOperationsValidationString .toString ().getBytes ().length );
104120
105121 //Test for 1000000 write operations
106122 assertReadWriteOps ("write" , largeValue , statistics .getWriteOps ());
@@ -116,12 +132,11 @@ public void testAbfsStreamOps() throws Exception {
116132 assertReadWriteOps ("read" , largeValue , statistics .getReadOps ());
117133
118134 } finally {
119- IOUtils .cleanupWithLogger (null , inForLargeOperations ,
135+ IOUtils .cleanupWithLogger (LOG , inForLargeOperations ,
120136 outForLargeOperations );
121137 }
122-
123138 //Validating if content is being written in largeOperationsFile
124- Assert . assertTrue ("Mismatch in content validation" ,
139+ assertTrue ("Mismatch in content validation" ,
125140 validateContent (fs , largeOperationsFile ,
126141 largeOperationsValidationString .toString ().getBytes ()));
127142
@@ -137,8 +152,7 @@ public void testAbfsStreamOps() throws Exception {
137152
138153 private void assertReadWriteOps (String operation , long expectedValue ,
139154 long actualValue ) {
140- Assert
141- .assertEquals ("Mismatch in " + operation + " operations" , expectedValue ,
142- actualValue );
155+ assertEquals ("Mismatch in " + operation + " operations" , expectedValue ,
156+ actualValue );
143157 }
144158}
0 commit comments