Skip to content

Commit 5882460

Browse files
authored
Revert "Nettest fix (#788)" (#824)
This reverts commit 2e02f37.
1 parent f487e01 commit 5882460

File tree

2 files changed

+51
-10
lines changed

2 files changed

+51
-10
lines changed

.circleci/config.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,17 @@ jobs:
184184
working_directory: *working_directory
185185
environment:
186186
KAFKA_VERSION: "2.4.1"
187+
188+
# Need to skip nettest to avoid these kinds of errors:
189+
# --- FAIL: TestConn/nettest (17.56s)
190+
# --- FAIL: TestConn/nettest/PingPong (7.40s)
191+
# conntest.go:112: unexpected Read error: [7] Request Timed Out: the request exceeded the user-specified time limit in the request
192+
# conntest.go:118: mismatching value: got 77, want 78
193+
# conntest.go:118: mismatching value: got 78, want 79
194+
# ...
195+
#
196+
# TODO: Figure out why these are happening and fix them (they don't appear to be new).
197+
KAFKA_SKIP_NETTEST: "1"
187198
docker:
188199
- image: circleci/golang
189200
- image: wurstmeister/zookeeper
@@ -200,6 +211,17 @@ jobs:
200211
working_directory: *working_directory
201212
environment:
202213
KAFKA_VERSION: "2.6.0"
214+
215+
# Need to skip nettest to avoid these kinds of errors:
216+
# --- FAIL: TestConn/nettest (17.56s)
217+
# --- FAIL: TestConn/nettest/PingPong (7.40s)
218+
# conntest.go:112: unexpected Read error: [7] Request Timed Out: the request exceeded the user-specified time limit in the request
219+
# conntest.go:118: mismatching value: got 77, want 78
220+
# conntest.go:118: mismatching value: got 78, want 79
221+
# ...
222+
#
223+
# TODO: Figure out why these are happening and fix them (they don't appear to be new).
224+
KAFKA_SKIP_NETTEST: "1"
203225
docker:
204226
- image: circleci/golang
205227
- image: wurstmeister/zookeeper
@@ -216,6 +238,17 @@ jobs:
216238
working_directory: *working_directory
217239
environment:
218240
KAFKA_VERSION: "2.7.1"
241+
242+
# Need to skip nettest to avoid these kinds of errors:
243+
# --- FAIL: TestConn/nettest (17.56s)
244+
# --- FAIL: TestConn/nettest/PingPong (7.40s)
245+
# conntest.go:112: unexpected Read error: [7] Request Timed Out: the request exceeded the user-specified time limit in the request
246+
# conntest.go:118: mismatching value: got 77, want 78
247+
# conntest.go:118: mismatching value: got 78, want 79
248+
# ...
249+
#
250+
# TODO: Figure out why these are happening and fix them (they don't appear to be new).
251+
KAFKA_SKIP_NETTEST: "1"
219252
docker:
220253
- image: circleci/golang
221254
- image: wurstmeister/zookeeper

conn.go

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,11 @@ const (
133133
ReadCommitted IsolationLevel = 1
134134
)
135135

136-
// DefaultClientID is the default value used as ClientID of kafka
137-
// connections.
138-
var DefaultClientID string
136+
var (
137+
// DefaultClientID is the default value used as ClientID of kafka
138+
// connections.
139+
DefaultClientID string
140+
)
139141

140142
func init() {
141143
progname := filepath.Base(os.Args[0])
@@ -261,12 +263,10 @@ func (c *Conn) Controller() (broker Broker, err error) {
261263
}
262264
for _, brokerMeta := range res.Brokers {
263265
if brokerMeta.NodeID == res.ControllerID {
264-
broker = Broker{
265-
ID: int(brokerMeta.NodeID),
266+
broker = Broker{ID: int(brokerMeta.NodeID),
266267
Port: int(brokerMeta.Port),
267268
Host: brokerMeta.Host,
268-
Rack: brokerMeta.Rack,
269-
}
269+
Rack: brokerMeta.Rack}
270270
break
271271
}
272272
}
@@ -322,6 +322,7 @@ func (c *Conn) findCoordinator(request findCoordinatorRequestV0) (findCoordinato
322322
err := c.readOperation(
323323
func(deadline time.Time, id int32) error {
324324
return c.writeRequest(findCoordinator, v0, id, request)
325+
325326
},
326327
func(deadline time.Time, size int) error {
327328
return expectZeroSize(func() (remain int, err error) {
@@ -751,8 +752,9 @@ func (c *Conn) ReadBatch(minBytes, maxBytes int) *Batch {
751752
// ReadBatchWith in every way is similar to ReadBatch. ReadBatch is configured
752753
// with the default values in ReadBatchConfig except for minBytes and maxBytes.
753754
func (c *Conn) ReadBatchWith(cfg ReadBatchConfig) *Batch {
755+
754756
var adjustedDeadline time.Time
755-
maxFetch := int(c.fetchMaxBytes)
757+
var maxFetch = int(c.fetchMaxBytes)
756758

757759
if cfg.MinBytes < 0 || cfg.MinBytes > maxFetch {
758760
return &Batch{err: fmt.Errorf("kafka.(*Conn).ReadBatch: minBytes of %d out of [1,%d] bounds", cfg.MinBytes, maxFetch)}
@@ -857,7 +859,11 @@ func (c *Conn) ReadBatchWith(cfg ReadBatchConfig) *Batch {
857859

858860
var msgs *messageSetReader
859861
if err == nil {
860-
msgs, err = newMessageSetReader(&c.rbuf, remain)
862+
if highWaterMark == offset {
863+
msgs = &messageSetReader{empty: true}
864+
} else {
865+
msgs, err = newMessageSetReader(&c.rbuf, remain)
866+
}
861867
}
862868
if err == errShortRead {
863869
err = checkTimeoutErr(adjustedDeadline)
@@ -953,6 +959,7 @@ func (c *Conn) readOffset(t int64) (offset int64, err error) {
953959
// connection. If there are none, the method fetches all partitions of the kafka
954960
// cluster.
955961
func (c *Conn) ReadPartitions(topics ...string) (partitions []Partition, err error) {
962+
956963
if len(topics) == 0 {
957964
if len(c.topic) != 0 {
958965
defaultTopics := [...]string{c.topic}
@@ -1181,6 +1188,7 @@ func (c *Conn) writeCompressedMessages(codec CompressionCodec, msgs ...Message)
11811188
}
11821189
return size, err
11831190
}
1191+
11841192
})
11851193
if err != nil {
11861194
return size, err
@@ -1548,7 +1556,7 @@ func (c *Conn) saslAuthenticate(data []byte) ([]byte, error) {
15481556
return nil, err
15491557
}
15501558
if version == v1 {
1551-
request := saslAuthenticateRequestV0{Data: data}
1559+
var request = saslAuthenticateRequestV0{Data: data}
15521560
var response saslAuthenticateResponseV0
15531561

15541562
err := c.writeOperation(

0 commit comments

Comments
 (0)