Skip to content

Commit

Permalink
Updating golang to v1.18, ginkgo to v2.2.0, fixing linting and format…
Browse files Browse the repository at this point in the history
…ting, and update travis dist image (#51)

In reference to issue #47

Signed-off-by: Chris Wolf <[email protected]>

Signed-off-by: Chris Wolf <[email protected]>
Co-authored-by: Jeffery Chauvin <[email protected]>
  • Loading branch information
jchauvin and Jeffery Chauvin authored Sep 21, 2022
1 parent 372bc3c commit 321265c
Show file tree
Hide file tree
Showing 23 changed files with 109 additions and 159 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
---
language: go
os: linux
dist: focal
go:
- "1.16"
- "1.18.6"

before_install:
- pip --quiet install yamllint
- go get github.com/sonatype-nexus-community/nancy
- go mod tidy

cache:
directories:
Expand Down
2 changes: 1 addition & 1 deletion cmd/ws/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func init() {
flag.BoolVar(&useTLS, "s", false, "specify to use tls")
}

//nolint
// nolint
func listen() *Listener {

log.Println("Starting server on port 8083")
Expand Down
2 changes: 2 additions & 0 deletions fluent/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const (
)

// MessageClient implementations send MessagePack messages to a peer
//
//counterfeiter:generate . MessageClient
type MessageClient interface {
Connect() error
Expand All @@ -62,6 +63,7 @@ type MessageClient interface {
}

// ConnectionFactory implementations create new connections
//
//counterfeiter:generate . ConnectionFactory
type ConnectionFactory interface {
New() (net.Conn, error)
Expand Down
2 changes: 1 addition & 1 deletion fluent/client/client_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package client_test
import (
"testing"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

Expand Down
2 changes: 1 addition & 1 deletion fluent/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
. "github.com/IBM/fluent-forward-go/fluent/client"
"github.com/IBM/fluent-forward-go/fluent/client/clientfakes"
"github.com/IBM/fluent-forward-go/fluent/protocol"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/tinylib/msgp/msgp"
)
Expand Down
2 changes: 1 addition & 1 deletion fluent/client/conn_factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"os"
"time"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

. "github.com/IBM/fluent-forward-go/fluent/client"
Expand Down
2 changes: 1 addition & 1 deletion fluent/client/ws/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (

"github.com/IBM/fluent-forward-go/fluent/client/ws"
"github.com/gorilla/websocket"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
)
Expand Down
1 change: 1 addition & 0 deletions fluent/client/ws/ext/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (

// Conn is an interface for websocket.Conn. Generated with
// ifacemaker (https://github.com/vburenin/ifacemaker).
//
//counterfeiter:generate . Conn
type Conn interface {
// Subprotocol returns the negotiated protocol for the connection.
Expand Down
2 changes: 1 addition & 1 deletion fluent/client/ws/ws_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package ws_test
import (
"testing"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

Expand Down
2 changes: 1 addition & 1 deletion fluent/client/ws_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import (
"github.com/IBM/fluent-forward-go/fluent/client/ws/wsfakes"
"github.com/IBM/fluent-forward-go/fluent/protocol"
"github.com/gorilla/websocket"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

Expand Down
2 changes: 1 addition & 1 deletion fluent/fluent_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package fluent_test
import (
"testing"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

Expand Down
7 changes: 3 additions & 4 deletions fluent/protocol/chunk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ package protocol_test
import (
"encoding/base64"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/IBM/fluent-forward-go/fluent/protocol"
. "github.com/IBM/fluent-forward-go/fluent/protocol"
)

var _ = Describe("Chunk", func() {
Expand All @@ -45,7 +44,7 @@ var _ = Describe("Chunk", func() {
bits, err := msg.MarshalMsg(nil)
Expect(err).ToNot(HaveOccurred())

chunk, err := GetChunk(bits)
chunk, err := protocol.GetChunk(bits)
Expect(err).ToNot(HaveOccurred())
Expect(chunk).To(Equal(expected))
})
Expand All @@ -56,7 +55,7 @@ var _ = Describe("Chunk", func() {
bits, err := msg.MarshalMsg(nil)
Expect(err).ToNot(HaveOccurred())

_, err = GetChunk(bits)
_, err = protocol.GetChunk(bits)
Expect(err.Error()).To(ContainSubstring("chunk not found"))
})
})
Expand Down
1 change: 1 addition & 0 deletions fluent/protocol/forward_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import "github.com/tinylib/msgp/msgp"

// ForwardMessage is used in Forward mode to send multiple events in a single
// msgpack array within a single request.
//
//msgp:tuple ForwardMessage
//mgsp:test ignore ForwardMessage
//msgp:encode ignore ForwardMessage
Expand Down
30 changes: 15 additions & 15 deletions fluent/protocol/forward_message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,52 +29,52 @@ import (
"io/ioutil"
"time"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/tinylib/msgp/msgp"

. "github.com/IBM/fluent-forward-go/fluent/protocol"
"github.com/IBM/fluent-forward-go/fluent/protocol"
)

var _ = Describe("ForwardMessage", func() {
var (
fwdmsg *ForwardMessage
fwdmsg *protocol.ForwardMessage
)

BeforeEach(func() {
bits, err := ioutil.ReadFile("protocolfakes/forwarded_records.msgpack.bin")
Expect(err).ToNot(HaveOccurred())
fwdmsg = &ForwardMessage{}
fwdmsg = &protocol.ForwardMessage{}
_, err = fwdmsg.UnmarshalMsg(bits)
Expect(err).NotTo(HaveOccurred())
entries := []EntryExt{
entries := []protocol.EntryExt{
{
Timestamp: EventTime{time.Now()},
Timestamp: protocol.EventTime{time.Now()},
Record: map[string]interface{}{
"foo": "bar",
"george": "jungle",
},
},
{
Timestamp: EventTime{time.Now()},
Timestamp: protocol.EventTime{time.Now()},
Record: map[string]interface{}{
"foo": "kablooie",
"george": "frank",
},
},
}

fwdmsg = NewForwardMessage("foo", entries)
fwdmsg = protocol.NewForwardMessage("foo", entries)
Expect(*fwdmsg.Options.Size).To(Equal(len(entries)))
})

Describe("Unmarshaling", func() {
testMarshalling := func(msg *ForwardMessage, opts *MessageOptions) {
testMarshalling := func(msg *protocol.ForwardMessage, opts *protocol.MessageOptions) {
msg.Options = opts
b, err := msg.MarshalMsg(nil)
Expect(err).NotTo(HaveOccurred())

var unmfwd ForwardMessage
var unmfwd protocol.ForwardMessage
_, err = unmfwd.UnmarshalMsg(b)
Expect(err).NotTo(HaveOccurred())

Expand All @@ -94,10 +94,10 @@ var _ = Describe("ForwardMessage", func() {

It("Marshals and unmarshals correctly", func() {
testMarshalling(fwdmsg, nil)
testMarshalling(fwdmsg, &MessageOptions{})
testMarshalling(fwdmsg, &protocol.MessageOptions{})
})

testEncodingDecoding := func(msg *ForwardMessage, opts *MessageOptions) {
testEncodingDecoding := func(msg *protocol.ForwardMessage, opts *protocol.MessageOptions) {
var buf bytes.Buffer
en := msgp.NewWriter(&buf)

Expand All @@ -106,7 +106,7 @@ var _ = Describe("ForwardMessage", func() {
Expect(err).NotTo(HaveOccurred())
en.Flush()

var unmfwd ForwardMessage
var unmfwd protocol.ForwardMessage
re := msgp.NewReader(&buf)
err = unmfwd.DecodeMsg(re)
Expect(err).NotTo(HaveOccurred())
Expand All @@ -127,14 +127,14 @@ var _ = Describe("ForwardMessage", func() {

It("Encodes and decodes correctly", func() {
testEncodingDecoding(fwdmsg, nil)
testEncodingDecoding(fwdmsg, &MessageOptions{})
testEncodingDecoding(fwdmsg, &protocol.MessageOptions{})
})

It("Properly deserializes real fluentbit messages with no options", func() {
bits, err := ioutil.ReadFile("protocolfakes/forwarded_records.msgpack.bin")
Expect(err).ToNot(HaveOccurred())

fwdmsg := ForwardMessage{}
fwdmsg := protocol.ForwardMessage{}
_, err = fwdmsg.UnmarshalMsg(bits)
Expect(err).NotTo(HaveOccurred())
})
Expand Down
3 changes: 3 additions & 0 deletions fluent/protocol/handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func NewHelo(opts *HeloOpts) *Helo {

// Helo is the initial handshake message, sent by the server and received
// by the client. Client will respond with a Ping.
//
//msgp:tuple Helo
type Helo struct {
MessageType string
Expand Down Expand Up @@ -112,6 +113,7 @@ func makePing(hostname string, sharedKey, salt, nonce []byte, creds ...string) (

// Ping is the response message sent by the client after receiving a
// Helo from the server. Server will respond with a Pong.
//
//msgp:tuple Ping
type Ping struct {
MessageType string
Expand Down Expand Up @@ -155,6 +157,7 @@ func NewPong(authResult bool, reason string, hostname string, sharedKey []byte,

// Pong is the response message sent by the server after receiving a
// Ping from the client. A Pong concludes the handshake.
//
//msgp:tuple Pong
type Pong struct {
MessageType string
Expand Down
2 changes: 2 additions & 0 deletions fluent/protocol/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
//go:generate msgp

// Message is used to send a single event at a time
//
//msgp:tuple Message
//msgp:decode ignore Message
//msgp:unmarshal ignore Message
Expand Down Expand Up @@ -166,6 +167,7 @@ func (msg *Message) Chunk() (string, error) {
}

// MessageExt
//
//msgp:tuple MessageExt
//msgp:decode ignore MessageExt
//msgp:unmarshal ignore MessageExt
Expand Down
1 change: 1 addition & 0 deletions fluent/protocol/packed_forward_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (

// PackedForwardMessage is just like ForwardMessage, except that the events
// are carried as a msgpack binary stream
//
//msgp:tuple PackedForwardMessage
//msgp:decode ignore PackedForwardMessage
//msgp:unmarshal ignore PackedForwardMessage
Expand Down
2 changes: 1 addition & 1 deletion fluent/protocol/protocol_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package protocol_test
import (
"testing"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

Expand Down
3 changes: 3 additions & 0 deletions fluent/protocol/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ func (et *EventTime) UnmarshalBinary(timeBytes []byte) error {

// EntryExt is the basic representation of an individual event, but using the
// msgpack extension format for the timestamp.
//
//msgp:tuple EntryExt
type EntryExt struct {
// Timestamp can contain the timestamp in either seconds or nanoseconds
Expand Down Expand Up @@ -210,6 +211,7 @@ func (el EntryList) Equal(e2 EntryList) bool {
// EntryExt is the basic representation of an individual event. The timestamp
// is an int64 representing seconds since the epoch (UTC). The initial creator
// of the entry is responsible for converting to UTC.
//
//msgp:tuple Entry
type Entry struct {
// Timestamp can contain the timestamp in either seconds or nanoseconds
Expand All @@ -229,6 +231,7 @@ type AckMessage struct {
}

// RawMessage is a ChunkEncoder wrapper for []byte.
//
//msgp:encode ignore RawMessage
type RawMessage []byte

Expand Down
Loading

0 comments on commit 321265c

Please sign in to comment.