choksi2212 commented on code in PR #4497: URL: https://github.com/apache/iggy/pull/4497#discussion_r4374701858
########## foreign/go/internal/fakevsr/fakevsr.go: ########## @@ -0,0 +1,296 @@ +// 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 fakevsr provides the fake VSR server the connection-string +// tests drive a full connect-and-login flow against, without a real +// server, and the shared certificate helper the transport tests mint +// their throwaway TLS certificates with. It is an internal package, so +// it never reaches SDK users. +package fakevsr + +import ( + "crypto/ecdsa" + "crypto/elliptic" + "crypto/rand" + "crypto/tls" + "crypto/x509" + "crypto/x509/pkix" + "encoding/binary" + "encoding/pem" + "io" + "math/big" + "net" + "os" + "path/filepath" + "sync" + "testing" + "time" + + iggcon "github.com/apache/iggy/foreign/go/contracts" + "github.com/apache/iggy/foreign/go/internal/command" + "github.com/apache/iggy/foreign/go/internal/vsr" + "github.com/stretchr/testify/require" +) + +// Frame offsets the fake server reads and writes. They mirror the +// unexported tables of the codec package, which no test can reach. +const ( + FrameOffsetSize = 48 + FrameOffsetCommand = 60 + FrameOffsetRequest = 168 + FrameOffsetOperation = 176 + FrameOffsetSession = 184 + FrameOffsetReserved = 196 + + ReplyFrameOffsetRequest = 200 + ReplyFrameOffsetOperation = 208 + ReplyFrameOffsetStatus = 216 +) + +// Request is one frame the fake server read off the wire. +type Request struct { + Header [vsr.HeaderSize]byte + Payload []byte +} + +// Operation reads the request operation code. +func (r Request) Operation() vsr.Operation { + return vsr.Operation(r.Header[FrameOffsetOperation]) +} + +// Code reads the request command code. +func (r Request) Code() uint32 { + return binary.LittleEndian.Uint32(r.Header[FrameOffsetReserved:]) +} + +// SessionID reads the logical session the request carries. +func (r Request) SessionID() uint64 { + return binary.LittleEndian.Uint64(r.Header[FrameOffsetSession:]) +} + +// ReadRequest reads one complete frame from conn. +func ReadRequest(conn net.Conn) (Request, error) { Review Comment: Done in d82966e — `tcp_testing_test.go` now delegates: `clusterMetadataFrame` wraps `fakevsr.ClusterMetadataFrame`, and `readRequest` wraps `fakevsr.ReadRequest`, adapting the result to the local `request` type the assertions use. ########## foreign/go/client/tcp/tcp_core.go: ########## @@ -450,6 +450,15 @@ func (c *IggyTcpClient) GetConnectionInfo() *iggcon.ConnectionInfo { return &iggcon.ConnectionInfo{Protocol: iggcon.Tcp, ServerAddress: c.links.address()} } +// GetNoDelay reports whether TCP_NODELAY is set on new connections, which +// tests and callers can use to observe the parsed nodelay option before a +// connection exists to read it off. +func (c *IggyTcpClient) GetNoDelay() bool { + c.mtx.Lock() Review Comment: Done in c4604c6b — it reads `c.config.noDelay` directly now, like the dial path. `GetHeartbeatInterval` keeps its lock on purpose: `tcp_replicas_test.go` rewrites `config.heartbeatInterval` after construction (the managed-link pacing test at line 303), so that field is not construction-frozen the way `noDelay` is. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
