Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ func init() {
rootCmd.Flags().Uint16VarP(&clientConfig.TargetPort, "target-port", "p", 0, "target port")
rootCmd.Flags().StringVarP(&clientConfig.Message, "message", "m", "defaultmessage", "message to send")
rootCmd.Flags().UintVarP(&clientConfig.Timeout, "timeout", "t", 2000, "timeout in ms")
rootCmd.Flags().UintVarP(&clientConfig.ReadTimeout, "read-timeout", "", 1500, "response read timeout in ms (tcp only)")
rootCmd.Flags().UintVarP(&clientConfig.Attempts, "attempts", "r", 1, "number of attempts, successful or not")
rootCmd.Flags().UintVar(&clientConfig.Period, "period", 5000, "send a new message every <period> ms")
rootCmd.Flags().UintVar(&clientConfig.SuccThrPec, "success-threshold", 80, "percentage of successful attempts needed")
Expand Down
1 change: 0 additions & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ type Config struct {
TargetPort uint16
Message string
Timeout uint
ReadTimeout uint
Attempts uint
Period uint
SuccThrPec uint
Expand Down
35 changes: 16 additions & 19 deletions pkg/conntester/conntester.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ var ErrTestFailed = errors.New("test failed")

// ConnTester performs connections against a certain destination
type ConnTester struct {
protocol string
targetHost string
targetPort uint16
message string
timeout uint
readTimeout uint
attempts uint
period uint
succThrPec uint
protocol string
targetHost string
targetPort uint16
message string
timeout uint
attempts uint
period uint
succThrPec uint

logger *log.Logger

Expand All @@ -46,15 +45,14 @@ func New(config *config.Config, logger *log.Logger) (*ConnTester, error) {
}

ct := &ConnTester{
protocol: config.Protocol,
targetHost: config.TargetHost,
targetPort: config.TargetPort,
message: config.Message,
timeout: config.Timeout,
readTimeout: config.ReadTimeout,
attempts: config.Attempts,
period: config.Period,
succThrPec: config.SuccThrPec,
protocol: config.Protocol,
targetHost: config.TargetHost,
targetPort: config.TargetPort,
message: config.Message,
timeout: config.Timeout,
attempts: config.Attempts,
period: config.Period,
succThrPec: config.SuccThrPec,
}
ct.logger = logger
return ct, nil
Expand Down Expand Up @@ -143,7 +141,6 @@ func (c *ConnTester) send(ctx context.Context, wg *sync.WaitGroup) {
c.logger.Info("TCP FIN packet sent, writing side closed")
}

conn.SetReadDeadline(time.Now().Add(time.Duration(c.readTimeout) * time.Millisecond))
_, err = io.Copy(io.Discard, conn)
if err != nil && err != io.EOF {
c.logger.Info(fmt.Sprintf("stopped discarding data from %s: %s", dstEndpoint, err))
Expand Down
Loading