@@ -179,6 +179,14 @@ func TestWriter(t *testing.T) {
179179 scenario : "test default configuration values" ,
180180 function : testWriterDefaults ,
181181 },
182+ {
183+ scenario : "test default stats values" ,
184+ function : testWriterDefaultStats ,
185+ },
186+ {
187+ scenario : "test stats values with override config" ,
188+ function : testWriterOverrideConfigStats ,
189+ },
182190 {
183191 scenario : "test write message with writer data" ,
184192 function : testWriteMessageWithWriterData ,
@@ -944,6 +952,84 @@ func testWriterDefaults(t *testing.T) {
944952 }
945953}
946954
955+ func testWriterDefaultStats (t * testing.T ) {
956+ w := & Writer {}
957+ defer w .Close ()
958+
959+ stats := w .Stats ()
960+
961+ if stats .MaxAttempts == 0 {
962+ t .Error ("Incorrect default MaxAttempts value" )
963+ }
964+
965+ if stats .WriteBackoffMin == 0 {
966+ t .Error ("Incorrect default WriteBackoffMin value" )
967+ }
968+
969+ if stats .WriteBackoffMax == 0 {
970+ t .Error ("Incorrect default WriteBackoffMax value" )
971+ }
972+
973+ if stats .MaxBatchSize == 0 {
974+ t .Error ("Incorrect default MaxBatchSize value" )
975+ }
976+
977+ if stats .BatchTimeout == 0 {
978+ t .Error ("Incorrect default BatchTimeout value" )
979+ }
980+
981+ if stats .ReadTimeout == 0 {
982+ t .Error ("Incorrect default ReadTimeout value" )
983+ }
984+
985+ if stats .WriteTimeout == 0 {
986+ t .Error ("Incorrect default WriteTimeout value" )
987+ }
988+ }
989+
990+ func testWriterOverrideConfigStats (t * testing.T ) {
991+ w := & Writer {
992+ MaxAttempts : 6 ,
993+ WriteBackoffMin : 2 ,
994+ WriteBackoffMax : 4 ,
995+ BatchSize : 1024 ,
996+ BatchTimeout : 16 ,
997+ ReadTimeout : 24 ,
998+ WriteTimeout : 32 ,
999+ }
1000+ defer w .Close ()
1001+
1002+ stats := w .Stats ()
1003+
1004+ if stats .MaxAttempts != 6 {
1005+ t .Error ("Incorrect MaxAttempts value" )
1006+ }
1007+
1008+ if stats .WriteBackoffMin != 2 {
1009+ t .Error ("Incorrect WriteBackoffMin value" )
1010+ }
1011+
1012+ if stats .WriteBackoffMax != 4 {
1013+ t .Error ("Incorrect WriteBackoffMax value" )
1014+ }
1015+
1016+ if stats .MaxBatchSize != 1024 {
1017+ t .Error ("Incorrect MaxBatchSize value" )
1018+ }
1019+
1020+ if stats .BatchTimeout != 16 {
1021+ t .Error ("Incorrect BatchTimeout value" )
1022+ }
1023+
1024+ if stats .ReadTimeout != 24 {
1025+ t .Error ("Incorrect ReadTimeout value" )
1026+ }
1027+
1028+ if stats .WriteTimeout != 32 {
1029+ t .Error ("Incorrect WriteTimeout value" )
1030+ }
1031+ }
1032+
9471033type staticBalancer struct {
9481034 partition int
9491035}
0 commit comments